SMC
6_0_1

net.sf.smc.generator
Class SmcCGenerator

java.lang.Object
  extended by net.sf.smc.model.SmcVisitor
      extended by net.sf.smc.generator.SmcCodeGenerator
          extended by net.sf.smc.generator.SmcCGenerator

public final class SmcCGenerator
extends SmcCodeGenerator

Visits the abstract syntax tree emitting C code to an output stream.

See Also:
SmcElement, SmcCodeGenerator, SmcVisitor, SmcOptions

Field Summary
 
Fields inherited from class net.sf.smc.generator.SmcCodeGenerator
_accessLevel, _castType, _debugLevel, _genericFlag, _graphLevel, _guardCount, _guardIndex, _headerDirectory, _indent, _noCatchFlag, _noExceptionFlag, _noStreamsFlag, _reflectFlag, _serialFlag, _source, _srcDirectory, _srcfileBase, _syncFlag, DEBUG_LEVEL_0, DEBUG_LEVEL_1, GRAPH_LEVEL_0, GRAPH_LEVEL_1, GRAPH_LEVEL_2, NO_DEBUG_OUTPUT, NO_GRAPH_LEVEL
 
Constructor Summary
SmcCGenerator(net.sf.smc.generator.SmcOptions options)
          Creates a C code generator for the given options.
 
Method Summary
protected  java.lang.String scopeStateName(java.lang.String stateName, java.lang.String mapName)
          Returns the scoped state name.
 void visit(SmcAction action)
          Emits C code for this FSM action.
 void visit(SmcFSM fsm)
          Emits the following C code for the FSM:
 void visit(SmcGuard guard)
          Emits C code for this FSM guard.
 void visit(SmcMap map)
          Emits C code for the FSM map.
 void visit(SmcParameter parameter)
          Emits C code for this transition parameter.
 void visit(SmcState state)
          Emits C code for this FSM state.
 void visit(SmcTransition transition)
          Emits C code for this FSM transition.
 
Methods inherited from class net.sf.smc.generator.SmcCodeGenerator
allNilEndStates, escape, isLoopback, setSource, sourceFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmcCGenerator

public SmcCGenerator(net.sf.smc.generator.SmcOptions options)
Creates a C code generator for the given options.

Parameters:
options - The target code generator options.
Method Detail

visit

public void visit(SmcFSM fsm)
Emits the following C code for the FSM:
 %{ %} raw source code - if any

 #include <%include header file>
 #include "context.h"
   
If the -headerd option is used, then this is generated:
 #include "header dir/context.h")
   

Overrides:
visit in class SmcVisitor
Parameters:
fsm - Emit code for this finite state machine.

visit

public void visit(SmcMap map)
Emits C code for the FSM map. Visits the map default state first (if there is one) and then each of the map's states.

Overrides:
visit in class SmcVisitor
Parameters:
map - emit code for this FSM map.

visit

public void visit(SmcState state)
Emits C code for this FSM state. Generates entry and exit action routines first (if any) and then the transition routines.

Overrides:
visit in class SmcVisitor
Parameters:
state - emit C code for this FSM state.

visit

public void visit(SmcTransition transition)
Emits C code for this FSM transition. Generates the transition subroutine and then each of the guards within that routine.

Overrides:
visit in class SmcVisitor
Parameters:
transition - emit C code for this FSM transition.

visit

public void visit(SmcGuard guard)
Emits C code for this FSM guard. If the guard has a condition, then the condition is placed inside an [else] if statement. The exit actions, transition actions, setting the next state and entry actions are called from within the condition body. If the condition has no condition but there are other guards, then the guard actions are placed within an else body. If the guard has no condition and there are no other guards, then the guard action code is emitted within the transition routine block.

Overrides:
visit in class SmcVisitor
Parameters:
guard - emit C code for this transition guard.

visit

public void visit(SmcAction action)
Emits C code for this FSM action. The emitted C code has the format:
 action(ctxt[, arg0, ... , argn]);
   

Overrides:
visit in class SmcVisitor
Parameters:
action - emit C code for this action.

visit

public void visit(SmcParameter parameter)
Emits C code for this transition parameter. The emitted C code has the format:
 type name
   

Overrides:
visit in class SmcVisitor
Parameters:
parameter - emit C code for this transition parameter.

scopeStateName

protected java.lang.String scopeStateName(java.lang.String stateName,
                                          java.lang.String mapName)
Returns the scoped state name. If the state is unscoped, then returns <i>mapName</i>.<i>stateName</i>. Replaces any "::" with "_" in the state name.

Overrides:
scopeStateName in class SmcCodeGenerator
Parameters:
stateName - the state name.
mapName - the map name.
Returns:
the scoped state name.

SMC
6_0_1

Copyright © 2009. Charles W. Rapp. All Rights Reserved. Use is subject to license terms.