fmrisc.Semantics
Class Environment

java.lang.Object
  extended by fmrisc.Semantics.Environment

public final class Environment
extends java.lang.Object

The context that determines the meaning of identifiers.


Constructor Summary
Environment()
          create empty type and value environment
 
Method Summary
 void addTCC(Expression formula)
          Add type checking condition to environment.
 Environment cloneGlobal()
          Create clone of global part of environment; the clone is a shallow copy (the symbols in the environment are not cloned).
 void enter()
          enter a new scope all changes done to the environment after enter() will be undone after exit()
 void exit()
          exit a scope all changes done after the after the last enter() are undone
 FormulaSymbol getFormulaSymbol(Identifier name)
          returns symbol associated to name (null, if none)
 java.util.Collection getFormulaSymbols()
          Get all formula symbols.
 java.util.Vector getGlobalValueSymbols()
          Get global value symbols in the order in which they were entered.
 java.util.Vector getLocalVariables()
          get local variables (all values with environment depth > 0)
 Expression[] getTCCs()
          Get type checking conditions of current scope (not of all scopes).
 Type getType(Identifier name)
          returns canonical type associated to key type equality implies pointer equality of types.
 TypeSymbol getTypeSymbol(Identifier name)
          returns type symbol associated to key
 java.util.Collection getTypeSymbols()
          Get all type symbols.
 ValueSymbol getValueSymbol(Identifier name)
          returns symbol associated to name (null, if none)
 java.util.Collection getValueSymbols()
          Get all value symbols.
 void put(ValueDeclIdentifier ident)
          add the symbol associated to ident to current environment
 FormulaSymbol putFormula(FormulaDeclIdentifier name, Expression formula, boolean axiom)
          put formula in environment
 FormulaSymbol putFormulaDeclaration(FormulaDeclaration fdecl)
          put formula declaration into environment
 TypeSymbol putType(TypeDeclIdentifier name, Type type)
          put type in type table
 TypeSymbol putTypeDeclaration(TypeDeclaration tdecl)
          put type declaration into environment
 ValueSymbol putValue(ValueDeclIdentifier name, Type type, Expression value)
          put named value in value table
 ValueSymbol putValueDeclaration(ValueDeclaration vdecl)
          put value declaration into environment
 boolean putVariables(TypedIdentifier[] vars)
          put variables into environment
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Environment

public Environment()
create empty type and value environment

Method Detail

cloneGlobal

public Environment cloneGlobal()
Create clone of global part of environment; the clone is a shallow copy (the symbols in the environment are not cloned).

Returns:
clone of environment containing all globally declared idents

enter

public void enter()
enter a new scope all changes done to the environment after enter() will be undone after exit()


exit

public void exit()
exit a scope all changes done after the after the last enter() are undone


putType

public TypeSymbol putType(TypeDeclIdentifier name,
                          Type type)
put type in type table

Parameters:
name - the name of the type
type - the type associated to the name
Returns:
the constructed type symbol (null, if an error occured)

getTypeSymbol

public TypeSymbol getTypeSymbol(Identifier name)
returns type symbol associated to key

Parameters:
name - the name of the type
Returns:
the symbol associated to type

getType

public Type getType(Identifier name)
returns canonical type associated to key type equality implies pointer equality of types.

Parameters:
name - the name of the type
Returns:
the canonical type associated to key

putValue

public ValueSymbol putValue(ValueDeclIdentifier name,
                            Type type,
                            Expression value)
put named value in value table

Parameters:
name - the name of the value
type - the type associated to the value
value - the value itself (may be null)
Returns:
the constructed symbol (null, if an error occured)

getValueSymbol

public ValueSymbol getValueSymbol(Identifier name)
returns symbol associated to name (null, if none)

Parameters:
name - the name
Returns:
the symbol associated to the name (may be null)

putTypeDeclaration

public TypeSymbol putTypeDeclaration(TypeDeclaration tdecl)
put type declaration into environment

Parameters:
tdecl - type declaration
Returns:
the constructed symbol (null, if an error occured)

putValueDeclaration

public ValueSymbol putValueDeclaration(ValueDeclaration vdecl)
put value declaration into environment

Parameters:
vdecl - value declaration
Returns:
the constructed symbol (null, if an error occured)

putVariables

public boolean putVariables(TypedIdentifier[] vars)
put variables into environment

Parameters:
vars - the variable sequence
Returns:
true iff no problem occured

getLocalVariables

public java.util.Vector getLocalVariables()
get local variables (all values with environment depth > 0)

Returns:
vector of ValueSymbol objects representing the local variables

putFormula

public FormulaSymbol putFormula(FormulaDeclIdentifier name,
                                Expression formula,
                                boolean axiom)
put formula in environment

Parameters:
name - the name of the formula
formula - the expression associated to the formula
axiom - true iff formula is axiom
Returns:
the constructed symbol (null, if an error occured)

getFormulaSymbol

public FormulaSymbol getFormulaSymbol(Identifier name)
returns symbol associated to name (null, if none)

Parameters:
name - the name
Returns:
the symbol associated to the name (may be null)

putFormulaDeclaration

public FormulaSymbol putFormulaDeclaration(FormulaDeclaration fdecl)
put formula declaration into environment

Parameters:
fdecl - formula declaration
Returns:
the constructed symbol (null, if an error occured)

put

public void put(ValueDeclIdentifier ident)
add the symbol associated to ident to current environment

Parameters:
ident - identifier for an already processed value declaration

getTypeSymbols

public java.util.Collection getTypeSymbols()
Get all type symbols.

Returns:
collection of all type symbols declared in current scope.

getValueSymbols

public java.util.Collection getValueSymbols()
Get all value symbols.

Returns:
collection of all value symbols declared in current scope.

getGlobalValueSymbols

public java.util.Vector getGlobalValueSymbols()
Get global value symbols in the order in which they were entered.

Returns:
vector of all value symbols stored at the top level of this environment in the order in which they were entered.

getFormulaSymbols

public java.util.Collection getFormulaSymbols()
Get all formula symbols.

Returns:
collection of all formula symbols declared in current scope.

addTCC

public void addTCC(Expression formula)
Add type checking condition to environment.


getTCCs

public Expression[] getTCCs()
Get type checking conditions of current scope (not of all scopes).

Returns:
the sequence of type checking conditions in the order they were added.