ptolemy.codegen.java.actor.lib
Class Expression

java.lang.Object
  extended by ptolemy.kernel.util.NamedObj
      extended by ptolemy.codegen.kernel.CodeGeneratorHelper
          extended by ptolemy.codegen.java.kernel.JavaCodeGeneratorHelper
              extended by ptolemy.codegen.java.actor.lib.Expression
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ActorCodeGenerator, ComponentCodeGenerator, Changeable, Debuggable, DebugListener, Derivable, ModelErrorHandler, MoMLExportable, Moveable, Nameable

public class Expression
extends JavaCodeGeneratorHelper

A code generation helper class for ptolemy.actor.lib.Expression.

Since:
Ptolemy II 8.0
Version:
$Id: Expression.java 57046 2010-01-27 23:35:53Z cxh $
Author:
Man-Kit Leung
See Also:
Serialized Form
Accepted Rating:
Red (mankit)
Proposed Rating:
Red (mankit) Needs 2nd pass for array children of different types

Nested Class Summary
protected static class Expression.VariableScope
          Variable scope class customized for the JavaParseTreeCodeGenerator.
 
Nested classes/interfaces inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper
CodeGeneratorHelper.Channel
 
Nested classes/interfaces inherited from class ptolemy.kernel.util.NamedObj
NamedObj.ContainedObjectsIterator
 
Field Summary
protected  JavaParseTreeCodeGenerator _javaParseTreeCodeGenerator
          The parse tree code generator.
 
Fields inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper
_codeGenerator, _codeStream, _eol, _INDENT1, _INDENT2, _parseTreeCodeGenerator, _portConversions, _referencedParameters
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _verbose, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Constructor Summary
Expression(Expression actor)
          Constructor method for the Expression helper.
 
Method Summary
protected  java.lang.String _generateFireCode()
          Generate fire code.
 java.lang.String generateInitializeCode()
          Generate initialize code.
 java.lang.String generatePreinitializeCode()
          Generate preinitialize code.
 java.lang.String generateWrapupCode()
          Generate wrap up code.
 java.util.Set getSharedCode()
          Get shared code.
 
Methods inherited from class ptolemy.codegen.java.kernel.JavaCodeGeneratorHelper
_generateInputVariableDeclaration, _generateOutputVariableDeclaration, _generateReferencedParameterDeclaration, _generateTypeConvertVariableDeclaration, _replaceMacro, generateVariableDeclaration, getCodeGenerator, getFunctionInvocation, getHeaderFiles, getJVMHeaderFiles, getNewInvocation, getParseTreeCodeGenerator, getReference
 
Methods inherited from class ptolemy.codegen.kernel.CodeGeneratorHelper
_createBufferSizeAndOffsetMap, _createInputBufferSizeAndOffsetMap, _findClosedParen, _generateBlockCode, _generateBlockCode, _generateTypeConvertMethod, _generateTypeConvertStatement, _generateTypeConvertStatements, _getCastType, _getChannelAndOffset, _getFireFunctionArguments, _getHelper, _getHelper, _getIndentPrefix, _getReference, _getReferenceChannels, _getTypeConvertChannels, _getTypeConvertReference, _indexOf, addFunctionUsed, addNewTypeUsed, analyzeTypeConvert, checkLocal, checkRemote, codeGenType, copyFilesToCodeDirectory, createOffsetVariablesIfNeeded, generateChannelOffset, generateFireCode, generateFireFunctionCode, generateFireFunctionCode2, generateModeTransitionCode, generateName, generateOffset, generatePortReference, generatePostfireCode, generatePrefireCode, generateSimpleName, generateTypeConvertFireCode, generateTypeConvertFireCode, generateVariableInitialization, generateVariableName, getBufferSize, getBufferSize, getComponent, getDefaultBlocks, getDirector, getDirectorHelper, getIncludeDirectories, getLibraries, getLibraryDirectories, getModifiedVariables, getObject, getParameterValue, getPort, getRates, getReadOffset, getReference, getReference, getReference, getSinkChannels, getSize, getSourceChannel, getWCET, getWriteOffset, isPrimitive, isPrimitive, parseList, processCode, resetInputPortsOffset, setBufferSize, setCodeGenerator, setReadOffset, setWriteOffset, targetType, toString
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _adjustOverride, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _description, _exportMoMLContents, _getContainedObject, _isMoMLSuppressed, _markContentsDerived, _propagateExistence, _propagateValue, _recordDecoratedAttributes, _removeAttribute, _splitName, _stripNumericSuffix, _validateSettables, addChangeListener, addDebugListener, attributeChanged, attributeList, attributeList, attributeTypeChanged, clone, clone, containedObjectsIterator, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, exportMoML, exportMoMLPlain, getAttribute, getAttribute, getAttributes, getChangeListeners, getClassName, getContainer, getDecoratorAttribute, getDecoratorAttributes, getDerivedLevel, getDerivedList, getDisplayName, getElementName, getFullName, getModelErrorHandler, getName, getName, getPrototypeList, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, lazyContainedObjectsIterator, message, moveDown, moveToFirst, moveToIndex, moveToLast, moveUp, propagateExistence, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setDisplayName, setModelErrorHandler, setName, setPersistent, setSource, sortContainedObjects, toplevel, uniqueName, validateSettables, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_javaParseTreeCodeGenerator

