public final class Environment
extends java.lang.Object
Constructor and Description |
---|
Environment(PackageSymbol top,
ErrorStream error)
Create a new environment at top-level.
|
Modifier and Type | Method and Description |
---|---|
void |
enterBody()
Enter from constructor/method level the body level.
|
boolean |
enterClass(ClassSymbol csymbol)
Enter from package level the class level.
|
boolean |
enterClassVariable(ClassVariableSymbol csymbol)
Enter in class level another class variable.
|
boolean |
enterClassVariables()
Enter from class level the initialization of class variables.
|
void |
enterMethod(ParamSymbol msymbol)
Enter from class level the constructor/method level.
|
void |
enterObject()
Enter object ("non-static") context.
|
boolean |
enterObjectVariable(ObjectVariableSymbol osymbol)
Enter in class level another object variable.
|
boolean |
enterObjectVariables()
Enter from class level the initialization of object variables.
|
void |
enterPackage(PackageSymbol psymbol)
Enter from top-level the package level.
|
void |
enterScope()
Enter a new local scope from (at least) body level.
|
void |
exitBody()
Return from body level to constructor/method level.
|
void |
exitClass()
Return from class level to package level.
|
boolean |
exitClassVariables()
Return from entering class variables.
|
void |
exitMethod()
Return from method level to class level.
|
void |
exitObject()
Leave object ("non-static") context.
|
boolean |
exitObjectVariables()
Return from entering object variables.
|
void |
exitPackage()
Return from package level to top-level.
|
void |
exitScope()
Return from local scope to previous level.
|
ClassSymbol |
getClass(Name name)
Return symbol for class denoted by name in current environment.
|
SymbolTable<ClassVariableSymbol> |
getClassVariables()
Get currently visible class variables.
|
ConstructorSymbol |
getConstructor(CallStatement stat,
TypeExpression[] atypes)
Return symbol for constructor denoted by name and argument types
in current environment.
|
ParamSymbol |
getCurrentMethod()
Get symbol of current method.
|
MethodSymbol |
getMethod(CallStatement call,
TypeExpression[] atypes)
Return symbol for a method called with arguments of denoted types
in current environment and annotate call with symbol.
|
SymbolTable<ObjectVariableSymbol> |
getObjectVariables()
Get currently visible object variables.
|
VariableSymbol |
getVariable(Identifier ident)
Return symbol for variable denoted by identifier in current environment.
|
VariableSymbol |
getVariable(Name name)
Return symbol for variable denoted by name in current environment.
|
VariableSymbol |
getVariable(Name name,
boolean verbose)
Return symbol for variable denoted by name in current environment.
|
boolean |
put(BodySymbol symbol)
Enter new body symbol into environment.
|
boolean |
put(ClassMethodDeclaration decl)
Enter new class method into environment.
|
boolean |
put(ClassSymbol symbol)
Enter new class symbol into environment.
|
boolean |
put(ClassVariableDeclaration decl)
Enter new class variable symbol into environment.
|
boolean |
put(ConstructorDeclaration decl)
Enter new constructor symbol into environment.
|
boolean |
put(ObjectMethodDeclaration decl)
Enter new object method symbol into environment.
|
boolean |
put(ObjectVariableDeclaration decl)
Enter new object variable symbol into environment.
|
boolean |
put(PackageSymbol symbol)
Enter new package symbol into environment.
|
boolean |
put(ParameterSymbol symbol)
Enter new parameter symbol into environment.
|
boolean |
put(VariableDeclaration decl)
Enter new local variable declaration into environment.
|
public Environment(PackageSymbol top, ErrorStream error)
top
- the package for holding "top-level" declarations.error
- the stream for printing error messages.public void enterPackage(PackageSymbol psymbol)
psymbol
- the symbol of the package that is entered.public void exitPackage()
public boolean enterClass(ClassSymbol csymbol)
csymbol
- the symbol of the class that is entered.public boolean enterObjectVariables()
public boolean exitObjectVariables()
public boolean enterObjectVariable(ObjectVariableSymbol osymbol)
osymbol
- the symbol of the object variable that is entered.public SymbolTable<ObjectVariableSymbol> getObjectVariables()
public boolean enterClassVariables()
public boolean exitClassVariables()
public boolean enterClassVariable(ClassVariableSymbol csymbol)
csymbol
- the symbol of the class variable that is entered.public SymbolTable<ClassVariableSymbol> getClassVariables()
public void exitClass()
public void enterObject()
public void exitObject()
public void enterMethod(ParamSymbol msymbol)
msymbol
- the symbol of the method that is entered.public void exitMethod()
public ParamSymbol getCurrentMethod()
public void enterBody()
public void exitBody()
public void enterScope()
public void exitScope()
public boolean put(PackageSymbol symbol)
symbol
- the package symbol.public boolean put(ClassSymbol symbol)
symbol
- the class symbol.public boolean put(ConstructorDeclaration decl)
decl
- the constructor declaration giving rise to the symbol.public boolean put(ClassMethodDeclaration decl)
decl
- the declaration of the class method.public boolean put(ObjectMethodDeclaration decl)
decl
- the declaration givning rise to the symbol.public boolean put(ClassVariableDeclaration decl)
decl
- the declaration giving rise to the symbol.public boolean put(ObjectVariableDeclaration decl)
decl
- the declaration giving rise to the symbol.public boolean put(ParameterSymbol symbol)
symbol
- the parameter symbol.public boolean put(VariableDeclaration decl)
decl
- the declaration.public boolean put(BodySymbol symbol)
symbol
- the symbol.public ClassSymbol getClass(Name name)
name
- a name which should denote a class.public ConstructorSymbol getConstructor(CallStatement stat, TypeExpression[] atypes)
stat
- the constructor call.atypes
- the argument types of the constructor.public MethodSymbol getMethod(CallStatement call, TypeExpression[] atypes)
call
- the method call.atypes
- the argument types of the method.public VariableSymbol getVariable(Identifier ident)
ident
- a name which should denote a variable.public VariableSymbol getVariable(Name name)
name
- a name which should denote a variable.public VariableSymbol getVariable(Name name, boolean verbose)
name
- a name which should denote a variable.verbose
- true iff error messages shall be printed if the lookup fails.