Sfoglia il codice sorgente

Digital Watch builds successfully with Rust (but haven't interacted with it yet)

Joeri Exelmans 4 anni fa
parent
commit
39fc866428

+ 2 - 3
.gitignore

@@ -7,8 +7,6 @@
 *.userprefs
 *~
 RemoteSystemsTempFiles
-csharp_tests/test-results
-csharp_tests/bin
 src/build
 # **/*target*
 test/build/
@@ -19,4 +17,5 @@ doc/_build
 src/MANIFEST
 __pycache__/
 .mypy_cache/
-*.smcat
+*.smcat
+codegen/

+ 6 - 6
examples/digitalwatch/model_digitalwatch.xml

@@ -42,7 +42,7 @@
       <parallel id="P">
         <state id="Alarm" initial="Off">
           <state id="Off">
-            <transition event="bottomLeftPressed" cond='INSTATE(["/P/Display/TimeUpdate"])' target="../On"/>
+            <transition event="bottomLeftPressed" cond='@in("/P/Display/TimeUpdate")' target="../On"/>
           </state>
 
           <state id="On" initial="NotBlinking">
@@ -55,7 +55,7 @@
 
             <state id="NotBlinking">
               <transition event="alarmStart" target="../Blinking"/>
-              <transition event="bottomLeftPressed" cond='INSTATE(["/P/Display/TimeUpdate"])' target="../../Off"/>
+              <transition event="bottomLeftPressed" cond='@in("/P/Display/TimeUpdate")' target="../../Off"/>
             </state>
 
             <state id="Blinking" initial="On">
@@ -106,7 +106,7 @@
         <state id="ChronoWrapper">
           <state id="Chrono" initial="Stopped">
             <state id="Stopped">
-              <transition event="bottomRightPressed" cond='INSTATE(["/P/Display/ChronoUpdate"])' target="../Running"/>
+              <transition event="bottomRightPressed" cond='@in("/P/Display/ChronoUpdate")' target="../Running"/>
             </state>
 
             <state id="Running">
@@ -114,10 +114,10 @@
                 <raise event="increaseChronoByOne"/>
                 <raise event="int_refresh_chrono"/>
               </transition>
-              <transition event="bottomRightPressed" cond='INSTATE(["/P/Display/ChronoUpdate"])' target="../Stopped"/>
+              <transition event="bottomRightPressed" cond='@in("/P/Display/ChronoUpdate")' target="../Stopped"/>
             </state>
 
-            <transition event="bottomLeftPressed" cond='INSTATE(["/P/Display/ChronoUpdate"])' target="Stopped">
+            <transition event="bottomLeftPressed" cond='@in("/P/Display/ChronoUpdate")' target="Stopped">
                 <raise event="resetChrono"/>
                 <raise event="int_refresh_chrono"/>
             </transition>
@@ -201,7 +201,7 @@
 
         <state id="Time" initial="Increasing">
           <state id="Increasing">
-<!--             <transition after="1 s" cond='INSTATE(["/P/Alarm/On"])' target=".">
+<!--             <transition after="1 s" cond='@in("/P/Alarm/On")' target=".">
               <raise event="increaseTimeByOne"/>
               <raise event="checkTime"/>
               <raise event="int_refresh_time"/>

+ 1 - 2
src/sccd/statechart/codegen/rust.py

@@ -116,7 +116,7 @@ class StatechartRustGenerator(ActionLangRustGenerator):
         source = instate.ref.source
         target = instate.ref.target
 
-        self.w.wnoln("{ // macro expansion for INSTATE(\"%s\")" % target.full_name)
+        self.w.wnoln("{ // macro expansion for @in(\"%s\")" % target.full_name)
         self.w.indent()
 
         # Non-exhaustive set of current states, given that 'source' is a current state
@@ -618,7 +618,6 @@ class StatechartRustGenerator(ActionLangRustGenerator):
                         self.w.writeln("// Transition's actions")
                         for a in t.actions:
                             a.accept(self)
-                        # compile_actions(t.actions, w)
 
                     self.w.writeln("// Enter actions")
                     write_enter(enter_path)

+ 1 - 1
src/sccd/statechart/static/tree.py

@@ -426,7 +426,7 @@ class StateTree:
 
     def lca(self, s1: State, s2: State) -> State:
         # Intersection between source & target ancestors, last member in depth-first sorted state list.
-        return self.state_list[bm_highest_bit((s1.ancestors | s1.state_id_bitmap) & (s2.ancestors | s2.state_id_bitmap))]
+        return self.state_list[bm_highest_bit((s1.ancestors) & (s2.ancestors))]
 
 def states_to_bitmap(states: Iterable[State]) -> Bitmap:
     return bm_from_list(s.state_id for s in states)