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

A class for keeping the current target configuration. More...

Inherited by org.lflang.federated.generator.FederateTargetConfig.

Public Member Functions

TargetDecl extractTargetDecl ()
 Construct a TargetDecl by extracting the fields of the given TargetConfig.
Optional< TargetProperty<?, ?> > forName (String name)
 Return the target property in this target config that matches the given string.
List< TargetProperty<?, ?> > getAssignedProperties ()
 Return the target properties that have been assigned a value.
Resource getMainResource ()
 Get the main resource that is under compilation.
List< TargetProperty<?, ?> > getRegisteredProperties ()
 Return the target properties that are currently registered.
boolean isFederated ()
 Return whether this configuration is used in the context of a federated program.
boolean isSet (TargetProperty<?, ?> property)
 Return true if this target property has been set (past initialization), false otherwise.
boolean isSupported (TargetProperty p)
 Return true if the given target property is supported, false otherwise.
String listOfRegisteredProperties ()
 Return the target properties that are currently registered.
void load (GeneratorArguments args, MessageReporter err)
 Load overrides passed in as CLI arguments.
List< TargetProperty<?, ?> > loaded ()
 Return all the target properties that have been set.
void mergeImportedConfig (Resource importedResource, Resource mainResource, Predicate< TargetProperty > loadOrNot, MessageReporter messageReporter)
 If the federate that the target configuration applies to is imported, merge target properties declared in the file that it was imported from.
void register (TargetProperty<?, ?>... properties)
 Register target properties and assign them their initial value.
void reportUnsupportedTargetProperty (String name, MessageReporter.Stage2 stage2)
 Report that a target property is not supported by the current target.
void reset (TargetProperty<?, ?> property)
 Reset this target property to its initial value (and mark it as unset).
String settings ()
 Return a description of the current settings.
 TargetConfig (Resource resource, GeneratorArguments args, MessageReporter reporter)
 Create a new target configuration based on the given target declaration AST node and the arguments passed to the code generator.
void update (TargetConfig config, List< KeyValuePair > pairs, Path relativePath, Predicate< TargetProperty > loadOrNot, MessageReporter err)
 Update the given configuration using the given target properties.
void validate (MessageReporter reporter)
 Validate all set properties and report issues via the given reporter.

Static Public Member Functions

static List< KeyValuePair > extractProperties (TargetConfig config)
 Extract all properties as a list of key-value pairs from a TargetConfig.
static TargetConfig getMockInstance (Target target)
 Return mock instance to use for testing, which is not tied to a generator context or a resource.

Public Attributes

final List< String > compileAdditionalSources = new ArrayList<>()
 Additional sources to add to the compile command if appropriate.
final Target target
 The target of this configuration (e.g., C, TypeScript, Python).

Static Public Attributes

static final String NOT_IN_LF_SYNTAX_MESSAGE
 Error message to use when a target property does not exist in LF syntax.

Protected Member Functions

void load (JsonObject jsonObject, MessageReporter messageReporter)
 Update this configuration based on the given JSON object.
void load (Resource resource, MessageReporter reporter)
 Load configuration from the given resource.
 TargetConfig (Target target)
 Create a new target configuration based on the given target declaration AST node only.

Protected Attributes

final Map< TargetProperty<?, ?>, KeyValuePair > keyValuePairs = new HashMap<>()
 Map from.
Resource mainResource
 The main resource that is under compilation.
final Map< TargetProperty<?, ?>, Object > properties = new HashMap<>()
 Map of target properties.

Package Functions

public< T, S extends TargetPropertyType > T get (TargetProperty< T, S > property) throws IllegalArgumentException
 Return the value currently assigned to the given target property.
public< T, S extends TargetPropertyType > T getOrDefault (TargetProperty< T, S > property)
 Return the value currently assigned to the given target property, or its default value if none been set.
public< T, S extends TargetPropertyType > KeyValuePair lookup (TargetProperty< T, S > targetProperty)
 Return the AST node that was used to assign a value for the given target property.
public< T, S extends TargetPropertyType > void set (TargetProperty< T, S > property, T value)
 Assign the given value to the given target property.

Detailed Description

