coalton-codegen-ast compiles top-level Coalton forms, prints the typechecked AST for each top-level define to *standard-output*, and returns nil.
Syntax
(coalton-codegen-ast
⟨toplevel-form⟩*)
Semantics
coalton-codegen-astaccepts the same top-level forms ascoalton-toplevel.- During compilation, it invokes
*codegen-hook*with:ASTright after typechecking and before dictionary translation and optimization. - For each top-level
definebinding in the unit, it prints⟨name⟩ :: ⟨type-scheme⟩followed by the readable structure of its typechecked body (coalton-impl/typechecker/expression:node-body) to*standard-output*. - Unlike
coalton-codegen, it prints during evaluation and returnsnil.
Examples
(coalton-codegen-ast
(declare double (Integer -> Integer))
(define (double x)
(+ x x)))
;; prints:
;; DOUBLE :: INTEGER → INTEGER
;; #S(NODE-BODY ...)
; => NIL
Other notes
- See
pprint-coalton-codegen-ast,coalton-codegen, andcoalton-codegen-types. - To look up the post-optimization codegen AST (
coalton-impl/codegen/ast:node) of an already-defined top-level symbol in the global environment, call(coalton:lookup-code 'name).