avrora.core.isdl.gen
Class InterpreterGenerator
java.lang.Object
avrora.core.isdl.ast.StmtVisitor.DepthFirst
avrora.core.isdl.gen.InterpreterGenerator
- All Implemented Interfaces:
- Architecture.EncodingVisitor, Architecture.InstrVisitor, Architecture.OperandVisitor, Architecture.SubroutineVisitor, Architecture.Visitor, StmtVisitor
- Direct Known Subclasses:
- FIFInterpreterGenerator
- public class InterpreterGenerator
- extends StmtVisitor.DepthFirst
- implements Architecture.Visitor
The InterpreterGenerator class is a visitor over the code of an
instruction declaration or subroutine that generates the appropriate Java
code that implements an interpreter for the architecture.
|
Constructor Summary |
InterpreterGenerator(Architecture a,
Printer p)
The constructor for the InterpreterGenerator class builds
an object capable of generating the interpreter for a particular architecture
that outputs to the specified printer. |
|
Method Summary |
protected java.lang.String |
andString(int mask)
|
protected void |
emitAnd(Expr e,
int val)
|
protected void |
emitBinOp(Expr e,
java.lang.String op,
int p,
int val)
|
protected void |
emitCall(java.lang.String s,
Expr e)
|
protected void |
emitCall(java.lang.String s,
Expr e1,
Expr e2)
|
protected void |
emitCall(java.lang.String s,
java.lang.String e1,
Expr e2,
Expr e3)
|
void |
generateCode()
|
protected int |
getBitRangeMask(int low,
int high)
|
protected int |
getInverseBitRangeMask(int low,
int high)
|
protected InterpreterGenerator.MapRep |
getMapRep(java.lang.String n)
|
protected int |
getSingleBitMask(int bit)
|
protected int |
getSingleInverseBitMask(int bit)
|
protected java.lang.String |
getVariable(Token variable)
|
protected void |
initializeMaps()
|
protected void |
initializeOperandMap(CodeRegion cr)
|
void |
visit(CallStmt s)
|
void |
visit(DeclStmt s)
|
void |
visit(EncodingDecl d)
|
void |
visit(IfStmt s)
|
void |
visit(InstrDecl d)
|
void |
visit(MapAssignStmt s)
|
void |
visit(MapBitAssignStmt s)
|
void |
visit(MapBitRangeAssignStmt s)
|
void |
visit(OperandDecl d)
|
void |
visit(ReturnStmt s)
|
void |
visit(SubroutineDecl d)
|
void |
visit(VarAssignStmt s)
|
void |
visit(VarBitAssignStmt s)
|
void |
visit(VarBitRangeAssignStmt s)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
printer
protected final Printer printer
architecture
protected final Architecture architecture
mapMap
protected final java.util.HashMap mapMap
operandMap
protected java.util.HashMap operandMap
codeGen
protected final InterpreterGenerator.CodeGenerator codeGen
InterpreterGenerator
public InterpreterGenerator(Architecture a,
Printer p)
- The constructor for the
InterpreterGenerator class builds
an object capable of generating the interpreter for a particular architecture
that outputs to the specified printer. In this implementation, the interpreter
generator simply outputs visit() methods for each instruction that are meant
to be pasted into a template file containing the rest of the interpreter.
This can be done by constructing a SectionFile instance.
- Parameters:
a - the architecture to generate an interrupter forp - a printer to output the code implementing the interpreter
initializeMaps
protected void initializeMaps()
generateCode
public void generateCode()
visit
public void visit(OperandDecl d)
- Specified by:
visit in interface Architecture.OperandVisitor
visit
public void visit(EncodingDecl d)
- Specified by:
visit in interface Architecture.EncodingVisitor
visit
public void visit(InstrDecl d)
- Specified by:
visit in interface Architecture.InstrVisitor
initializeOperandMap
protected void initializeOperandMap(CodeRegion cr)
visit
public void visit(SubroutineDecl d)
- Specified by:
visit in interface Architecture.SubroutineVisitor
visit
public void visit(CallStmt s)
- Specified by:
visit in interface StmtVisitor- Overrides:
visit in class StmtVisitor.DepthFirst
visit
public void visit(DeclStmt s)
- Specified by:
visit in interface StmtVisitor- Overrides:
visit in class StmtVisitor.DepthFirst
visit
public void visit(IfStmt s)
- Specified by:
visit in interface StmtVisitor- Overrides:
visit in class StmtVisitor.DepthFirst
visit
public void visit(MapAssignStmt s)
- Specified by:
visit in interface StmtVisitor- Overrides:
visit in class StmtVisitor.DepthFirst
visit
public void visit(MapBitAssignStmt s)
- Specified by:
visit in interface StmtVisitor- Overrides:
visit in class StmtVisitor.DepthFirst
visit
public void visit(MapBitRangeAssignStmt s)
- Specified by:
visit in interface StmtVisitor- Overrides:
visit in class StmtVisitor.DepthFirst
getMapRep
protected InterpreterGenerator.MapRep getMapRep(java.lang.String n)
visit
public void visit(ReturnStmt s)
- Specified by:
visit in interface StmtVisitor- Overrides:
visit in class StmtVisitor.DepthFirst
visit
public void visit(VarAssignStmt s)
- Specified by:
visit in interface StmtVisitor- Overrides:
visit in class StmtVisitor.DepthFirst
visit
public void visit(VarBitAssignStmt s)
- Specified by:
visit in interface StmtVisitor- Overrides:
visit in class StmtVisitor.DepthFirst
visit
public void visit(VarBitRangeAssignStmt s)
- Specified by:
visit in interface StmtVisitor- Overrides:
visit in class StmtVisitor.DepthFirst
getVariable
protected java.lang.String getVariable(Token variable)
emitBinOp
protected void emitBinOp(Expr e,
java.lang.String op,
int p,
int val)
andString
protected java.lang.String andString(int mask)
emitAnd
protected void emitAnd(Expr e,
int val)
emitCall
protected void emitCall(java.lang.String s,
Expr e)
emitCall
protected void emitCall(java.lang.String s,
Expr e1,
Expr e2)
emitCall
protected void emitCall(java.lang.String s,
java.lang.String e1,
Expr e2,
Expr e3)
getSingleBitMask
protected int getSingleBitMask(int bit)
getSingleInverseBitMask
protected int getSingleInverseBitMask(int bit)
getBitRangeMask
protected int getBitRangeMask(int low,
int high)
getInverseBitRangeMask
protected int getInverseBitRangeMask(int low,
int high)