Skip to content
redchrom edited this page Sep 13, 2010 · 6 revisions

The compilation process split on 4 stages:

  1. Macro expansion
  2. CPS conversion
  3. Code generation
  4. Assembly

Macro expansion

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.

CPS conversion

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.

Code generation

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

Assembly

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.

Clone this wiki locally