8. Compilation Strategy
The overall approach RABBIT takes to the compilation of SCHEME code may be summarized as follows:
- Alpha-conversion (renaming of variables) and macro-expansion (expansion of syntactic rewrite rules).
- Preliminary analysis (variable references, "trivial" expressions, and side effects).
- Optimization (meta-evaluation).
- Conversion to continuation-passing style.
- Environment and closure analysis.
- Code generation.
During (1) a data structure is built which is structurally a copy of the user program but in which all variables have been renamed and in which at each "node" of the program tree are additional slots for extra information. These slots are filled in during (2). In (3) the topology of the structure may be modified to reflect transformations made to the program; routines from (2) may be called to update the information slots. In (4) a new data structure is contructed from the old one, radically different in structure, but nevertheless also tree-like in form. During (5) information is added to slots in the second structure. In (6) this information is used to produce the final code.