Generator base class for specifying core functionality that all code generators should have.
More...
Inherits AbstractLFValidator.
Inherited by org.lflang.analyses.uclid.UclidGenerator.
Generator base class for specifying core functionality that all code generators should have.
- Author
- Edward A. Lee
-
Marten Lohstroh
-
Christian Menard
-
Matt Weber
-
Soroush Bateni
◆ GeneratorBase()
◆ additionalPostProcessingForModes()
| void org.lflang.generator.GeneratorBase.additionalPostProcessingForModes |
( |
| ) |
|
|
protected |
Hook for additional post-processing of the model.
◆ buildUsingDocker()
| boolean org.lflang.generator.GeneratorBase.buildUsingDocker |
( |
| ) |
|
|
protected |
Create Dockerfiles and docker-compose.yml, build, and create a launcher.
◆ checkModalReactorSupport()
| void org.lflang.generator.GeneratorBase.checkModalReactorSupport |
( |
boolean | isSupported | ) |
|
|
protected |
Checks whether modal reactors are present and require appropriate code generation.
This will set the hasModalReactors variable.
- Parameters
-
| isSupported | indicates if modes are supported by this code generation. |
◆ checkWatchdogSupport()
| void org.lflang.generator.GeneratorBase.checkWatchdogSupport |
( |
boolean | isSupported | ) |
|
|
protected |
Check whether watchdogs are present and are supported.
- Parameters
-
| isSupported | indicates whether or not this is a supported target and whether or not it is a threaded runtime. |
◆ cleanIfNeeded()
Check if a clean was requested from the standalone compiler and perform the clean step.
◆ copyUserFiles()
Copy user specific files to the src-gen folder.
This should be overridden by the target generators.
- Parameters
-
| targetConfig | The targetConfig to read the files from. |
| fileConfig | The fileConfig used to make the copy and resolve paths. |
◆ createMainInstantiation()
| void org.lflang.generator.GeneratorBase.createMainInstantiation |
( |
| ) |
|
|
protected |
If there is a main or federated reactor, then create a synthetic Instantiation for that top-level reactor and set the field mainDef to refer to it.
◆ doGenerate()
| void org.lflang.generator.GeneratorBase.doGenerate |
( |
Resource | resource, |
|
|
LFGeneratorContext | context ) |
Generate code from the Lingua Franca model contained by the specified resource.
This is the main entry point for code generation. This base class finds all reactor class definitions, including any reactors defined in imported .lf files (except any main reactors in those imported files), and adds them to the reactors list. If errors occur during generation, then a subsequent call to errorsOccurred() will return true.
- Parameters
-
| resource | The resource containing the source code. |
| context | Context relating to invocation of the code generator. In standalone mode, this object is also used to relay CLI arguments. |
Reimplemented in org.lflang.analyses.uclid.UclidGenerator.
◆ errorsOccurred()
| boolean org.lflang.generator.GeneratorBase.errorsOccurred |
( |
| ) |
|
Return true if errors occurred in the last call to doGenerate().
This will return true if any of the reportError methods was called.
- Returns
- True if errors occurred.
◆ getCommandFactory()
◆ getConflictingConnectionsInModalReactorsBody()
| String org.lflang.generator.GeneratorBase.getConflictingConnectionsInModalReactorsBody |
( |
VarRef | source, |
|
|
VarRef | dest ) |
|
protected |
Return target code for forwarding reactions iff the connections have the same destination as other connections or reaction in mutually exclusive modes.
This method needs to be overridden in target specific code generators that support modal reactors.
◆ getDockerGenerator()
◆ getMainDef()
| Instantiation org.lflang.generator.GeneratorBase.getMainDef |
( |
| ) |
|
◆ getReactionBankIndex()
| int org.lflang.generator.GeneratorBase.getReactionBankIndex |
( |
Reaction | reaction | ) |
|
Return the reaction bank index.
- See also
- setReactionBankIndex
- Parameters
-
- Returns
- The reaction bank index, if one has been set, and -1 otherwise.
◆ getTarget()
| abstract Target org.lflang.generator.GeneratorBase.getTarget |
( |
| ) |
|
|
abstract |
◆ getTargetConfig()
| TargetConfig org.lflang.generator.GeneratorBase.getTargetConfig |
( |
| ) |
|
◆ getTargetTypes()
| abstract TargetTypes org.lflang.generator.GeneratorBase.getTargetTypes |
( |
| ) |
|
|
abstract |
◆ parseCommandOutput()
| ErrorFileAndLine org.lflang.generator.GeneratorBase.parseCommandOutput |
( |
String | line | ) |
|
|
protected |
Given a line of text from the output of a compiler, return an instance of ErrorFileAndLine if the line is recognized as the first line of an error message.
Otherwise, return null. This base class simply returns null.
- Parameters
-
| line | A line of output from a compiler or other external tool that might generate errors. |
- Returns
- If the line is recognized as the start of an error message, then return a class containing the path to the file on which the error occurred (or null if there is none), the line number (or the string "1" if there is none), the character position (or the string "0" if there is none), and the message (or an empty string if there is none).
◆ printInfo()
Print to stdout information about what source file is being generated, what mode the generator is in, and where the generated sources are to be put.
◆ registerTransformation()
| void org.lflang.generator.GeneratorBase.registerTransformation |
( |
AstTransformation | transformation | ) |
|
|
protected |
Register an AST transformation to be applied to the AST.
The transformations will be applied in the order that they are registered in.
◆ reportCommandErrors()
| void org.lflang.generator.GeneratorBase.reportCommandErrors |
( |
String | stderr | ) |
|
Parse the specified string for command errors that can be reported using marks in the Eclipse IDE.
In this class, we attempt to parse the messages to look for file and line information, thereby generating marks on the appropriate lines. This should not be called in standalone mode.
- Parameters
-
| stderr | The output on standard error of executing a command. |
◆ setReactionBankIndex()
| void org.lflang.generator.GeneratorBase.setReactionBankIndex |
( |
Reaction | reaction, |
|
|
int | bankIndex ) |
Mark the specified reaction to belong to only the specified bank index.
This is needed because reactions cannot declare a specific bank index as an effect or trigger. Reactions that send messages between federates, including absent messages, need to be specific to a bank member.
- Parameters
-
| reaction | The reaction. |
| bankIndex | The bank index, or -1 if there is no bank. |
◆ setReactorsAndInstantiationGraph()
Create a new instantiation graph.
This is a graph where each node is a Reactor (not a ReactorInstance) and an arc from Reactor A to Reactor B means that B contains an instance of A, constructed with a statement like a = new A(); After creating the graph, sort the reactors in topological order and assign them to the reactors class variable. Hence, after this method returns, this.reactors will be a list of Reactors such that any reactor is preceded in the list by reactors that it instantiates.
◆ commandFactory
A factory for compiler commands.
◆ context
◆ hasModalReactors
| boolean org.lflang.generator.GeneratorBase.hasModalReactors = false |
Indicates whether the current Lingua Franca program contains model reactors.
◆ hasWatchdogs
| boolean org.lflang.generator.GeneratorBase.hasWatchdogs = false |
Indicates whether the program has any watchdogs.
This is used to check for support.
◆ instantiationGraph
Graph that tracks dependencies between instantiations.
This is a graph where each node is a Reactor (not a ReactorInstance) and an arc from Reactor A to Reactor B means that B contains an instance of A, constructed with a statement like a = new A(); After creating the graph, sort the reactors in topological order and assign them to the reactors class variable. Hence, after this method returns, this.reactors will be a list of Reactors such that any reactor is preceded in the list by reactors that it instantiates.
◆ main
The main (top-level) reactor instance.
◆ mainDef
| Instantiation org.lflang.generator.GeneratorBase.mainDef |
|
protected |
Definition of the main (top-level) reactor.
This is an automatically generated AST node for the top-level reactor.
◆ messageReporter
An error reporter for reporting any errors or warnings during the code generation.
◆ reactionBankIndices
| Map<Reaction, Integer> org.lflang.generator.GeneratorBase.reactionBankIndices = null |
|
protected |
Map from reactions to bank indices.
◆ reactors
| List<Reactor> org.lflang.generator.GeneratorBase.reactors = new ArrayList<>() |
|
protected |
A list of Reactor definitions in the main resource, including non-main reactors defined in imported resources.
These are ordered in the list in such a way that each reactor is preceded by any reactor that it instantiates using a command like foo = new Foo();
◆ targetConfig
| final TargetConfig org.lflang.generator.GeneratorBase.targetConfig |
|
protected |
The current target configuration.
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/GeneratorBase.java