Repository navigation
Conversation
Plugin Test Summary 1 files 3 suites 1s ⏱️ Results for commit 38cb11f. ♻️ This comment has been updated with latest results. |
Compactc E2E Test Summary 1 files ± 0 1 suites - 52 6m 41s ⏱️ + 4m 54s Results for commit 38cb11f. ± Comparison against base commit 56c3b77. This pull request removes 477 and adds 3106 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
There was a problem hiding this comment.
Pull request overview
Adds a lightweight Scheme hook for consumers to process analyzed compiler IR without exposing compiler libraries.
Changes:
- Adds and documents
--ir-hook. - Stores the loaded hook in compiler configuration.
- Invokes the hook with IR, proof names, VM expander, and output directory.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
compiler/compactc.ss |
Parses, loads, and validates the hook. |
compiler/config-params.ss |
Defines the hook parameter. |
compiler/passes.ss |
Invokes the hook after analysis. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
1cafa41 to
1368d2a
Compare
…e file Signed-off-by: Rodrigo Quelhas <rodrigo_quelhas@outlook.pt>
Adds
--ir-hook. The compiler calls a procedure in a Scheme file with the program at each stage of compilation. The compiler writes no file of its own. The hook decides what to emit.(hook stage* proof-circuit-name* compiler target-directory) stage* = ((lsrc <program> <unparse>) (frontend <program> <unparse>) (analyzed <program> <unparse>) (circuit <program> <unparse>))Each stage carries the unparser of its own language, taken from the pass that made it.
compilerholds what a file cannot reach on its own:expand-vm-code, analignconstructor, and the three version strings.Example
Write a file that defines
hook. This one takes the analyzed stage, and prints it with the unparser that stage carried in:Run the compiler with it:
It writes
out/compiler/analyzed.sexp:(program (kernel-declaration (%kernel.0 () (Kernel))) (public-ledger-declaration ((%round.1 (0) (Counter))) (constructor () (tuple))) (circuit %increment.2 () (ttuple) (seq (let* (((%tmp.3 (tunsigned 65535)) (safe-cast (tunsigned 65535) (tunsigned 1) 1))) (public-ledger %round.1 (0) increment %tmp.3)) (tuple))))Take
(assq 'lsrc stage*),'frontendor'circuitfor the other stages. Each one prints with its own unparser.The unparse templates drop some fields. The
public-ledgerform above prints without its operation class, its type, and its expanded VM instructions. Atadtprints without itsvm-exprand its two operation tables. AProgramprints without the export table and the contract types. A hook that needs those walks the tree itself, and calls the unparser for the parts it covers.A 366-line hook writes the same
compiler/analyzed-ir.sexpas LFDT-Minokawa#722. All 215 example contracts that compile give byte-identical files.