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

Linker

A linker is passed information from its compiler and a link-time environment. This environment is simply a top-level run-time environment; it does not need to be extended and it is only referenced by  scheme_link_expr.

The result of plain compilation is data that is not yet attached to specific global variables. Linking compiled code changes references to global variable names to direct uses of a global variable. Compiled code can be linked mulitple times within different global variable namespaces.

The result of linking 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 linked data and the environment at run-time is the executor. Therefore, the result of linking is (usually) a function-data pair created with  make_syntax_link.

For most syntactic forms, linking is simply linking all of the syntax's sub-expressions.

Often, an expresison is known to be singly-linked at compile time. To avoid a double-traversal of the code, compilation and linking are performed together. A compiler must check the can_optimize_constants field of its input  Scheme_Compile_Info structure; if this field is true, the compiler must both compie and link code and return linked code. Setting up sub-expression  Scheme_Compile_Info records automatically propogates the can_optimize_constants field so that calling  scheme_compile_expr on sub-expressions obtains linked code for the sub-expressions instead of compiled code.



PLT