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

Parse target variable STP (STAA) #2374

Open
Depetrol opened this issue Jul 17, 2024 · 0 comments
Open

Parse target variable STP (STAA) #2374

Depetrol opened this issue Jul 17, 2024 · 0 comments
Labels
enhancement Enhancement of existing feature

Comments

@Depetrol
Copy link
Collaborator

Currently Lingua Franca syntax allows passing target variable as STP:

reaction() {=
      ...
    =} STP({=FOREVER=}) {=
      ...
    =}

The above code is currently accepted by lfc as valid code, but the generated code is

staa_lst[0]->STAA = SEC(0);

This is because the function findMaxSTP() in FedASTUtils.java has the following code

return STPList.stream()
        .map(ASTUtils::getLiteralTimeValue)
        .filter(Objects::nonNull)
        .reduce(TimeValue.ZERO, TimeValue::max);

that filters out null values produced by getLiteralTimeValue when the STP parameter is target code.

This cannot be simply fixed by inserting the expression verbatim because the value of STP parameter is currently used in compile time to determine the max. A fix could be to move finding the max STP to runtime, but this introduces larger change to the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhancement of existing feature
Projects
None yet
Development

No branches or pull requests

1 participant