University of Salzburg (Michael Gschwandtner, Peter Wild)


As a course project for the compiler construction class 2005, we have implemented a compiler (wgsc) for a custom designed subset of the programming language Microsoft C# (the compiler is also bootstrapped in this language) and a virtual machine (wgsvm) written in C to support a variety of different platforms. Special features include:

  • Datatypes: Basic types (integer, boolean, char - all call-by-value), complex types (strings, dynamic 1-dimensional anonymous-typed arrays, and possibly nested structs - all call-by-reference). Explicit type-checking (name equivalence, mode equivalence, structural equivalence up to base type for arrays) is done at every assignment. Symbol tables are generated for classes, class members, fields and local variables. Self-referencing is supported.
  • Functions/Procedures: No function prototyping is necessary due to a symbolic parse step and call address fixup. No caller or callee save storage and restoring of registers at function calls is required. Procedures and functions are grouped in classes and may be called with parameters. Local hiding of functions, calling undeclared functions is supported. We do not provide polymorphism or inheritance, but solely encapsulation.
  • Exception handling: Both compiletime and runtime checks (Null-pointer, Out of bounds) are executed. However, the language is very restrictive, thus many errors will be detected by checking syntax only (distinguishing between procedure calls and assignments as well as between assigned expressions and function calls or class/array initialization is via productions only and not via checking additional state information within the parser).
  • Language elements: Support is given for standard arithmetics, expressions, conditions (if) and loops (while), lazy evaluation, standard IO, file IO and type conversion.
  • Virtual machine: The proposed system architecture supports 64 bit commands, even if only 32-bit registers are used, as this design simplifies instruction fetching. Each command is composed of an 8-bit OP-code, 8-bit destination register, 8-bit source register 1, 8-bit source register 2, and 32-bit immediate field.


Last modified: 07 November 2015 04:57:34
© Peter Wild. All rights reserved.