From 3e48c9ea20495f60591cf5e5eabe986e3a955b76 Mon Sep 17 00:00:00 2001 From: Dirk Ziegelmeier Date: Thu, 8 Aug 2024 10:54:09 +0200 Subject: [PATCH] Correct sorting of guard evaluation order --- generator/src/generator/ScxmlModel.egl | 9 +-------- generator/src/generator/Transformations.egl | 4 ++-- generator/src/generator/XmiDeclaration.egl | 1 + generator/src/generator/XmiInstance.egl | 1 + generator/src/generator/XmiInterface.egl | 1 + generator/src/generator/XmiModel.egl | 16 ++-------------- 6 files changed, 8 insertions(+), 24 deletions(-) diff --git a/generator/src/generator/ScxmlModel.egl b/generator/src/generator/ScxmlModel.egl index 321c9f9..84f8151 100644 --- a/generator/src/generator/ScxmlModel.egl +++ b/generator/src/generator/ScxmlModel.egl @@ -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); @@ -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; -} %] \ No newline at end of file diff --git a/generator/src/generator/Transformations.egl b/generator/src/generator/Transformations.egl index 5d492d8..1838c03 100644 --- a/generator/src/generator/Transformations.egl +++ b/generator/src/generator/Transformations.egl @@ -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"; } } diff --git a/generator/src/generator/XmiDeclaration.egl b/generator/src/generator/XmiDeclaration.egl index 7f6bda3..7444e6a 100644 --- a/generator/src/generator/XmiDeclaration.egl +++ b/generator/src/generator/XmiDeclaration.egl @@ -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); %] diff --git a/generator/src/generator/XmiInstance.egl b/generator/src/generator/XmiInstance.egl index f7c156c..2467dd1 100644 --- a/generator/src/generator/XmiInstance.egl +++ b/generator/src/generator/XmiInstance.egl @@ -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); %] diff --git a/generator/src/generator/XmiInterface.egl b/generator/src/generator/XmiInterface.egl index 81d9e82..cd14860 100644 --- a/generator/src/generator/XmiInterface.egl +++ b/generator/src/generator/XmiInterface.egl @@ -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); %] diff --git a/generator/src/generator/XmiModel.egl b/generator/src/generator/XmiModel.egl index ffc3f86..081958d 100644 --- a/generator/src/generator/XmiModel.egl +++ b/generator/src/generator/XmiModel.egl @@ -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); } @@ -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; @@ -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"; -} %] \ No newline at end of file