Translate
Class Frame

java.lang.Object
  extended by Translate.Frame
Direct Known Subclasses:
Frame, Frame

public abstract class Frame
extends java.lang.Object

Frame is an abstract class whose concrete instances represent frames on the target machine.


Nested Class Summary
 class Frame.Access
          An Access represents storage for a local variable in this frame.
 
Field Summary
 java.util.LinkedList<Frame.Access> formals
          LinkedList of the allocated formals.
 int maxArgsOut
          Maximum number of arguments used by calls in this frame;
 Temp.Label name
          The label for this frame.
 
Constructor Summary
protected Frame(Temp.Label n)
           
 
Method Summary
abstract  Frame.Access allocFormal(Temp t)
          Allocate a formal parameter represented by temporary t.
abstract  Frame.Access allocLocal(Temp t)
          Allocate a local variable represented by temporary t.
abstract  Temp.Label badPtr()
          Get the label to branch to for null pointers
abstract  Temp.Label badSub()
          Get the label to branch to for bad subscripts
abstract  Tree.Visitor<java.util.LinkedList<Instr>,Temp> codegen()
          Obtain a code generator visitor for the target, producing a list of assembler instructions.
abstract  Tree.Exp external(java.lang.String func)
          Get a reference to an external procedure.
abstract  Frame mainFrame()
          The frame of the C main procedure.
abstract  Frame newFrame(java.lang.String name)
          Factory for obtaining concrete instances of the target frame.
abstract  void procEntryExit1(java.util.LinkedList<Tree.Stm> body)
          Wrap the statement tree body of a procedure with entry/exit after translation.
abstract  void procEntryExit2(java.util.LinkedList<Instr> insns)
          Wrap the assembly body of a procedure with entry/exit after code generation.
abstract  void procEntryExit3(java.util.LinkedList<Instr> insns, Temp.Map map)
          Wrap the assembly body of a procedure with entry/exit after register allocation.
abstract  java.lang.String record(Temp.Label label, int words)
          Allocate a zeroed static record
abstract  Temp[] registers()
          The registers supported by this target.
abstract  Tree.Exp RV()
          An expression for the return value of this frame.
abstract  java.lang.String string(Temp.Label label, java.lang.String value)
          Allocate an initialized static string literal.
abstract  java.lang.String vtable(Temp.Label label, java.util.Collection<Temp.Label> methods)
          Allocate and initialize a static virtual dispatch table
abstract  int wordSize()
          The word size (in bytes) of this target.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

public final Temp.Label name
The label for this frame.


formals

public final java.util.LinkedList<Frame.Access> formals
LinkedList of the allocated formals.


maxArgsOut

public int maxArgsOut
Maximum number of arguments used by calls in this frame;

Constructor Detail

Frame

protected Frame(Temp.Label n)
Method Detail

newFrame

public abstract Frame newFrame(java.lang.String name)
Factory for obtaining concrete instances of the target frame.

Parameters:
name - the name of the method
Returns:
a new frame

mainFrame

public abstract Frame mainFrame()
The frame of the C main procedure.

Returns:
the main frame

allocFormal

public abstract Frame.Access allocFormal(Temp t)
Allocate a formal parameter represented by temporary t. If t is null, then allocate the parameter in the frame.


allocLocal

public abstract Frame.Access allocLocal(Temp t)
Allocate a local variable represented by temporary t. If t is null, then allocate the variable in the frame.


registers

public abstract Temp[] registers()
The registers supported by this target.


wordSize

public abstract int wordSize()
The word size (in bytes) of this target.


external

public abstract Tree.Exp external(java.lang.String func)
Get a reference to an external procedure.


RV

public abstract Tree.Exp RV()
An expression for the return value of this frame.


string

public abstract java.lang.String string(Temp.Label label,
                                        java.lang.String value)
Allocate an initialized static string literal.

Parameters:
label - the label to use for the string
value - the value of the literal
Returns:
the assembler data fragment

record

public abstract java.lang.String record(Temp.Label label,
                                        int words)
Allocate a zeroed static record

Parameters:
label - the label to use for the record
words - the size of the record in words
Returns:
the assembler data fragment

vtable

public abstract java.lang.String vtable(Temp.Label label,
                                        java.util.Collection<Temp.Label> methods)
Allocate and initialize a static virtual dispatch table

Parameters:
label - the label to use for the record
methods - the labels of the methods in the table
Returns:
the assembler data fragment

badPtr

public abstract Temp.Label badPtr()
Get the label to branch to for null pointers

Returns:
the label

badSub

public abstract Temp.Label badSub()
Get the label to branch to for bad subscripts

Returns:
the label

procEntryExit1

public abstract void procEntryExit1(java.util.LinkedList<Tree.Stm> body)
Wrap the statement tree body of a procedure with entry/exit after translation.

Parameters:
body - the procedure body

codegen

public abstract Tree.Visitor<java.util.LinkedList<Instr>,Temp> codegen()
Obtain a code generator visitor for the target, producing a list of assembler instructions.

Returns:
the code generator visitor

procEntryExit2

public abstract void procEntryExit2(java.util.LinkedList<Instr> insns)
Wrap the assembly body of a procedure with entry/exit after code generation.

Parameters:
insns - the procedure body

procEntryExit3

public abstract void procEntryExit3(java.util.LinkedList<Instr> insns,
                                    Temp.Map map)
Wrap the assembly body of a procedure with entry/exit after register allocation.

Parameters:
insns - the procedure body
map - the register allocation mapping temporaries to hard registers