edu.cornell.cs.sam.core
Interface Program

All Known Implementing Classes:
SamProgram

public interface Program

The program object contains the symbol table for the program and the instructions to execute


Method Summary
 void addInst(Instruction ins)
          Add instruction to the program
 void addInst(Instruction[] ins)
          Add multiple instructions to the program
 Instruction getInst(int pos)
          Get instruction at specificed location
 java.util.List<Instruction> getInstList()
          Get all instructions as a list
 int getLength()
          Gets total number of instructions in program
 ReferenceTable getReferenceTable()
          Returns the references table
 SymbolTable getSymbolTable()
          Returns the symbol table
 boolean isExecutable()
          Returns whether this program can be executed - it is executable if all symbols have been resolved.
 void resolveReferences()
          Resolves references in this program from the symbol table
 void resolveReferencesFrom(Program prog)
          Resolves prog's references from the symbol table
 void setReferenceTable(ReferenceTable table)
          Sets the references table
 void setSymbolTable(SymbolTable table)
          Sets the symbol table
 

Method Detail

addInst

void addInst(Instruction ins)
Add instruction to the program

Parameters:
ins - The instruction to add

addInst

void addInst(Instruction[] ins)
Add multiple instructions to the program

Parameters:
ins - An array of instructions to add

getInst

Instruction getInst(int pos)
Get instruction at specificed location

Parameters:
pos - The instruction address
Returns:
The instruction located at that address

getInstList

java.util.List<Instruction> getInstList()
Get all instructions as a list

Returns:
The list of instructions

getLength

int getLength()
Gets total number of instructions in program

Returns:
The number of instructions

getSymbolTable

SymbolTable getSymbolTable()
Returns the symbol table

Returns:
The symbol table for this program

getReferenceTable

ReferenceTable getReferenceTable()
Returns the references table

Returns:
The references table for this program

setSymbolTable

void setSymbolTable(SymbolTable table)
Sets the symbol table

Parameters:
table - The symbol table for this program

setReferenceTable

void setReferenceTable(ReferenceTable table)
Sets the references table

Parameters:
table - The references table for this program

isExecutable

boolean isExecutable()
Returns whether this program can be executed - it is executable if all symbols have been resolved.

Returns:
true if this program contains no unresolved references

resolveReferences

void resolveReferences()
Resolves references in this program from the symbol table


resolveReferencesFrom

void resolveReferencesFrom(Program prog)
Resolves prog's references from the symbol table

Parameters:
prog - The program whose references to resolve