edu.ksu.cis.projects.bogor.ast
Class FSM

java.lang.Object
  extended by edu.ksu.cis.projects.bogor.ast.Node
      extended by edu.ksu.cis.projects.bogor.ast.SystemMember
          extended by edu.ksu.cis.projects.bogor.ast.FSM
All Implemented Interfaces:
IExpParent, IStatementParent, ITypedIdParent, ITypeParent, Disposable, Serializable, Cloneable

public final class FSM
extends SystemMember
implements ITypedIdParent, IExpParent, ITypeParent, IStatementParent

FSM AST.

Version:
CVS $Revision: 1.14 $ $Date: 2005/05/06 17:25:17 $
Author:
Robby , Matt Hoosier
See Also:
Serialized Form

Nested Class Summary
static class FSM.DeclarationKeyword
           
 
Field Summary
static int DEFAULT_ACTIVE_FSM_MULTIPLICITY
           
protected  ASTType returnType
          Holds the optional return type.
 
Fields inherited from class edu.ksu.cis.projects.bogor.ast.Node
ILLEGAL_LOCAL_ID_CHAR
 
Constructor Summary
FSM(FSM.DeclarationKeyword keyword, boolean active, Exp optionalNumActiveExp, boolean main, String id, ArrayList<Param> params, ASTType optionalReturnType, List<Local> locals, List<Location> locations, List<Catch> catches, Statement statement)
          Internal constructor.
 
Method Summary
 FSM clone()
          Clones this object (deep clone); including location info.
 void dispose()
          Disposes params, locals, locations, and catches.
 boolean getActive()
          Query whether this thread type is automatically started in the initial state.
 Catch getCatch(int index)
          Gets a catch at a specified index.
 int getCatchCount()
          Gets the number of catches.
 FSM.DeclarationKeyword getDeclarationKeyword()
           
 String getId()
          Gets the id.
 Local getLocal(int index)
          Gets the local at a specified index.
 int getLocalCount()
          Gets the number of locals.
 Location getLocation(int index)
          Gets the location at a specified index.
 int getLocationCount()
          Gets the number of locations.
 boolean getMain()
          Gets the main.
 Exp getOptionalActiveMultiplicityExp()
          Retrieve expression giving multiplicity of an active thread type.
 ASTType getOptionalReturnType()
          Gets the return type.
 Param getParam(int index)
          Gets the param at a specified index.
 int getParamCount()
          Gets the number of params.
 Statement getStatement()
          Gets the statement of this FSM.
 void setActive(boolean newActive)
          Sets whether this thread type is automatically started in the initial state.
 void setCatches(List<Catch> newCatches)
          Sets the catches.
 void setDeclarationKeyword(FSM.DeclarationKeyword newKeyword)
           
 void setId(String newId)
          Sets the function id.
 void setLocals(List<Local> newLocals)
          Sets the locals.
 void setLocations(List<Location> newLocations)
          Sets the location.
 void setMain(boolean newMain)
          Sets the main.
 void setOptionalActiveMultiplicityExp(Exp num)
          Install syntax tree for expression giving number of replicated versions of this thread (only applicable for active thread types).
 void setParams(ArrayList<Param> newParams)
          Sets the params.
 void setReturnType(ASTType newReturnType)
          Sets the return type.
 void setStatement(Statement stmt)
          Sets the statement of this FSM.
 String toString()
          Returns the string representation of this object.
 void visit(ASTVisitor visitor)
           
 
Methods inherited from class edu.ksu.cis.projects.bogor.ast.SystemMember
getParent, setParent
 
Methods inherited from class edu.ksu.cis.projects.bogor.ast.Node
getLocationInfo, getProperty, putProperty, setLocationInfo
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_ACTIVE_FSM_MULTIPLICITY

public static final int DEFAULT_ACTIVE_FSM_MULTIPLICITY
See Also:
Constant Field Values

returnType

protected ASTType returnType
Holds the optional return type.

Constructor Detail

FSM

public FSM(FSM.DeclarationKeyword keyword,
           boolean active,
           Exp optionalNumActiveExp,
           boolean main,
           String id,
           ArrayList<Param> params,
           ASTType optionalReturnType,
           List<Local> locals,
           List<Location> locations,
           List<Catch> catches,
           Statement statement)
Internal constructor. Sets this object as each param's, each local's, and each location's parent.

Parameters:
keyword - Token indicating which keyword was used to declare this FSM.
active - Flag indicating whether thread type should auto-start in initial state.
optionalNumActiveExp - Number of copies of an active thread to start. May be null (indicates either nonactive thread type or exactly one active thread).
main - The main.
id - The id.
params - The params. Must be non-null. Each element must be instance of Param.
optionalReturnType - The return type. Must be non-null.
locals - The locals. Must be non-null. Each element must be instance of Local.
locations - The locations. Must be non-null. Each element must be instance of Location. The number of elements must be greater than zero.
catches - The catches. Must be non-null. Each element must be instance of Catch.
Method Detail

getCatch

public Catch getCatch(int index)
Gets a catch at a specified index.

