提交 8ddb62c0 authored 作者: James Bergstra's avatar James Bergstra

vm using standard raise_with_op

上级 8bde3d2f
...@@ -20,24 +20,8 @@ AddConfigVar('profile', ...@@ -20,24 +20,8 @@ AddConfigVar('profile',
"If VM should collect profile information", "If VM should collect profile information",
BoolParam(False)) BoolParam(False))
raise_with_op = link.raise_with_op
def raise_with_op(op, exc_info = None):
"""WRITEME"""
if exc_info is None:
exc_info = sys.exc_info()
exc_type, exc_value, exc_trace = exc_info
if exc_type == KeyboardInterrupt:
# print a simple traceback from KeyboardInterrupt
raise exc_type, exc_value, exc_trace
try:
trace = op.tag.trace
except AttributeError:
trace = ()
exc_value.__thunk_trace__ = trace
exc_value.args += (op, )
if op in op.env.toposort():
exc_value.args += ('Sequence id of Apply node='+str(op.env.toposort().index(op)),)
raise exc_type, exc_value, exc_trace
class VM(object): class VM(object):
""" """
...@@ -114,6 +98,7 @@ class VM(object): ...@@ -114,6 +98,7 @@ class VM(object):
self.call_times[i] = 0.0 self.call_times[i] = 0.0
self.call_counts[i] = 0 self.call_counts[i] = 0
class Loop(VM): class Loop(VM):
""" """
Unconditional start-to-finish program execution in Python. Unconditional start-to-finish program execution in Python.
...@@ -141,6 +126,7 @@ class Loop(VM): ...@@ -141,6 +126,7 @@ class Loop(VM):
except: except:
raise_with_op(node) raise_with_op(node)
class LoopGC(VM): class LoopGC(VM):
""" """
Unconditional start-to-finish program execution in Python. Unconditional start-to-finish program execution in Python.
...@@ -179,6 +165,7 @@ class LoopGC(VM): ...@@ -179,6 +165,7 @@ class LoopGC(VM):
except: except:
raise_with_op(node) raise_with_op(node)
class Stack(VM): class Stack(VM):
""" """
Finish-to-start evalution order of thunks. Finish-to-start evalution order of thunks.
...@@ -385,6 +372,7 @@ class Stack(VM): ...@@ -385,6 +372,7 @@ class Stack(VM):
if empty_storage_map: if empty_storage_map:
storage_map[i][0] = None storage_map[i][0] = None
try: try:
import lazylinker_c import lazylinker_c
class CVM(lazylinker_c.CLazyLinker, VM): class CVM(lazylinker_c.CLazyLinker, VM):
...@@ -394,6 +382,7 @@ try: ...@@ -394,6 +382,7 @@ try:
except ImportError: except ImportError:
pass pass
class VM_Linker(link.LocalLinker): class VM_Linker(link.LocalLinker):
""" """
Class that satisfies the Linker interface by acting as a VM factory. Class that satisfies the Linker interface by acting as a VM factory.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论