A class for keeping the current target configuration.

Class members of type String are initialized as empty strings, unless otherwise stated.

Author
Marten Lohstroh

Constructor & Destructor Documentation

◆ TargetConfig() [1/2]

org.lflang.target.TargetConfig.TargetConfig ( Target target)
protected

Create a new target configuration based on the given target declaration AST node only.

Parameters
targetAST node of a target declaration.

◆ TargetConfig() [2/2]

org.lflang.target.TargetConfig.TargetConfig ( Resource resource,
GeneratorArguments args,
MessageReporter reporter )

Create a new target configuration based on the given target declaration AST node and the arguments passed to the code generator.

Parameters
resourceThe main resource.
argsThe arguments passed to the code generator.
reporterAn error reporter.

Member Function Documentation

◆ extractProperties()

List< KeyValuePair > org.lflang.target.TargetConfig.extractProperties ( TargetConfig config)
static

Extract all properties as a list of key-value pairs from a TargetConfig.

The returned list only includes properties that were explicitly set.

Parameters
configThe TargetConfig to extract from.
Returns
The extracted properties.

◆ extractTargetDecl()

TargetDecl org.lflang.target.TargetConfig.extractTargetDecl ( )

Construct a TargetDecl by extracting the fields of the given TargetConfig.

Returns
A generated TargetDecl.

◆ forName()

Optional< TargetProperty<?, ?> > org.lflang.target.TargetConfig.forName ( String name)

Return the target property in this target config that matches the given string.

Parameters
nameThe string to match against.

◆ get()

public< T, S extends TargetPropertyType > T org.lflang.target.TargetConfig.get ( TargetProperty< T, S > property) throws IllegalArgumentException
package

Return the value currently assigned to the given target property.

◆ getAssignedProperties()

List< TargetProperty<?, ?> > org.lflang.target.TargetConfig.getAssignedProperties ( )

Return the target properties that have been assigned a value.

◆ getMainResource()

Resource org.lflang.target.TargetConfig.getMainResource ( )

Get the main resource that is under compilation.

◆ getMockInstance()

TargetConfig org.lflang.target.TargetConfig.getMockInstance ( Target target)
static

Return mock instance to use for testing, which is not tied to a generator context or a resource.

◆ getOrDefault()

public< T, S extends TargetPropertyType > T org.lflang.target.TargetConfig.getOrDefault ( TargetProperty< T, S > property)
package

Return the value currently assigned to the given target property, or its default value if none been set.

Parameters
propertyThe property to get the value of
Returns
The current value, or the initial value of none was assigned.
Parameters
<T>The Java type of the returned value.
<S>The LF type of the returned value.

◆ getRegisteredProperties()

List< TargetProperty<?, ?> > org.lflang.target.TargetConfig.getRegisteredProperties ( )

Return the target properties that are currently registered.

◆ isFederated()

boolean org.lflang.target.TargetConfig.isFederated ( )

Return whether this configuration is used in the context of a federated program.

◆ isSet()

boolean org.lflang.target.TargetConfig.isSet ( TargetProperty<?, ?> property)

Return true if this target property has been set (past initialization), false otherwise.

◆ isSupported()

boolean org.lflang.target.TargetConfig.isSupported ( TargetProperty p)

Return true if the given target property is supported, false otherwise.

◆ listOfRegisteredProperties()

String org.lflang.target.TargetConfig.listOfRegisteredProperties ( )

Return the target properties that are currently registered.

◆ load() [1/3]

void org.lflang.target.TargetConfig.load ( GeneratorArguments args,
MessageReporter err )

Load overrides passed in as CLI arguments.

Parameters
argsList of overrides that may or may not be set
errMessage reporter to report attempts to set unsupported target properties.

◆ load() [2/3]

void org.lflang.target.TargetConfig.load ( JsonObject jsonObject,
MessageReporter messageReporter )
protected

Update this configuration based on the given JSON object.

Parameters
jsonObjectThe JSON object to read updates from.
messageReporterA message reporter to report issues.

◆ load() [3/3]

void org.lflang.target.TargetConfig.load ( Resource resource,
MessageReporter reporter )
protected

