avrora.core.isdl.gen
Class InterpreterGenerator
java.lang.Object
avrora.core.isdl.gen.PrettyPrinter
avrora.core.isdl.gen.InterpreterGenerator
- All Implemented Interfaces:
- Architecture.EncodingVisitor, Architecture.InstrVisitor, Architecture.OperandVisitor, Architecture.SubroutineVisitor, Architecture.Visitor, CodeVisitor, StmtVisitor
- Direct Known Subclasses:
- DBBC.CodeGenerator
- public class InterpreterGenerator
- extends PrettyPrinter
- 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 |
generate()
|
protected PrettyPrinter.MapRep |
getMapRep(java.lang.String n)
|
protected java.lang.String |
getVariable(Token variable)
|
protected void |
initializeMaps()
|
protected void |
initializeOperandMap(CodeRegion cr)
|
void |
visit(Arith.XorExpr e)
|
void |
visit(BitExpr e)
|
void |
visit(BitRangeExpr e)
|
void |
visit(EncodingDecl d)
|
void |
visit(InstrDecl d)
|
void |
visit(Logical.AndExpr e)
|
void |
visit(Logical.OrExpr e)
|
void |
visit(Logical.XorExpr e)
|
void |
visit(OperandDecl d)
|
void |
visit(SubroutineDecl d)
|
void |
visit(VarBitAssignStmt s)
|
void |
visit(VarBitRangeAssignStmt s)
|
Methods inherited from class avrora.core.isdl.gen.PrettyPrinter |
binop, getMethod, inner, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitExprList, visitStmtList |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
architecture
protected final Architecture architecture
mapMap
protected final java.util.HashMap mapMap
variableMap
protected java.util.HashMap variableMap
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()
generate
public void generate()
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
getMapRep
protected PrettyPrinter.MapRep getMapRep(java.lang.String n)
- Overrides:
getMapRep
in class PrettyPrinter
visit
public void visit(VarBitAssignStmt s)
- Specified by:
visit
in interface StmtVisitor
- Overrides:
visit
in class PrettyPrinter
visit
public void visit(VarBitRangeAssignStmt s)
- Specified by:
visit
in interface StmtVisitor
- Overrides:
visit
in class PrettyPrinter
getVariable
protected java.lang.String getVariable(Token variable)
- Overrides:
getVariable
in class PrettyPrinter
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)
visit
public void visit(BitExpr e)
- Specified by:
visit
in interface CodeVisitor
- Overrides:
visit
in class PrettyPrinter
visit
public void visit(BitRangeExpr e)
- Specified by:
visit
in interface CodeVisitor
- Overrides:
visit
in class PrettyPrinter
visit
public void visit(Logical.AndExpr e)
- Specified by:
visit
in interface CodeVisitor
- Overrides:
visit
in class PrettyPrinter
visit
public void visit(Logical.OrExpr e)
- Specified by:
visit
in interface CodeVisitor
- Overrides:
visit
in class PrettyPrinter
visit
public void visit(Logical.XorExpr e)
- Specified by:
visit
in interface CodeVisitor
- Overrides:
visit
in class PrettyPrinter
visit
public void visit(Arith.XorExpr e)
- Specified by:
visit
in interface CodeVisitor
- Overrides:
visit
in class PrettyPrinter