openjava.mop
Class Environment

java.lang.Object
  |
  +--openjava.mop.Environment
Direct Known Subclasses:
ClosedEnvironment, FileEnvironment, GlobalEnvironment, RelEnvironment, VolcanoPlannerTest.TestEnvironment

public abstract class Environment
extends Object


Nested Class Summary
protected static class Environment.BasicVariableInfo
           
static interface Environment.VariableInfo
           
 
Field Summary
protected  Environment parent
           
 
Constructor Summary
Environment()
           
Environment(Environment e)
           
 
Method Summary
abstract  void bindVariable(String name, Environment.VariableInfo info)
          Binds the name of a variable to information about the variable, including its class.
 void bindVariable(String name, OJClass clazz)
          Binds the name of a variable to its class.
 String currentClassName()
           
 ClassEnvironment getClassEnvironmentParent()
          Gets the nearest ancestor which is a ClassEnvironment, or null.
 GlobalEnvironment getGlobalEnvironment()
          Gets the root environment, which is always a GlobalEnvironment.
 String getPackage()
          Gets the package name.
 Environment getParent()
          Gets the parent environment.
 boolean isBind(String name)
          Returns whether a name is a variable.
static boolean isQualifiedName(String name)
          Tests if the given name is a qualified name or not.
 boolean isRegisteredModifier(String str)
           
 Environment.VariableInfo lookupBind(String name)
          Looks up a binded type of the given variable or field name.
 OJClass lookupClass(String name)
          Looks a class object up.
 OJClass lookupClass(String name, int dimensionCount)
          Looks up a class with a given dimension.
abstract  void record(String name, OJClass clazz)
          Records a class object.
 void recordMemberClass(String declarerName, String innerName)
          If this is a ClassEnvironment for declarerName, record new inner class innerName; otherwise, pass up the environment hierarchy.
static String toPackageName(String qualified_name)
          Converts a fully-qualified name to the corresponding package name.
 String toQualifiedName(String name)
          Obtains the fully-qualified name of the given class name.
static String toSimpleName(String qualified_name)
          Converts a fully-qualified name to the corresponding simple-name.
abstract  String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parent

protected Environment parent
Constructor Detail

Environment

public Environment()

Environment

public Environment(Environment e)
Method Detail

toString

public abstract String toString()
Overrides:
toString in class Object

getParent

public Environment getParent()
Gets the parent environment.


getClassEnvironmentParent

public ClassEnvironment getClassEnvironmentParent()
Gets the nearest ancestor which is a ClassEnvironment, or null.


getGlobalEnvironment

public GlobalEnvironment getGlobalEnvironment()
Gets the root environment, which is always a GlobalEnvironment.


getPackage

public String getPackage()
Gets the package name.


lookupClass

public OJClass lookupClass(String name)
Looks a class object up.

Parameters:
name - the name of the fully-qualified name of the class looked for

lookupClass

public OJClass lookupClass(String name,
                           int dimensionCount)
Looks up a class with a given dimension. For example, lookupClass("java.lang.String", 2) returns the OJClass representing the class String[][].

Parameters:
name - the fully-qualified name of the class
dimensionCount - the dimensionality of the type
Returns:
a class with the given name and dimensionality

record

public abstract void record(String name,
                            OJClass clazz)
Records a class object.

Parameters:
name - the fully-qualified name of the class
clazz - the class object associated with that name

lookupBind

public Environment.VariableInfo lookupBind(String name)
Looks up a binded type of the given variable or field name.

Parameters:
name - the fully-qualified name of the class

isBind

public boolean isBind(String name)
Returns whether a name is a variable. (In some situations, we cannot use lookupBind(java.lang.String), because the tree is not yet in a state where we can infer types.)


bindVariable

public void bindVariable(String name,
                         OJClass clazz)
Binds the name of a variable to its class.

Parameters:
name - the fully-qualified name of the class
clazz - the class object associated with that name

bindVariable

public abstract void bindVariable(String name,
                                  Environment.VariableInfo info)
Binds the name of a variable to information about the variable, including its class.


toQualifiedName

public String toQualifiedName(String name)
Obtains the fully-qualified name of the given class name.

Parameters:
name - a simple class name or a fully-qualified class name
Returns:
the fully-qualified name of the class

isQualifiedName

public static boolean isQualifiedName(String name)
Tests if the given name is a qualified name or not.


toSimpleName

public static String toSimpleName(String qualified_name)
Converts a fully-qualified name to the corresponding simple-name.
 For example :
   toSimpleName( "java.lang.Class" ) returns  "Class".
 

Returns:
the given name as is if it is not a qualified name

toPackageName

public static String toPackageName(String qualified_name)
Converts a fully-qualified name to the corresponding package name.
 For example :
   toPackageName( "java.lang.Class" ) returns  "java.lang".
   toPackageName( "MyClass" ) returns  "".
 

Returns:
the given name as is if it is not a qualified name

currentClassName

public String currentClassName()

isRegisteredModifier

public boolean isRegisteredModifier(String str)

recordMemberClass

public void recordMemberClass(String declarerName,
                              String innerName)
If this is a ClassEnvironment for declarerName, record new inner class innerName; otherwise, pass up the environment hierarchy.

Parameters:
declarerName - fully-qualified name of enclosing class
innerName - simple name of inner class

SourceForge.net_Logo