Joeri Exelmans 4 anni fa
parent
commit
57b0349e58

+ 17 - 7
src/sccd/statechart/codegen/rust.py

@@ -93,7 +93,10 @@ class StatechartRustGenerator(ActionLangRustGenerator):
 
     def get_parallel_states_tuple(self):
         parallel_states = self.get_parallel_states(self.state_stack[-1])
-        return "(" + ", ".join("*"+ident_var(s) for s in parallel_states) + ", )"
+        if len(parallel_states) > 0:
+            return "(" + ", ".join("*"+ident_var(s) for s in parallel_states) + ", )"
+        else:
+            return "()"
 
     def visit_InStateMacroExpansion(self, instate):
         source = instate.ref.source
@@ -151,7 +154,11 @@ class StatechartRustGenerator(ActionLangRustGenerator):
         # self.w.wno("false")
 
     def visit_SCCDStateConfiguration(self, type):
-        self.w.wno("(%s, )" % ", ".join(ident_type(s) for s in self.get_parallel_states(type.state)))
+        parallel_states = self.get_parallel_states(type.state)
+        if len(parallel_states) > 0:
+            self.w.wno("(%s, )" % ", ".join(ident_type(s) for s in parallel_states))
+        else:
+            self.w.wno("()")
 
     def visit_RaiseOutputEvent(self, a):
         # TODO: evaluate event parameters
@@ -165,10 +172,13 @@ class StatechartRustGenerator(ActionLangRustGenerator):
         self.w.writeln("internal.raise().%s = Some(%s{});" % (ident_event_field(a.name), (ident_event_type(a.name))))
 
     def visit_Code(self, a):
-            self.w.write()
-            a.block.accept(self) # block is a function
-            self.w.wno("(%s, scope);" % self.get_parallel_states_tuple()) # call it!
-            self.w.wnoln()
+        if a.block.scope.size() > 1:
+            raise UnsupportedFeature("Event parameters")
+
+        self.w.write()
+        a.block.accept(self) # block is a function
+        self.w.wno("(%s, scope);" % self.get_parallel_states_tuple()) # call it!
+        self.w.wnoln()
 
     def visit_State(self, state):
         self.state_stack.append(state)
@@ -572,7 +582,7 @@ class StatechartRustGenerator(ActionLangRustGenerator):
 
                     if t.guard is not None:
                         if t.guard.scope.size() > 1:
-                            raise UnsupportedFeature("Guard reads an event parameter")
+                            raise UnsupportedFeature("Event parameters")
                         self.w.write("if ")
                         t.guard.accept(self) # guard is a function...
                         self.w.wno("(") # call it!

+ 1 - 1
test_files/day_atlee/statechart_fig20_invar.xml

@@ -44,7 +44,7 @@
           </transition>
         </state>
         <state id="S6">
-          <transition cond='INSTATE(["/Invar/I1/S3"])' target="/Done"/>
+          <transition cond='@in("/Invar/I1/S3")' target="/Done"/>
         </state>
       </state>
     </parallel>

+ 1 - 1
test_files/day_atlee/test_19_swaptwice_combo.xml

@@ -59,7 +59,7 @@
             </transition>
           </state>
           <state id="S6">
-            <transition cond='INSTATE(["/Swap/A/S3"])' target="/done">
+            <transition cond='@in("/Swap/A/S3")' target="/done">
               <raise event="swapped">
                 <param expr="a"/>
                 <param expr="b"/>

+ 1 - 1
test_files/features/after/test_after_reentry.xml

@@ -14,7 +14,7 @@
       <parallel id="p">
         <state id="o0" initial="a">
           <state id="a">
-            <transition after="100 ms" cond='INSTATE(["/p/o1/x"])' target="../b"/>
+            <transition after="100 ms" cond='@in("/p/o1/x")' target="../b"/>
             <transition after="150 ms" target="../c"/>
           </state>
           <state id="b">

+ 3 - 5
test_files/features/history/test_parallel_deep.xml

@@ -49,20 +49,20 @@
             </transition>
           </state>
           <state id="step1">
-            <transition cond='INSTATE(["/P/orthogonal/wrapper/state_2/inner_4", "/P/orthogonal/wrapper/state_1/inner_2"])'
+            <transition cond='@in("/P/orthogonal/wrapper/state_2/inner_4") and @in("/P/orthogonal/wrapper/state_1/inner_2")'
               target="../step2">
               <raise event="check1" />
               <raise event="to_outer" />
             </transition>
           </state>
           <state id="step2">
-            <transition cond='INSTATE(["/P/orthogonal/outer"])' target="../step3">
+            <transition cond='@in("/P/orthogonal/outer")' target="../step3">
               <raise event="check2" />
               <raise event="to_history" />
             </transition>
           </state>
           <state id="step3">
-            <transition cond='INSTATE(["/P/orthogonal/wrapper/state_2/inner_4", "/P/orthogonal/wrapper/state_1/inner_2"])' target="../end">
+            <transition cond='@in("/P/orthogonal/wrapper/state_2/inner_4") and @in("/P/orthogonal/wrapper/state_1/inner_2")' target="../end">
               <raise event="check3" />
             </transition>
           </state>
@@ -70,8 +70,6 @@
         </state>
       </parallel>
     </root>
-
-
   </statechart>
 
   <input>

+ 1 - 1
test_files/semantics/memory_protocol/statechart_enabledness.xml

@@ -17,7 +17,7 @@
     <parallel id="p">
       <state id="increment">
         <state id="a">
-          <transition event="e" target="." cond='not INSTATE(["/p/status/done"])'>
+          <transition event="e" target="." cond='not @in("/p/status/done")'>
             <raise event="inc"/>
             <code> i += 1; </code>
           </transition>