Skip to content

Lara-4 migration (WeaverGen2 + TS toolchain) - #64

Open
lm-sousa wants to merge 4 commits into
multi-weaverfrom
lara-4
Open

Lara-4 migration (WeaverGen2 + TS toolchain)#64
lm-sousa wants to merge 4 commits into
multi-weaverfrom
lara-4

Conversation

@lm-sousa

@lm-sousa lm-sousa commented Sep 7, 2026

Copy link
Copy Markdown
Member

Note

omen-alpha responding on behalf of @lm-sousa

Problem

The repo's multi-weaver branch (weaver-instance refactor: removal of THREAD_LOCAL_WEAVER, Weaver engine threading through the joinpoints, CI fixes) was 600+ commits behind main, and the whole weaver stack needs to move to lara-4 (@specs-feup/lara 4.0.0) to stay in lockstep with clava and lara-framework.

Solution

Rebased multi-weaver onto main (#65, incl. the FortranWeaver.json conflict resolution in favor of main's regeneration, which already contained all multi-weaver attribute additions) and migrated both halves to the lara-4 stack, mirroring what was done in clava:

Java (FortranWeaver): the three XML specs (joinPointModel.xml, artifacts.xml, actionModel.xml) are replaced by the Java DSL spec class FortranSpec (new src-spec source set); the build now uses LangSpec2/WeaverGen2 (LanguageSpecification/WeaverGenerator no longer exist in lara-framework). Abstract joinpoints are generated by WeaverGen2 (CRTP zig-zag hierarchy) instead of being committed; all concrete joinpoints were converted to the new API (getNodeImpl(), *Impl methods, typed InsertPosition). A Gradle Sync task now refreshes Fortran-JS/java-binaries on installDist.

JS (Fortran-JS): sources moved src-apiapi, src-codecode (no transpilation step anymore — the package ships raw .ts); version 4.0.0 with @specs-feup/lara ^4.0.0; single noEmit tsconfig (TS7, erasableSyntaxOnly, verbatimModuleSyntax); jest→vitest via createWeaverVitestConfig from lara-4; eslint→oxlint/oxfmt; api/Joinpoints.ts regenerated with lara-build-interfaces from the generated FortranWeaver.json; nightly CI bumped to Node 24/25 (Java CI stays on 21).

Depends on the lara-4 branches of specs-feup/lara-framework and specs-feup/specs-java-libs (CI's branch-resolver resolves them by branch name).

Stack

mainmulti-weaver (#65) ← this PR (lara-4).

Migration notes / judgment calls

  • Rebase compile debt resolved here: main's ~55 new F* joinpoint classes and importable/AstFactory still used 1-arg constructors predating the weaver-threading refactor — all threaded with the FortranWeaver instance as part of the CRTP conversion. FortranWeaver.getContext()/getFactory() statics (which called the removed getFortranWeaver()) became instance methods, and AstFactory now takes the weaver as first parameter.
  • Real bugs fixed in passing: insertBefore(jp) actually inserted after; FortranMainProgram was never registered in the joinpoint factory; getNode() returned null in FortranFile/FInitialization/FSpecification/FMainProgram.
  • Joinpoint class renames: F<X>Fortran<X> (e.g. FProgramFortranProgram; FDoConstructFortranDoStatement for joinpoint doStatement) — WeaverGen2 validates that concrete classes are named <Prefix><CapitalizedJpName>. Prefix Fortran (not F) keeps the weaver class/JSON named FortranWeaver/FortranWeaver.json. LARA-visible joinpoint names are byte-identical to the XMLs.
  • BinaryOperatorKind enum carries the real runtime values (ADD, SUBTRACT, ...) — the old XML's inline {add, sub, ...} values were stale; the old implementation already returned the AST enum names.
  • Boxed types: everything primitive except base line/column (INTEGER, impl returns null — the Fortran AST has no source locations), following clava's conventions.
  • scopeNodes now returns the children (the old implementation threw NotImplementedException).
  • Version: 22.2.1 → 4.0.0, aligned with the other lara-4 repos (clava set 4.0.0 for the same transition).

Verification

  • gradle clean installDist (includes generateWeaver): BUILD SUCCESSFUL. (Gradle test suite needs flang, not available in the verification environment.)
  • tsc clean, oxlint clean, vitest: 2/2 passed (same as the main-line baseline — the weaver actually executes and weaves Fortran).

Comment thread .github/workflows/copilot-setup-steps.yml Fixed
@lm-sousa lm-sousa mentioned this pull request Sep 7, 2026
@lm-sousa
lm-sousa changed the base branch from main to multi-weaver September 7, 2026 18:30

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8537a59c7c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Fortran-JS/package.json
Replace the XML weaver specification (joinPointModel.xml, artifacts.xml,
actionModel.xml) with the Java DSL spec class FortranSpec (new src-spec
source set), and generate the abstract joinpoint classes with WeaverGen2
instead of the old WeaverGenerator.

- FortranSpec: prefix 'Fortran', root join point 'program', all 53 join
  points from the XML model, keeping the LARA-visible names identical.
  Concrete joinpoints renamed to the WeaverGen2 convention
  <Prefix><JpName> (F* -> Fortran*, e.g. FProgram -> FortranProgram;
  FDoConstruct -> FortranDoStatement). BinaryOperatorKind and DoKind
  enums now carry the values the old implementation actually produced
  (enum names such as ADD, instead of the stale lowercase XML list).
- New editable base FortranJoinpoint holds the implementation shared by
  all join points (code, children, descendants, scopeNodes, parent,
  root, leftJp/rightJp, getAncestor, contains, indexOfSelf, insert,
  insertBefore/After, replaceWith, detach, copy/deepCopy); the generic
  fallback join point is now FortranJoinpoint itself.
- FortranWeaver: drop buildLanguageSpecification/buildLangSpecs and the
  static getFactory()/getContext() helpers (weaver is threaded through
  join points and AstFactory), use setData in begin(), typed
  getRootJp(), add getAstMethods() bridge backed by the new
  FortranAstMethods.
- AstFactory methods take the weaver as first argument, mirroring the
  clava importable factory; callers in LARA pass Weaver.getWeaverEngine().
- Boxed types per conventions: indexOfSelf/contains are primitive
  (INT/BOOLEAN), line/column stay boxed (INTEGER) but return null (the
  Fortran AST has no source locations).
- Gradle: LangSpec2/WeaverGen2 includeBuilds, generateWeaver JavaExec
  running WeaverGen2Cli, spec source set, syncFortranJsJavaBinaries task
  finalizing installDist to refresh Fortran-JS/java-binaries.
- Delete committed generated abstracts, old XML resources and
  FortranWeaverException; gitignore the new generated paths.

Also fixed in passing: insertBefore(joinpoint) used to insert AFTER
(copied-over bug from the old generator stubs); getDescendants and other
internal factories were still calling the removed 1-arg
FortranJoinpoints.create; FortranFile/FInitialization/FSpecification/
FMainProgram getNode returned null; the unused FortranMainProgram join
point is now reachable from the factory.
- Move sources src-api -> api and src-code -> code; drop the transpile
  step (build is now a single tsc noEmit typecheck over a root tsconfig
  with NodeNext, strict, verbatimModuleSyntax, erasableSyntaxOnly).
- package.json: version 4.0.0 (aligning with the lara-4 major, replaces
  22.2.1), @specs-feup/lara ^4.0.0, package exports map, bin entry
  pointing at ./code/index.ts, oxlint/oxfmt/vitest scripts and prepack
  java-binaries validation; remove jest/ts-jest/eslint tooling.
- jest -> vitest: single vitest.config.ts using createWeaverVitestConfig
  with the weaver configuration; port Query.test.ts to the lara-4 test
  helpers from @specs-feup/lara/vitest.
- eslint -> oxlint: oxlint.config.ts extending @specs-feup/lara's
  config; delete the eslint config.
- WeaverConfiguration: weaverFileName and the new api/Joinpoints.ts side
  effects import; remove the obsolete sideEffects.ts.
- Regenerate api/Joinpoints.ts with lara-build-interfaces from the
  WeaverGen2-generated FortranWeaver.json; update imports to .ts
  extensions; enum attributes (DoKind, BinaryOperatorKind) are now
  typed const-object enums.
- FortranJoinPoints.ts: thread the weaver engine into the Java
  AstFactory (Weaver.getWeaverEngine()), mirroring clava's
  importable-AstFactory API.
- Parameter properties in the loop passes replaced with explicit fields
  (erasableSyntaxOnly); remove unused import and unnecessary spreads
  flagged by oxlint.
- Update the node versions in the nightly workflow to match the lara-4
  toolchain (25.x/24.x).
The lara-4 pull requests are stacked on multi-weaver; without this the
PR pushes run no CI at all.
@sonarqubecloud

sonarqubecloud Bot commented Sep 7, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants