IntermediateCodeTypeInference
Class containing code for determining the type of ImpLan expressions and adding casts. Does not perform type checking in any way. Hence this class should only be used for code which is known to be type correct.
Attributes
- Graph
- Supertypes
- class Objecttrait Matchableclass Any
- Self type
Members list
Value members
Concrete methods
Casts an expression to a target type if necessary. Also assures type equality by wrapping sub-expressions into casts where necessary.
Casts an expression to a target type if necessary. Also assures type equality by wrapping sub-expressions into casts where necessary.
Attributes
- exp
Expression to be casted
- target
Type to which the expression should be casted. Optional. If None only the sub-expressions are casted if necessary.
- varTypes
Type environment, mapping every possibly involved variable identifier to its type
- Returns:
Expression potentially wrapped into a IntermediateCode.CastingExpression and all sub-expression with non-expected type also wrapped into a cast expression.
Includes casts where necessary in a source listing
Includes casts where necessary in a source listing
Attributes
- listing
The source listing to be examined
- varTypes
Type environment, mapping every possibly involved variable identifier to its type
- Returns:
The source listing with casts added
Adds casts to sub-expressions of a statement sequence where necessary
Adds casts to sub-expressions of a statement sequence where necessary
Attributes
- retType
Type to which return statements from stmts are casted. Optional. If None, no casting is performed for these return statements (but still for sub-expressions)
- stmts
Statements to be examined.
- varTypes
Type environment, mapping every possibly involved variable identifier to its type
- Returns:
Statement sequence with casts added
Casts a function expression into a function expression with another signature by wrapping a lambda expression around the original function. The parameters and return value are casted in the usual way when calling the original function.
Casts a function expression into a function expression with another signature by wrapping a lambda expression around the original function. The parameters and return value are casted in the usual way when calling the original function.
Example:
f : LongType x LongType -> LongType casted to Lazy[GeneralType] x Lazy[GeneralType] -> Lazy[GeneralType]
would produce
(tp1: Lazy[GeneralType], tp2: Lazy[GeneralType]) => {(Lazy[GeneralType])(f((LongType)tp1, (LongType)tp2)}
Attributes
- from
Type of innerExp
- innerExp
Expression to be casted.
- to
Type to cast to
- varTypes
Type environment, mapping every possibly involved variable identifier to its type
- Returns:
Casted expression (wrapped into lambda)
Determines the type of an IntermediateCode.ImpLanExpr. This function may return error-prone results if the examined expression is not type-correct.
Determines the type of an IntermediateCode.ImpLanExpr. This function may return error-prone results if the examined expression is not type-correct.
Attributes
- impLanExpr
Expression to be examined
- varTypes
Type environment, mapping every possibly involved variable identifier to its type
- Returns:
Type of the expression