|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object kanga.visitor.GJDepthFirst<MResult,MContext> kanga.translate.MIPSTranslator
public final class MIPSTranslator
Translates a Kanga AST into MIPS by printing the resulting code to the
a PrintStream
.
Constructor Summary | |
---|---|
MIPSTranslator(java.io.PrintStream out)
Creates a MIPS translator that prints its result to the given output stream. |
Method Summary | |
---|---|
void |
translate(Goal p)
Visits a Kanga AST, writing a MIPS code translation to the PrintStream output given in the constructor method. |
MResult |
visit(ALoadStmt n,
MContext argu)
nodeToken -> "ALOAD" reg -> Reg() spilledArg -> SpilledArg() |
MResult |
visit(AStoreStmt n,
MContext argu)
nodeToken -> "ASTORE" spilledArg -> SpilledArg() reg -> Reg() |
MResult |
visit(BinOp n,
MContext argu)
operator -> Operator() reg -> Reg() simpleExp -> SimpleExp() |
MResult |
visit(CallStmt n,
MContext argu)
nodeToken -> "CALL" simpleExp -> SimpleExp() |
MResult |
visit(CJumpStmt n,
MContext argu)
nodeToken -> "CJUMP" reg -> Reg() label -> Label() |
MResult |
visit(ErrorStmt n,
MContext argu)
nodeToken -> "ERROR" |
MResult |
visit(Exp n,
MContext argu)
nodeChoice -> HAllocate() | BinOp() | SimpleExp() |
MResult |
visit(HAllocate n,
MContext argu)
nodeToken -> "HALLOCATE" simpleExp -> SimpleExp() |
MResult |
visit(HLoadStmt n,
MContext argu)
nodeToken -> "HLOAD" reg -> Reg() reg1 -> Reg() integerLiteral -> IntegerLiteral() |
MResult |
visit(HStoreStmt n,
MContext argu)
nodeToken -> "HSTORE" reg -> Reg() integerLiteral -> IntegerLiteral() reg1 -> Reg() |
MResult |
visit(IntegerLiteral n,
MContext argu)
nodeToken -> <INTEGER_LITERAL> |
MResult |
visit(JumpStmt n,
MContext argu)
nodeToken -> "JUMP" label -> Label() |
MResult |
visit(Label n,
MContext argu)
nodeToken -> <IDENTIFIER> |
MResult |
visit(MoveStmt n,
MContext argu)
nodeToken -> "MOVE" reg -> Reg() exp -> Exp() |
MResult |
visit(NodeListOptional n,
MContext argu)
|
MResult |
visit(NoOpStmt n,
MContext argu)
nodeToken -> "NOOP" |
MResult |
visit(PassArgStmt n,
MContext argu)
nodeToken -> "PASSARG" integerLiteral -> IntegerLiteral() reg -> Reg() |
MResult |
visit(PrintStmt n,
MContext argu)
nodeToken -> "PRINT" simpleExp -> SimpleExp() |
MResult |
visit(Procedure n,
MContext argu)
label -> Label() nodeToken -> "[" integerLiteral -> IntegerLiteral() nodeToken1 -> "]" nodeToken2 -> "[" integerLiteral1 -> IntegerLiteral() nodeToken3 -> "]" nodeToken4 -> "[" integerLiteral2 -> IntegerLiteral() nodeToken5 -> "]" stmtList -> StmtList() nodeToken6 -> "END" |
MResult |
visit(Reg n,
MContext argu)
nodeChoice -> "a0" | "a1" | "a2" | "a3" | "t0" | "t1" | "t2" | "t3" | "t4" | "t5" | "t6" | "t7" | "s0" | "s1" | "s2" | "s3" | "s4" | "s5" | "s6" | "s7" | "t8" | "t9" | "v0" | "v1" |
MResult |
visit(SimpleExp n,
MContext argu)
nodeChoice -> Reg() | IntegerLiteral() | Label() |
MResult |
visit(SpilledArg n,
MContext argu)
nodeToken -> "SPILLEDARG" integerLiteral -> IntegerLiteral() |
Methods inherited from class kanga.visitor.GJDepthFirst |
---|
visit, visit, visit, visit, visit, visit, visit, visit |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MIPSTranslator(java.io.PrintStream out)
out
- the output streamMethod Detail |
---|
public void translate(Goal p)
PrintStream
output given in the constructor method.
p
- the Kanga AST's root node (Goal)public MResult visit(Procedure n, MContext argu)
GJDepthFirst
label -> Label() nodeToken -> "[" integerLiteral -> IntegerLiteral() nodeToken1 -> "]" nodeToken2 -> "[" integerLiteral1 -> IntegerLiteral() nodeToken3 -> "]" nodeToken4 -> "[" integerLiteral2 -> IntegerLiteral() nodeToken5 -> "]" stmtList -> StmtList() nodeToken6 -> "END"
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(NodeListOptional n, MContext argu)
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(NoOpStmt n, MContext argu)
GJDepthFirst
nodeToken -> "NOOP"
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(ErrorStmt n, MContext argu)
GJDepthFirst
nodeToken -> "ERROR"
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(CJumpStmt n, MContext argu)
GJDepthFirst
nodeToken -> "CJUMP" reg -> Reg() label -> Label()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(JumpStmt n, MContext argu)
GJDepthFirst
nodeToken -> "JUMP" label -> Label()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(HStoreStmt n, MContext argu)
GJDepthFirst
nodeToken -> "HSTORE" reg -> Reg() integerLiteral -> IntegerLiteral() reg1 -> Reg()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(HLoadStmt n, MContext argu)
GJDepthFirst
nodeToken -> "HLOAD" reg -> Reg() reg1 -> Reg() integerLiteral -> IntegerLiteral()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(MoveStmt n, MContext argu)
GJDepthFirst
nodeToken -> "MOVE" reg -> Reg() exp -> Exp()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(PrintStmt n, MContext argu)
GJDepthFirst
nodeToken -> "PRINT" simpleExp -> SimpleExp()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(ALoadStmt n, MContext argu)
GJDepthFirst
nodeToken -> "ALOAD" reg -> Reg() spilledArg -> SpilledArg()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(AStoreStmt n, MContext argu)
GJDepthFirst
nodeToken -> "ASTORE" spilledArg -> SpilledArg() reg -> Reg()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(PassArgStmt n, MContext argu)
GJDepthFirst
nodeToken -> "PASSARG" integerLiteral -> IntegerLiteral() reg -> Reg()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(CallStmt n, MContext argu)
GJDepthFirst
nodeToken -> "CALL" simpleExp -> SimpleExp()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(Exp n, MContext argu)
GJDepthFirst
nodeChoice -> HAllocate() | BinOp() | SimpleExp()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(HAllocate n, MContext argu)
GJDepthFirst
nodeToken -> "HALLOCATE" simpleExp -> SimpleExp()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(BinOp n, MContext argu)
GJDepthFirst
operator -> Operator() reg -> Reg() simpleExp -> SimpleExp()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(SpilledArg n, MContext argu)
GJDepthFirst
nodeToken -> "SPILLEDARG" integerLiteral -> IntegerLiteral()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(SimpleExp n, MContext argu)
GJDepthFirst
nodeChoice -> Reg() | IntegerLiteral() | Label()
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(Reg n, MContext argu)
GJDepthFirst
nodeChoice -> "a0" | "a1" | "a2" | "a3" | "t0" | "t1" | "t2" | "t3" | "t4" | "t5" | "t6" | "t7" | "s0" | "s1" | "s2" | "s3" | "s4" | "s5" | "s6" | "s7" | "t8" | "t9" | "v0" | "v1"
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(IntegerLiteral n, MContext argu)
GJDepthFirst
nodeToken -> <INTEGER_LITERAL>
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
public MResult visit(Label n, MContext argu)
GJDepthFirst
nodeToken -> <IDENTIFIER>
visit
in interface GJVisitor<MResult,MContext>
visit
in class GJDepthFirst<MResult,MContext>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |