changeset 364:b07e2f71f240

Empty ECL stack when calling a callback.
author Thibaut Girka <thib@sitedethib.com>
date Mon, 09 Jul 2012 22:13:52 +0200
parents cb1460b9b6cf
children 238d06c6603e
files pytouhou/vm/eclrunner.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pytouhou/vm/eclrunner.py
+++ b/pytouhou/vm/eclrunner.py
@@ -142,7 +142,9 @@ class ECLRunner(object):
         self.stack = []
 
 
-    def switch_to_sub(self, sub):
+    def switch_to_sub(self, sub, preserve_stack=False):
+        if not preserve_stack:
+            self.stack = []
         self.running = True
         self.frame = 0
         self.sub = sub
@@ -407,7 +409,7 @@ class ECLRunner(object):
                            list(self.variables), self.comparison_reg))
         self.variables[0] = param1
         self.variables[4] = param2
-        self.switch_to_sub(sub)
+        self.switch_to_sub(sub, preserve_stack=True)
 
 
     @instruction(36)