Class UnaryOperation
java.lang.Object
simula.compiler.syntaxClass.SyntaxClass
simula.compiler.syntaxClass.expression.Expression
simula.compiler.syntaxClass.expression.UnaryOperation
Unary Operation.
Syntax: unary-operation = unary-operator Expression unary-operator = NOT | + | -
Link to GitHub: Source File.
- Author:
- Øystein Myhre Andersen
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) Expression
The operand Expression.(package private) int
The unary operator.Fields inherited from class Expression
backLink, type
Fields inherited from class SyntaxClass
CHECKED, lineNumber, OBJECT_SEQU
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Default constructor used by Attribute File I/Oprivate
UnaryOperation
(int oprator, Expression operand) Create a new UnaryOperation. -
Method Summary
Modifier and TypeMethodDescriptionvoid
buildEvaluation
(Expression rightPart, CodeBuilder codeBuilder) ClassFile coding utility: Build Evaluation Code.static void
buildNOT
(CodeBuilder codeBuilder) Build code for the NOT operation.(package private) static Expression
create
(int oprator, Expression operand) Create a new UnaryOperation.void
Perform semantic checking.evaluate()
Try to Compile-time Evaluate this expressionboolean
Returns true if this expression may be used as a statement.static UnaryOperation
Read and return an UnaryOperation object.Generate Java code for this Syntax Class.toString()
void
Write a SyntaxClass object to a AttributeOutputStream.Methods inherited from class Expression
acceptExpression, checkCompatibility, expectExpression, get, getInt, getNumber, getQualification, getWriteableVariable, printTree, put
Methods inherited from class SyntaxClass
ASSERT_SEMANTICS_CHECKED, buildByteCode, doDeclarationCoding, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, SET_SEMANTICS_CHECKED, setLineNumber
-
Field Details
-
oprator
int opratorThe unary operator. -
operand
Expression operandThe operand Expression.
-
-
Constructor Details
-
UnaryOperation
Create a new UnaryOperation.- Parameters:
oprator
- the unary operator.operand
- the operand Expression
-
UnaryOperation
private UnaryOperation()Default constructor used by Attribute File I/O
-
-
Method Details
-
create
Create a new UnaryOperation.- Parameters:
oprator
- the unary operator.operand
- the operand Expression- Returns:
- the newly created UnaryOperation
-
evaluate
Description copied from class:Expression
Try to Compile-time Evaluate this expression- Overrides:
evaluate
in classExpression
- Returns:
- the resulting evaluated expression
-
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
-
buildEvaluation
Description copied from class:Expression
ClassFile coding utility: Build Evaluation Code.- Specified by:
buildEvaluation
in classExpression
- Parameters:
rightPart
- expressioncodeBuilder
- the codeBuilder used.
-
buildNOT
Build code for the NOT operation.- Parameters:
codeBuilder
- the codeBuilder to use.
-
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
-
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 an UnaryOperation object.- Parameters:
inpt
- the AttributeInputStream to read from- Returns:
- the UnaryOperation object read from the stream.
- Throws:
IOException
- if something went wrong.
-