2.10.3

We know that we're going to need some sort of assembly to contain the executable code. Since AL does not support objects or methods, we'll use a simple translation scheme. To create the executable program, we'll generate an assembly with a Main method into which we'll place all the generated IL. Figure 2.19 illustrates the structure of the executable produced by the compiler.

The compiler takes progname.al, compiles it, and generates an executable called progname.exe. The latter represents a single-file assembly, AlcAsm, which in turn contains a single module, AlcMod, containing a single class AlcCls. The compilation process automatically generates a default constructor for AlcCls which simply calls the base class, System.Object, constructor. AlcCls.Main is where we place the IL generated by the compilation process.

We'll use the Framework's System.Reflection.Emit classes to create each of these building blocks, and we'll discuss them in turn. The full compiler program is presented in listing 2.15. It is presented here in outline form.