Marker trait for all built-in entities.
A built-in type with an implicit definition that the compiler must have special knowledge about.
A user-defined constant entity represented by a constant declaration.
A built-in value of some type that is represented by a particular integer value.
A user-defined module represented by a module declaration.
An entity representing by a user-provided type declaration.
A user-defined type.
A variable entity including a reference to its types' definition.
Built-in Boolean type.
Built-in Boolean type.
Return an IF cascade equivaleant to the given cases and optional else block.
Return an IF cascade equivaleant to the given cases and optional else block. The variable ce holds the selection value. Specifically, these cases on ce CASE e1 : s1 CASE e2 .. e3 : s2 ELSE s3 are transformed into IF ce = e1 THEN s1 ELSEIF (ce >= e2) & (ce <= e3) THEN s2 ELSE 32 END If a case has more than one condition then they are combined with Or operators.
Check an AST node for semantic errors.
Check an AST node for semantic errors. Report any errors using the messaging module. This default implementation just ask the node's children to check themselves.
The default environment.
The default environment.
Desugar CASE statements into equivalent blocks containing cascading IF statements.
Desugar CASE statements into equivalent blocks containing cascading IF statements. A new variable called "casevar" is introduced in the block to hold the selection value so that it does not need to be re-evaluated. Specifically, CASE e OF cases END is transformed into VAR caseval : INTEGER; BEGIN caseval := e; IF caseval ... THEN ... END END
Desugar FOR statements into equivalent blocks containing a WHILE loop.
Desugar FOR statements into equivalent blocks containing a WHILE loop. A new variable called "limit" is introduced in the block to hold the upper limit of the FOR to protect against changes in the body. Specifically, FOR id := e1 TO e2 BY e3 DO body END is transformed into VAR limit : INTEGER; BEGIN id := e1; limit := e2; WHILE (id op limit) DO body id := id + e3 END END If e3 is negative, op is <=, otherwise it is >=.
The program entity referred to by an identifier definition or use.
The program entity referred to by an identifier definition or use. In the case of a definition it's the thing being defined, so define it to be a reference to the declaration. If it's already defined, return a entity that indicates a multiple definition. In the case of a use, it's the thing defined elsewhere that is being referred to here, so look it up in the environment.
The entity for an identifier definition as given by its declaration context.
The entity for an identifier definition as given by its declaration context.
The environment containing bindings for all identifiers visible at the given node.
The environment containing bindings for all identifiers visible at the given node. It starts at the module declaration with the default environment. At blocks we enter a nested scope which is removed on exit from the block. At constant and type declarations the left-hand side binding is not in scope on the right-hand side. Each identifier definition just adds its binding to the chain. The envout cases for assignment and expression mean that we don't need to traverse into those constructs, since declarations can't occur there.
Is an expression expected to be constant or not? Either the expression is the root of an expected constant expression or its parent expression is expected to be constant.
Is an expression expected to be constant or not? Either the expression is the root of an expected constant expression or its parent expression is expected to be constant.
Built-in false constant.
Built-in false constant.
Built-in integer type.
Built-in integer type.
Return true if the given type is Boolean or an unknown type.
Return true if the given type is Boolean or an unknown type.
Return true if the entity is erroneous or is a constant.
Return true if the entity is erroneous or is a constant.
Return true if the entity is an error, false otherwise.
Return true if the entity is an error, false otherwise.
Return true if the given type is integer or an unknown type.
Return true if the given type is integer or an unknown type.
Return true if the expression can legally appear on the left-hand side of an assignment statement.
Return true if the expression can legally appear on the left-hand side of an assignment statement. At this level only allow identifiers of variables or things we don't know anything about. The true default is used so that this computation can be used in redefinitions.
Return true if the entity is erroneous or is a module.
Return true if the entity is erroneous or is a module.
Return true if the identifier is an r-value and hence its value can be used (ie.
Return true if the identifier is an r-value and hence its value can be used (ie. it's erroneous or is a constant, value or variable).
Return true if the entity is erroneous or is a type.
Return true if the entity is erroneous or is a type.
Return true if the entity is erroneous or is a variable.
Return true if the entity is erroneous or is a variable.
Is an expression constant or not? Unknown entities are constant.
Is an expression constant or not? Unknown entities are constant. Strictly speaking we only need to support integer expressions here, but we treat Boolean ones as constant in the same way so that we avoid spurious errors. Type analysis will reject Boolean constant expressions anyway.
Is this expression the root of what is expected to be a constant expression? At this level only expressions on the RHS of a constant declaration have this property.
Is this expression the root of what is expected to be a constant expression? At this level only expressions on the RHS of a constant declaration have this property.
Desugar FOR and CASE statements into simpler constructs.
Desugar FOR and CASE statements into simpler constructs. Then call the next level of transformation.
Built-in true constant.
Built-in true constant.
Rename user-defined names to avoid clashes with outer declarations of the same name.
Rename user-defined names to avoid clashes with outer declarations of the same name. This transformation is not idempotent.
A type that is unknown, eg because the typed thing is erroneously defined.
A type that is unknown, eg because the typed thing is erroneously defined.
What is the value of an integer expression? Only needs to be valid if the expression is an integer constant (see isconst above) and is defined (eg, no divide by zero.
What is the value of an integer expression? Only needs to be valid if the expression is an integer constant (see isconst above) and is defined (eg, no divide by zero.) Returns zero in all other cases. FIXME: Ignores issues of overflow.
Desugaring transformation for L2.