Class StepUntilElement
java.lang.Object
simula.compiler.syntaxClass.SyntaxClass
simula.compiler.syntaxClass.statement.ForListElement
simula.compiler.syntaxClass.statement.StepUntilElement
Utility class: For-list Step until element.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static int
Used to make deltaID unique.(package private) Expression
The second expression.(package private) Expression
The third expression.Fields inherited from class simula.compiler.syntaxClass.statement.ForListElement
expr1, forStatement
Fields inherited from class simula.compiler.syntaxClass.SyntaxClass
CHECKED, lineNumber, OBJECT_SEQU
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
Default constructor used by Attribute File I/OStepUntilElement
(ForStatement forStatement, Expression expr1, Expression expr2, Expression expr3) Create a new StepUntilElement. -
Method Summary
Modifier and TypeMethodDescriptionvoid
buildByteCode
(CodeBuilder codeBuilder, VariableExpression controlVariable) Build byte code.void
Perform semantic checking.void
Perform simplified JavaCoding.void
doSingleElementByteCoding
(CodeBuilder codeBuilder) ClassFile coding utility: doSingleElementByteCoding.Edit Java source code for this ForListElement.private void
ClassFile coding utility: generalCase.Checks if this ForListElement can be optimized.static StepUntilElement
Read and return an object.toString()
void
Write a SyntaxClass object to a AttributeOutputStream.Methods inherited from class simula.compiler.syntaxClass.SyntaxClass
ASSERT_SEMANTICS_CHECKED, buildByteCode, doDeclarationCoding, doJavaCoding, edIndent, edTreeIndent, IS_SEMANTICS_CHECKED, print, printTree, SET_SEMANTICS_CHECKED, setLineNumber, toJavaCode
-
Field Details
-
expr2
Expression expr2The second expression. -
expr3
Expression expr3The third expression. -
DELTA_SEQU
private static int DELTA_SEQUUsed to make deltaID unique.
-
-
Constructor Details
-
StepUntilElement
public StepUntilElement(ForStatement forStatement, Expression expr1, Expression expr2, Expression expr3) Create a new StepUntilElement.- Parameters:
forStatement
- the ForStatementexpr1
- The first expressionexpr2
- The second expressionexpr3
- The third expression
-
StepUntilElement
private StepUntilElement()Default constructor used by Attribute File I/O
-
-
Method Details
-
doChecking
public void doChecking()Description copied from class:ForListElement
Perform semantic checking.- Overrides:
doChecking
in classForListElement
-
edCode
Description copied from class:ForListElement
Edit Java source code for this ForListElement.- Overrides:
edCode
in classForListElement
- Parameters:
classIdent
- Java class identifierxType
- control variable's type- Returns:
- the resulting Java source code for this ForListElement
-
isOptimisable
Description copied from class:ForListElement
Checks if this ForListElement can be optimized.- Overrides:
isOptimisable
in classForListElement
- Returns:
- this ForListElement if it can be optimized
-
doSimplifiedJavaCoding
public void doSimplifiedJavaCoding()Description copied from class:ForListElement
Perform simplified JavaCoding.- Overrides:
doSimplifiedJavaCoding
in classForListElement
-
generalCase
private void generalCase()ClassFile coding utility: generalCase.
FOR controlVariable := expr1 STEP expr2 UNTIL expr3 DO statement; According to Simula Standard: int/float/double DELTA; // Local controlVariable = expr1(); DELTA = expr2(); while( sign(DELTA)*(controlVariable-expr3()) <= 0) { STATEMENT(); DELTA = expr2(); controlVariable = controlVariable + DELTA; } // end while;
-
doSingleElementByteCoding
ClassFile coding utility: doSingleElementByteCoding.
FOR controlVariable := expr1 STEP expr2 UNTIL expr3 DO statement; int/float/double DELTA; // Local controlVariable = expr1(); DELTA = expr2(); while( sign(DELTA)/// (controlVariable - expr3() ) <= 0) { STATEMENT(); DELTA = expr2(); controlVariable = controlVariable + DELTA; } // end while; // controlVariable = expr1(); aload_0 aload_0 invokevirtual #24 // Method expr1:()I putfield #12 // Field controlVariable:I // DELTA = expr2(); aload_0 invokevirtual #26 // Method expr2:()I istore_1 // Local DELTA TST: // if(DELTA*(controlVariable-expr3()) > 0) goto END iload_1 // Local DELTA aload_0 getfield #12 // Field controlVariable:I aload_0 invokevirtual #30 // Method expr3:()I isub imul ifle END // STATEMENT aload_0 invokevirtual #28 // Method STATEMENT:()V // DELTA = expr2(); aload_0 invokevirtual #26 // Method expr2:()I istore_1 // Local DELTA // controlVariable = controlVariable + DELTA; aload_0 dup getfield #12 // Field controlVariable:I iload_1 // Local DELTA iadd putfield #12 // Field controlVariable:I goto TST END:
- Overrides:
doSingleElementByteCoding
in classForListElement
- Parameters:
codeBuilder
- the codeBuilder to use.
-
buildByteCode
Description copied from class:ForListElement
Build byte code.- Overrides:
buildByteCode
in classForListElement
- Parameters:
codeBuilder
- the codeBuilder to use.controlVariable
- the ForStatement's controlVariable.
-
toString
- Overrides:
toString
in classForListElement
-
writeObject
Description copied from class:SyntaxClass
Write a SyntaxClass object to a AttributeOutputStream.- Overrides:
writeObject
in classForListElement
- Parameters:
oupt
- the AttributeOutputStream to write to.- Throws:
IOException
- if something went wrong.
-
readObject
Read and return an object.- Parameters:
inpt
- the AttributeInputStream to read from- Returns:
- the object read from the stream.
- Throws:
IOException
- if something went wrong.
-