-
Notifications
You must be signed in to change notification settings - Fork 1
Compilation stages
The compilation process split on 4 stages:
- Macro expansion
- CPS conversion
- Code generation
- Assembly
The expander use lazy algorithm by R. Kent Dybvig, In Andy Oram and Greg Wilson described in their work Syntactic abstraction: the syntax-case expander
Output of this stage is core-form (define, set!, lambda, begin, if) representation of a program. Besides expansion, the expander also manage libraries.
lgears use method known as CPS conversion. CPS conversion generate a code representation where each call is placed in a tail context and has a continuation as first parameter.
On this stage, compiler analyze functions, resolve names and finally, generate linear code representation for VM.
Command is a list of:
- Opcode symbol
- Argument
- Stack usage by this command
- Optional debug symbol
The assembler take the code from the previous stage and generate a binary bytecode. Opcode symbols resolves to integers and debug information writes to a separate file.