Author: Juergen Boemmels <[email protected]>
Branch: 
Changeset: r43:608107b5b24d
Date: 2012-05-28 09:47 +0200
http://bitbucket.org/pypy/lang-scheme/changeset/608107b5b24d/

Log:    Factor out context creation from execution.py, solves some problems
        with cyclic imports

diff --git a/scheme/execution.py b/scheme/execution.py
--- a/scheme/execution.py
+++ b/scheme/execution.py
@@ -1,28 +1,13 @@
+
 import scheme.object as ssobject
-import scheme.syntax as syntax
-import scheme.procedure as procedure
 import scheme.macro as macro
-from scheme.ssparser import parse
+
 import py
 
 class Location(object):
     def __init__(self, w_obj=None):
         self.obj = w_obj
 
-OPERATION_MAP = {}
-for mod in (ssobject, syntax, procedure, macro):
-    for obj_name in dir(mod):
-        obj = getattr(mod, obj_name)
-        try:
-            issubclass(obj, ssobject.W_Callable)
-            OPERATION_MAP[obj._symbol_name] = obj(obj._symbol_name)
-        except (TypeError, AttributeError):
-            pass
-
-de_file = py.path.local(__file__).dirpath().join("r5rs_derived_expr.ss")
-de_code = de_file.read()
-de_expr_lst = parse(de_code)
-
 class ExecutionContext(object):
     """Execution context implemented as a dict.
 
@@ -43,8 +28,9 @@
             self.cont_stack = cont_stack
 
         if globalscope is None:
+            from scheme.systemcontext import _sys_dict, de_expr_lst
             self.globalscope = {}
-            for name, oper in OPERATION_MAP.items():
+            for name, oper in _sys_dict.items():
                 self.globalscope[name] = Location(oper)
 
             for expr in de_expr_lst:
diff --git a/scheme/systemcontext.py b/scheme/systemcontext.py
new file mode 100644
--- /dev/null
+++ b/scheme/systemcontext.py
@@ -0,0 +1,31 @@
+
+import scheme.object as ssobject
+import scheme.syntax as syntax
+import scheme.procedure as procedure
+import scheme.macro as macro
+from scheme.ssparser import parse
+
+
+from scheme.execution import ExecutionContext, Location
+
+import py
+
+_sys_dict = {}
+for mod in (ssobject, syntax, procedure, macro):
+    for obj_name in dir(mod):
+        obj = getattr(mod, obj_name)
+        try:
+            issubclass(obj, ssobject.W_Callable)
+            name = obj._symbol_name
+            _sys_dict[name] = obj(name)
+        except (TypeError, AttributeError):
+            pass
+
+de_file = py.path.local(__file__).dirpath().join("r5rs_derived_expr.ss")
+de_code = de_file.read()
+de_expr_lst = parse(de_code)
+
+_sys_ctx = ExecutionContext(globalscope = _sys_dict)
+
+#for expr in de_expr_lst:
+#    expr.eval(_sys_ctx)
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to