dspl.intermediate.instructions
Class Instruction

java.lang.Object
  extended by dspl.intermediate.instructions.Instruction
Direct Known Subclasses:
ArithmaticInstruction, BranchInstruction, CCallInstruction, LoopInstruction, RelationInstruction

public abstract class Instruction
extends java.lang.Object

Basic Abstract class for all other Abstract classes which represent the various kinds of 3-operand intermediary instructions generated from the AST

Author:
David

Field Summary
static int INST_TYPE_ARITHMATIC
          type for ArithmaticInstruction
static int INST_TYPE_BRANCH
          type for BranchInstruction
static int INST_TYPE_CCALL
          type for CCallInstruction
static int INST_TYPE_FORLOOP
          type for LoopInstruction
 Instruction lastInstruction
          Valid only in the first instruction (head of the list), the lastInstruction points to the Instruction at the end of the list
 Instruction nextInstruction
          The next instruction to be executed after this one Note in the case of branches, this is the next instruction to be executed after all of the instructions in a particular path of the branch are executed.
 Instruction prevInstruction
          The previous instruction executed, or in the case of the instruction following an if { } else { } block, it would refer to the BranchInstruction, rather than the previous instruction actually executed.
 
Constructor Summary
Instruction()
           
 
Method Summary
abstract  int getInstType()
           
 void setNextInstruction(Instruction next)
           
abstract  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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nextInstruction

public Instruction nextInstruction
The next instruction to be executed after this one Note in the case of branches, this is the next instruction to be executed after all of the instructions in a particular path of the branch are executed.


prevInstruction

public Instruction prevInstruction
The previous instruction executed, or in the case of the instruction following an if { } else { } block, it would refer to the BranchInstruction, rather than the previous instruction actually executed.


lastInstruction

public Instruction lastInstruction
Valid only in the first instruction (head of the list), the lastInstruction points to the Instruction at the end of the list


INST_TYPE_BRANCH

public static final int INST_TYPE_BRANCH
type for BranchInstruction

See Also:
Constant Field Values

INST_TYPE_ARITHMATIC

public static final int INST_TYPE_ARITHMATIC
type for ArithmaticInstruction

See Also:
Constant Field Values

INST_TYPE_CCALL

public static final int INST_TYPE_CCALL
type for CCallInstruction

See Also:
Constant Field Values

INST_TYPE_FORLOOP

public static final int INST_TYPE_FORLOOP
type for LoopInstruction

See Also:
Constant Field Values
Constructor Detail

Instruction

public Instruction()
Method Detail

getInstType

public abstract int getInstType()
Returns:
the instruction type of this instruction

usesVariable

public abstract 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. Intention is to allow a way to parse the Instruction tree to see if a specific variable is used again. NOTE: may not be necessary, or may need to be augmented to return a value indicating how far away from the current instruction will it be used again if desire to perform better register allocation.

Parameters:
v - the variable to search for to see if it is used
Returns:

setNextInstruction

public void setNextInstruction(Instruction next)