Class CTemplateParser
- java.lang.Object
 - 
- ptolemy.cg.kernel.generic.program.TemplateParser
 - 
- ptolemy.cg.kernel.generic.program.procedural.ProceduralTemplateParser
 - 
- ptolemy.cg.kernel.generic.program.procedural.c.CTemplateParser
 
 
 
 
- 
public class CTemplateParser extends ProceduralTemplateParser
A class that allows to parse macros of templates in a code generator perspective.- Since:
 - Ptolemy II 10.0
 - Version:
 - $Id$
 - Author:
 - Bert Rodiers
 - Pt.AcceptedRating:
 - Red (rodiers)
 - Pt.ProposedRating:
 - Red (rodiers)
 
 
- 
- 
Field Summary
- 
Fields inherited from class ptolemy.cg.kernel.generic.program.procedural.ProceduralTemplateParser
_includeFiles 
- 
Fields inherited from class ptolemy.cg.kernel.generic.program.TemplateParser
_codeGenerator, _component, _parseTreeCodeGenerator 
 - 
 
- 
Constructor Summary
Constructors Constructor Description CTemplateParser()Construct the CTemplateParser associated with the given component and the given adapter. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected CCodeGenerator_getCodeGenerator()Get the code generator associated with this adapter class.protected java.lang.String_replaceMacro(java.lang.String macro, java.lang.String parameter)Return the replacement string of the given macro.java.lang.StringgenerateTypeConvertStatement(ProgramCodeGeneratorAdapter.Channel source, ProgramCodeGeneratorAdapter.Channel sink, int offset, java.lang.String alternativeSourceRef)Generate the type conversion statement for the particular offset of the two given channels.java.lang.StringgetFunctionInvocation(java.lang.String functionString, boolean isStatic)Return the translated token instance function invocation string.ParseTreeCodeGeneratorgetParseTreeCodeGenerator()Return a new parse tree code generator to use with expressions.- 
Methods inherited from class ptolemy.cg.kernel.generic.program.procedural.ProceduralTemplateParser
generateFireCode, getHeaderFiles, init 
- 
Methods inherited from class ptolemy.cg.kernel.generic.program.TemplateParser
_findClosedParen, addFunctionUsed, addNewTypesUsed, escapeName, escapePortName, generateBlockCode, generateTypeConvertMethod, getCodeStream, getNewInvocation, getParameterValue, getPort, getSize, indexOf, parseList, processCode, setCodeGenerator, unescapeName, unescapePortName 
 - 
 
 - 
 
- 
- 
Method Detail
- 
generateTypeConvertStatement
public java.lang.String generateTypeConvertStatement(ProgramCodeGeneratorAdapter.Channel source, ProgramCodeGeneratorAdapter.Channel sink, int offset, java.lang.String alternativeSourceRef) throws IllegalActionException
Generate the type conversion statement for the particular offset of the two given channels. This assumes that the offset is the same for both channel. Advancing the offset of one has to advance the offset of the other.- Overrides:
 generateTypeConvertStatementin classTemplateParser- Parameters:
 source- The given source channel.sink- The given sink channel.offset- The given offset.alternativeSourceRef- The alternative source reference for the port. If alternativeSourceRef is null, then the adapter for the port of the source channel is used.z- Returns:
 - The type convert statement for assigning the converted source variable to the sink variable with the given offset.
 - Throws:
 IllegalActionException- If there is a problem getting the adapters for the ports or if the conversion cannot be handled.
 
- 
getFunctionInvocation
public java.lang.String getFunctionInvocation(java.lang.String functionString, boolean isStatic) throws IllegalActionExceptionReturn the translated token instance function invocation string.- Overrides:
 getFunctionInvocationin classTemplateParser- Parameters:
 functionString- The string within the $tokenFunc() macro.isStatic- True if the method is static.- Returns:
 - The translated type function invocation string.
 - Throws:
 IllegalActionException- The given function string is not well-formed.
 
- 
getParseTreeCodeGenerator
public ParseTreeCodeGenerator getParseTreeCodeGenerator()
Return a new parse tree code generator to use with expressions.- Overrides:
 getParseTreeCodeGeneratorin classProceduralTemplateParser- Returns:
 - the parse tree code generator to use with expressions.
 
 
- 
_getCodeGenerator
protected CCodeGenerator _getCodeGenerator()
Get the code generator associated with this adapter class.- Overrides:
 _getCodeGeneratorin classTemplateParser- Returns:
 - The code generator associated with this adapter class.
 - See Also:
 TemplateParser.setCodeGenerator(ProgramCodeGenerator)
 
- 
_replaceMacro
protected java.lang.String _replaceMacro(java.lang.String macro, java.lang.String parameter) throws IllegalActionExceptionReturn the replacement string of the given macro. Subclass of GenericCodeGenerator may overriding this method to extend or support a different set of macros.- Overrides:
 _replaceMacroin classTemplateParser- Parameters:
 macro- The given macro.parameter- The given parameter to the macro.- Returns:
 - The replacement string of the given macro.
 - Throws:
 IllegalActionException- Thrown if the given macro or parameter is not valid.
 
 - 
 
 -