Browse Source

Keep line info in dictionary

Yentl Van Tendeloo 8 years ago
parent
commit
1bb980a8a2
2 changed files with 12 additions and 11 deletions
  1. 11 10
      kernel/modelverse_kernel/main.py
  2. 1 1
      kernel/mvk_server/server.py

+ 11 - 10
kernel/modelverse_kernel/main.py

@@ -1,5 +1,6 @@
 import modelverse_kernel.primitives as primitive_functions
 import modelverse_kernel.compiled as compiled_functions
+from collections import defaultdict
 import sys
 import time
 
@@ -18,7 +19,7 @@ class ModelverseKernel(object):
         self.generators = {}
         self.allow_compiled = True
         #self.allow_compiled = False
-        self.debug_info = "(no debug information found)"
+        self.debug_info = defaultdict(lambda : "(no debug information found)")
 
     def execute_yields(self, username, operation, params, reply):
         try:
@@ -38,7 +39,7 @@ class ModelverseKernel(object):
             del self.generators[username][operation]
             return None
         except:
-            print("Unknown error @ %s" % self.debug_info)
+            print("Unknown error @ %s" % self.debug_info[username])
             raise
 
     def execute_rule(self, username):
@@ -54,7 +55,7 @@ class ModelverseKernel(object):
                                    ("RV", [self.inst]),
                                   ]
             if self.new_debug is not None:
-                self.debug_info, = yield [("RV", [self.new_debug])]
+                self.debug_info[username], = yield [("RV", [self.new_debug])]
 
             if self.phase_v == "finish":
                 gen = self.helper_init(user_root)
@@ -65,17 +66,17 @@ class ModelverseKernel(object):
                     #print("%-30s(%s)" % ("COMPILED " + str(self.compiled[self.inst]), self.phase_v))
                     gen = self.execute_primitive(user_root, self.inst, username)
                 elif inst_v is None:
-                    raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info, inst_v, self.phase_v))
+                    raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info[username], inst_v, self.phase_v))
                 else:
                     #print("%-30s(%s) -- %s" % (inst_v["value"], self.phase_v, username))
                     gen = getattr(self, "%s_%s" % (inst_v["value"], self.phase_v))(user_root)
             elif inst_v is None:
-                raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info, inst_v, self.phase_v))
+                raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info[username], inst_v, self.phase_v))
             elif inst_v["value"] == "call":
                 #print("%-30s(%s)" % ("call", "param"))
                 gen = self.call_param(user_root)
             else:
-                raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info, inst_v, self.phase_v))
+                raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info[username], inst_v, self.phase_v))
 
             try:
                 inp = None
@@ -128,7 +129,7 @@ class ModelverseKernel(object):
                 inp = yield prim.send(inp)
         except StopIteration:
             # Execution has ended without return value, so we have no idea what to do
-            raise Exception("%s: primitive finished without returning a value!" % (self.debug_info))
+            raise Exception("%s: primitive finished without returning a value!" % (self.debug_info[username]))
         except primitive_functions.PrimitiveFinished as e:
             # Execution has ended with a returnvalue, so read it out from the exception being thrown
             result = e.result
@@ -421,7 +422,7 @@ class ModelverseKernel(object):
                                    ("CNV", ["finish"]),
                                   ]
             if variable is None:
-                raise Exception("%s: not found as global: %s" % (self.debug_info, var_name))
+                raise Exception("%s: not found as global: %s" % (self.debug_info[username], var_name))
 
             # Resolved a global, so this is a string
             # Potentially, this might even be a function that we have precompiled already!
@@ -730,9 +731,9 @@ class ModelverseKernel(object):
         if len(matches) == 1:
             return matches[0]
         elif len(matches) > 1:
-            raise Exception("%s: error: multiple overlapping elements" % self.debug_info)
+            raise Exception("%s: error: multiple overlapping elements" % self.debug_info[username])
         else:
-            raise Exception("%s: error: could not find any overlap" % self.debug_info)
+            raise Exception("%s: error: could not find any overlap" % self.debug_info[username])
 
     def call_param(self, user_root):
         user_frame, =       yield [("RD", [user_root, "frame"])]

+ 1 - 1
kernel/mvk_server/server.py

@@ -1,7 +1,7 @@
 """
 Generated by Statechart compiler by Glenn De Jonghe, Joeri Exelmans, Simon Van Mierlo, and Yentl Van Tendeloo (for the inspiration)
 
-Date:   Thu Feb 09 16:22:18 2017
+Date:   Thu Feb  9 16:38:23 2017
 
 Model author: Yentl Van Tendeloo
 Model name:   MvK Server