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