jltools.types
Interface Context

All Superinterfaces:
Resolver
All Known Subinterfaces:
JifContext
All Known Implementing Classes:
Context_c

public interface Context
extends Resolver

A context represents a stack of scopes used for looking up types, methods, and variables.


Inner Class Summary
static interface Context.Mark
          A Mark is used to indicate a point in the stack of scopes.
 
Method Summary
 void addMethod(MethodInstance mi)
          Add a method to the current scope.
 void addType(NamedType t)
          Add a type to the current scope.
 void addVariable(VarInstance vi)
          Add a variable to the current scope.
 void assertMark(Context.Mark m)
          Assert that the mark at the top of the stack is mark.
 ParsedClassType currentClass()
          Return the innermost class in scope.
 CodeInstance currentCode()
          Return the innermost method or constructor in scope.
 FieldInstance findField(java.lang.String name)
          Looks up a field in the current scope.
 ParsedClassType findFieldScope(java.lang.String name)
          Finds the class which added a field to the scope.
 LocalInstance findLocal(java.lang.String name)
          Looks up a local variable in the current scope.
 MethodInstance findMethod(java.lang.String name, java.util.List argumentTypes)
          Looks up a method in the current scope.
 ParsedClassType 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.
 boolean inCode()
          Return whether innermost non-block scope is a code scope.
 boolean isLocal(java.lang.String name)
          Returns whether the symbol is defined within the current method.
 Context.Mark mark()
          Return the mark at the top of the stack.
 void popBlock()
          Leave the scope of a block.
 void popClass()
          Leave the scope of a class.
 void popCode()
          Leave the scope of a method or constructor.
 void popToMark(Context.Mark m)
          Pop the stack until the top of the stack is mark.
 void pushBlock()
          Enter the scope of a block.
 void pushClass(ParsedClassType c)
          Enter the scope of a class.
 void pushCode(CodeInstance f)
          Enter the scope of a method or constructor.
 TypeSystem typeSystem()
          The type system.
 
Methods inherited from interface jltools.types.Resolver
findQualifier, findType
 

Method Detail

mark

public Context.Mark mark()
Return the mark at the top of the stack.

popToMark

public void popToMark(Context.Mark m)
Pop the stack until the top of the stack is mark.

assertMark

public void assertMark(Context.Mark m)
Assert that the mark at the top of the stack is mark.

typeSystem

public TypeSystem typeSystem()
The type system.

addVariable

public void addVariable(VarInstance vi)
Add a variable to the current scope.

addMethod

public void addMethod(MethodInstance mi)
Add a method to the current scope.

addType

public void addType(NamedType t)
Add a type to the current scope.

findMethod

public MethodInstance findMethod(java.lang.String name,
                                 java.util.List argumentTypes)
                          throws SemanticException
Looks up a method in the current scope.

findVariable

public VarInstance findVariable(java.lang.String name)
                         throws SemanticException
Looks up a local variable or field in the current scope.

findLocal

public LocalInstance findLocal(java.lang.String name)
                        throws SemanticException
Looks up a local variable in the current scope.

findField

public FieldInstance findField(java.lang.String name)
                        throws SemanticException
Looks up a field in the current scope.

findFieldScope

public ParsedClassType findFieldScope(java.lang.String name)
                               throws SemanticException
Finds the class which added a field to the scope. This is usually a subclass of findField(name).container().

findMethodScope

public ParsedClassType findMethodScope(java.lang.String name)
                                throws SemanticException
Finds the class which added a method to the scope. This is usually a subclass of findMethod(name).container().

pushClass

public void pushClass(ParsedClassType c)
Enter the scope of a class.

popClass

public void popClass()
Leave the scope of a class.

pushCode

public void pushCode(CodeInstance f)
Enter the scope of a method or constructor.

popCode

public void popCode()
Leave the scope of a method or constructor.

pushBlock

public void pushBlock()
Enter the scope of a block.

popBlock

public void popBlock()
Leave the scope of a block.

inCode

public boolean inCode()
Return whether innermost non-block scope is a code scope.

isLocal

public boolean isLocal(java.lang.String name)
Returns whether the symbol is defined within the current method.

currentClass

public ParsedClassType currentClass()
Return the innermost class in scope.

currentCode

public CodeInstance currentCode()
Return the innermost method or constructor in scope.