edu.ksu.cis.projects.bogor.module.state
Interface IState

All Superinterfaces:
Disposable, Serializable
All Known Implementing Classes:
DefaultState

public interface IState
extends Disposable, Serializable

An interface for a state.

Version:
CVS $Revision: 1.5 $ $Date: 2004/12/18 22:36:34 $
Author:
Robby

Method Summary
 IState clone(Map<Object,Object> cloneMap)
          Deep clone this state.
 void enterFunction(int threadId, IValueArray localValues, int beginLocationDesc, int transformationIndex)
          Enters a function for a particular thread.
 IValueArray exitFunction(int threadId)
          Exits a function for particular thread.
 IValueArray exitThread(int threadId)
          Kills a thread.
 int getGlobalCount()
          Gets the number of globals.
 IValue getGlobalValue(int globalIndex)
          Gets a global's value.
 IValueArray getGlobalValues()
          Gets all global values.
 int getLocalCount(int threadId)
          Gets the number of locals for a particular thread.
 IValue getLocalValue(int threadId, int localIndex)
          Gets a local's value.
 IValueArray getLocalValues(int threadId)
          Gets local values for a particular thread.
 IValueArray[] getLocalValuesStack(int threadId)
          Gets local values stack for a particular thread.
 int getLocation(int threadId)
          Gets a thread's location.
 int[] getLocationStack(int threadId)
          Gets the location stack for a particular thread.
 int getLockCount(int threadId)
          Gets the lock count for a particular thread when waiting.
 int getStackHeight(int threadId)
          Gets the stack height for a particular thread.
 int[] getThreadIds()
          Gets all the thread ids in this state.
 int getTransformationIndex(int threadId)
          Gets a thread's transformation index.
 int[] getTransformationIndexStack(int threadId)
          Gets the transformation index stack for a particular thread.
 boolean isThreadAlive(int threadId)
          Determines whether a thread is still alive.
 void newThread(int threadId, IValueArray localValues, int beginLocationDesc)
          Creates a new thread.
 int removeLockCount(int threadId)
          Removes the lock count for a particular thread when waiting.
 void setGlobalValue(int globalIndex, IValue value)
          Sets a global's value.
 void setLocalValue(int threadId, int localIndex, IValue value)
          Sets a local's value.
 void setLocation(int threadId, int locationDesc, int transformationIndex)
          Sets a thread's location.
 void storeLockCount(int threadId, int lockCount)
          Stores the lock count for a particular thread when waiting.
 void validate(IBogorConfiguration bc)
          Validates this state wrt.
 
Methods inherited from interface edu.ksu.cis.projects.bogor.util.Disposable
dispose
 

Method Detail

getGlobalCount

int getGlobalCount()
Gets the number of globals.

Returns:
The number of globals in this state.

setGlobalValue

void setGlobalValue(int globalIndex,
                    IValue value)
Sets a global's value.

Parameters:
globalIndex - The index of the global. Must be at least zero and at most less than the number of globals.
value - The new value of the global. Must be non-null.
See Also:
SymbolTable.getGlobalIndexTable()

getGlobalValue

IValue getGlobalValue(int globalIndex)
Gets a global's value.

Parameters:
globalIndex - The index of the global. Must be at least zero and at most less than the number of globals.
Returns:
The global's value.
See Also:
SymbolTable.getGlobalIndexTable()

getGlobalValues

IValueArray getGlobalValues()
Gets all global values.

Returns:
All global values. Non-null.

getLocalCount

int getLocalCount(int threadId)
Gets the number of locals for a particular thread.

Parameters:
threadId - The thread id that is associated to the local. The thread id must be a valid thread id in this state.
Returns:
The number of locals for the given thread.

setLocalValue

void setLocalValue(int threadId,
                   int localIndex,
                   IValue value)
Sets a local's value.

Parameters:
threadId - The thread id that is associated to the local. The thread id must be a valid thread id in this state.
localIndex - The index of the local. Must be at least zero and at most less than the number of locals.
value - The new value of the local. Must be non-null.
See Also:
FSMSymbolTable.getLocalIndexTable()

getLocalValue

IValue getLocalValue(int threadId,
                     int localIndex)
Gets a local's value.

Parameters:
threadId - The thread id that is associated to the local. The thread id must be a valid thread id in this state.
localIndex - The index of the local. Must be at least zero and at most less than the number of locals.
Returns:
The local's value.
See Also:
FSMSymbolTable.getLocalIndexTable()

getLocalValues

IValueArray getLocalValues(int threadId)
Gets local values for a particular thread.

Parameters:
threadId - The thread id that is associated to the locals. The thread id must be a valid thread id in this state.
Returns:
The local values for the given thread. Non-null.

getLocalValuesStack

IValueArray[] getLocalValuesStack(int threadId)
Gets local values stack for a particular thread.

Parameters:
threadId - The thread id that is associated to the locals. The thread id must be a valid thread id in this state.
Returns:
The local values stack for the given thread. Non-null. Each element is non-null. Top most (current) local values is at index zero.

