![]() |
lingua-franca 0.10.1
Lingua Franca code generator
|
A helper class for modifying and analyzing the AST. More...
Static Public Member Functions | |
| static void | addReactionAttribute (Reaction reaction, String name) |
| Add an attribute to the given reaction. | |
| static String | addZeroToLeadingDot (String literal) |
| If the given string can be recognized as a floating-point number that has a leading decimal point, prepend the string with a zero and return it. | |
| static List< Action > | allActions (Reactor definition) |
| Given a reactor class, return a list of all its actions, which includes actions of base classes that it extends. | |
| static List< Connection > | allConnections (Reactor definition) |
| Given a reactor class, return a list of all its connections, which includes connections of base classes that it extends. | |
| static< T extends EObject > Iterable< T > | allElementsOfClass (Resource resource, Class< T > elementClass) |
| static LinkedHashSet< Preamble > | allFileLevelPreambles (Reactor reactor) |
| Return all the file-level preambles in the files that define the specified class and its superclasses in deepest-first order. | |
| static List< Input > | allInputs (Reactor definition) |
| Given a reactor class, return a list of all its inputs, which includes inputs of base classes that it extends. | |
| static List< Instantiation > | allInstantiations (Reactor definition) |
| Given a reactor class, return a list of all its instantiations, which includes instantiations of base classes that it extends. | |
| static List< Method > | allMethods (Reactor definition) |
| Given a reactor class, return a list of all its methods, which includes methods of base classes that it extends. | |
| static List< Mode > | allModes (Reactor definition) |
| Given a reactor class, returns a list of all its modes, which includes modes of base classes that it extends. | |
| static Stream< Reactor > | allNestedClasses (Reactor definition) |
| static List< Output > | allOutputs (Reactor definition) |
| Given a reactor class, return a list of all its outputs, which includes outputs of base classes that it extends. | |
| static List< Parameter > | allParameters (Reactor definition) |
| Given a reactor class, return a list of all its parameters, which includes parameters of base classes that it extends. | |
| static List< Port > | allPorts (Reactor definition) |
| A list of all ports of definition, in an unspecified order. | |
| static List< Preamble > | allPreambles (Reactor definition) |
| Given a reactor class, return a list of all its preambles, which includes preambles of base classes that it extends. | |
| static List< Reaction > | allReactions (Reactor definition) |
| Given a reactor class, return a list of all its reactions, which includes reactions of base classes that it extends. | |
| static List< StateVar > | allStateVars (Reactor definition) |
| Given a reactor class, return a list of all its state variables, which includes state variables of base classes that it extends. | |
| static List< Timer > | allTimers (Reactor definition) |
| Given a reactor class, return a list of all its timers, which includes timers of base classes that it extends. | |
| static List< Watchdog > | allWatchdogs (Reactor definition) |
| Given a reactor class, return a list of all its watchdogs. | |
| static String | baseType (Type type) |
| Translate the given type into its textual representation, but do not append any array specifications or type arguments. | |
| static boolean | belongsTo (EObject eobject, Instantiation instantiation) |
| Return true if the specified object (a Parameter, Port, Action, or Timer) belongs to the specified instantiation, meaning that it is defined in the reactor class being instantiated or one of its base classes. | |
| static boolean | belongsTo (EObject eobject, Reactor reactor) |
| Return true if the specified object (a Parameter, Port, Action, or Timer) belongs to the specified reactor, meaning that it is defined in reactor class or one of its base classes. | |
| static boolean | changeTargetName (Resource resource, String newTargetName) |
| Change the target name to 'newTargetName'. | |
| static< T extends EObject > List< T > | collectElements (Reactor definition, EStructuralFeature feature) |
| Collect elements of type T from the class hierarchy and modes defined by a given reactor definition. | |
| static< T extends EObject > List< T > | collectElements (Reactor definition, EStructuralFeature feature, boolean includeSuperClasses, boolean includeModes) |
| Collect elements of type T contained in given reactor definition, including modes and the class hierarchy defined depending on configuration. | |
| static< T > List< T > | convertToEmptyListIfNull (List< T > list) |
| Returns the list if it is not null. | |
| static Instantiation | createInstantiation (Reactor reactor) |
| Create a new instantiation node with the given reactor as its defining class. | |
| static ReactorInstance | createMainReactorInstance (Instantiation mainDef, List< Reactor > reactors, MessageReporter messageReporter, TargetConfig targetConfig) |
| If a main or federated reactor has been declared, create a ReactorInstance for this top level. | |
| static List< String > | elementToListOfStrings (Element value) |
| Given the right-hand side of a target property, return a list with all the strings that the property lists. | |
| static String | elementToSingleString (Element e) |
| Given the right-hand side of a target property, return a string that represents the given value/. | |
| static Map< String, String > | elementToStringMaps (Element value) |
| Convert key-value pairs in an Element to a map, assuming that both the key and the value are strings. | |
| static Collection< Connection > | findConflictingConnectionsInModalReactors (Resource resource) |
| Find connections in the given resource that would be conflicting writes if they were not located in mutually exclusive modes. | |
| static Reactor | findMainReactor (Resource resource) |
| Return the main reactor in the given resource if there is one, null otherwise. | |
| static String | generateVarRef (VarRef reference) |
| Generate code for referencing a port, action, or timer. | |
| static List< Reactor > | getAllReactors (Resource resource) |
| Get all reactors defined in the given resource. | |
| static TimeValue | getDefaultAsTimeValue (Parameter p) |
| If the parameter is of time type, return its default value. | |
| static Long | getDelay (Expression delay) |
| Return the delay (in nanoseconds) denoted by delay, or null if the delay cannot be determined. | |
| static TimeValue | getDelayAsTimeValue (Expression delay) |
| Return the delay denoted by delay or null if the delay cannot be determined. | |
| static Set< Instantiation > | getEnclaves (Reactor top) |
| Return the set of enclave instantiations in the given reactor definition. | |
| static Reactor | getEnclosingReactor (EObject obj) |
| Return the enclosing reactor of an LF EObject in a reactor or mode. | |
| static Optional< Reactor > | getFederatedReactor (Resource resource) |
| Get the federated reactor defined in the given resource, if there is one. | |
| static InferredType | getInferredType (Action a) |
| Construct an inferred type from an "action" AST node based on its declared type. | |
| static InferredType | getInferredType (Parameter p) |
| Given a parameter, return an inferred type. | |
| static InferredType | getInferredType (Port p) |
| Construct an inferred type from a "port" AST node based on its declared type. | |
| static InferredType | getInferredType (StateVar s) |
| Given a state variable, return an inferred type. | |
| static InferredType | getInferredType (Type type, Initializer init) |
| Return the type of a declaration with the given (nullable) explicit type, and the given (nullable) initializer. | |
| static TimeValue | getLiteralTimeValue (Expression expr) |
| Assuming that the given expression denotes a valid time value, return a time value. | |
| static Optional< Reactor > | getMainReactor (Resource resource) |
| Get the main reactor defined in the given resource, if there is one. | |
| static Stream< INode > | getPrecedingCommentNodes (ICompositeNode compNode, Predicate< INode > filter) |
| Return all single-line or multi-line comments immediately preceding the given EObject. | |
| static Stream< String > | getPrecedingComments (ICompositeNode compNode, Predicate< INode > filter) |
| Return all single-line or multi-line comments immediately preceding the given EObject. | |
| static Target | getTarget (EObject object) |
| Return the target of the file in which the given node lives. | |
| static String | getUniqueIdentifier (Reactor reactor, String name) |
| Produce a unique identifier within a reactor based on a given based name. | |
| static boolean | hasMultipleConnections (Connection connection) |
| Return true if the connection involves multiple ports on the left or right side of the connection, or if the port on the left or right of the connection involves a bank of reactors or a multiport. | |
| static int | inferPortWidth (VarRef reference, Connection connection, List< Instantiation > instantiations) |
| Infer the width of a port reference in a connection. | |
| static Expression | initialValue (Parameter parameter, List< Instantiation > instantiations) |
| Given a parameter, return its initial value. | |
| static Integer | initialValueInt (Parameter parameter, List< Instantiation > instantiations) |
| Given a parameter return its integer value or null if it does not have an integer value. | |
| static boolean | isBigInteger (String literal) |
| Report whether the given string literal is an integer number or not. | |
| static boolean | isBoolean (String literal) |
| Report whether the given string literal is a boolean value or not. | |
| static boolean | isComment (INode node) |
| Return whether node is a comment. | |
| static boolean | isFloat (String literal) |
| Report whether the given string literal is a float value or not. | |
| static boolean | isGeneric (Reactor r) |
| Check if the reactor class uses generics. | |
| static boolean | isInCode (INode node) |
| static boolean | isInitialized (StateVar v) |
| Report whether a state variable has been initialized or not. | |
| static boolean | isInteger (String literal) |
| Report whether the given string literal is an integer number or not. | |
| static boolean | isMultilineComment (INode node) |
| Return whether node is a multiline comment. | |
| static boolean | isMultiport (Port port) |
| Return true if the specified port is a multiport. | |
| static boolean | isOfTimeType (Parameter param) |
| Return whether the given parameter is inferred to a time type. | |
| static boolean | isOfTimeType (StateVar state) |
| Return whether the given state variable is inferred to a time type. | |
| static boolean | isParameterized (StateVar s) |
| Report whether the given time state variable is initialized using a parameter or not. | |
| static boolean | isSingleLineComment (INode node) |
| Return whether node is a multiline comment. | |
| static boolean | isTopLevel (NamedInstance<?> instance) |
| Return true if the given instance is top-level, i.e., its parent is null. | |
| static boolean | isValidTime (Time t) |
| Report whether the given time denotes a valid time or not. | |
| static boolean | isZero (Expression expr) |
| Report whether the given expression is zero or not. | |
| static boolean | isZero (String literal) |
| Report whether the given literal is zero or not. | |
| static boolean | makeFederated (Resource resource) |
| Find the main reactor and change it to a federated reactor. | |
| static void | overrideParameter (ParameterInstance param, CodeExpr expr) |
| Override the parameter initializer with a code expression. | |
| static List< ReactorInstance > | recursiveChildren (ReactorInstance r) |
| static void | rerouteViaInstance (List< Pair< Connection, Instantiation > > conns) |
| Reroute the given connection to go through the given instantiation. | |
| static Predicate< INode > | sameLine (ICompositeNode compNode) |
| Return true if the given node starts on the same line as the given other node. | |
| static void | setMainName (Resource resource, String name) |
| Find the main reactor and set its name if none was defined. | |
| static LinkedHashSet< Reactor > | superClasses (Reactor reactor) |
| Return all the superclasses of the specified reactor in deepest-first order. | |
| static TargetDecl | targetDecl (Model model) |
| Returns the target declaration in the given model. | |
| static TargetDecl | targetDecl (Resource model) |
| Returns the target declaration in the given resource. | |
| static boolean | toBoolean (Element e) |
| Return a boolean based on the given element. | |
| static Reactor | toDefinition (ReactorDecl r) |
| If the specified reactor declaration is an import, then return the imported reactor class definition. | |
| static Element | toElement (boolean val) |
| static Element | toElement (int val) |
| static Element | toElement (List< String > list) |
| Given a list of strings, convert it into its AST representation. | |
| static Element | toElement (Map< String, String > map) |
| Convert a <String, String> map to key-value pairs in an Element. | |
| static Element | toElement (String str) |
| Given a single string, convert it into its AST representation. | |
| static Element | toElement (TimeValue tv) |
| Convert a TimeValue to its AST representation. | |
| static Integer | toInteger (Element e) |
| Return an integer representation of the given element. | |
| static String | toOriginalText (EObject node) |
| Translate the given code into its textual representation without CodeMap.Correspondence tags, or return the empty string if node is null. | |
| static String | toText (EObject node) |
| Translate the given code into its textual representation with CodeMap.Correspondence tags inserted, or return the empty string if node is null. | |
| static TimeValue | toTimeValue (Element e) |
| Return a time value based on the given element. | |
| static TimeValue | toTimeValue (Time e) |
| Returns the time value represented by the given AST node. | |
| static int | width (WidthSpec spec, List< Instantiation > instantiations) |
| Given the width specification of port or instantiation and an (optional) list of nested instantiations, return the width if it can be determined and -1 if not. | |
| static int | widthSpecification (Instantiation instantiation) |
| Given an instantiation of a reactor or bank of reactors, return the width. | |
Static Public Attributes | |
| static final LfFactory | factory = LfFactory.eINSTANCE |
| The Lingua Franca factory for creating new AST nodes. | |
| static final LfPackage | featurePackage = LfPackage.eINSTANCE |
| The Lingua Franca feature package. | |
A helper class for modifying and analyzing the AST.
|
static |
Add an attribute to the given reaction.
| reaction | The reaction to add the attribute to. |
| name | The name of the attribute to add. |
|
static |
If the given string can be recognized as a floating-point number that has a leading decimal point, prepend the string with a zero and return it.
Otherwise, return the original string.
| literal | A string might be recognizable as a floating point number with a leading decimal point. |
literal
|
static |
Given a reactor class, return a list of all its actions, which includes actions of base classes that it extends.
This also includes actions in modes, returning a flattened view over all modes.
| definition | Reactor class definition. |
|
static |
Given a reactor class, return a list of all its connections, which includes connections of base classes that it extends.
This also includes connections in modes, returning a flattened view over all modes.
| definition | Reactor class definition. |
|
static |
|
static |
Return all the file-level preambles in the files that define the specified class and its superclasses in deepest-first order.
Duplicates are removed. If there are no file-level preambles, then return an empty list. If a cycle is found, where X extends Y and Y extends X, or if a superclass is declared that is not found, then return null.
| reactor | The specified reactor. |
|
static |
Given a reactor class, return a list of all its inputs, which includes inputs of base classes that it extends.
If the base classes include a cycle, where X extends Y and Y extends X, then return only the input defined in the base class. The returned list may be empty.
| definition | Reactor class definition. |
|
static |
Given a reactor class, return a list of all its instantiations, which includes instantiations of base classes that it extends.
This also includes instantiations in modes, returning a flattened view over all modes.
| definition | Reactor class definition. |
|
static |
Given a reactor class, return a list of all its methods, which includes methods of base classes that it extends.
| definition | Reactor class definition. |
|
static |
Given a reactor class, returns a list of all its modes, which includes modes of base classes that it extends.
| definition | Reactor class definition. |
|
static |
|
static |
Given a reactor class, return a list of all its outputs, which includes outputs of base classes that it extends.
| definition | Reactor class definition. |
|
static |
Given a reactor class, return a list of all its parameters, which includes parameters of base classes that it extends.
| definition | Reactor class definition. |
|
static |
A list of all ports of definition, in an unspecified order.
|
static |
Given a reactor class, return a list of all its preambles, which includes preambles of base classes that it extends.
If the base classes include a cycle, where X extends Y and Y extends X, then return only the input defined in the base class. The returned list may be empty.
| definition | Reactor class definition. |
|
static |
Given a reactor class, return a list of all its reactions, which includes reactions of base classes that it extends.
This also includes reactions in modes, returning a flattened view over all modes.
| definition | Reactor class definition. |
|
static |
Given a reactor class, return a list of all its state variables, which includes state variables of base classes that it extends.
This also includes reactions in modes, returning a flattened view over all modes.
| definition | Reactor class definition. |
|
static |
Given a reactor class, return a list of all its timers, which includes timers of base classes that it extends.
This also includes reactions in modes, returning a flattened view over all modes.
| definition | Reactor class definition. |
|
static |
Given a reactor class, return a list of all its watchdogs.
| definition | Reactor class definition |
|
static |
Translate the given type into its textual representation, but do not append any array specifications or type arguments.
| type | AST node to render as string. |
|
static |
Return true if the specified object (a Parameter, Port, Action, or Timer) belongs to the specified instantiation, meaning that it is defined in the reactor class being instantiated or one of its base classes.
| eobject | The object. |
| instantiation | The instantiation. |
|
static |
Return true if the specified object (a Parameter, Port, Action, or Timer) belongs to the specified reactor, meaning that it is defined in reactor class or one of its base classes.
| eobject | The object. |
| reactor | The reactor. |
|
static |
Change the target name to 'newTargetName'.
For example, change C to CCpp.
|
static |
Collect elements of type T from the class hierarchy and modes defined by a given reactor definition.
| definition | The reactor definition. |
| feature | The structural feature to collect. |
| <T> | The type of elements to collect (e.g., Port, Timer, etc.) |
|
static |
Collect elements of type T contained in given reactor definition, including modes and the class hierarchy defined depending on configuration.
| definition | The reactor definition. |
| feature | The structual model elements to collect. |
| includeSuperClasses | Whether to include elements in super classes. |
| includeModes | Whether to include elements in modes. |
| <T> | The type of elements to collect (e.g., Port, Timer, etc.) |
|
static |
Returns the list if it is not null.
Otherwise, return an empty list.
|
static |
Create a new instantiation node with the given reactor as its defining class.
| reactor | The reactor class to create an instantiation of. |
|
static |
If a main or federated reactor has been declared, create a ReactorInstance for this top level.
This will also assign levels to reactions, then, if the program is federated, perform an AST transformation to disconnect connections between federates.
|
static |
Given the right-hand side of a target property, return a list with all the strings that the property lists.
Arrays are traversed, so strings are collected recursively. Empty strings are ignored; they are not added to the list.
| value | The right-hand side of a target property. |
|
static |
Given the right-hand side of a target property, return a string that represents the given value/.
If the given value is not a literal or and id (but for instance and array or dict), an empty string is returned. If the element is a string, any quotes are removed.
| e | The right-hand side of a target property. |
|
static |
Convert key-value pairs in an Element to a map, assuming that both the key and the value are strings.
|
static |
Find connections in the given resource that would be conflicting writes if they were not located in mutually exclusive modes.
| resource | The AST. |
|
static |
Return the main reactor in the given resource if there is one, null otherwise.
|
static |
Generate code for referencing a port, action, or timer.
| reference | The reference to the variable. |
|
static |
Get all reactors defined in the given resource.
| resource | the resource to extract reactors from |
|
static |
If the parameter is of time type, return its default value.
Otherwise, return null.
|
static |
Return the delay (in nanoseconds) denoted by delay, or null if the delay cannot be determined.
| delay | The delay to get the time value from. |
|
static |
Return the delay denoted by delay or null if the delay cannot be determined.
| delay | The delay to get the time value from. |
|
static |
Return the set of enclave instantiations in the given reactor definition.
| top | The reactor definition to search in. |
|
static |
Return the enclosing reactor of an LF EObject in a reactor or mode.
| obj | the LF model element |
|
static |
Get the federated reactor defined in the given resource, if there is one.
| resource | the resource to extract reactors from |
|
static |
Construct an inferred type from an "action" AST node based on its declared type.
If no type is declared, return the "undefined" type.
| a | An action to construct an inferred type object for. |
|
static |
Given a parameter, return an inferred type.
Only two types can be inferred: "time" and "timeList". Return the "undefined" type if neither can be inferred.
| p | A parameter to infer the type of. |
|
static |
Construct an inferred type from a "port" AST node based on its declared type.
If no type is declared, return the "undefined" type.
| p | A port to construct an inferred type object for. |
|
static |
Given a state variable, return an inferred type.
Only two types can be inferred: "time" and "timeList". Return the "undefined" type if neither can be inferred.
| s | A state variable to infer the type of. |
|
static |
Return the type of a declaration with the given (nullable) explicit type, and the given (nullable) initializer.
If the explicit type is null, then the type is inferred from the initializer. Only two types can be inferred: "time" and "timeList". Return the "undefined" type if neither can be inferred.
| type | Explicit type declared on the declaration |
| init | The initializer expression |
|
static |
Assuming that the given expression denotes a valid time value, return a time value.
| expr | The expression to inspect. |
|
static |
Get the main reactor defined in the given resource, if there is one.
| resource | the resource to extract reactors from |
|
static |
Return all single-line or multi-line comments immediately preceding the given EObject.
|
static |
Return all single-line or multi-line comments immediately preceding the given EObject.
|
static |
Return the target of the file in which the given node lives.
|
static |
Produce a unique identifier within a reactor based on a given based name.
If the name has not been used before, it is returned; if has been used, an index is appended that makes the name unique.
| reactor | The reactor to find a unique identifier within. |
| name | The name to base the returned identifier on. |
|
static |
Return true if the connection involves multiple ports on the left or right side of the connection, or if the port on the left or right of the connection involves a bank of reactors or a multiport.
| connection | The connection. |
|
static |
Infer the width of a port reference in a connection.
The port reference one or two parts, a port and an (optional) container which is an Instantiation that may refer to a bank of reactors. The width will be the product of the bank width and the port width. The returned value will be 1 if the port is not in a bank and is not a multiport.
If the width cannot be determined, this will return -1. The width cannot be determined if the list of instantiations is missing or incomplete.
The instantiations list is as in initialValue. The first element on this list should be the instantiation that contains the specified connection.
| reference | A port reference. |
| connection | A connection, or null if not in the context of a connection. |
| instantiations | The (optional) list of instantiations. |
| IllegalArgumentException | If an instantiation provided is not as given above or if the chain of instantiations is not nested. |
|
static |
Given a parameter, return its initial value.
If the instantiations argument is null or an empty list, then the value returned is simply the default value given when the parameter is defined.
If a list of instantiations is given, then the first instantiation is required to be an instantiation of the reactor class that is parameterized by the parameter. I.e.,
parameter.eContainer == instantiations.get(0).reactorClass
If a second instantiation is given, then it is required to be an instantiation of a reactor class that contains the first instantiation. That is,
instantiations.get(0).eContainer == instantiations.get(1).reactorClass
More generally, for all 0 <= i < instantiations.size - 1,
instantiations.get(i).eContainer == instantiations.get(i + 1).reactorClass
If any of these conditions is not satisfied, then an IllegalArgumentException will be thrown.
Note that this chain of reactions cannot be inferred from the parameter because in each of the predicates above, there may be more than one instantiation that can appear on the right hand side of the predicate.
For example, consider the following program:
reactor A(x:int(1)) {}
reactor B(y:int(2)) {
a1 = new A(x = y);
a2 = new A(x = -1);
}
reactor C(z:int(3)) {
b1 = new B(y = z);
b2 = new B(y = -2);
}
Notice that there are a total of four instances of reactor class A. Then
initialValue(x, null) returns 1
initialValue(x, [a1]) returns 2
initialValue(x, [a2]) returns -1
initialValue(x, [a1, b1]) returns 3
initialValue(x, [a2, b1]) returns -1
initialValue(x, [a1, b2]) returns -2
initialValue(x, [a2, b2]) returns -1
(Actually, in each of the above cases, the returned value is a list with one entry, a Literal, e.g. ["1"]).
There are two instances of reactor class B.
initialValue(y, null) returns 2
initialValue(y, [a1]) throws an IllegalArgumentException
initialValue(y, [b1]) returns 3
initialValue(y, [b2]) returns -2
| parameter | The parameter. |
| instantiations | The (optional) list of instantiations. |
| IllegalArgumentException | If an instantiation provided is not an instantiation of the reactor class that is parameterized by the respective parameter or if the chain of instantiations is not nested. |
|
static |
Given a parameter return its integer value or null if it does not have an integer value.
If the value of the parameter is a list of integers, return the sum of value in the list. The instantiations parameter is as in initialValue.
| parameter | The parameter. |
| instantiations | The (optional) list of instantiations. |
| IllegalArgumentException | If an instantiation provided is not an instantiation of the reactor class that is parameterized by the respective parameter or if the chain of instantiations is not nested. |
|
static |
Report whether the given string literal is an integer number or not.
| literal | AST node to inspect. |
|
static |
Report whether the given string literal is a boolean value or not.
| literal | AST node to inspect. |
|
static |
Return whether node is a comment.
|
static |
Report whether the given string literal is a float value or not.
| literal | AST node to inspect. |
|
static |
Check if the reactor class uses generics.
| r | the reactor to check |
|
static |
|
static |
Report whether a state variable has been initialized or not.
| v | The state variable to be checked. |
|
static |
Report whether the given string literal is an integer number or not.
| literal | AST node to inspect. |
|
static |
Return whether node is a multiline comment.
|
static |
Return true if the specified port is a multiport.
| port | The port. |
|
static |
Return whether the given parameter is inferred to a time type.
|
static |
Return whether the given state variable is inferred to a time type.
|
static |
Report whether the given time state variable is initialized using a parameter or not.
| s | A state variable. |
|
static |
Return whether node is a multiline comment.
|
static |
Return true if the given instance is top-level, i.e., its parent is null.
| instance | The instance to check. |
|
static |
Report whether the given time denotes a valid time or not.
| t | AST node to inspect. |
|
static |
Report whether the given expression is zero or not.
| expr | AST node to inspect. |
|
static |
Report whether the given literal is zero or not.
| literal | AST node to inspect. |
|
static |
Find the main reactor and change it to a federated reactor.
Return true if the transformation was successful (or the given resource already had a federated reactor); return false otherwise.
|
static |
Override the parameter initializer with a code expression.
| param | The parameter to override. |
| expr | The code expression to use as the initializer. |
|
static |
|
static |
Reroute the given connection to go through the given instantiation.
For each given pair of a connection and a newly created instantiation, create two connections to reroute specified connection to instead go through the specified instantiation. This is used when code-generating after-delay reactors and enclave connections. This assumes that the specified instantiation has at least one input port and at least one output port and uses the first of such ports. The old connection is removed.
If a connection is iterated, then the downstream new connection is iterated as well.
| conns | The list of pairs to reroute. |
|
static |
Return true if the given node starts on the same line as the given other node.
|
static |
Find the main reactor and set its name if none was defined.
| resource | The resource to find the main reactor in. |
| name | The name to set for the main reactor. |
|
static |
Return all the superclasses of the specified reactor in deepest-first order.
For example, if A extends B and C, and B and C both extend D, this will return the list [D, B, C, A]. Duplicates are removed. If the specified reactor does not extend any other reactor, then return an empty list. If a cycle is found, where X extends Y and Y extends X, or if a superclass is declared that is not found, then return null.
| reactor | The specified reactor. |
|
static |
Returns the target declaration in the given model.
Non-null because it would cause a parse error.
|
static |
Returns the target declaration in the given resource.
Non-null because it would cause a parse error.
|
static |
Return a boolean based on the given element.
| e | The element to be rendered as a boolean. |
|
static |
If the specified reactor declaration is an import, then return the imported reactor class definition.
Otherwise, just return the argument.
| r | A Reactor or an ImportedReactor. |
|
static |
|
static |
|
static |
Given a list of strings, convert it into its AST representation.
Stores the list in the Array field of the element, unless the list only has one string, in which case it is stored in the Literal field. Returns null if the provided list is empty.
|
static |
Convert a <String, String> map to key-value pairs in an Element.
|
static |
Given a single string, convert it into its AST representation.
|
static |
Convert a TimeValue to its AST representation.
The value is type-cast to int in order to fit inside an Element.
|
static |
Return an integer representation of the given element.
Internally, this method uses Integer.decode, so it will also understand hexadecimal, binary, etc.
| e | The element to be rendered as an integer. |
|
static |
Translate the given code into its textual representation without CodeMap.Correspondence tags, or return the empty string if node is null.
This method should be used for analyzing AST nodes in cases where they are easiest to analyze as strings.
| node | AST node to render as string. |
|
static |
Translate the given code into its textual representation with CodeMap.Correspondence tags inserted, or return the empty string if node is null.
This method should be used to generate code.
| node | AST node to render as string. |
|
static |
Return a time value based on the given element.
| e | The element to be rendered as a time value. |
|
static |
Returns the time value represented by the given AST node.
|
static |
Given the width specification of port or instantiation and an (optional) list of nested instantiations, return the width if it can be determined and -1 if not.
This will not be able to be determined if either the width is variable (in which case you should use inferPortWidth ) or the list of instantiations is incomplete or missing. If there are parameter references in the width, they are evaluated to the extent possible given the instantiations list.
The instantiations list is as in initialValue. If the spec belongs to an instantiation (for a bank of reactors), then the first element on this list should be the instantiation that contains this instantiation. If the spec belongs to a port, then the first element on the list should be the instantiation of the reactor that contains the port.
| spec | The width specification or null (to return 1). |
| instantiations | The (optional) list of instantiations. |
| IllegalArgumentException | If an instantiation provided is not as given above or if the chain of instantiations is not nested. |
|
static |
Given an instantiation of a reactor or bank of reactors, return the width.
This will be 1 if this is not a reactor bank. Otherwise, this will attempt to determine the width. If the width is declared as a literal constant, it will return that constant. If the width is specified as a reference to a parameter, this will throw an exception. If the width is variable, this will find connections in the enclosing reactor and attempt to infer the width. If the width cannot be determined, it will throw an exception.
IMPORTANT: This method should not be used you really need to determine the width! It will not evaluate parameter values.
| instantiation | A reactor instantiation. |
|
static |
The Lingua Franca factory for creating new AST nodes.
|
static |
The Lingua Franca feature package.