Parameters:
index - The index of the catch. Must be between 0 and getCatchCount() - 1, inclusive.
Returns:
The catch at the specified index.

getCatchCount

public int getCatchCount()
Gets the number of catches.

Returns:
The number of catches.

setCatches

public void setCatches(List<Catch> newCatches)
Sets the catches. Sets this object as each catch's parent.

Parameters:
newCatches - The new catches. Must be non-null. Each element must be instance of Catch.

getDeclarationKeyword

public FSM.DeclarationKeyword getDeclarationKeyword()

setDeclarationKeyword

public void setDeclarationKeyword(FSM.DeclarationKeyword newKeyword)

setId

public void setId(String newId)
Sets the function id.

Parameters:
newId - The new function id. Must be non-null.

getId

public String getId()
Gets the id.

Returns:
The function id. Non-null.

getLocal

public Local getLocal(int index)
Gets the local at a specified index.

Parameters:
index - The index of the local. Must be between 0 and getLocalCount() - 1, inclusive.
Returns:
The local at the specified index. Non-null.

getLocalCount

public int getLocalCount()
Gets the number of locals.

Returns:
The number of locals.

setLocals

public void setLocals(List<Local> newLocals)
Sets the locals. Sets this object as each local's parent.

Parameters:
newLocals - The new locals. Must be non-null. Each element must be instance of Local.

getLocation

public Location getLocation(int index)
Gets the location at a specified index.

Parameters:
index - The index of the location. Must be between 0 and getLocationCount() - 1, inclusive.
Returns:
The location at the specified index. Non-null.

getLocationCount

public int getLocationCount()
Gets the number of locations.

Returns:
The number of locations. Greater than zero.

setLocations

public void setLocations(List<Location> newLocations)
Sets the location. Sets this object as each location's parent.

Parameters:
newLocations - The new locations. Must be non-null. Each element must be instance of Location. The number of elements must be greater than zero.

getParam

public Param getParam(int index)
Gets the param at a specified index.

Parameters:
index - The index of the param. Must be between 0 and getParamCount() - 1, inclusive.
Returns:
The param at the specified index. Non-null.

getParamCount

public int getParamCount()
Gets the number of params.

Returns:
The number of params.

getOptionalActiveMultiplicityExp

public Exp getOptionalActiveMultiplicityExp()
Retrieve expression giving multiplicity of an active thread type.

Returns:
the syntax tree node for multiplicity expression

setOptionalActiveMultiplicityExp

public void setOptionalActiveMultiplicityExp(Exp num)
Install syntax tree for expression giving number of replicated versions of this thread (only applicable for active thread types).

Parameters:
num - The new main.

getActive

public boolean getActive()
Query whether this thread type is automatically started in the initial state.

Returns:
true if this thread type should be created in the initial state, false otherwise

setActive

public void setActive(boolean newActive)
Sets whether this thread type is automatically started in the initial state.


setParams

public void setParams(ArrayList<Param> newParams)
Sets the params. Sets this object as each param's parent.

Parameters:
newParams - The new params. Must be non-null. Each element must be instance ofTypedId.

getMain

public boolean getMain()
Gets the main.

Returns:
True, if this object is the main function. False, otherwise.

setMain

public void setMain(boolean newMain)
Sets the main.

Parameters:
newMain - The new main.

setReturnType

public void setReturnType(ASTType newReturnType)
Sets the return type. Sets this object as the return type's parent.

Parameters:
newReturnType - The new return type. Must be non-null.

getOptionalReturnType

public ASTType getOptionalReturnType()
Gets the return type.

Returns:
The return type.

getStatement

public Statement getStatement()
Gets the statement of this FSM.

Returns:
Returns the stmt.

setStatement

public void setStatement(Statement stmt)
Sets the statement of this FSM. Sets this object as the stmt's parent.

Parameters:
stmt - The stmt to set. Must be non-null.

dispose

public void dispose()
Disposes params, locals, locations, and catches. Once called, avoid using this object.

Specified by:
dispose in interface Disposable
Overrides:
dispose in class SystemMember

toString

public String toString()
Returns the string representation of this object.

Specified by:
toString in class Node
Returns:
 
  
   
    
     
      
       
        
         
          
           
            
             
              
               
                
                 
                  
                   
                    
                     
                      
                       
                        
                         
                          
                           
                            
                             
                              
                               
                                
                                   "    function id( ( params , )* ) [ returns returnType ]\n"
                                   + "    {"
                                   + "        ( locals )*\n"
                                   + "( locations )+"
                                   + "( catches )*"
                                   + "    }".
                                 
                                
                               
                              
                             
                            
                           
                          
                         
                        
                       
                      
                     
                    
                   
                  
                 
                
               
              
             
            
           
          
         
        
       
      
     
    
   
  
 

clone

public FSM clone()
Clones this object (deep clone); including location info.

Specified by:
clone in class SystemMember
Returns:
The clone of this object. Non-null.

visit

public void visit(ASTVisitor visitor)
Specified by:
visit in class Node