Overview | Package | Class | Tree | Deprecated | Index | Help
| SMC 6_0_1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## net.sf.smc.generator
Class SmcCodeGenerator

    java.lang.Object
      net.sf.smc.model.SmcVisitor
          net.sf.smc.generator.SmcCodeGenerator

Direct Known Subclasses:
  SmcCGenerator, SmcCppGenerator, SmcCSharpGenerator, SmcGraphGenerator, SmcGroovyGenerator, SmcHeaderCGenerator, SmcHeaderGenerator, SmcHeaderObjCGenerator, SmcJavaGenerator, SmcLuaGenerator, SmcObjCGenerator, SmcPerlGenerator, SmcPhpGenerator, SmcPythonGenerator, SmcRubyGenerator, SmcScalaGenerator, SmcTableGenerator, SmcTclGenerator, SmcVBGenerator

    public abstract class SmcCodeGenerator

extends SmcVisitor

Base class for all target language code generators. The syntax tree visitation methods of the `SmcVisitor` super class are left to this class' subclasses to define.

See Also:
  `SmcElement`, `SmcVisitor`, `SmcOptions`

Field Summary
`protected java.lang.String` | `_accessLevel` Used this access keyword for the generated classes.
`protected java.lang.String` | `_castType` Use this cast type (C++ only).
`protected int` | `_debugLevel` This flag is true when debug output is to be generated.
`protected boolean` | `_genericFlag` This flag is true when reflection is to use a generic transition map.
`protected int` | `_graphLevel` Generate this much detail in the graph (-graph only).
`protected int` | `_guardCount` The total number of guards to be generated at this time.
`protected int` | `_guardIndex` The guard currently being generated.
`protected java.lang.String` | `_headerDirectory` Place the generated header file in this directory.
`protected java.lang.String` | `_indent` Output this indent before generating a line of code.
`protected boolean` | `_noCatchFlag` This flag is true when exceptions are not caught.
`protected boolean` | `_noExceptionFlag` This flag is true when exceptions are not be thrown.
`protected boolean` | `_noStreamsFlag` This flag is true when I/O streams should not be used.
`protected boolean` | `_reflectFlag` This flag is true when reflection is supported.
`protected boolean` | `_serialFlag` This flag is true when serialization is to be generated.
`protected java.io.PrintStream` | `_source` Emit the target source code to this output stream.
`protected java.lang.String` | `_srcDirectory` Write the target source file to this directory.
`protected java.lang.String` | `_srcfileBase` The .sm file's base name.
`protected boolean` | `_syncFlag` This flag is true when synchronization code is to be generated.
`static int` | `DEBUG_LEVEL_0` Output states and transitions.
`static int` | `DEBUG_LEVEL_1` Output states, transitions and all transition, entry and exit actions.
`static int` | `GRAPH_LEVEL_0` Provide state and transition names only.
`static int` | `GRAPH_LEVEL_1` Provide state and transition names plus transition guards and actions.
`static int` | `GRAPH_LEVEL_2` Provides state names, entry and exit actions, transition name and arguments, guards, actions and their action parameters and pop transition arguments.
`static int` | `NO_DEBUG_OUTPUT` No debug output.
`static int` | `NO_GRAPH_LEVEL` No graphing is done.

Constructor Summary
`protected` | `SmcCodeGenerator(net.sf.smc.generator.SmcOptions options, java.lang.String suffix)` Constructs the target code generator for the given parameters.

Method Summary
`protected boolean` | `allNilEndStates(java.util.List<SmcGuard> guards)` Returns `true` if each of the transition guards uses the nil end state.
`static java.lang.String` | `escape(java.lang.String s)` Place a backslash escape character in front of backslashes and doublequotes.
`protected boolean` | `isLoopback(SmcElement.TransType transType, java.lang.String endState)` Returns `true` if this transition is an internal loopback or a push transition and `false` otherwise.
`protected java.lang.String` | `scopeStateName(java.lang.String stateName, java.lang.String mapName)`
`void` | `setSource(java.io.PrintStream source)` Sets the source code output destination.
`java.lang.String` | `sourceFile(java.lang.String path, java.lang.String basename, java.lang.String suffix)` Returns the source file name generated from the destination directory, base name and suffix using the source name format.

Methods inherited from class net.sf.smc.model.SmcVisitor
`visit, visit, visit, visit, visit, visit, visit`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _source

    protected java.io.PrintStream _source

  Emit the target source code to this output stream.

### _srcfileBase

    protected final java.lang.String _srcfileBase

  The .sm file's base name.

### _srcDirectory

    protected final java.lang.String _srcDirectory

  Write the target source file to this directory.

