cs132.vapor.ast
Class VFunction

java.lang.Object
  extended by cs132.vapor.ast.Node
      extended by cs132.vapor.ast.VTarget
          extended by cs132.vapor.ast.VFunction

public class VFunction
extends VTarget

A function definition.


Nested Class Summary
static class VFunction.Stack
          The details of a function's stack space declaration.
 
Field Summary
 VInstr[] body
          The function body is just a list of instructions.
 int index
          All functions in a single program are assigned an index contiguously, starting from zero.
 VCodeLabel[] labels
          The function's list of code labels.
 VVarRef.Local[] params
          The function's parameter list.
 VFunction.Stack stack
          The function's stack declaration.
 String[] vars
          The full list of local variables used in this function.
 
Fields inherited from class cs132.vapor.ast.VTarget
ident
 
Fields inherited from class cs132.vapor.ast.Node
sourcePos
 
Constructor Summary
VFunction(SourcePos sourcePos, String ident, int index, VVarRef.Local[] params, VFunction.Stack stack)
           
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

index

public final int index
All functions in a single program are assigned an index contiguously, starting from zero.


params

public final VVarRef.Local[] params
The function's parameter list.


labels

public VCodeLabel[] labels
The function's list of code labels. This array keeps the labels in the same order they appear in the code.


stack

public final VFunction.Stack stack
The function's stack declaration. Ex: [in 1, out 2, local 0].


body

public VInstr[] body
The function body is just a list of instructions. The code labels appear separately in the labels array.


vars

public String[] vars
The full list of local variables used in this function. VVarRef.Local nodes have an index that point into this array.

Constructor Detail

VFunction

public VFunction(SourcePos sourcePos,
                 String ident,
                 int index,
                 VVarRef.Local[] params,
                 VFunction.Stack stack)