comp
Class FuncDefNode
java.lang.Object
|
+--comp.Node
|
+--comp.FuncDefNode
- class FuncDefNode
- extends Node
A function definition. Consists of a parameter list, a body, and
a scope.
- See Also:
ParmList
,
Scope
,
BlockNode
Method Summary |
void |
asHTML(java.io.PrintStream out)
Process the parameter list and processeach of the body statements. |
java.lang.String |
codeGen(Scope s,
RegBank bank)
We implement a caller-saves register convention, aside for the
return address and the frame pointer. |
void |
makeScope()
Create a scope for this function. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
id
java.lang.String id
parms
ParmList parms
block
BlockNode block
scope
Scope scope
returnLabel
java.lang.String returnLabel
FuncDefNode
public FuncDefNode(java.lang.String id,
ParmList parms,
BlockNode b)
toString
public java.lang.String toString()
- Overrides:
toString
in class java.lang.Object
codeGen
public java.lang.String codeGen(Scope s,
RegBank bank)
- We implement a caller-saves register convention, aside for the
return address and the frame pointer. On entry, a function must
allocate enough space for those two registers PLUS any local variables.
The stack is grown by this amount, registers saved, and then the
frame pointer is made to indicate the current stack top. This allows
us to use the frame pointer to access locals, arguments, etc in a
sane manner, while the stack pointer is free to grow and shrink
throughout the execution of the body (for doing other calls, etc).
- Specified by:
codeGen
in class Node
makeScope
public void makeScope()
- Create a scope for this function. We make a new empty scope,
and then traverse the subtree, adding definitions to it. We could
do this during parsing, probably...
asHTML
public void asHTML(java.io.PrintStream out)
- Process the parameter list and processeach of the body statements.
- Specified by:
asHTML
in class Node