Load configuration from the given resource.

Parameters
resourceA resource to load from.
reporterA message reporter for reporting errors and warnings.

◆ loaded()

List< TargetProperty<?, ?> > org.lflang.target.TargetConfig.loaded ( )

Return all the target properties that have been set.

◆ lookup()

public< T, S extends TargetPropertyType > KeyValuePair org.lflang.target.TargetConfig.lookup ( TargetProperty< T, S > targetProperty)
package

Return the AST node that was used to assign a value for the given target property.

Parameters
targetPropertyThe target property to find a matching AST node for.
<T>The Java type of values assigned to the given target property.
<S>The LF type of values assigned to the given target property.

◆ mergeImportedConfig()

void org.lflang.target.TargetConfig.mergeImportedConfig ( Resource importedResource,
Resource mainResource,
Predicate< TargetProperty > loadOrNot,
MessageReporter messageReporter )

If the federate that the target configuration applies to is imported, merge target properties declared in the file that it was imported from.

Parameters
importedResourceThe resource in which the target configuration is to be loaded from.
mainResourceThe resource in which the main reactor is specified.
loadOrNotPredicate to determine for each target property whether it should be loaded.
messageReporterAn error reporter to use when problems are encountered.

◆ register()

void org.lflang.target.TargetConfig.register ( TargetProperty<?, ?>... properties)

Register target properties and assign them their initial value.

Parameters
propertiesThe target properties to register.

◆ reportUnsupportedTargetProperty()

void org.lflang.target.TargetConfig.reportUnsupportedTargetProperty ( String name,
MessageReporter.Stage2 stage2 )

Report that a target property is not supported by the current target.

Parameters
nameThe name of the unsupported target property.
stage2The second stage an the error reporter through which to report the warning.

◆ reset()

void org.lflang.target.TargetConfig.reset ( TargetProperty<?, ?> property)

Reset this target property to its initial value (and mark it as unset).

◆ set()

public< T, S extends TargetPropertyType > void org.lflang.target.TargetConfig.set ( TargetProperty< T, S > property,
T value )
package

Assign the given value to the given target property.

Parameters
propertyThe target property to assign the value to.
valueThe value to assign to the target property.
<T>The Java type of the value.
<S>The LF type of the value.

◆ settings()

String org.lflang.target.TargetConfig.settings ( )

Return a description of the current settings.

◆ update()

void org.lflang.target.TargetConfig.update ( TargetConfig config,
List< KeyValuePair > pairs,
Path relativePath,
Predicate< TargetProperty > loadOrNot,
MessageReporter err )

Update the given configuration using the given target properties.

Parameters
configThe configuration object to update.
pairsAST node that holds all the target properties.
relativePathThe path from the main resource to the resource from which the new properties originate.
loadOrNotPredicate to determine whether a property should be loaded.
errMessage reporter for errors.

◆ validate()

void org.lflang.target.TargetConfig.validate ( MessageReporter reporter)

Validate all set properties and report issues via the given reporter.

Parameters
reporterA reporter to report errors and warnings through.

Member Data Documentation

◆ compileAdditionalSources

final List<String> org.lflang.target.TargetConfig.compileAdditionalSources = new ArrayList<>()

Additional sources to add to the compile command if appropriate.

◆ keyValuePairs

final Map<TargetProperty<?, ?>, KeyValuePair> org.lflang.target.TargetConfig.keyValuePairs = new HashMap<>()
protected

Map from.

◆ mainResource

Resource org.lflang.target.TargetConfig.mainResource
protected

The main resource that is under compilation.

◆ NOT_IN_LF_SYNTAX_MESSAGE

final String org.lflang.target.TargetConfig.NOT_IN_LF_SYNTAX_MESSAGE
static
Initial value:
=
"There is no representation of this property in the LF target property syntax"

Error message to use when a target property does not exist in LF syntax.

◆ properties

final Map<TargetProperty<?, ?>, Object> org.lflang.target.TargetConfig.properties = new HashMap<>()
protected

Map of target properties.

◆ target

final Target org.lflang.target.TargetConfig.target

The target of this configuration (e.g., C, TypeScript, Python).


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