![]() |
lingua-franca 0.10.1
Lingua Franca code generator
|
Representation of a compile-time instance of a reaction. More...
Inherits org.lflang.generator.NamedInstance< Reaction >.
Classes | |
| class | Runtime |
| Inner class representing a runtime instance of a reaction. More... | |
Public Member Functions | |
| void | clearCaches (boolean includingRuntimes) |
| Clear caches used in reporting dependentReactions() and dependsOnReactions(). | |
| Set< ReactionInstance > | dependentReactions () |
| Return the set of immediate downstream reactions, which are reactions that receive data produced by this reaction plus at most one reaction in the same reactor whose definition lexically follows this one. | |
| Set< ReactionInstance > | dependsOnReactions () |
| Return the set of immediate upstream reactions, which are reactions that send data to this one plus at most one reaction in the same reactor whose definition immediately precedes the definition of this one. | |
| ReactorInstance | getContainingEnclaveReactor () |
| Return the reactor that is the enclave in charge of this reaction. | |
| T | getDefinition () |
| Return the definition, which is the AST node for this object. | |
| int | getDepth () |
| Get the depth of the reactor instance. | |
| String | getFullName () |
| Return the full name of this instance, which has the form "a.b.c", where "c" is the name of this instance, "b" is the name of its container, and "a" is the name of its container, stopping at the container in main. | |
| String | getFullNameWithJoiner (String joiner) |
| Return a string of the form "a.b.c", where "." is replaced by the specified joiner, "c" is the name of this instance, "b" is the name of its container, and "a" is the name of its container, stopping at the container in main. | |
| Set< TimeValue > | getInferredDeadlines () |
| Return a set of deadlines that runtime instances of this reaction have. | |
| List< TimeValue > | getInferredDeadlinesList () |
| Return a list of the deadlines that runtime instances of this reaction have. | |
| Set< Integer > | getLevels () |
| Return a set of levels that runtime instances of this reaction have. | |
| List< Integer > | getLevelsList () |
| Return a list of levels that runtime instances of this reaction have. | |
| ModeInstance | getMode (boolean direct) |
| Returns the directly/indirectly enclosing mode. | |
| String | getName () |
| Return the name of this reaction. | |
| ReactorInstance | getParent () |
| Return the parent or null if this is a top-level reactor. | |
| List< Runtime > | getRuntimeInstances () |
| Return an array of runtime instances of this reaction in a natural order, defined as follows. | |
| int | getWidth () |
| Return the width of this instance, which in this base class is 1. | |
| boolean | hasParent (ReactorInstance container) |
| Return true if this instance has the specified parent (possibly indirectly, anywhere up the hierarchy). | |
| List< ReactorInstance > | parents () |
| Return a list of all the parents starting with the root(). | |
| ReactionInstance (Reaction definition, ReactorInstance parent, int index) | |
| Create a new reaction instance from the specified definition within the specified parent. | |
| ReactorInstance | root () |
| Return the root reactor, which is the top-level parent. | |
| void | setWidth (int width) |
| Set the width. | |
| String | toString () |
| Return a descriptive string. | |
| String | uniqueID () |
| Return an identifier for this instance, which has the form "a_b_c" or "a_b_c_n", where "c" is the name of this instance, "b" is the name of its container, and "a" is the name of its container, stopping at the container in main. | |
Public Attributes | |
| DeadlineInstance | declaredDeadline |
| Deadline for this reaction instance, if declared. | |
| Set< TriggerInstance<? extends Variable > > | effects = new LinkedHashSet<>() |
| The ports or actions that this reaction may write to. | |
| int | index |
| Index of order of occurrence within the reactor definition. | |
| Set< TriggerInstance<? extends Variable > > | reads = new LinkedHashSet<>() |
| The ports that this reaction reads but that do not trigger it. | |
| Set< TriggerInstance<? extends Variable > > | sources = new LinkedHashSet<>() |
| The ports, actions, or timers that this reaction is triggered by or uses. | |
| Set< TriggerInstance<? extends Variable > > | triggers = new LinkedHashSet<>() |
| The trigger instances (input ports, timers, and actions that trigger reactions) that trigger this reaction. | |
Static Public Attributes | |
| static int | identifierLengthLimit |
| A limit on the number of characters returned by uniqueID. | |
Protected Attributes | |
| int | depth |
| The depth in the hierarchy of this instance. | |
Package Attributes | |
| T | definition |
| The Instantiation AST object from which this was created. | |
| ReactorInstance | parent |
| The reactor instance that creates this instance. | |
| HashMap< String, Integer > | uniqueIDCount |
| Map from a name of the form a_b_c to the number of unique IDs with that prefix that have been already assigned. | |
| int | width |
| The width of this instance. | |
Representation of a compile-time instance of a reaction.
Like ReactorInstance, if one or more parents of this reaction is a bank of reactors, then there will be more than one runtime instance corresponding to this compile-time instance. The getRuntimeInstances() method returns a list of these runtime instances, each an instance of the inner class ReactionInstance.Runtime. Each runtime instance has a "level", which is its depth an acyclic precedence graph representing the dependencies between reactions at a tag.
| org.lflang.generator.ReactionInstance.ReactionInstance | ( | Reaction | definition, |
| ReactorInstance | parent, | ||
| int | index ) |
Create a new reaction instance from the specified definition within the specified parent.
This constructor should be called only by the ReactorInstance class, but it is public to enable unit tests.
| definition | A reaction definition. |
| parent | The parent reactor instance, which cannot be null. |
| index | The index of the reaction within the reactor (0 for the first reaction, 1 for the second, etc.). |
| void org.lflang.generator.ReactionInstance.clearCaches | ( | boolean | includingRuntimes | ) |
Clear caches used in reporting dependentReactions() and dependsOnReactions().
This method should be called if any changes are made to triggers, sources, or effects.
| includingRuntimes | If false, leave the runtime instances intact. This is useful for federated execution where levels are computed using the top-level connections, but then those connections are discarded. |
| Set< ReactionInstance > org.lflang.generator.ReactionInstance.dependentReactions | ( | ) |
Return the set of immediate downstream reactions, which are reactions that receive data produced by this reaction plus at most one reaction in the same reactor whose definition lexically follows this one.
| Set< ReactionInstance > org.lflang.generator.ReactionInstance.dependsOnReactions | ( | ) |
Return the set of immediate upstream reactions, which are reactions that send data to this one plus at most one reaction in the same reactor whose definition immediately precedes the definition of this one.
| ReactorInstance org.lflang.generator.ReactionInstance.getContainingEnclaveReactor | ( | ) |
Return the reactor that is the enclave in charge of this reaction.
If the containing reactor is an enclave connection reactor, then the enclave in charge of this reaction depends on which reaction this is. The first two reactions use the enclave of the destination reactor, while the last reaction uses the enclave of the source reactor.
|
inherited |
Return the definition, which is the AST node for this object.
|
inherited |
Get the depth of the reactor instance.
This is 0 for the main reactor, 1 for reactors immediately contained therein, etc.
|
inherited |
Return the full name of this instance, which has the form "a.b.c", where "c" is the name of this instance, "b" is the name of its container, and "a" is the name of its container, stopping at the container in main.
If any reactor in the hierarchy is in a bank of reactors then, it will appear as a[index]. Similarly, if c is a port in a multiport, it will appear as c[index].
|
inherited |
Return a string of the form "a.b.c", where "." is replaced by the specified joiner, "c" is the name of this instance, "b" is the name of its container, and "a" is the name of its container, stopping at the container in main.
| Set< TimeValue > org.lflang.generator.ReactionInstance.getInferredDeadlines | ( | ) |
Return a set of deadlines that runtime instances of this reaction have.
A ReactionInstance may have more than one deadline if it lies within a bank.
| List< TimeValue > org.lflang.generator.ReactionInstance.getInferredDeadlinesList | ( | ) |
Return a list of the deadlines that runtime instances of this reaction have.
The size of this list is the total number of runtime instances. A ReactionInstance may have more than one deadline if it lies within a bank.
| Set< Integer > org.lflang.generator.ReactionInstance.getLevels | ( | ) |
Return a set of levels that runtime instances of this reaction have.
A ReactionInstance may have more than one level if it lies within a bank and its dependencies on other reactions pass through multiports.
| List< Integer > org.lflang.generator.ReactionInstance.getLevelsList | ( | ) |
Return a list of levels that runtime instances of this reaction have.
The size of this list is the total number of runtime instances. A ReactionInstance may have more than one level if it lies within a bank and its dependencies on other reactions pass through multiports.
|
inherited |
Returns the directly/indirectly enclosing mode.
| direct | flag whether to check only for direct enclosing mode or also consider modes of parent reactor instances. |
| String org.lflang.generator.ReactionInstance.getName | ( | ) |
Return the name of this reaction.
If the reaction is not named, this returns 'reaction_n', where n is replaced by the reaction index + 1.
|
inherited |
Return the parent or null if this is a top-level reactor.
| List< Runtime > org.lflang.generator.ReactionInstance.getRuntimeInstances | ( | ) |
Return an array of runtime instances of this reaction in a natural order, defined as follows.
The position within the returned list of the runtime instance is given by a mixed-radix number where the low-order digit is the bank index within the container reactor (or 0 if it is not a bank), the second low order digit is the bank index of the container's container (or 0 if it is not a bank), etc., until the container that is directly contained by the top level (the top-level reactor need not be included because its index is always 0).
The size of the returned array is the product of the widths of all the container ReactorInstance objects. If none of these is a bank, then the size will be 1.
This method creates this array the first time it is called, but then holds on to it. The array is used by ReactionInstanceGraph to determine and record levels and deadline for runtime instances of reactors.
|
inherited |
Return the width of this instance, which in this base class is 1.
Subclasses PortInstance and ReactorInstance change this to the multiport and bank widths respectively.
|
inherited |
Return true if this instance has the specified parent (possibly indirectly, anywhere up the hierarchy).
|
inherited |
Return a list of all the parents starting with the root().
|
inherited |
Return the root reactor, which is the top-level parent.
|
inherited |
Set the width.
This method is here for testing only and should not be used for any other purpose.
| width | The new width. |
| String org.lflang.generator.ReactionInstance.toString | ( | ) |
Return a descriptive string.
|
inherited |
Return an identifier for this instance, which has the form "a_b_c" or "a_b_c_n", where "c" is the name of this instance, "b" is the name of its container, and "a" is the name of its container, stopping at the container in main.
All names are converted to lower case. The suffix n is usually omitted, but it is possible to get name collisions using the above scheme, in which case _n will be an increasing integer until there is no collision. If the length of the root of the name as calculated above (the root is without the _n suffix) is longer than the static variable identifierLengthLimit, then the name will be truncated. The returned name will be the tail of the name calculated above with the prefix ''.
| DeadlineInstance org.lflang.generator.ReactionInstance.declaredDeadline |
Deadline for this reaction instance, if declared.
|
packageinherited |
The Instantiation AST object from which this was created.
|
protectedinherited |
The depth in the hierarchy of this instance.
This is 0 for main or federated, 1 for the reactors immediately contained, etc.
| Set<TriggerInstance<? extends Variable> > org.lflang.generator.ReactionInstance.effects = new LinkedHashSet<>() |
The ports or actions that this reaction may write to.
|
staticinherited |
A limit on the number of characters returned by uniqueID.
| int org.lflang.generator.ReactionInstance.index |
Index of order of occurrence within the reactor definition.
The first reaction has index 0, the second index 1, etc.
|
packageinherited |
The reactor instance that creates this instance.
| Set<TriggerInstance<? extends Variable> > org.lflang.generator.ReactionInstance.reads = new LinkedHashSet<>() |
The ports that this reaction reads but that do not trigger it.
| Set<TriggerInstance<? extends Variable> > org.lflang.generator.ReactionInstance.sources = new LinkedHashSet<>() |
The ports, actions, or timers that this reaction is triggered by or uses.
| Set<TriggerInstance<? extends Variable> > org.lflang.generator.ReactionInstance.triggers = new LinkedHashSet<>() |
The trigger instances (input ports, timers, and actions that trigger reactions) that trigger this reaction.
|
packageinherited |
Map from a name of the form a_b_c to the number of unique IDs with that prefix that have been already assigned.
If none have been assigned, then there is no entry in this map. This map should be non-null only for the main reactor (the top level).
|
packageinherited |
The width of this instance.
This is 1 for everything except a PortInstance representing a multiport and a ReactorInstance representing a bank.