Browse Source

Fix yet another bug with continue/break

Yentl Van Tendeloo 4 years ago
parent
commit
e7837db6a6
1 changed files with 10 additions and 6 deletions
  1. 10 6
      kernel/modelverse_kernel/main.py

+ 10 - 6
kernel/modelverse_kernel/main.py

@@ -293,10 +293,6 @@ class ModelverseKernel(object):
             print("Got roots: " + str(evalstack_roots))
             raise Exception("Could not process continue statement!")
 
-        # Remove the self.taskname link from the evalstack, as we will repush it
-        lnk, = yield [("RDE", [evalstack_root, self.taskname])]
-        yield [("DE", [lnk])]
-
         prev_evalstack_roots, old_evalstack_phase_link = \
                             yield [("RRD", [evalstack_root, "prev"]),
                                    ("RDE", [evalstack_root, "phase"]),
@@ -340,6 +336,10 @@ class ModelverseKernel(object):
         else:
             raise Exception("Could not process break statement!")
 
+        # Remove the self.taskname link from the evalstack, as we will repush it
+        lnk, = yield [("RDE", [evalstack_root, self.taskname])]
+        yield [("DE", [lnk])]
+
         prev_evalstack_roots, old_evalstack_phase_link = \
                             yield [("RRD", [evalstack_root, "prev"]),
                                    ("RDE", [evalstack_root, "phase"]),
@@ -496,18 +496,22 @@ class ModelverseKernel(object):
                                    ("CNV", ["init"]),
                                    ("CNV", ["init"]),
                                   ]
-            _, _, _, _, _, _, _, _, _, _ = \
+            _, _, _, _, _, _, _, _, _ = \
                             yield [("CD", [task_frame, "IP", body]),
                                    ("CD", [task_frame, "phase", new_phase]),
                                    ("CD", [task_frame, "evalstack", new_evalstack]),
                                    ("CD", [new_evalstack, "prev", evalstack]),
                                    ("CD", [evalstack, "inst", inst]),
-                                   ("CD", [evalstack, self.taskname, inst]),
                                    ("CD", [evalstack, "phase", evalstack_phase]),
                                    ("DE", [evalstack_link]),
                                    ("DE", [ip_link]),
                                    ("DE", [phase_link]),
                                   ]
+
+            # Check if we already have a taskname link to the evalstack
+            links, = yield [("RD", [evalstack, self.taskname])]
+            if links is None:
+                yield [("CD", [evalstack, self.taskname, inst])]
         else:
             phase_link, new_phase = \
                             yield [("RDE", [task_frame, "phase"]),