Special symbols |
The compiler uses several special symbols for representing auxiliary programs and storing special information in environments. A hopefully exhaustive list follows below. We will have to modify some names and ensure that no name clashes can occur.
Add section on global variables.
This is a special converter for an expression of any type into Void.
Programs BEGIN (prg1, …, prgn) represent sequential blocks in which prg1 until prgn have already been declared. In particular, the declaration phase transforms input programs of the form begin (prg1, …, prgn) into auxiliary programs of the form BEGIN (prg1', …, prgk') which will next be passed to the routine compile.
Programs READ (this, var: tp) represent read-only field access for class fields.
Programs WRITE (this, var: tp) represent writable field access for class fields.
Programs METHOD (lambda (this: This): R do prg) represent methods of classes and result in the possibility to denote this.var directly by var inside prg.
Programs CONSTRUCT (prg, This) correspond
constructors for the class
The program Lambda (name, locs, params, body, rtype) stands for an unnested lambda expression with given name, parameters params, body and return type rtype. The parameter locs stands for non-global variables which are referred to from within the body, without being declared in the body and without being among the parameters.
This construct is used for auxiliary programs during the building phase. It corresponds to a block of commands which is not directly a begin.
A cleaner solution might be implemented.
If sym is a macro, then this environment variable is set to the body of that macro.
At the moment, macros with parameters are not yet implemented.
Macros importation is not yet handled either for modules.
This variable contains the expected return type when compiling the body of a lambda expression.
This variable contains the type of the environment under consideration, among top, lambda, class and module.
Name of the current class or module being declared.
Current declaration mode for classes and modules among extern, intern, method or constructor.
Current access mode for declarations among constant and mutable.
Visibility of declarations among public and private.
Overloading mode for declarations among preemptive (variables are completely redeclared in inner environment) or extensive (variables overload variables of the same name in the parent environment).
Not yet implemented.
Vector with all fields of the current class being declared.
Environment which is used for the compilation of methods. Methods are rewritten into the form METHOD (lambda (this: This): R do prg) and the METHOD primitive has the effect of selecting the method environment. This environment has macro declarations meth ==> this.name for all methods meth.
The environment variable with the list of all converter definitions in the current environement. This list of converters is constructed during the declaration phase. All other environment variables for converter management below are only used for caching potentially expensive computations.
The converter from an atomic type F into another atomic type T. This converter is given in the form of a function which takes a compiled program of type F on input and returns the compiled converted program of type T.
Penalty for the conversion from F to T.
Left transitivity of the converter from F to T (true or false).
Right transitivity of the converter from F to T (true or false).
Table t with incoming converters. Given a type T, the value t[T] is again a table and t[T][F] is set if there is a converter from F to T.
Table t with outgoing converters. Given a type F, the value t[F] is again a table and t[F][T] is set if there is a converter from F to T.
List of converters (of type CONVS) from a general type F into T.
List of possible joins between types T and U (used by if-then-else).
List of possible function applications for a function of type F to a list of arguments of type A.