public class Context_c extends java.lang.Object implements Context
Modifier and Type | Class and Description |
---|---|
static class |
Context_c.Kind |
Modifier and Type | Field and Description |
---|---|
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.lang.String |
label |
static Context_c.Kind |
LABEL |
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<java.lang.String,Named> |
types |
protected java.util.Map<java.lang.String,VarInstance> |
vars |
Constructor and Description |
---|
Context_c(Lang lang,
TypeSystem ts) |
Context_c(TypeSystem ts)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
void |
addMethod(MethodInstance mi)
Deprecated.
|
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) |
Context |
copy() |
ClassType |
currentClass()
Gets current class
|
ParsedClassType |
currentClassScope()
Gets current class
|
CodeInstance |
currentCode()
Gets the current method
|
CodeInstance |
definingCodeDef(java.lang.String name)
Return the code def that defines the local variable or type with the given name.
|
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) |
java.lang.String |
findLabelSilent(java.lang.String label)
Looks up a label in the current scope.
|
LocalInstance |
findLocal(java.lang.String name)
Gets a local of a particular name.
|
LocalInstance |
findLocalSilent(java.lang.String name)
Gets a local of a particular name.
|
MethodInstance |
findMethod(java.lang.String name,
java.util.List<? extends Type> 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() |
Lang |
lang()
The language this context represents.
|
protected java.lang.String |
mapsToString() |
Resolver |
outerResolver()
Deprecated.
|
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 classScope,
ClassType type)
Pushes on a class scoping.
|
Context |
pushCode(CodeInstance ci)
enters a method
|
Context |
pushLabel(java.lang.String label)
enters a label.
|
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.
|
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 LABEL
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.lang.String label
protected java.util.Map<java.lang.String,Named> types
protected java.util.Map<java.lang.String,VarInstance> vars
protected boolean inCode
protected boolean staticContext
@Deprecated public Context_c(TypeSystem ts)
public Context_c(Lang lang, TypeSystem ts)
public boolean isBlock()
public boolean isClass()
public boolean isCode()
public boolean isOuter()
public boolean isSource()
public Lang lang()
Context
public TypeSystem typeSystem()
Context
typeSystem
in interface Context
protected Context_c push()
@Deprecated public Resolver outerResolver()
Context
outerResolver
in interface Context
public ImportTable importTable()
Context
importTable
in interface Context
public Package package_()
public CodeInstance definingCodeDef(java.lang.String name)
definingCodeDef
in interface Context
public boolean isLocal(java.lang.String name)
public MethodInstance findMethod(java.lang.String name, java.util.List<? extends Type> argTypes) throws SemanticException
findMethod
in interface Context
argTypes
- A list of Type
.SemanticException
Type
public LocalInstance findLocal(java.lang.String name) throws SemanticException
findLocal
in interface Context
SemanticException
- if there is no such localpublic LocalInstance findLocalSilent(java.lang.String name)
findLocalSilent
in interface Context
public ClassType findFieldScope(java.lang.String name) throws SemanticException
findFieldScope
in interface Context
SemanticException
public ClassType findMethodScope(java.lang.String name) throws SemanticException
findMethodScope
in interface Context
SemanticException
public FieldInstance findField(java.lang.String name) throws SemanticException
findField
in interface Context
SemanticException
public VarInstance findVariable(java.lang.String name) throws SemanticException
findVariable
in interface Context
SemanticException
public VarInstance findVariableSilent(java.lang.String name)
findVariableSilent
in interface Context
public java.lang.String findLabelSilent(java.lang.String label)
Context
findLabelSilent
in interface Context
protected java.lang.String mapsToString()
public java.lang.String toString()
toString
in class java.lang.Object
public Named find(java.lang.String name) throws SemanticException
find
in interface Resolver
SemanticException
public Context pushSource(ImportTable it)
pushSource
in interface Context
public Context pushClass(ParsedClassType classScope, ClassType type)
pushClass
in interface Context
classScope
- The class whose scope is being entered. This is
the object associated with the class declaration and is returned by
currentClassScope. This is a mutable class type since for some
passes (e.g., addMembers), the object returned by currentClassScope
is modified.type
- The type to be returned by currentClass(). For JL, this
type is the same as classScope. For other languages, it may differ
since currentClassScope might not represent a type.public Context pushBlock()
public Context pushLabel(java.lang.String label)
public Context pushStatic()
pushStatic
in interface Context
public Context pushCode(CodeInstance ci)
public CodeInstance currentCode()
currentCode
in interface Context
public boolean inCode()
public boolean inStaticContext()
inStaticContext
in interface Context
public ClassType currentClass()
currentClass
in interface Context
public ParsedClassType currentClassScope()
currentClassScope
in interface Context
public void addVariable(VarInstance vi)
addVariable
in interface Context
@Deprecated public void addMethod(MethodInstance mi)
public void addNamed(Named t)
public Named findInThisScope(java.lang.String name)
public void addNamedToThisScope(Named type)
public ClassType findMethodContainerInThisScope(java.lang.String name)
public VarInstance findVariableInThisScope(java.lang.String name)
public void addVariableToThisScope(VarInstance var)