java.lang.Object
simula.compiler.syntaxClass.SyntaxClass
simula.compiler.syntaxClass.expression.Expression
simula.compiler.syntaxClass.expression.TypeConversion
Type Conversion.
Link to GitHub: Source File.
-
Field Summary
Fields inherited from class simula.compiler.syntaxClass.expression.Expression
backLink, type
Fields inherited from class simula.compiler.syntaxClass.SyntaxClass
lineNumber
-
Constructor Summary
ModifierConstructorDescriptionprivate
TypeConversion
(Type type, Expression expression) Create a new TypeConversion. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Perform semantic checking.Get a writeable variable.static String
mayBeConvert
(Type fromType, Type toType, String expr) Test if a TypeConversion is necessary and then create it.boolean
Returns true if this expression may be used as a statement.static Expression
testAndCreate
(Type toType, Expression expression) Test if a TypeConversion is necessary and then create it.private static boolean
testCastNeccessary
(Type toType, Expression expression) Test if a TypeConversion is necessary.Generate Java code for this Syntax Class.toString()
Methods inherited from class simula.compiler.syntaxClass.expression.Expression
acceptExpression, checkCompatibility, evaluate, expectExpression, get, getInt, getNumber, getQualification, printTree, put
Methods inherited from class simula.compiler.syntaxClass.SyntaxClass
ASSERT_SEMANTICS_CHECKED, doDeclarationCoding, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, SET_SEMANTICS_CHECKED
-
Field Details
-
expression
The expression.
-
-
Constructor Details
-
TypeConversion
Create a new TypeConversion.- Parameters:
type
- the new typeexpression
- the expression
-
-
Method Details
-
mayBeConvert
Test if a TypeConversion is necessary and then create it.- Parameters:
fromType
- convert from this typetoType
- convert to this typeexpr
- the expression- Returns:
- piece of Java source code
-
testAndCreate
Test if a TypeConversion is necessary and then create it.- Parameters:
toType
- convert to toTypeexpression
- the expression- Returns:
- the resulting expression
-
testCastNeccessary
Test if a TypeConversion is necessary.- Parameters:
toType
- the desired typeexpression
- the expression- Returns:
- piece of Java source code
-
getWriteableVariable
Description copied from class:Expression
Get a writeable variable.This method is redefined in Variable, RemoteVariable and TypeConversion
- Overrides:
getWriteableVariable
in classExpression
- Returns:
- a writeable variable or null
-
doChecking
public void doChecking()Description copied from class:SyntaxClass
Perform semantic checking.This must be redefined in every subclass.
- Overrides:
doChecking
in classSyntaxClass
-
maybeStatement
public boolean maybeStatement()Description copied from class:Expression
Returns true if this expression may be used as a statement.- Specified by:
maybeStatement
in classExpression
- Returns:
- true if this expression may be used as a statement
-
toJavaCode
Description copied from class:SyntaxClass
Generate Java code for this Syntax Class.- Overrides:
toJavaCode
in classSyntaxClass
- Returns:
- Java code
-
toString
- Overrides:
toString
in classExpression
-