public interface Context extends Resolver, Copy<Context>
push*
methods to return a new context. The old context may still be used
and may be accessed directly through a call to pop()
.
While the stack of scopes is treated functionally, each individual
scope is updated in place. Names added to the context are added
in the current scope.Modifier and Type | Method and Description |
---|---|
void |
addMethod(MethodInstance mi)
Add a method to the current scope.
|
void |
addNamed(Named t)
Add a named type object to the current scope.
|
void |
addVariable(VarInstance vi)
Add a variable to the current scope.
|
ClassType |
currentClass()
Return the innermost class in scope.
|
ParsedClassType |
currentClassScope()
Return the innermost class in scope.
|
CodeInstance |
currentCode()
Return the innermost method or constructor in scope.
|
CodeInstance |
definingCodeDef(java.lang.String name)
Return the code instance that defines the local symbol with the given name, or null.
|
FieldInstance |
findField(java.lang.String name)
Looks up a field in the current scope.
|
ClassType |
findFieldScope(java.lang.String name)
Finds the class which added a field to the scope.
|
java.lang.String |
findLabelSilent(java.lang.String label)
Looks up a label in the current scope.
|
LocalInstance |
findLocal(java.lang.String name)
Looks up a local variable in the current scope.
|
LocalInstance |
findLocalSilent(java.lang.String name)
Looks up a local variable in the current scope.
|
MethodInstance |
findMethod(java.lang.String name,
java.util.List<? extends Type> formalTypes)
Looks up a method in the current scope.
|
ClassType |
findMethodScope(java.lang.String name)
Finds the class which added a method to the scope.
|
VarInstance |
findVariable(java.lang.String name)
Looks up a local variable or field in the current scope.
|
VarInstance |
findVariableSilent(java.lang.String name)
Looks up a local variable or field in the current scope.
|
ImportTable |
importTable()
Get import table currently in scope.
|
boolean |
inCode()
Return whether innermost non-block scope is a code scope.
|
boolean |
inStaticContext()
Returns whether the current context is a static context.
|
boolean |
isLocal(java.lang.String name)
Returns whether the symbol is defined within the current method.
|
Lang |
lang()
The language this context represents.
|
Resolver |
outerResolver()
Deprecated.
|
Package |
package_()
The current package, or null if not in a package.
|
Context |
pop()
Pop the context.
|
Context |
pushBlock()
Enter the scope of a block.
|
Context |
pushClass(ParsedClassType scope,
ClassType type)
Enter the scope of a class.
|
Context |
pushCode(CodeInstance f)
Enter the scope of a method or constructor.
|
Context |
pushLabel(java.lang.String label)
Enter the scope of a label.
|
Context |
pushSource(ImportTable it)
Enter the scope of a source file.
|
Context |
pushStatic()
Enter a static scope.
|
TypeSystem |
typeSystem()
The type system.
|
Lang lang()
TypeSystem typeSystem()
void addVariable(VarInstance vi)
void addMethod(MethodInstance mi)
void addNamed(Named t)
MethodInstance findMethod(java.lang.String name, java.util.List<? extends Type> formalTypes) throws SemanticException
formalTypes
- A list of Type
.SemanticException
Type
VarInstance findVariable(java.lang.String name) throws SemanticException
SemanticException
VarInstance findVariableSilent(java.lang.String name)
LocalInstance findLocal(java.lang.String name) throws SemanticException
SemanticException
LocalInstance findLocalSilent(java.lang.String name)
FieldInstance findField(java.lang.String name) throws SemanticException
SemanticException
ClassType findFieldScope(java.lang.String name) throws SemanticException
findField(name).container()
.SemanticException
ClassType findMethodScope(java.lang.String name) throws SemanticException
findMethod(name).container()
.SemanticException
java.lang.String findLabelSilent(java.lang.String label)
ImportTable importTable()
@Deprecated Resolver outerResolver()
Context pushSource(ImportTable it)
Context pushClass(ParsedClassType scope, ClassType type)
Context pushCode(CodeInstance f)
Context pushBlock()
Context pushLabel(java.lang.String label)
Context pushStatic()
Context pop()
boolean inCode()
boolean isLocal(java.lang.String name)
CodeInstance definingCodeDef(java.lang.String name)
boolean inStaticContext()
ClassType currentClass()
ParsedClassType currentClassScope()
CodeInstance currentCode()
Package package_()