|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectpolyglot.ext.jl.types.Context_c
This class maintains a context for looking up named variables, types, and methods. It's implemented as a stack of Context objects. Each Context points to an outer context. To enter a new scope, call one of the pushXXX methods. To leave a scope, just follow the outer() pointer. NodeVisitors handle leaving scope automatically. Each context object contains maps from names to variable, type, and method objects declared in that scope.
| Nested Class Summary | |
static class |
Context_c.Kind
|
| Field Summary | |
static Context_c.Kind |
BLOCK
|
static Context_c.Kind |
CLASS
|
protected CodeInstance |
code
|
static Context_c.Kind |
CODE
|
protected boolean |
inCode
|
protected ImportTable |
it
The import table for the file |
protected Context_c.Kind |
kind
|
protected java.util.Map |
methods
|
protected Context |
outer
|
static Context_c.Kind |
OUTER
|
protected ParsedClassType |
scope
|
static Context_c.Kind |
SOURCE
|
protected boolean |
staticContext
Is the context static? |
protected TypeSystem |
ts
|
protected ClassType |
type
|
protected java.util.Map |
types
|
protected java.util.Map |
vars
|
| Constructor Summary | |
Context_c(TypeSystem ts)
|
|
| Method Summary | |
void |
addMethod(MethodInstance mi)
Adds a method to the current scoping level. |
void |
addMethodContainerToThisScope(MethodInstance mi)
|
void |
addNamed(Named t)
Adds a named type object to the current scoping level. |
void |
addNamedToThisScope(Named type)
|
void |
addVariable(VarInstance vi)
Adds a symbol to the current scoping level. |
void |
addVariableToThisScope(VarInstance var)
|
java.lang.Object |
copy()
|
ClassType |
currentClass()
Gets current class |
ParsedClassType |
currentClassScope()
Gets current class |
CodeInstance |
currentCode()
Gets the current method |
Named |
find(java.lang.String name)
Finds the definition of a particular type. |
FieldInstance |
findField(java.lang.String name)
Gets a field of a particular name. |
ClassType |
findFieldScope(java.lang.String name)
Finds the class which added a field to the scope. |
Named |
findInThisScope(java.lang.String name)
|
LocalInstance |
findLocal(java.lang.String name)
Gets a local of a particular name. |
MethodInstance |
findMethod(java.lang.String name,
java.util.List argTypes)
Looks up a method with name "name" and arguments compatible with "argTypes". |
ClassType |
findMethodContainerInThisScope(java.lang.String name)
|
ClassType |
findMethodScope(java.lang.String name)
Finds the class which added a method to the scope. |
VarInstance |
findVariable(java.lang.String name)
Gets a local or field of a particular name. |
VarInstance |
findVariableInThisScope(java.lang.String name)
|
VarInstance |
findVariableSilent(java.lang.String name)
Gets a local or field of a particular name. |
ImportTable |
importTable()
Get import table currently in scope. |
boolean |
inCode()
Return true if in a method's scope and not in a local class within the innermost method. |
boolean |
inStaticContext()
Returns whether the current context is a static context. |
boolean |
isBlock()
|
boolean |
isClass()
|
boolean |
isCode()
|
boolean |
isLocal(java.lang.String name)
Returns whether the particular symbol is defined locally. |
boolean |
isOuter()
|
boolean |
isSource()
|
protected java.lang.String |
mapsToString()
|
Resolver |
outerResolver()
Get the outer-most resolver for the source file currently in scope. |
Package |
package_()
The current package, or null if not in a package. |
Context |
pop()
Pop the context. |
protected Context_c |
push()
|
Context |
pushBlock()
pushes an additional block-scoping level. |
Context |
pushClass(ParsedClassType c,
ClassType t)
Pushes on a class scoping |
Context |
pushCode(CodeInstance ci)
enters a method |
Context |
pushSource(ImportTable it)
Push a source file scope. |
Context |
pushStatic()
pushes an additional static scoping level. |
java.lang.String |
toString()
|
TypeSystem |
typeSystem()
The type system. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected Context outer
protected TypeSystem ts
public static final Context_c.Kind BLOCK
public static final Context_c.Kind CLASS
public static final Context_c.Kind CODE
public static final Context_c.Kind OUTER
public static final Context_c.Kind SOURCE
protected ImportTable it
protected Context_c.Kind kind
protected ClassType type
protected ParsedClassType scope
protected CodeInstance code
protected java.util.Map types
protected java.util.Map methods
protected java.util.Map vars
protected boolean inCode
protected boolean staticContext
| Constructor Detail |
public Context_c(TypeSystem ts)
| Method Detail |
public boolean isBlock()
public boolean isClass()
public boolean isCode()
public boolean isOuter()
public boolean isSource()
public TypeSystem typeSystem()
Context
typeSystem in interface Contextpublic java.lang.Object copy()
copy in interface Copyprotected Context_c push()
public Resolver outerResolver()
Context
outerResolver in interface Contextpublic ImportTable importTable()
Context
importTable in interface Contextpublic Package package_()
package_ in interface Contextpublic boolean isLocal(java.lang.String name)
isLocal in interface Context
public MethodInstance findMethod(java.lang.String name,
java.util.List argTypes)
throws SemanticException
findMethod in interface ContextargTypes - A list of Type.
SemanticExceptionType
public LocalInstance findLocal(java.lang.String name)
throws SemanticException
findLocal in interface ContextSemanticException
public ClassType findFieldScope(java.lang.String name)
throws SemanticException
findFieldScope in interface ContextSemanticException
public ClassType findMethodScope(java.lang.String name)
throws SemanticException
findMethodScope in interface ContextSemanticException
public FieldInstance findField(java.lang.String name)
throws SemanticException
findField in interface ContextSemanticException
public VarInstance findVariable(java.lang.String name)
throws SemanticException
findVariable in interface ContextSemanticExceptionpublic VarInstance findVariableSilent(java.lang.String name)
findVariableSilent in interface Contextprotected java.lang.String mapsToString()
public java.lang.String toString()
public Context pop()
Context
pop in interface Context
public Named find(java.lang.String name)
throws SemanticException
find in interface ResolverSemanticExceptionpublic Context pushSource(ImportTable it)
pushSource in interface Context
public Context pushClass(ParsedClassType c,
ClassType t)
pushClass in interface Contextpublic Context pushBlock()
pushBlock in interface Contextpublic Context pushStatic()
pushStatic in interface Contextpublic Context pushCode(CodeInstance ci)
pushCode in interface Contextpublic CodeInstance currentCode()
currentCode in interface Contextpublic boolean inCode()
inCode in interface Contextpublic boolean inStaticContext()
inStaticContext in interface Contextpublic ClassType currentClass()
currentClass in interface Contextpublic ParsedClassType currentClassScope()
currentClassScope in interface Contextpublic void addVariable(VarInstance vi)
addVariable in interface Contextpublic void addMethod(MethodInstance mi)
addMethod in interface Contextpublic void addNamed(Named t)
addNamed in interface Contextpublic Named findInThisScope(java.lang.String name)
public void addNamedToThisScope(Named type)
public ClassType findMethodContainerInThisScope(java.lang.String name)
public void addMethodContainerToThisScope(MethodInstance mi)
public VarInstance findVariableInThisScope(java.lang.String name)
public void addVariableToThisScope(VarInstance var)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||