### _headerDirectory

    protected final java.lang.String _headerDirectory

  Place the generated header file in this directory.

### _castType

    protected final java.lang.String _castType

  Use this cast type (C++ only).

### _graphLevel

    protected final int _graphLevel

  Generate this much detail in the graph (-graph only).

### _indent

    protected java.lang.String _indent

  Output this indent before generating a line of code.

### _guardCount

    protected int _guardCount

  The total number of guards to be generated at this time.

### _guardIndex

    protected int _guardIndex

  The guard currently being generated.

### _serialFlag

    protected final boolean _serialFlag

  This flag is true when serialization is to be generated.

### _debugLevel

    protected final int _debugLevel

  This flag is true when debug output is to be generated.

### _noExceptionFlag

    protected final boolean _noExceptionFlag

  This flag is true when exceptions are not be thrown.

### _noCatchFlag

    protected final boolean _noCatchFlag

  This flag is true when exceptions are not caught.

### _noStreamsFlag

    protected final boolean _noStreamsFlag

  This flag is true when I/O streams should not be used.

### _reflectFlag

    protected final boolean _reflectFlag

  This flag is true when reflection is supported.

### _syncFlag

    protected final boolean _syncFlag

  This flag is true when synchronization code is to be generated.

### _genericFlag

    protected final boolean _genericFlag

  This flag is true when reflection is to use a generic transition map. Used with -java and -reflect only.

### _accessLevel

    protected final java.lang.String _accessLevel

  Used this access keyword for the generated classes.

### NO_DEBUG_OUTPUT

    public static final int NO_DEBUG_OUTPUT

  No debug output.

  See Also:
    Constant Field Values

### DEBUG_LEVEL_0

    public static final int DEBUG_LEVEL_0

  Output states and transitions.

  See Also:
    Constant Field Values

### DEBUG_LEVEL_1

    public static final int DEBUG_LEVEL_1

  Output states, transitions and all transition, entry and exit actions.

  See Also:
    Constant Field Values

### NO_GRAPH_LEVEL

    public static final int NO_GRAPH_LEVEL

  No graphing is done.

  See Also:
    Constant Field Values

### GRAPH_LEVEL_0

    public static final int GRAPH_LEVEL_0

  Provide state and transition names only.

  See Also:
    Constant Field Values

### GRAPH_LEVEL_1

    public static final int GRAPH_LEVEL_1

  Provide state and transition names plus transition guards and actions.

  See Also:
    Constant Field Values

### GRAPH_LEVEL_2

    public static final int GRAPH_LEVEL_2

  Provides state names, entry and exit actions, transition name and arguments, guards, actions and their action parameters and pop transition arguments.

  See Also:
    Constant Field Values

Constructor Detail

### SmcCodeGenerator

    protected SmcCodeGenerator(net.sf.smc.generator.SmcOptions options,
                               java.lang.String suffix)

  Constructs the target code generator for the given parameters. All subclass constructors receive the same arguments even though not all arguments apply to every concrete code generator.

  Parameters:
    `options` - The target code generator options.
    `suffix` - the target source file name suffix.

Method Detail

### sourceFile

    public java.lang.String sourceFile(java.lang.String path,
                                       java.lang.String basename,
                                       java.lang.String suffix)

  Returns the source file name generated from the destination directory, base name and suffix using the source name format.

  Parameters:
    `path` - The destination directory.
    `basename` - The file's basename sans suffix.
    `suffix` - Append this suffix to the file.

### isLoopback

    protected boolean isLoopback(SmcElement.TransType transType,
                                 java.lang.String endState)

  Returns `true` if this transition is an internal loopback or a push transition and `false` otherwise. If true, then do not perform the the state exit and entry actions.

  Parameters:
    `transType` - the transition type.
    `endState` - entering this state.
  Returns:
    `true` if this transition is an internal loopback or push transition and `false` otherwise.

### allNilEndStates

    protected boolean allNilEndStates(java.util.List<SmcGuard> guards)

  Returns `true` if each of the transition guards uses the nil end state.

  Parameters:
    `guards` - check if all this transitions use the nil end state.
  Returns:
    `true` if each of the transition guards uses the nil end state.

### setSource

    public void setSource(java.io.PrintStream source)

  Sets the source code output destination.

  Parameters:
    `source` - the generated source code output stream.

### escape

    public static java.lang.String escape(java.lang.String s)

  Place a backslash escape character in front of backslashes and doublequotes.

  Parameters:
    `s` - Escape this string.
  Returns:
    the backslash escaped string.

### scopeStateName

    protected java.lang.String scopeStateName(java.lang.String stateName,
                                              java.lang.String mapName)

Overview | Package | Class | Tree | Deprecated | Index | Help
| SMC 6_0_1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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