protected JavaParseTreeCodeGenerator _javaParseTreeCodeGenerator
The parse tree code generator.

Constructor Detail

Expression

public Expression(Expression actor)
Constructor method for the Expression helper.

Parameters:
actor - The associated actor.
Method Detail

_generateFireCode

protected java.lang.String _generateFireCode()
                                      throws IllegalActionException
Generate fire code. The method reads in fireBlock from Expression.c, replaces macros with their values and appends the processed code block to the given code buffer.

Overrides:
_generateFireCode in class CodeGeneratorHelper
Returns:
The generated code.
Throws:
IllegalActionException - If the code stream encounters an error in processing the specified code block(s).

generateInitializeCode

public java.lang.String generateInitializeCode()
                                        throws IllegalActionException
Generate initialize code. This method reads the initBlock from Expression.c, replaces macros with their values and returns the processed code string.

Specified by:
generateInitializeCode in interface ComponentCodeGenerator
Overrides:
generateInitializeCode in class CodeGeneratorHelper
Returns:
The processed code string.
Throws:
IllegalActionException - If the code stream encounters an error in processing the specified code block(s).

generatePreinitializeCode

public java.lang.String generatePreinitializeCode()
                                           throws IllegalActionException
Generate preinitialize code. This method reads the preinitBlock from Expression.c, replaces macros with their values and returns the processed code string.

Specified by:
generatePreinitializeCode in interface ActorCodeGenerator
Overrides:
generatePreinitializeCode in class CodeGeneratorHelper
Returns:
The processed code string.
Throws:
IllegalActionException - If the code stream encounters an error in processing the specified code block(s).

getSharedCode

public java.util.Set getSharedCode()
                            throws IllegalActionException
Get shared code. This method reads the sharedBlock from Expression.c, replaces macros with their values and returns the processed code string.

Specified by:
getSharedCode in interface ActorCodeGenerator
Overrides:
getSharedCode in class CodeGeneratorHelper
Returns:
A set of strings that are code shared by multiple instances of the same actor.
Throws:
IllegalActionException - If the code stream encounters an error in processing the specified code block(s).

generateWrapupCode

public java.lang.String generateWrapupCode()
                                    throws IllegalActionException
Generate wrap up code. This method reads the wrapupBlock from Expression.c, replaces macros with their values and appends the processed code block to the given code buffer.

Specified by:
generateWrapupCode in interface ComponentCodeGenerator
Overrides:
generateWrapupCode in class CodeGeneratorHelper
Returns:
The processed code string.
Throws:
IllegalActionException - If the code stream encounters an error in processing the specified code block(s).