class Context extends Object
Modifier and Type | Field and Description |
---|---|
protected ClassContext |
classContext
The surrounding class context.
|
protected CompilationUnitContext |
compilationUnitContext
The compilation unit context (for the whole source program or file).
|
protected Map<String,IDefn> |
entries
Map of (local variable, formal parameters, type) names to their
definitions.
|
protected Context |
surroundingContext
The surrounding context (scope).
|
Modifier | Constructor and Description |
---|---|
protected |
Context(Context surrounding,
ClassContext classContext,
CompilationUnitContext compilationUnitContext)
Construct a Context.
|
Modifier and Type | Method and Description |
---|---|
void |
addEntry(int line,
String name,
IDefn definition)
Add an entry to the symbol table, binding a name to its definition in the
current context.
|
void |
addType(int line,
Type type)
Add the type to the environment.
|
ClassContext |
classContext()
Return the surrounding class context.
|
CompilationUnitContext |
compilationUnitContext()
Return the surrounding compilation unit context.
|
Type |
definingType()
The type that defines this context (used principally for checking
acessibility).
|
IDefn |
lookup(String name)
Return the definition for a name in the environment.
|
Type |
lookupType(String name)
Return the definition for a type name in the environment.
|
MethodContext |
methodContext()
Return the closest surrounding method context.
|
Set<String> |
names()
The names declared in this context.
|
Context |
surroundingContext()
Return the surrounding context (scope) in the stack of contexts.
|
void |
writeToStdOut(PrettyPrinter p)
Write the contents of this context to STDOUT.
|
protected Context surroundingContext
protected ClassContext classContext
protected CompilationUnitContext compilationUnitContext
protected Context(Context surrounding, ClassContext classContext, CompilationUnitContext compilationUnitContext)
surrounding
- the surrounding context (scope).classContext
- the surrounding class context.compilationUnitContext
- the compilation unit context (for the whole source program or
file).public void addEntry(int line, String name, IDefn definition)
name
- the name being declared.definition
- and its definition.public IDefn lookup(String name)
name
- the name whose definition we're looking for.public Type lookupType(String name)
name
- the name of the type whose definition we're looking for.public void addType(int line, Type type)
line
- line number of type declaration.type
- the type we are declaring.public Type definingType()
public Context surroundingContext()
public ClassContext classContext()
public CompilationUnitContext compilationUnitContext()
public MethodContext methodContext()
public Set<String> names()
public void writeToStdOut(PrettyPrinter p)
p
- for pretty printing with indentation.