Skip to content

Commit

Permalink
Correct sorting of guard evaluation order
Browse files Browse the repository at this point in the history
  • Loading branch information
dziegel committed Aug 8, 2024
1 parent e5920b9 commit 3e48c9e
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 24 deletions.
9 changes: 1 addition & 8 deletions generator/src/generator/ScxmlModel.egl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ operation t_state getModel() : Tuple {
}

result.transitions = new List();
for (transition in self.c_transition.sortBy(t | t.getSortKey())) {
for (transition in self.c_transition) {
var t = transition.getModel();
t.start = result.name;
result.transitions.add(t);
Expand Down Expand Up @@ -82,11 +82,4 @@ operation t_transition getModel() : Tuple {

return result;
}

operation t_transition getSortKey() : String {
if ((not self.a_cond.isDefined()) or (self.a_cond = "else")) {
return "999999-";
}
return "0" + self.a_cond;
}
%]
4 changes: 2 additions & 2 deletions generator/src/generator/Transformations.egl
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ operation Tuple transformTransition(statemachine : Tuple) {
}
self.has_guard = not guards.isEmpty();
if (self.has_guard) {
self.priority = 0;
self.priority = 100-guards.size();
self.guards_list = guards.concat(" && ");
} else {
self.priority = 9999999;
self.priority = 100;
self.guards_list = "true";
}
}
Expand Down
1 change: 1 addition & 0 deletions generator/src/generator/XmiDeclaration.egl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
var statemachine = sm.getModel();
statemachine.transformStatemachine();

("Generate declaration for statemachine " + sm.name).println();
var declarationTemplate : Template = TemplateFactory.load("Declaration.egl");
declarationTemplate.populate("statemachine", statemachine);
%]
Expand Down
1 change: 1 addition & 0 deletions generator/src/generator/XmiInstance.egl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
var statemachine = sm.getModel();
statemachine.transformStatemachine();

("Generate instance for statemachine " + sm.name).println();
var instanceTemplate : Template = TemplateFactory.load("Instance.egl");
instanceTemplate.populate("statemachine", statemachine);
%]
Expand Down
1 change: 1 addition & 0 deletions generator/src/generator/XmiInterface.egl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
var statemachine = sm.getModel();
statemachine.transformStatemachine();

("Generate interface for statemachine " + sm.name).println();
var interfaceTemplate : Template = TemplateFactory.load("Interface.egl");
interfaceTemplate.populate("statemachine", statemachine);
%]
Expand Down
16 changes: 2 additions & 14 deletions generator/src/generator/XmiModel.egl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ operation State getModel(sm : Tuple) : Tuple {
}

result.transitions = new List();
for (transition in self.outgoing.sortBy(t | t.getSortKey())) {
for (transition in self.outgoing) {
transition.getModel(sm, result, result.transitions);
}

Expand Down Expand Up @@ -110,7 +110,7 @@ operation Transition getTarget(sm : Tuple, transition : Tuple, transitions : Lis
}

if ((self.target.isKindOf(Pseudostate)) and (self.target.kind = PseudostateKind#choice)) {
for (choice_transition in self.target.outgoing.sortBy(t | t.getSortKey())) {
for (choice_transition in self.target.outgoing) {
var t = new Tuple();
t.start = transition.start;
t.trigger = transition.trigger;
Expand All @@ -121,16 +121,4 @@ operation Transition getTarget(sm : Tuple, transition : Tuple, transitions : Lis
}
}
}

operation Transition getSortKey() : String {
if (self.guard = null) {
return "999999-";
}

var guard = self.guard.getGuard();
if (guard != "else") {
return "0" + guard;
}
return "999999-else";
}
%]

0 comments on commit 3e48c9e

Please sign in to comment.