Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructuring of mechanism for compiling federated programs #1221

Merged
merged 379 commits into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from 59 commits
Commits
Show all changes
379 commits
Select commit Hold shift + click to select a range
e788dec
Fixed delay reactors
Soroosh129 Aug 4, 2022
dd2733a
Minor fix
Soroosh129 Aug 4, 2022
ba45194
Make sure GIL is locked in body of network reactions
Soroosh129 Aug 4, 2022
df06de5
Added getNetworkReactionTarget
Soroosh129 Aug 4, 2022
c1476fa
Override toString properly for TimeUnit Enum.
hokeun Aug 4, 2022
b4e4637
fix ASTUtils.toElement(TimeValue)
billy-bao Aug 4, 2022
14f377f
just use toString()
billy-bao Aug 4, 2022
ee8367f
Add TODOs for the error in TypeScript fed-gen.
hokeun Aug 4, 2022
1de5399
Fix parsing for min_output_delay, as time value 0 does not come with …
hokeun Aug 5, 2022
fed63d4
fix key-value style target property getters to return null if there a…
billy-bao Aug 5, 2022
192a50b
Add an updater for COORDINATION_OPTIONS.
hokeun Aug 5, 2022
e7806be
Merge branch 'fed-gen' of github.com:lf-lang/lingua-franca into fed-gen
hokeun Aug 5, 2022
c9c286c
Removed interfaces for now (but this can be reverted)
Soroosh129 Aug 6, 2022
f2a3357
Added relative dependency within a federate for input control reactions.
Soroosh129 Aug 8, 2022
d803d33
Also add the relative dependency to network receiver reactions
Soroosh129 Aug 8, 2022
3ec1e55
Update reactor-ts version.
hokeun Aug 8, 2022
9f1199c
Simplify handling of quotes for elements with string literals
Soroosh129 Aug 9, 2022
a40fe1c
Added back support for unordered reactions with @lhstrh
Soroosh129 Aug 9, 2022
6729e80
Removed dead code
Soroosh129 Aug 9, 2022
8916b28
Added a DOT generation mechanism to ReactionInstanceGraph for debuggi…
Soroosh129 Aug 9, 2022
67dafe5
Updated rector-c
Soroosh129 Aug 9, 2022
a346e5d
Fixed merge conflicts
Soroosh129 Aug 9, 2022
fb98b6c
Update call to ReactorInstance constructor
Soroosh129 Aug 9, 2022
b6846c3
Only generate the language attribute if needed
Soroosh129 Aug 9, 2022
9481449
Also follow reactions upstream when finding zero-delay cycles
Soroosh129 Aug 10, 2022
8a26d3c
Fixed stackoverflow reported by @ByeongGil-Jun
Soroosh129 Aug 10, 2022
88989f4
Clear the clock-sync target property for generated .lf files
Soroosh129 Aug 10, 2022
17d08b7
Removed unnecessary calls to contains
Soroosh129 Aug 10, 2022
1711762
Avoid relativizing an import multiple times
Soroosh129 Aug 10, 2022
5e87059
Also generate top-level state variables, but with a FIXME
Soroosh129 Aug 10, 2022
514417d
Filter unused imports
Soroosh129 Aug 10, 2022
32163c7
Tweak the dependency finding algorithm
Soroosh129 Aug 10, 2022
38f325b
Report results to main LfGeneratorContext.
petervdonovan Aug 10, 2022
f66a0cb
Tweaked the dependency finder algorithm
Soroosh129 Aug 10, 2022
cb96eae
Potential solution to avoid cycles
Soroosh129 Aug 11, 2022
888adcc
Use the coordination of the main file
Soroosh129 Aug 11, 2022
9488233
Account for null types
Soroosh129 Aug 11, 2022
5892ec6
Revert the state of handling string ports to where it was on master. …
Soroosh129 Aug 11, 2022
a33117f
update C & Python target federated tests to current API
billy-bao Aug 11, 2022
76558b6
use TargetPropertyType properly for _fed_setup property
billy-bao Aug 11, 2022
261c302
fix test
billy-bao Aug 11, 2022
083ff1f
augment ValidationTest to test StringDictionaryType target properties
billy-bao Aug 11, 2022
e9503bc
Add merge policy for docker docker property
Soroosh129 Aug 11, 2022
7233121
Added more tests and also follow upstream
Soroosh129 Aug 12, 2022
2af57d6
Avoid visiting reactions twice overall
Soroosh129 Aug 12, 2022
5d21278
Fixed syntax
Soroosh129 Aug 12, 2022
95c8d33
Fixed a few tests
Soroosh129 Aug 12, 2022
6b55c83
Reverted another test that was segfaulting
Soroosh129 Aug 12, 2022
149de25
Adjust diagnostic line numbers in fed generator.
petervdonovan Aug 12, 2022
df46f35
Format tests.
petervdonovan Aug 12, 2022
c0e361e
move language attribute test to validation tests
billy-bao Aug 12, 2022
5764df7
Merge remote-tracking branch 'origin/fed-gen' into fed-gen
billy-bao Aug 12, 2022
4fa2c3d
format and fix syntax errors in failing tests
billy-bao Aug 12, 2022
2439f5f
fix creating launchers for federations with no federates
billy-bao Aug 12, 2022
670e7c3
Merge progress from parallel compilations.
petervdonovan Aug 13, 2022
45b53ae
Clean up after previous commit.
petervdonovan Aug 13, 2022
ee96f3c
Add annotation for the main reactor generated from federated reactor …
hokeun Aug 26, 2022
b08dc88
Generate config in TypeSciprt to be constructed as "interface federat…
hokeun Aug 26, 2022
5075cc4
Use FederateConfig interface of reactor-ts and delete TSFederateConfig.
hokeun Aug 26, 2022
e355a93
Have federateConfig to be overiden by command-line arguments.
hokeun Aug 26, 2022
0afec11
Add keepAlive target config explicitly for LoopDistributedDouble to a…
hokeun Aug 26, 2022
968f212
Generate code for checking defaultFederateConfig.minOutputDelay only …
hokeun Aug 27, 2022
290928b
Revert Rust generator changes causing errors.
hokeun Aug 27, 2022
ae98a18
Update reactor-ts version.
hokeun Aug 27, 2022
78c3a87
Merge pull request #1336 from lf-lang/fed-gen-ts
hokeun Aug 27, 2022
878753a
Merge branch 'gradle-fix' into fed-gen
byeonggiljun Sep 21, 2022
d37e59d
Merge origin/master
lhstrh Sep 24, 2022
2097908
Remove unused code
lhstrh Sep 24, 2022
45225a5
Remove stray conflict markers
lhstrh Sep 25, 2022
fcb0300
Fix missing brackets
lhstrh Sep 25, 2022
3b99b76
Comment out code that refers to out-of-scope variables
lhstrh Sep 25, 2022
067891b
Fix problems with target properties
lhstrh Sep 25, 2022
022753f
Added back missing declarations
lhstrh Sep 25, 2022
4eccf9b
Merge remote-tracking branch 'origin/master' into fed-gen
lhstrh Sep 25, 2022
a00b1b9
Merge remote-tracking branch 'origin/master' into fed-gen
lhstrh Sep 25, 2022
0ab9798
Fix another merge artifact
lhstrh Sep 25, 2022
4974ab0
Fix another merge bug
lhstrh Sep 26, 2022
e3db9bb
Update reactor-c-py submodule.
petervdonovan Sep 26, 2022
fe74042
Bringing fed-gen up-to-date with master
lhstrh Oct 14, 2022
5428956
Fix compile errors
lhstrh Oct 14, 2022
d0102ab
Fix missing import for FederateConfig.
hokeun Oct 19, 2022
675b82f
Merge branch 'master' into fed-gen
petervdonovan Oct 20, 2022
c2204a5
Fix compile errors
lhstrh Oct 20, 2022
fb6c084
Set NUMBER_OF_WORKERS.
petervdonovan Oct 20, 2022
ea8c25f
Update submodule.
petervdonovan Oct 24, 2022
ad64ebb
Update submodule.
petervdonovan Oct 24, 2022
7383674
Fix merge error in PythonPreambleGenerator.
petervdonovan Oct 24, 2022
bebc935
Attempt: clean fed-gen also by overriding doClean (doesn't work)
axmmisaka Oct 25, 2022
d5efde1
Merge remote-tracking branch 'origin/main' into fed-gen
lhstrh Oct 28, 2022
bde74e2
Merge remote-tracking branch 'origin/master' into fed-gen
lhstrh Oct 31, 2022
86681d6
add doclean to fedgenerator and fix fedfileconfig clean
axmmisaka Nov 3, 2022
99f1657
Merge remote tracking branch 'origin/main' into fed-gen
lhstrh Nov 8, 2022
21f0659
Fix TS compile error due to missing import
lhstrh Nov 9, 2022
3bc4f6b
Merge branch 'master' into fed-gen
oowekyala Nov 9, 2022
71ef8d0
Cleanup after #1457 merge
oowekyala Nov 9, 2022
46f0dac
Recovered missing line due to faulty merge
lhstrh Nov 9, 2022
3d76b1b
Remove superfluous exception thrown in `createDirectoryIfDoesNotExist`
lhstrh Nov 9, 2022
d7bc743
Update FedFileConfig to remove the whole directory
axmmisaka Nov 18, 2022
0b45929
Fixing the loss of the hostname that is specified in a federated lf f…
ChadliaJerad Nov 19, 2022
82a33be
Merge pull request #1484 from lf-lang/fed-gen-docker
lhstrh Nov 21, 2022
03ba451
Adding host name null check in the federate reactor. This fixes the n…
ChadliaJerad Nov 21, 2022
e6aa511
Format files that are formatted in master.
petervdonovan Dec 17, 2022
411cb38
Bring in a few small changes from master.
petervdonovan Dec 17, 2022
e85e838
Merge branch 'master' into fed-gen
petervdonovan Dec 17, 2022
0b257d4
Fix failing validation test.
petervdonovan Dec 17, 2022
b78d8fc
Repair test.
petervdonovan Aug 13, 2022
4dd774c
Print stack trace for exceptions in LSP tests.
petervdonovan Aug 13, 2022
0785600
Convert an ESLint error to warning.
petervdonovan Aug 13, 2022
5c822b3
Add error message in case of unsupported target.
petervdonovan Aug 13, 2022
c2fed76
Print stack trace in tests.
petervdonovan Dec 17, 2022
2c8f5c5
Address failing Cpp DistributedCount.
petervdonovan Dec 17, 2022
6a5bc8a
Pass LSP test.
petervdonovan Dec 17, 2022
833a154
Apparently CCPP does support federated execution.
petervdonovan Dec 17, 2022
f3d1481
Create directory for preamble.
petervdonovan Aug 13, 2022
0679084
Merge branch 'fed-gen' into axmmisaka/fix-clean
axmmisaka Dec 24, 2022
86ddca8
Replace clean string with BuildParm
axmmisaka Dec 24, 2022
8a93865
Interim commit. Nothing is expected to work yet.
lhstrh Dec 29, 2022
8e9aa51
Fix compile errors in CppGenerator
lhstrh Jan 7, 2023
1e84ed1
Fix compile errors in cpp package
lhstrh Jan 8, 2023
f18083e
Compiling version of the compiler
lhstrh Jan 9, 2023
f1ce535
Merged fed-gen
lhstrh Jan 9, 2023
262df92
Add missing file
lhstrh Jan 9, 2023
3273b5d
More missing files. Not sure why they were untracked. Did they get de…
lhstrh Jan 9, 2023
3bcad35
Properly check result and only attempt to execute command if the buil…
lhstrh Jan 9, 2023
71a31ea
Attempt to fix dynamic loading of generator classes written in Kotlin
lhstrh Jan 9, 2023
b8e47a9
Return a fileconfig for CCpp
lhstrh Jan 9, 2023
1023fe6
TSFileConfig fixes.
petervdonovan Jan 10, 2023
baf1b1b
Clean up after previous commit.
petervdonovan Jan 10, 2023
24e5405
Address LSP test failures.
petervdonovan Jan 10, 2023
14b8db5
Try to pass TS Docker federated test.
petervdonovan Jan 10, 2023
40304de
Use ConcurrentHashMap instead of HashMap.
petervdonovan Jan 10, 2023
3627d78
Try to address failing C federated tests.
petervdonovan Jan 10, 2023
3172968
Try to address failing Python tests.
petervdonovan Jan 10, 2023
7125a6b
Add THREADED and UNTHREADED to cmake generator
erlingrj Dec 11, 2022
d57cd1f
Try to address failing CCpp tests.
petervdonovan Jan 10, 2023
b33cd57
Try to address failing Python docker tests.
petervdonovan Jan 10, 2023
265e637
Update trace macro
erlingrj Dec 21, 2022
8497120
Try to pass Rust tests.
petervdonovan Jan 10, 2023
fd9886d
Mark Cpp DistributedCount as failing.
petervdonovan Jan 11, 2023
c924911
Remove unused class.
lhstrh Jan 10, 2023
1cc4845
Address comments from @cmnrd
lhstrh Jan 11, 2023
5ff8fdd
Attempt to fix ClassCastException
lhstrh Jan 11, 2023
fb73705
Fix field access problem
lhstrh Jan 11, 2023
051a57a
One more private field access
lhstrh Jan 11, 2023
e2b03fa
Get rid of two more illegal field accesses
lhstrh Jan 11, 2023
5a5a9e4
Try to pass TS serialization test.
petervdonovan Jan 11, 2023
b2620c0
Clean up after previous commits.
petervdonovan Jan 11, 2023
8b73b3c
Fix string processing bug.
petervdonovan Jan 11, 2023
15edb01
Remove dangling inports
cmnrd Jan 11, 2023
3dfb765
Merge pull request #1521 from lf-lang/fed-gen-wip
lhstrh Jan 11, 2023
8f197fc
partial merge of runtime tests from marter
cmnrd Jan 11, 2023
0edf26e
pull in gradle changes from master
cmnrd Jan 11, 2023
ec07c6b
merge more files from master
cmnrd Jan 11, 2023
1937d23
fix compilation errors
cmnrd Jan 11, 2023
542e5ac
add extra args before constructing the context
cmnrd Jan 11, 2023
6c1ff69
delete superfluous C++ test
cmnrd Jan 11, 2023
48b206c
remove unused Rut and C++ federation extensions
cmnrd Jan 11, 2023
49c1ddc
Merge pull request #1538 from lf-lang/fed-gen-tests
lhstrh Jan 11, 2023
f048647
Mega merge with master. Probably broke a lot of things.
lhstrh Jan 12, 2023
9ab1365
Merge branch 'master' into fed-gen
lhstrh Jan 12, 2023
c82bfcb
Update reactor-cpp
lhstrh Jan 12, 2023
7951034
Filter out when there is no network message action in the federate.
hokeun Jan 12, 2023
5710070
Fix failure in Python test that uses after delays
petervdonovan Jan 12, 2023
12af1eb
Try again to fix Python failure.
petervdonovan Jan 12, 2023
ab2cd14
Cleanup cargodependencyspec
oowekyala Jan 12, 2023
9c5f33f
Fix the Python issue with "after" delays.
petervdonovan Jan 12, 2023
6fec9a0
Attempt to address failing LSP tests.
petervdonovan Jan 13, 2023
d6d22ce
Address failing CCpp tests.
petervdonovan Jan 13, 2023
ffa5f0f
Fix gendelays in Python the right way.
petervdonovan Jan 13, 2023
c2b2343
TS: Exit with non-zero error code if app fails
lhstrh Jan 13, 2023
93d2fbd
Fix error in logic of DistributedCount test in TS.
hokeun Jan 14, 2023
a2015cc
Update org.lflang/src/org/lflang/ASTUtils.java
lhstrh Jan 14, 2023
fb26367
Merge branch 'master' into fed-gen
petervdonovan Jan 14, 2023
fd1a5ca
Fix merge artifact
lhstrh Jan 14, 2023
2fda9ef
Update reactor-c (adaptive scheduler bugfix)
petervdonovan Jan 15, 2023
e9855fd
Address deadlock in LoopDistributedCentralizedPhysicalAction.
petervdonovan Jan 15, 2023
10b59db
Update reactor-c
petervdonovan Jan 15, 2023
9f81f0f
Merge branch 'fed-gen' into axmmisaka/fix-clean
petervdonovan Jan 15, 2023
0ff948f
Merge pull request #1475 from lf-lang/axmmisaka/fix-clean
petervdonovan Jan 15, 2023
9418c60
Fix docker CCPP.
petervdonovan Jan 15, 2023
e5d8558
Do not cache the targetConfig.
petervdonovan Jan 15, 2023
1999ec0
Address comment from @cmnrd.
lhstrh Jan 16, 2023
3411a70
Revert "Do not cache the targetConfig."
lhstrh Jan 16, 2023
3a5da73
Alternative fix for problem found by @peterdonovan.
lhstrh Jan 16, 2023
f10f5ce
Add missing file
lhstrh Jan 16, 2023
3bdeb4c
Revert "Add missing file"
lhstrh Jan 16, 2023
bba9662
Now only add the file I had intended to change
lhstrh Jan 16, 2023
0691e9d
Address another comment from @cmnrd.
lhstrh Jan 16, 2023
9a14dda
Update org.lflang.tests/src/org/lflang/tests/TestRegistry.java
lhstrh Jan 16, 2023
3afe50a
Use findAttributeByName as suggested by @cmnrd.
lhstrh Jan 16, 2023
4b98ea2
Address IllegalAccessExceptions.
petervdonovan Jan 16, 2023
68f0ab2
Change RuntimeException to IllegalArgumentException
lhstrh Jan 16, 2023
417ad49
Adjust comment
lhstrh Jan 16, 2023
93cd9b3
Removal of OldFedFileConfig
lhstrh Jan 16, 2023
8e58d82
Remote unused (and no longer existing) import
lhstrh Jan 16, 2023
10591b3
Merge pull request #1549 from lf-lang/rm-old-fedfc
lhstrh Jan 16, 2023
bf0e946
Merge origin/master.
lhstrh Jan 16, 2023
f5d1b55
Also print the names of the tests that have passed.
lhstrh Jan 16, 2023
67d1764
Fix printing passed tests.
lhstrh Jan 16, 2023
11fc3f2
Fix silly stream reuse bug
lhstrh Jan 16, 2023
130243a
Add missing newline
lhstrh Jan 16, 2023
67ee590
Address federated Python LSP test failure.
petervdonovan Jan 17, 2023
3784afe
Interim commit that restores Docker support for unfederated C
lhstrh Jan 17, 2023
9ad6e1c
Docker support for federated LF is now working
lhstrh Jan 17, 2023
0ee6f2e
introduce "unordered" attribute
cmnrd Jan 17, 2023
29e8900
rename unordered -> _unordered
cmnrd Jan 17, 2023
4a5e372
remove some dead code and comments
cmnrd Jan 17, 2023
5a4f98e
clean up usage of _fed_config
cmnrd Jan 17, 2023
153f6da
revert changes to idea style settings
cmnrd Jan 17, 2023
246ad92
remove @language attribute and replade it with @_c_body
cmnrd Jan 17, 2023
68d50e4
remove language attribute test
cmnrd Jan 17, 2023
5039529
Added support for Platform Config to AST Node Conversion
arengarajan99 Jan 17, 2023
d3937c1
Add back ignored directory
lhstrh Jan 17, 2023
ddeac11
Merge pull request #1552 from lf-lang/fed-gen-attributes
lhstrh Jan 17, 2023
ba18111
Fix NPE
lhstrh Jan 17, 2023
f8976e8
Fix another NPE
lhstrh Jan 17, 2023
39f620a
Do not build when Docker is supposed to do it
lhstrh Jan 17, 2023
b766dad
Try to address docker test failures.
petervdonovan Jan 17, 2023
6ab91c2
Reduce test timeout from 300 to 180 seconds.
petervdonovan Jan 17, 2023
1503f13
[lsp] Do validation with noCompile & with Docker
petervdonovan Jan 17, 2023
87a0604
Add missing file from previous commit.
petervdonovan Jan 17, 2023
6c2de90
Fix Docker for unfederated TypeScript
lhstrh Jan 18, 2023
3b24cf9
Work in progress fixing Docker support
lhstrh Jan 18, 2023
f8cbc75
Reverse polarity for better readability
lhstrh Jan 18, 2023
19175ef
Leave out mysterious command section in DockerFile for unfederated use
lhstrh Jan 18, 2023
3bf00ba
Simplified implementation of Docker support
lhstrh Jan 18, 2023
912a7ce
Fix NPE that appears in `eclipse-tests` workflow
lhstrh Jan 18, 2023
6234e78
Fix warning
lhstrh Jan 18, 2023
c4c7dcf
fix exception printing in tests
cmnrd Jan 18, 2023
4f69401
fix error handling in case docker is not installed
cmnrd Jan 18, 2023
492116d
fix dockerfile output
cmnrd Jan 18, 2023
e98ec25
Also check if docker-compose is installed
cmnrd Jan 18, 2023
6a6b099
build a more reliable docker test script
cmnrd Jan 18, 2023
6e1b726
use the new script for running the federated docker tests
cmnrd Jan 18, 2023
fda6a04
use the same script to run non-federated docker tests
cmnrd Jan 18, 2023
1ff2ad0
create only a single process builder
cmnrd Jan 18, 2023
3f4f156
Remove check for `docker-compose` which is no longer used.
lhstrh Jan 18, 2023
539a12e
Merge pull request #1556 from lf-lang/fix-docker-tests
lhstrh Jan 18, 2023
15ed9fc
fix typo
cmnrd Jan 18, 2023
de1bb3d
Revert "Remove check for `docker-compose` which is no longer used."
lhstrh Jan 18, 2023
c368d9e
Name the default network explicitly
lhstrh Jan 19, 2023
68ddd53
Add Docker options in attempt to avoid problems with active endpoints…
lhstrh Jan 19, 2023
3ad413b
Re-enable temporarily disabled test
lhstrh Jan 19, 2023
850e7ff
Declare dependency between federates and RTI in docker-compose.yml
lhstrh Jan 19, 2023
04d5605
Do not ignore after delays between federates.
petervdonovan Jan 19, 2023
34559d3
Various cleanups
lhstrh Jan 20, 2023
5dfe1ab
Use more text blocks
lhstrh Jan 20, 2023
8d25d50
Removed commented out code and reverted change to docker compose comm…
lhstrh Jan 20, 2023
b0b5108
Merge branch 'master' into fed-gen
lhstrh Jan 20, 2023
94c70a6
Disable docker tests for Python for the time being
lhstrh Jan 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
**/build/
**/test-bin/
**/src-gen/
**/fed-gen/
**/xtend-gen/
# Created by https://www.toptal.com/developers/gitignore/api/intellij,gradle,eclipse,maven,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij,gradle,eclipse,maven,visualstudiocode
Expand Down
19 changes: 17 additions & 2 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion org.lflang.tests/src/org/lflang/tests/TestRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public Set<LFTest> getTests(Target t, TestCategory c) {
* test file that has a directory in its path that matches an entry in this
* array will not be discovered.
*/
public static final String[] IGNORED_DIRECTORIES = {"failing", "knownfailed", "failed"};
public static final String[] IGNORED_DIRECTORIES = {"failing", "knownfailed", "failed", "fed-gen"};
lhstrh marked this conversation as resolved.
Show resolved Hide resolved

/**
* Path to the root of the repository.
Expand Down
65 changes: 60 additions & 5 deletions org.lflang/src/org/lflang/ASTUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,18 +284,23 @@ public static Reactor getEnclosingReactor(EObject obj) {
}
return null;
}



lhstrh marked this conversation as resolved.
Show resolved Hide resolved
public static Reactor findMainReactor(Resource resource) {
return IteratorExtensions.findFirst(
Iterators.filter(resource.getAllContents(), Reactor.class),
Reactor::isMain
);
}

/**
* 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.
*/
public static boolean makeFederated(Resource resource) {
// Find the main reactor
Reactor r = IteratorExtensions.findFirst(
Iterators.filter(resource.getAllContents(), Reactor.class),
Reactor::isMain
);
Reactor r = findMainReactor(resource);
if (r == null) {
return false;
}
Expand Down Expand Up @@ -879,6 +884,56 @@ public static List<String> elementToListOfStrings(Element value) {
}
return elements;
}

// Various utility methods to convert various data types to Elements

/**
* Given a single string, convert it into its AST representation.
*/
public static Element toElement(String str) {
if (str == null) return null;
Element e = LfFactory.eINSTANCE.createElement();
e.setLiteral(str);
return e;
}

/**
* 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.
*/
public static Element toElement(List<String> list) {
Element e = LfFactory.eINSTANCE.createElement();
if (list.size() == 0) return null;
else if (list.size() == 1) {
e.setLiteral(list.get(0));
} else {
var arr = LfFactory.eINSTANCE.createArray();
for (String s : list) {
arr.getElements().add(ASTUtils.toElement(s));
}
e.setArray(arr);
}
return e;
}

/**
* Converts a TimeValue to its AST representation. The value is type-cast to int in order to fit inside an Element.
lhstrh marked this conversation as resolved.
Show resolved Hide resolved
*/
public static Element toElement(TimeValue tv) {
Element e = LfFactory.eINSTANCE.createElement();
e.setTime((int)tv.time);
e.setUnit(tv.unit.toString());
return e;
}

public static Element toElement(boolean val) {
return toElement(Boolean.toString(val));
}

public static Element toElement(int val) {
return toElement(Integer.toString(val));
}

/**
* Translate the given type into its textual representation, but
Expand Down
28 changes: 28 additions & 0 deletions org.lflang/src/org/lflang/TargetConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

import org.lflang.TargetProperty.BuildType;
Expand Down Expand Up @@ -254,6 +255,9 @@ public class TargetConfig {
/** Rust-specific configuration. */
public final RustTargetConfig rust = new RustTargetConfig();

/** Path to a C file used by the Python target to setup federated execution. */
public String fedSetupPreamble = null;
lhstrh marked this conversation as resolved.
Show resolved Hide resolved

/**
* Settings related to clock synchronization.
*/
Expand Down Expand Up @@ -325,6 +329,18 @@ public static class DockerOptions {
* The base image and tag from which to build the Docker image. The default is "alpine:latest".
*/
public String from = "alpine:latest";

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
DockerOptions that = (DockerOptions) o;
return from.equals(that.from);
}
}

/**
Expand All @@ -336,6 +352,18 @@ public static class TracingOptions {
* This defaults to the name of the .lf file.
*/
public String traceFileName = null;

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TracingOptions that = (TracingOptions) o;
return Objects.equals(traceFileName, that.traceFileName); // traceFileName may be null
}
}

}
Loading