|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdspl.intermediate.instructions.Instruction
dspl.intermediate.instructions.LoopInstruction
public class LoopInstruction
LoopInstruction is used to represent for and while loops.
Note that in DSPL a while loop is a subclass of for-loop internally.
meaning "for(x=0; x<10; x++) { ... }" == "x=0; while(x<10) { ... x++; }"
A note on terminology:
Assume a for loop of structure "for (x=0, y=7, z=10; x<10; x++) { a = 5+x; ... }
The first portion ("x=0, y=7, z=10") is referred to as the Assignment Instruction(s)
The second portion ("x<10;") is referred to as the Condition Instruction(s)
The third portion ("x++") is referred to as the Arithmatic Instruction(s)
The fourth portion ("a = 5+x") is referred to as the Loop Instruction(s)
| Field Summary | |
|---|---|
Instruction |
arithmaticInstr
Contains the instruction(s) to be evaluated directly before evaluating the conditionInstr instruction(s) |
Instruction |
assignmentInstr
Contains the instruction(s) to be evaluated before entering the loop is allowed to be empty |
Comparison |
comp
Contains the single comparison instruction which if false, terminates the loop |
Instruction |
loopInstr
Contains the instructions to be evaluated wtihin the body fo the loop |
| Fields inherited from class dspl.intermediate.instructions.Instruction |
|---|
INST_TYPE_ARITHMATIC, INST_TYPE_BRANCH, INST_TYPE_CCALL, INST_TYPE_FORLOOP, lastInstruction, nextInstruction, prevInstruction |
| Constructor Summary | |
|---|---|
LoopInstruction(Instruction assignmentInstr,
Comparison comp,
Instruction arithmaticInstr,
Instruction loopInstr)
|
|
| Method Summary | |
|---|---|
int |
getInstType()
|
boolean |
usesVariable(Variable v)
Designed to be a recursive call to see if a given variable is used anymore within a code block, after the current instruction. |
| Methods inherited from class dspl.intermediate.instructions.Instruction |
|---|
setNextInstruction |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public Instruction assignmentInstr
public Comparison comp
public Instruction arithmaticInstr
public Instruction loopInstr
| Constructor Detail |
|---|
public LoopInstruction(Instruction assignmentInstr,
Comparison comp,
Instruction arithmaticInstr,
Instruction loopInstr)
assignmentInstr - Assignment Instruction(s)conditionInstr - Condition Instruction(s)arithmaticInstr - Arithmatic Instruction(s)loopInstr - Loop Instruction(s)| Method Detail |
|---|
public boolean usesVariable(Variable v)
Instruction
usesVariable in class Instructionv - the variable to search for to see if it is used
public int getInstType()
getInstType in class Instruction
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||