Skip to content

Commit

Permalink
Attempt at assigning LET for reaction. Not yet tested
Browse files Browse the repository at this point in the history
  • Loading branch information
CloverCho committed Jul 13, 2022
1 parent 8062383 commit a82353f
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions org.lflang/src/org/lflang/generator/ReactionInstance.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,47 @@ public String toString() {
return getName() + " of " + parent.getFullName();
}

public TimeValue getLogicalExecutionTime() {
if (this.let != null) {
return this.let;
}

var let = null;

// Iterate over effect and find minimum delay.
for (TriggerInstance<? extends Variable> effect : effects) {
if (effect instanceof PortInstance) {
var afters = this.parent.getParent().children.stream().filter(c -> {
if (c.isGeneratedDelay()) {
return c.inputs.iterator().next().equals((PortInstance) effect);
}
return false;
}).map(c -> c.actions.iterator().next().getMinDelay())
.min(TimeValue::compare);

if (afters.isPresent()) {
if (let == null) {
let = afters.get();
} else {
let = TimeValue.min(afters.get(), (TimeValue) let);
}
}
} else if (effect instanceof ActionInstance) {
var action = ((ActionInstance) effect).getMinDelay();
if (let == null) {
let = action;
} else {
let = TimeValue.min(action, (TimeValue) let);
}
}
}

if (let == null) {

This comment has been minimized.

Copy link
@lhstrh

lhstrh Jul 13, 2022

Member

I would simplify this by just assigning TimeValue.ZERO on line 456. That means you can also get rid of lines 470-472.

let = TimeValue.ZERO;
}
return this.let = let;
}

//////////////////////////////////////////////////////
//// Private variables.

Expand All @@ -472,6 +513,8 @@ public String toString() {
*/
private List<Runtime> runtimeInstances;

private TimeValue let = null;

///////////////////////////////////////////////////////////
//// Inner classes

Expand Down

1 comment on commit a82353f

@lhstrh
Copy link
Member

@lhstrh lhstrh commented on a82353f Jul 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty good to me! 🚀

Please sign in to comment.