Skip to content

Add --analyzed-ir to write the analyzed program as one S-expression - #16

Closed
RomarQ wants to merge 5 commits into
mainfrom
rp/normalized-ir
Closed

RomarQ wants to merge 5 commits into
mainfrom
rp/normalized-ir

Conversation

@RomarQ

@RomarQ RomarQ commented Aug 16, 2026 •

Copy link
Copy Markdown
Owner

Adds --analyzed-ir. The flag writes one more file into the target directory, compiler/analyzed-ir.sexp.

The file holds the analyzed program in the compiler's own vocabulary. Each ledger operation and each emit carries its expanded Impact VM instructions. Circuits carry their exported, pure and proof flags, and the program carries its export table.

Part of CoIP: LFDT-Minokawa#700.

@github-actions

github-actions Bot commented Aug 16, 2026 •

Copy link
Copy Markdown

Plugin Test Summary

 1 files   3 suites   1s ⏱️
21 tests 21 ✅ 0 💤 0 ❌
23 runs  23 ✅ 0 💤 0 ❌

Results for commit 39521ed.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Aug 16, 2026 •

Copy link
Copy Markdown

Compactc E2E Test Summary

  1 files  ±0   53 suites  ±0   1m 58s ⏱️ +11s
477 tests ±0  477 ✅ ±0  0 💤 ±0  0 ❌ ±0 
488 runs  ±0  488 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit 39521ed. ± Comparison against base commit 56c3b77.

♻️ This comment has been updated with latest results.

Copilot AI 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.

Pull request overview

Adds opt-in normalized IR generation for language-agnostic SDK consumers.

Changes:

  • Adds --normalized-ir CLI support.
  • Serializes analyzed programs and expanded Impact VM instructions as S-expressions.
  • Integrates artifact generation into the compiler pipeline.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
compiler/compactc.ss Defines the flag and help text.
compiler/config-params.ss Adds the configuration parameter.
compiler/passes.ss Runs normalized IR generation when enabled.
compiler/save-normalized-ir-passes.ss Defines the pass library.
compiler/save-normalized-ir-passes/extract-normalized-ir.ss Converts analyzed IR into normalized S-expressions.
compiler/save-normalized-ir-passes/save-normalized-ir.ss Writes the normalized artifact.
Suppressed comments (2)

compiler/save-normalized-ir-passes/extract-normalized-ir.ss:50

  • The operands of VMnull and VMmax-sizeof are IR types (see rt-null/rt-max-sizeof in vm.ss), but this routes them back through vm-value->sexp, whose fallback treats them as expressions. Operations such as Map.insertDefault therefore fail while extracting their (null value_type) operand. Serialize these operands with the Type transformer.
           [(VMnull x) `(null ,(vm-value->sexp x))]
           [(VMmax-sizeof x) `(max-sizeof ,(vm-value->sexp x))]

compiler/save-normalized-ir-passes/extract-normalized-ir.ss:250

  • The serialized operation drops op-class, so it cannot reproduce update-with-coin-check semantics. TypeScript checks that class and its coin/recipient indices to call hasCoinCommitment before queryLedgerState (print-typescript.ss:464-501); that check is not part of the expanded VM instruction list. Preserve the operation class and indices (or emit equivalent explicit metadata), otherwise writeCoin/insertCoin operations execute differently from generated TypeScript.
           ,ledger-op
           ,(Type type)
           (instructions ,@(expand-ops src path-elt* adt-formal* adt-arg* var-name* expr* vm-code))

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@RomarQ RomarQ changed the title Add --normalized-ir to write the analyzed program as one S-expression Add --analyzed-ir to write the analyzed program as one S-expression Aug 16, 2026
@RomarQ
RomarQ requested a balanced review from Copilot August 17, 2026 10:14

Copilot AI 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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Suppressed comments (2)

compiler/save-analyzed-ir-passes/extract-analyzed-ir.ss:29

  • Identifier text is not stable here: formatting an id invokes the record writer, which lazily assigns id-uniq (langs.ss:493-501). With --trace-passes, earlier pass unparsing at passes.ss:71-73 assigns those numbers in a different traversal before this serializer runs, so the same source produces a different analyzed-ir.sexp merely by enabling tracing. Please make artifact identifiers independent of prior printing (or assign compiler IDs deterministically before any optional unparsing).
    (define (id->sym i) (string->symbol (format "~a" i)))

compiler/passes.ss:152

  • The new flag and 329-line serializer have no compiler-suite coverage. The existing suite snapshots many contract-info.json variants, but nothing enables write-analyzed-ir or checks this output. Add tests that assert the flag-off file is absent, snapshot representative ledger/emit/native output when enabled, and verify diagnostic flags such as trace-passes do not alter the artifact.
                        (when (write-analyzed-ir)
                          (with-target-ports
                            '((analyzed-ir.sexp . "compiler/analyzed-ir.sexp"))
                            (run-passes save-analyzed-ir-passes analyzed-ir proof-circuit-name*)))

Copilot AI 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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

Suppressed comments (1)

compiler/passes.ss:152

  • The new output branch and 338-line serializer are not exercised by tests; the man-page fixture only verifies help text. This leaves flag wiring, default absence, file creation, S-expression readability, and the required ledger/emit instruction and export/proof metadata unprotected. Please add an end-to-end flag test plus golden/pass-level coverage, following the existing save-contract-info coverage in compiler/test.ss:35597.
                        (when (write-analyzed-ir)
                          (with-target-ports
                            '((analyzed-ir.sexp . "compiler/analyzed-ir.sexp"))
                            (run-passes save-analyzed-ir-passes analyzed-ir proof-circuit-name*)))

@RomarQ
RomarQ force-pushed the rp/normalized-ir branch 2 times, most recently from f9a22f5 to b5b0b5f Compare August 18, 2026 14:42
RomarQ added 5 commits August 18, 2026 18:10
Signed-off-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
Signed-off-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
Signed-off-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
Signed-off-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
Signed-off-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
@RomarQ RomarQ closed this Aug 18, 2026
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