org.norecess.citkit.environment
Class NullEnvironment<T>

java.lang.Object
  extended by org.norecess.citkit.environment.NullEnvironment<T>
All Implemented Interfaces:
java.io.Serializable, IEnvironment<T>

public class NullEnvironment<T>
extends java.lang.Object
implements IEnvironment<T>

See Also:
Serialized Form

Constructor Summary
NullEnvironment()
           
 
Method Summary
 void add(ISymbol variable, T value)
          Adds a new variable to the current environment.
 Environment<T> create()
          Creates a nested environment.
 void define(ISymbol variable, T value)
          Defines the variable in the top level environment.
 boolean equals(java.lang.Object o)
           
 T get(ISymbol variable)
          Returns the value associated with the specified variable.
 int hashCode()
           
 T set(ISymbol variable, T value)
          Changes the value associated with the specified variable.
 HobbesTIR setInCurrentScope(ISymbol variable, T value)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NullEnvironment

public NullEnvironment()
Method Detail

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

add

public void add(ISymbol variable,
                T value)
         throws InvalidVariableException
Description copied from interface: IEnvironment
Adds a new variable to the current environment. Presently, this does not check the previous environments to see if this shadows an earlier declaration; if this were implemented, it'd be a warning, not an error.

Specified by:
add in interface IEnvironment<T>
Parameters:
variable - the new variable to add to the environment.
value - the new value to associate with the new variable.
Throws:
InvalidVariableException - when the variable is already declared in the current scope.

define

public void define(ISymbol variable,
                   T value)
Description copied from interface: IEnvironment
Defines the variable in the top level environment.

Specified by:
define in interface IEnvironment<T>
Parameters:
variable - the variable to define.
value - the value to set it to.

get

public T get(ISymbol variable)
      throws InvalidVariableException
Description copied from interface: IEnvironment
Returns the value associated with the specified variable. The variable is searched for in all of the previous scopes.

Specified by:
get in interface IEnvironment<T>
Parameters:
variable - the variable to search for.
Returns:
the value associated with the variable.
Throws:
InvalidVariableException - when the variable is undeclared (in this or any previous scope).

set

public T set(ISymbol variable,
             T value)
      throws InvalidVariableException
Description copied from interface: IEnvironment
Changes the value associated with the specified variable. The variable is searched for in all of the previous scopes; the old value is returned.

Specified by:
set in interface IEnvironment<T>
Parameters:
variable - the variable to search for.
value - the new value for the variable.
Returns:
the old value associated with the variable.
Throws:
InvalidVariableException - when the variable is undeclared (in this or any previous scope).

setInCurrentScope

public HobbesTIR setInCurrentScope(ISymbol variable,
                                   T value)
                            throws InvalidVariableException
Throws:
InvalidVariableException

create

public Environment<T> create()
Description copied from interface: IEnvironment
Creates a nested environment.

Specified by:
create in interface IEnvironment<T>