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

Diagram synthesis is broken for many tests and examples #801

Closed
cmnrd opened this issue Dec 15, 2021 · 3 comments · Fixed by #811
Closed

Diagram synthesis is broken for many tests and examples #801

cmnrd opened this issue Dec 15, 2021 · 3 comments · Fixed by #811
Labels
bug Something isn't working diagrams Problems with diagram synthesis

Comments

@cmnrd
Copy link
Collaborator

cmnrd commented Dec 15, 2021

I noticed that many of our examples do not produce valid diagrams in Epoch anymore. Instead, only an error message regarding a NullPointerException is shown. I suspect that this is caused by the recent refactorings in #759, but it could also be any other of the recent large PRs.

Examples and tests that do not work include:

  • example/C/src/Delay.lf
  • example/C/src/Patterns/Chain_02_Pipeline.lf
  • example/C/src/Patterns/Loop_01_Single.lf
  • example/C/src/Patterns/Loop_02_SingleDelay.lf
  • test/C/src/ActionWithNoReaction.lf
  • test/C/src/After.lf
  • test/C/src/Alignment.lf
  • test/C/src/CountTest.lf
  • test/C/src/DanglingOutput.lf
  • test/C/src/Deadline.lf
  • test/C/src/DelayedAction.lf
  • test/C/src/ToReactionNested.lf
  • test/C/src/TriggerDownstreamOnlyIfPresent2.lf
  • test/C/src/UnconnectedInput.lf

Note that this list is not exhaustive. There are many more files that do not produce valid diagrams. I was not able to identify a clear pattern of which language elements produce valid or invalid diagrams.

I think this shows that we need to be more thorough with testing. The correct operation of our diagram synthesis is currently not validated at all. I will open a separate issue for this (see #802).

@cmnrd cmnrd added bug Something isn't working diagrams Problems with diagram synthesis labels Dec 15, 2021
@lhstrh
Copy link
Member

lhstrh commented Dec 15, 2021 via email

@lf-lang lf-lang deleted a comment from cmnrd Dec 15, 2021
@lf-lang lf-lang deleted a comment from lhstrh Dec 15, 2021
@edwardalee
Copy link
Collaborator

OK, these errors seem to be related to recent changes to support SI time units (?). Specifically, JavaASTUtils.java has the following:

    public static TimeValue getTimeValue(Value v) {
        if (v.getParameter() != null) {
            return getDefaultAsTimeValue(v.getParameter());
        } else if (v.getTime() != null) {
            return toTimeValue(v.getTime());
        } else {
            return null;
        }
    }

This is returning null for these examples. In particular, it returns null when the time value is specified as the literal "0". TimerInstance uses the above method to set its offset and period fields, and the diagram synthesis is assuming that those fields are never null.

I think we should rewrite this code to in fact ensure that these fields are never null. Volunteer to do that?

@cmnrd
Copy link
Collaborator Author

cmnrd commented Dec 16, 2021

Thanks for the analysis. I already created a fix, but I found a few other problems on the way. I will push something soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working diagrams Problems with diagram synthesis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants