com.adamcornett.cminus
Class Symbol

java.lang.Object
  extended by com.adamcornett.cminus.Symbol
All Implemented Interfaces:
Comparable<Symbol>

public class Symbol
extends Object
implements Comparable<Symbol>

Author:
Adam Cornett

Field Summary
private  int arraySize
          If this symbol is an array, this represents how many elements are in the array.
private  org.antlr.runtime.Token ID
          The Identifier token
private  boolean isArray
          TRUE if this symbol is an array.
private  TokenLocation loc
          The location of the symbol definition.
private  String name
          The name of the token.
private static int nextStackLocation
           
private  Type type
          The type of this symbol
private  List<TokenLocation> uses
          The locations of the uses of this symbol.
private  int varLocation
          The location of this variable in the local variable table.
 
Constructor Summary
Symbol(CMinusParser.type_specifier_return t, org.antlr.runtime.Token token)
          The non-array constructor
Symbol(CMinusParser.type_specifier_return t, org.antlr.runtime.Token token, org.antlr.runtime.Token size)
          The array constructor
Symbol(Type ty, org.antlr.runtime.Token token)
           
 
Method Summary
 void addUse(TokenLocation tl)
          Add a usage of a symbol
 int compareTo(Symbol o)
           
 boolean equals(Object obj)
           
 int getArraySize()
           
 TokenLocation getLocation()
          Get the location of the definition of this symbol.
 String getName()
           
 Type getType()
           
 int getVarLocation()
           
 boolean isArray()
           
static void resetStackLocation()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nextStackLocation

private static int nextStackLocation

arraySize

private int arraySize
If this symbol is an array, this represents how many elements are in the array.


ID

private final org.antlr.runtime.Token ID
The Identifier token


isArray

private final boolean isArray
TRUE if this symbol is an array.


loc

private final TokenLocation loc
The location of the symbol definition.


name

private final String name
The name of the token.


varLocation

private final int varLocation
The location of this variable in the local variable table.


type

private final Type type
The type of this symbol


uses

private final List<TokenLocation> uses
The locations of the uses of this symbol.

Constructor Detail

Symbol

public Symbol(CMinusParser.type_specifier_return t,
              org.antlr.runtime.Token token)
The non-array constructor

Parameters:
t - The type of the symbol
token - The identifier for this token

Symbol

public Symbol(CMinusParser.type_specifier_return t,
              org.antlr.runtime.Token token,
              org.antlr.runtime.Token size)
The array constructor

Parameters:
t - The array type
token - The array name
size - The size of the array.

Symbol

public Symbol(Type ty,
              org.antlr.runtime.Token token)
Method Detail

getArraySize

public int getArraySize()

resetStackLocation

public static void resetStackLocation()

addUse

public void addUse(TokenLocation tl)
Add a usage of a symbol

Parameters:
tl - The location of the symbol

compareTo

public int compareTo(Symbol o)
Specified by:
compareTo in interface Comparable<Symbol>

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

getLocation

public TokenLocation getLocation()
Get the location of the definition of this symbol.

Returns:

getName

public String getName()

getVarLocation

public int getVarLocation()

getType

public Type getType()

toString

public String toString()
Overrides:
toString in class Object

isArray

public boolean isArray()