setLocation

void setLocation(int threadId,
                 int locationDesc,
                 int transformationIndex)
Sets a thread's location.

Parameters:
threadId - The thread id that its location to be set. The thread id must be a valid thread id in this state.
locationDesc - The new location of the thread.
transformationIndex - The transformation index causing the move. It must be a transformation index of the old location desc.
See Also:
FSMSymbolTable.getLocationDescTable()

getLocation

int getLocation(int threadId)
Gets a thread's location.

Parameters:
threadId - The thread id that its location is queried. The thread id must be a valid thread id in this state.
Returns:
The thread's location.
See Also:
FSMSymbolTable.getLocationDescTable()

getLocationStack

int[] getLocationStack(int threadId)
Gets the location stack for a particular thread.

Parameters:
threadId - The thread id that is associated to the location stack. The thread id must be a valid thread id in this state.
Returns:
The location stack for the given thread. Non-null. Top most (current) location is at index zero.

getLockCount

int getLockCount(int threadId)
Gets the lock count for a particular thread when waiting.

Parameters:
threadId - The thread id that is (must be) waiting.
Returns:
The number of locks operations. At least zero.

getStackHeight

int getStackHeight(int threadId)
Gets the stack height for a particular thread.

Parameters:
threadId - The thread id that is associated to the stack. The thread id must be a valid thread id in this state.
Returns:
The stack height for the given thread. At least one.

isThreadAlive

boolean isThreadAlive(int threadId)
Determines whether a thread is still alive.

Parameters:
threadId - The thread to be determined.
Returns:
True, if the given thread is still alive. False, otherwise.

getThreadIds

int[] getThreadIds()
Gets all the thread ids in this state.

Returns:
The sorted array containing all the thread ids in this state. Non-null.

getTransformationIndex

int getTransformationIndex(int threadId)
Gets a thread's transformation index.

Parameters:
threadId - The thread id that its transformation index is queried. The thread id must be a valid thread id in this state.
Returns:
The thread's transformation index.

getTransformationIndexStack

int[] getTransformationIndexStack(int threadId)
Gets the transformation index stack for a particular thread.

Parameters:
threadId - The thread id that is associated to the transformation index stack. The thread id must be a valid thread id in this state.
Returns:
The transformation index stack for the given thread. Non-null. Top most (current) transformation index is at index zero.

clone

IState clone(Map<Object,Object> cloneMap)
Deep clone this state.

Parameters:
cloneMap - Original values (IValue) to their clones ( IValue) mapping. The clone map to solve circular references in values.
Returns:
The clone of this state. Non-null.

enterFunction

void enterFunction(int threadId,
                   IValueArray localValues,
                   int beginLocationDesc,
                   int transformationIndex)
Enters a function for a particular thread. The current thread location is pushed to a stack and set the thread's current location to the function's initial location. The current thread local values are also pushed to a stack in a similar manner.

Parameters:
threadId - The thread id of the thread that enters a function. The thread id must be a valid thread id in this state.
localValues - The local values of the function to be entered. Must be non-null.
beginLocationDesc - The function initial location.
See Also:
FSMSymbolTable.getLocationDescTable()

exitFunction

IValueArray exitFunction(int threadId)
Exits a function for particular thread. The current thread location is popped out from a stack and set the thread's location to the exit location. The current thread local values are also popped from a stack in a similar manner. The thread id no longer exists in this state.

Parameters:
threadId - The thread id of the thread that enters a function. The thread id must be a valid thread id in this state.
Returns:
The local values of the exited function. Non-null.
See Also:
FSMSymbolTable.getLocationDescTable()

exitThread

IValueArray exitThread(int threadId)
Kills a thread. The thread with the given thread id will be assigned the dead status. All mappings of the thread id to its local values and its location are removed from the state.

Parameters:
threadId - The thread id to be killed. The thread id must be a valid thread id in this state.
Returns:
The local values of the exited thread. Non-null.

newThread

void newThread(int threadId,
               IValueArray localValues,
               int beginLocationDesc)
Creates a new thread. A new thread with the given thread id will be created in the state with status new. A mapping from thread id to the thread's local values and the thread's location are also located.

Parameters:
threadId - The thread id for the new thread. The thread id must not already be in this state.
localValues - The local values of the new thread. Must be non-null.
beginLocationDesc - The initial location of the new thread.
See Also:
FSMSymbolTable.getLocationDescTable()

removeLockCount

int removeLockCount(int threadId)
Removes the lock count for a particular thread when waiting.

Parameters:
threadId - The thread id that is (must be) waiting.
Returns:
The number of locks operations. At least zero.

storeLockCount

void storeLockCount(int threadId,
                    int lockCount)
Stores the lock count for a particular thread when waiting.

Parameters:
threadId - The thread id that is waiting. The thread id must be a valid thread id in this state.
lockCount - The number of locks operations. At least zero.

validate

void validate(IBogorConfiguration bc)
Validates this state wrt. a configuration.

Parameters:
bc - The Bogor configuration to validate to.