JML

org.multijava.mjc
Class CVariableInfoTable

java.lang.Object
  extended byorg.multijava.mjc.CVariableInfoTable
All Implemented Interfaces:
Cloneable

public final class CVariableInfoTable
extends Object
implements Cloneable

This class stores information about the set of local variables in a given context. This information is collected during typechecking. It includes the information necessary to replace the source code's variable identifiers with references to the appropriately numbered positions in a bytecode method's frame (JVM2, 3.6.1). The information also includes whether the variable has been assigned to (JLS2 16).

See Also:
CFlowControlContextType

Field Summary
private static int DEFAULT_SIZE
          The default size of the array constructed to hold local variable information.
private  CVariableState[] states
          The states of the variables represented by this information table.
 
Constructor Summary
  CVariableInfoTable()
           
private CVariableInfoTable(CVariableState[] states)
           
 
Method Summary
 Object clone()
           
 CVariableInfoTable duplicate()
           
private  void expandArrayToInclude(int pos)
          Expands the states array to hold state information for at least pos variables.
 CVariableState getState(int pos)
          Returns the state of the variable at the given position in the local frame.
 void initialize(VariableDescriptor varDesc)
           
 void mergeState(int pos, CVariableState state)
          Merges the given state information with the stored information in the given position.
 void mergeUpTo(int numberOfPos, CVariableInfoTable other)
          Merges the state information from other into this for positions from 0 to numberOfPos - 1.
 void replaceState(int pos, CVariableState state)
          Replaces the state information for the variable at the given position with the given state information.
 void replaceUpTo(int numberOfPos, CVariableInfoTable other)
          Replaces the state information of this with information from other for positions from 0 to numberOfPos - 1.
 String toString()
           
private  void tryFinallyMergeState(int pos, CVariableState tryVariableState)
           
 void tryFinallyMergeUpTo(int numberOfPos, CVariableInfoTable tryInfoTable)
          Merges the state information from other into this for positions from 0 to numberOfPos - 1 using the function for merging a finally block (this) with a try block.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SIZE

private static final int DEFAULT_SIZE
The default size of the array constructed to hold local variable information. Corresponds roughly to the number of local variable declarations expected in a given lexical contour.


states

private CVariableState[] states
The states of the variables represented by this information table. Note that for efficiency to following invariant holds.


 private invariant states != null &&
 		(\forall int i; 0 <= i && i < states.length;
 			states[i]==null ==>
                   (* the corresponding variable is definitely not
                      assigned *));
 

Constructor Detail

CVariableInfoTable

public CVariableInfoTable()

CVariableInfoTable

private CVariableInfoTable(CVariableState[] states)
Method Detail

clone

public Object clone()
Overrides:
clone in class Object

toString

public String toString()
Overrides:
toString in class Object

duplicate

public CVariableInfoTable duplicate()

initialize

public void initialize(VariableDescriptor varDesc)

getState

public CVariableState getState(int pos)
Returns the state of the variable at the given position in the local frame.

Returns:
an alias to the variable state object stored in the given position of this table

mergeState

public void mergeState(int pos,
                       CVariableState state)
Merges the given state information with the stored information in the given position.


tryFinallyMergeState

private void tryFinallyMergeState(int pos,
                                  CVariableState tryVariableState)

mergeUpTo

public void mergeUpTo(int numberOfPos,
                      CVariableInfoTable other)
Merges the state information from other into this for positions from 0 to numberOfPos - 1.


tryFinallyMergeUpTo

public void tryFinallyMergeUpTo(int numberOfPos,
                                CVariableInfoTable tryInfoTable)
Merges the state information from other into this for positions from 0 to numberOfPos - 1 using the function for merging a finally block (this) with a try block.

Parameters:
numberOfPos - number of positions that should be merged
tryInfoTable - the variable state information for the try block

replaceState

public void replaceState(int pos,
                         CVariableState state)
Replaces the state information for the variable at the given position with the given state information.


replaceUpTo

public void replaceUpTo(int numberOfPos,
                        CVariableInfoTable other)
Replaces the state information of this with information from other for positions from 0 to numberOfPos - 1.


expandArrayToInclude

private void expandArrayToInclude(int pos)
Expands the states array to hold state information for at least pos variables.

Parameters:
pos - the highest position for variable that this table needs to accomodate (so far)


            requires pos >= states.length;
            ensures states.length > pos;
            ensures (\forall int i; 0<=i && i<\old(states.length);
            			states[i] == \old(states[i]) );
            

JML

JML is Copyright (C) 1998-2002 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This release depends on code from the MultiJava project and is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.