Class TypeConversion
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
FieldsFields inherited from class simula.compiler.syntaxClass.expression.Expression
backLink, type
Fields inherited from class simula.compiler.syntaxClass.SyntaxClass
CHECKED, lineNumber, OBJECT_SEQU
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Default constructor used by Attribute File I/OTypeConversion
(Type type, Expression expression) Create a new TypeConversion. -
Method Summary
Modifier and TypeMethodDescriptionvoid
buildEvaluation
(Expression rightPart, CodeBuilder codeBuilder) ClassFile coding utility: Build Evaluation Code.static void
buildMayBeConvert
(Type fromType, Type toType, CodeBuilder codeBuilder) ClassFile coding utility: Test if a TypeConversion is necessary and then create it.void
Perform semantic checking.Get a writeable variable.static String
mayBeConvert
(Type fromType, Type toType, String expr) Java Coding utility: Test if a TypeConversion is necessary and then create it.boolean
Returns true if this expression may be used as a statement.static TypeConversion
Read and return a TypeConversion object.static Expression
testAndCreate
(Type toType, Expression expression) Java Coding utility: Test if a TypeConversion is necessary and then create it.private static boolean
testCastNeccessary
(Type toType, Expression expression) Java coding utility: Test if a Type Cast is necessary.Generate Java code for this Syntax Class.toString()
void
Write a SyntaxClass object to a AttributeOutputStream.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, buildByteCode, doDeclarationCoding, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, SET_SEMANTICS_CHECKED, setLineNumber
-
Field Details
-
expression
The expression.
-
-
Constructor Details
-
TypeConversion
Create a new TypeConversion.- Parameters:
type
- the new typeexpression
- the expression
-
TypeConversion
private TypeConversion()Default constructor used by Attribute File I/O
-
-
Method Details
-
mayBeConvert
-
buildMayBeConvert
ClassFile coding utility: Test if a TypeConversion is necessary and then create it.- Parameters:
fromType
- convert from this typetoType
- convert to this typecodeBuilder
- the codeBuilder to use.
-
testAndCreate
Java Coding utility: Test if a TypeConversion is necessary and then create it.- Parameters:
toType
- convert to toTypeexpression
- the expression- Returns:
- the resulting expression
-
testCastNeccessary
Java coding utility: Test if a Type Cast 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
-
buildEvaluation
Description copied from class:Expression
ClassFile coding utility: Build Evaluation Code.- Specified by:
buildEvaluation
in classExpression
- Parameters:
rightPart
- expressioncodeBuilder
- the codeBuilder used.
-
toString
- Overrides:
toString
in classExpression
-
writeObject
Description copied from class:SyntaxClass
Write a SyntaxClass object to a AttributeOutputStream.- Overrides:
writeObject
in classSyntaxClass
- Parameters:
oupt
- the AttributeOutputStream to write to.- Throws:
IOException
- if something went wrong.
-
readObject
Read and return a TypeConversion object.- Parameters:
inpt
- the AttributeInputStream to read from- Returns:
- the TypeConversion object read from the stream.
- Throws:
IOException
- if something went wrong.
-