previous up next     contents index
Next: Compilation Info Up: Syntax Previous: Syntax

Compilier

The input S-expression to a syntax compiler is the full subexpression which invoked the syntax. Thus, the  car of this syntax will always be the global variable name though which the syntax was accessed. The goal of the compiler is to perform as much evaluation work as possible on this expression without using variable values; part of this work is converting variable names to run-time locations.

The compiler is passed a compile-time environment as a Scheme_Env *; in this environment the ``value'' of each local variable is a symbol which is the variable's name. The function  scheme_lookup_value takes a synbol and a compile-time environment and returns the location of the variable in a run-time environment, either as a static-distance value ( scheme_static_distance_type) or a global-location value ( scheme_variable_type).

The compiler is also passed a pointer to a Scheme_Compile_Info structure. This structure contains information about the context in which the syntax occurs; before the compiler returns, this structure must be filled in with information needed by the external context.

When the syntax compiler compiles subexpressions, then it provides an appropriately initialized Scheme_Compile_Info structure for each subexpression compilation. The syntax compiler may find the information returned by subexpressions to be useful. In any case, syntax compiler is responsible for merging the compilation info from the subexpressions into its own Scheme_Compile_Info. Utilities are provided to facilitate this process.

The result of compiling is a collection of data that, together with a run-time enviroment (containing data instead of names), produce a Scheme value. The function which combines the compiled data and the environment at run-time is the executor. Therefore, the result of compilation is (usually) a function-data pair created with  make_syntax_compilation.

In order to save this function-data pair to a file as compiled code, MzScheme must be able to:




previous up next     contents index
Next: Compilation Info Up: Syntax Previous: Syntax

PLT