lingua-franca 0.10.1
Lingua Franca code generator
Loading...
Searching...
No Matches
org.lflang.generator.python.PythonPortGenerator Class Reference

Generate Python code for ports. More...

Static Public Member Functions

static void generateActionVariableToSendToPythonReaction (List< String > pyObjects, Action action, ReactorDecl decl)
 Generate code to convert C actions to Python action capsules.
static String generateAliasTypeDef (TypeParameterizedReactor tpr, Port port, boolean isTokenType, String genericPortType)
static void generateInputVariablesToSendToPythonReaction (List< String > pyObjects, Input input, ReactorDecl decl)
 Generate into the specified string builder the code to send local variables for input ports to a Python reaction function from the "self" struct.
static void generateOutputVariablesToSendToPythonReaction (List< String > pyObjects, Output output)
 Generate into the specified string builder the code to send local variables for output ports to a Python reaction function from the "self" struct.
static String generatePortVariablesToSendToPythonReaction (List< String > pyObjects, VarRef port, ReactorDecl decl)
 Generate code to convert C ports to Python ports capsules (.
static String generatePythonListForContainedBank (String reactorName, Port port, String widthSpec)
 Generate code that creates a Python list (i.e., []) for contained banks to be passed to Python reactions.
static String generatePythonPortVariableInReaction (VarRef port)
 Generate into the specified string builder (inits) the code to initialize local variable for port so that it can be used in the body of the Python reaction.
static String generateVariablesForSendingToContainedReactors (List< String > pyObjects, Instantiation definition, Port port)
 Generate into the specified string builder the code to pass local variables for sending data to an input of a contained reaction (e.g.

Static Public Attributes

static final String NONMULTIPORT_WIDTHSPEC = "-2"

Detailed Description

Generate Python code for ports.

Member Function Documentation

◆ generateActionVariableToSendToPythonReaction()

void org.lflang.generator.python.PythonPortGenerator.generateActionVariableToSendToPythonReaction ( List< String > pyObjects,
Action action,
ReactorDecl decl )
static

Generate code to convert C actions to Python action capsules.

See pythontarget.h for details.

Parameters
pyObjectsA string containing a list of comma-separated expressions that will create the action capsules.
actionThe action itself.
declThe reactor decl that contains the action.

◆ generateAliasTypeDef()

String org.lflang.generator.python.PythonPortGenerator.generateAliasTypeDef ( TypeParameterizedReactor tpr,
Port port,
boolean isTokenType,
String genericPortType )
static

◆ generateInputVariablesToSendToPythonReaction()

void org.lflang.generator.python.PythonPortGenerator.generateInputVariablesToSendToPythonReaction ( List< String > pyObjects,
Input input,
ReactorDecl decl )
static

Generate into the specified string builder the code to send local variables for input ports to a Python reaction function from the "self" struct.

Parameters
pyObjectsThe list of Python object references.
inputThe input port.
declThe reactor declaration.

◆ generateOutputVariablesToSendToPythonReaction()

void org.lflang.generator.python.PythonPortGenerator.generateOutputVariablesToSendToPythonReaction ( List< String > pyObjects,
Output output )
static

Generate into the specified string builder the code to send local variables for output ports to a Python reaction function from the "self" struct.

Parameters
pyObjectsThe list of Python object references.
outputThe output port.

◆ generatePortVariablesToSendToPythonReaction()

String org.lflang.generator.python.PythonPortGenerator.generatePortVariablesToSendToPythonReaction ( List< String > pyObjects,
VarRef port,
ReactorDecl decl )
static

Generate code to convert C ports to Python ports capsules (.

See also
pythontarget.h).

The port may be an input of the reactor or an output of a contained reactor.

Parameters
pyObjectsA string containing a list of comma-separated expressions that will create the port capsules.
portThe port itself.
declThe reactor decl that contains the port.

◆ generatePythonListForContainedBank()

String org.lflang.generator.python.PythonPortGenerator.generatePythonListForContainedBank ( String reactorName,
Port port,
String widthSpec )
static

Generate code that creates a Python list (i.e., []) for contained banks to be passed to Python reactions.

The Python reaction will then subsequently be able to address each individual bank member of the contained bank using an index or an iterator. Each list member will contain the given port (which could be a multiport with a width determined by widthSpec).

This is to accommodate reactions like reaction() -> s.out where s is a bank. In this example, the generated Python function will have the signature reaction_function_0(self, s_out), where s_out is a list of out ports. This will later be turned into the proper s.out format using the Python code generated in generatePythonPortVariableInReaction.

Parameters
reactorNameThe name of the bank of reactors (which is the name of the reactor class).
portThe port that should be put in the Python list.
widthSpecA string that should be -2 for non-multiports and the width expression for multiports.

◆ generatePythonPortVariableInReaction()

String org.lflang.generator.python.PythonPortGenerator.generatePythonPortVariableInReaction ( VarRef port)
static

Generate into the specified string builder (inits) the code to initialize local variable for port so that it can be used in the body of the Python reaction.

Parameters
portThe port to generate code for.

◆ generateVariablesForSendingToContainedReactors()

String org.lflang.generator.python.PythonPortGenerator.generateVariablesForSendingToContainedReactors ( List< String > pyObjects,
Instantiation definition,
Port port )
static

Generate into the specified string builder the code to pass local variables for sending data to an input of a contained reaction (e.g.

for a deadline violation).

Parameters
pyObjectsThe list of Python object references.
definitionAST node defining the reactor within which this occurs
portInput of the contained reactor.

Member Data Documentation

◆ NONMULTIPORT_WIDTHSPEC

final String org.lflang.generator.python.PythonPortGenerator.NONMULTIPORT_WIDTHSPEC = "-2"
static

The documentation for this class was generated from the following file:
  • /Users/runner/work/lingua-franca/lingua-franca/core/src/main/java/org/lflang/generator/python/PythonPortGenerator.java