WG211/M12Rhiger

From WG 2.11
Jump to: navigation, search

Towards static compilation of dynamic code generation by Morten Rhiger

Multi-stage languages provide first-class code fragments that can be constructed, composed, and executed dynamically at runtime.

We present a translation from a typed multi-stage source language to multi-stage target code. The source language is high level: It represents variables (including variables in code fragments) by their name. The target code is low level: It represents variables (including variables in code fragments) by their memory location.

This translation, therefore, is one step towards multi-stage languages that compile code fragments statically at compile time rather than dynamically at runtime.

The translation is based on a simple type system for multi-stage languages and an observation that the code type of this type system precisely characterizes the memory layout of code fragments.