|
@@ -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):
|
|
@@ -58,7 +59,7 @@ class ModelverseKernel(object):
|
|
|
("RV", [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 phase_v == "finish":
|
|
|
gen = self.helper_init(user_root)
|
|
@@ -69,17 +70,17 @@ class ModelverseKernel(object):
|
|
|
#print("%-30s(%s)" % ("COMPILED " + str(self.compiled[inst]), phase_v))
|
|
|
gen = self.execute_primitive(user_root, inst, username)
|
|
|
elif inst_v is None:
|
|
|
- raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info, inst_v, phase_v))
|
|
|
+ raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info[username], inst_v, phase_v))
|
|
|
else:
|
|
|
#print("%-30s(%s) -- %s" % (inst_v["value"], phase_v, username))
|
|
|
gen = getattr(self, "%s_%s" % (inst_v["value"], phase_v))(user_root)
|
|
|
elif inst_v is None:
|
|
|
- raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info, inst_v, phase_v))
|
|
|
+ raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info[username], inst_v, 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, phase_v))
|
|
|
+ raise Exception("%s: error understanding command (%s, %s)" % (self.debug_info[username], inst_v, phase_v))
|
|
|
|
|
|
try:
|
|
|
inp = None
|
|
@@ -130,7 +131,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
|
|
@@ -423,7 +424,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("Not found as global: %s" % var_name)
|
|
|
|
|
|
# Resolved a global, so this is a string
|
|
|
# Potentially, this might even be a function that we have precompiled already!
|
|
@@ -728,16 +729,16 @@ class ModelverseKernel(object):
|
|
|
("DE", [phase_link]),
|
|
|
]
|
|
|
|
|
|
- def find_overlapping(self, a, b):
|
|
|
+ def find_overlapping(self, username, a, b):
|
|
|
newer_frames = set(a)
|
|
|
invoking_frames = set(b)
|
|
|
matches = list(newer_frames.intersection(invoking_frames))
|
|
|
if len(matches) == 1:
|
|
|
return matches[0]
|
|
|
elif len(matches) > 1:
|
|
|
- raise Exception("%s: error: multiple overlapping elements" % self.debug_info)
|
|
|
+ raise Exception("Error: multiple overlapping elements")
|
|
|
else:
|
|
|
- raise Exception("%s: error: could not find any overlap" % self.debug_info)
|
|
|
+ raise Exception("Error: could not find any overlap")
|
|
|
|
|
|
def call_param(self, user_root):
|
|
|
user_frame, = yield [("RD", [user_root, "frame"])]
|