com.adamcornett.cminus
Class Function

java.lang.Object
  extended by com.adamcornett.cminus.Function

public class Function
extends Object

A function to be stored in the function table.

Author:
Adam Cornett

Field Summary
private  List<TokenLocation> calls
          A list of calls of this function.
private  org.antlr.runtime.Token ID
          The token representing the name/ID of this function.
private  SymbolTable localSymbols
          The SymbolTable for this function.
NOTE: Due to the nested scoping of functions, this symbol table only contains the function parameters, the local variables are declared in a child scope that is started with the CompoundStatement that represents the body of the function.
private  String name
          The name of the function.
private  SortedSet<Symbol> params
          The list of symbols that make up the function's parameters.
private  Type type
          The return type of the function.
 
Constructor Summary
Function(org.antlr.runtime.Token token, CMinusParser.type_specifier_return t)
          Create a new function
Function(org.antlr.runtime.Token token, Type returnType)
          Create a new function
 
Method Summary
 void addCall(TokenLocation tokenLocation)
          Record a call to this function.
 void addParam(Symbol s)
          Add a parameter to this function
 void addSymbol(Symbol s)
          Add a symbol to the local symbol table.
 String getDefPos()
          Get the location where this function was defined.
 String getName()
          Get the name of the function.
 SortedSet<Symbol> getParams()
           
 Type getReturnType()
           
 String getSignature()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

calls

private final List<TokenLocation> calls
A list of calls of this function.


ID

private final org.antlr.runtime.Token ID
The token representing the name/ID of this function.


localSymbols

private final SymbolTable localSymbols
The SymbolTable for this function.
NOTE: Due to the nested scoping of functions, this symbol table only contains the function parameters, the local variables are declared in a child scope that is started with the CompoundStatement that represents the body of the function.


name

private final String name
The name of the function.


params

private final SortedSet<Symbol> params
The list of symbols that make up the function's parameters.


type

private final Type type
The return type of the function.

Constructor Detail

Function

public Function(org.antlr.runtime.Token token,
                CMinusParser.type_specifier_return t)
Create a new function

Parameters:
token - The token representing the ID of this function
t - The return type of this function.

Function

public Function(org.antlr.runtime.Token token,
                Type returnType)
Create a new function

Parameters:
token - The token representing the ID of this function
t - The return type of this function.
Method Detail

addCall

public void addCall(TokenLocation tokenLocation)
Record a call to this function.

Parameters:
tokenLocation - The location of the call.

addParam

public void addParam(Symbol s)
Add a parameter to this function

Parameters:
s - They symbol representing the parameter.

addSymbol

public void addSymbol(Symbol s)
Add a symbol to the local symbol table.

Parameters:
s - The symbol to be added.

getDefPos

public String getDefPos()
Get the location where this function was defined.

Returns:
A string representing the definition location.

getName

public String getName()
Get the name of the function.

Returns:
The name of the function.

getReturnType

public Type getReturnType()

getSignature

public String getSignature()

toString

public String toString()
Overrides:
toString in class Object

getParams

public SortedSet<Symbol> getParams()