|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.adamcornett.cminus.Scope
public class Scope
Represents a variable scope. This implementation is NOT multi-thread safe!
| Field Summary | |
|---|---|
private Set<Scope> |
childern
|
private static Scope |
currentScope
The current scope that the parser or analyzer is in. |
private static int |
nextScopeNumber
The next scope number ot be issued. |
private Scope |
parentScope
The parent of this scope. |
private static Scope |
rootScope
The root scope. |
private static Map<Integer,Scope> |
scopeMap
A map linking a given scope number to a scope. |
private int |
scopeNumber
The scope number of this Scope. |
private SymbolTable |
symbols
The symbol table for this scope. |
private org.antlr.runtime.Token |
token
The token which is at the start of this scope, usually a function identifier, or a '{' at the beginning of a compound statement |
| Constructor Summary | |
|---|---|
Scope(org.antlr.runtime.Token t)
Create a new scope. |
|
| Method Summary | |
|---|---|
void |
addChild(Scope s)
Add a child scope and set it's parent as this class |
static void |
cleanEmpty()
|
private static void |
cleanEmpty(Scope s)
|
static void |
clear()
|
void |
delete()
Delete this scope and re-assign all childern to parent; |
static Scope |
getCurrentScope()
Get the current scope. |
String |
getName()
Get the name of the scope |
Scope |
getParent()
Get the parent scope |
static Scope |
getScope(Integer sn)
Get the Scope object with the given scope number. |
int |
getScopeNumber()
Get this scope's number |
SymbolTable |
getSymbols()
Get the symbol table for this scope |
org.antlr.runtime.Token |
getToken()
Get the token this scope started on. |
static Symbol |
lookup(String s)
Looks up a symbol with the name s in the current scope |
static Symbol |
lookup(String s,
Scope scope)
Look up a symbol in a specified scope |
static void |
popScope()
Pops the current scope, replacing with it with its parent, unless it is the root scope, which cannot be popped. |
static String |
print()
Prints all symbols in the table. |
static void |
pushScope(Scope s)
Add a new scope to the stack. |
static void |
pushSymbol(Symbol s)
Add a symbol to the current scope. |
void |
removeChild(Scope s)
Remove a child scope |
static void |
setScope(Integer scopeNumber)
Lookup a given scope and set it as the current scope. |
void |
setSymbols(SymbolTable symbols)
Set the symbol table for this scope. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private static Scope currentScope
private static int nextScopeNumber
private static Scope rootScope
private static Map<Integer,Scope> scopeMap
private Scope parentScope
private Set<Scope> childern
private final int scopeNumber
private SymbolTable symbols
private final org.antlr.runtime.Token token
| Constructor Detail |
|---|
public Scope(org.antlr.runtime.Token t)
t - The token which the scope starts at.| Method Detail |
|---|
public static void cleanEmpty()
public static Scope getCurrentScope()
public static Scope getScope(Integer sn)
sn - The scope number to look up.
public static Symbol lookup(String s)
s - The name of the symbol to look for.
public static Symbol lookup(String s,
Scope scope)
s - The name of the symbol to look forscope - The scope to search for the symbol in
public static void popScope()
public static String print()
public static void pushScope(Scope s)
s - The scope to push.public static void pushSymbol(Symbol s)
s - The symbol to be added.public static void setScope(Integer scopeNumber)
scopeNumber - private static void cleanEmpty(Scope s)
public void addChild(Scope s)
s - public void delete()
public String getName()
public Scope getParent()
public int getScopeNumber()
public SymbolTable getSymbols()
public org.antlr.runtime.Token getToken()
public void removeChild(Scope s)
s - public void setSymbols(SymbolTable symbols)
symbols - The new Symbol Tablepublic String toString()
toString in class Objectpublic static void clear()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||