Author: Ronan Lamy <[email protected]>
Branch: annotator
Changeset: r68743:58127250a1ca
Date: 2014-01-17 01:41 +0000
http://bitbucket.org/pypy/pypy/changeset/58127250a1ca/
Log: move find_global() out of FlowObjSpace
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -5,6 +5,7 @@
import sys
import collections
import types
+import __builtin__
from rpython.tool.error import source_lines
from rpython.tool.stdlib_opcode import host_bytecode_spec
@@ -898,8 +899,19 @@
w_const = self.getconstant_w(constindex)
self.pushvalue(w_const)
+ def find_global(self, w_globals, varname):
+ try:
+ value = w_globals.value[varname]
+ except KeyError:
+ # not in the globals, now look in the built-ins
+ try:
+ value = getattr(__builtin__, varname)
+ except AttributeError:
+ raise FlowingError("global name '%s' is not defined" % varname)
+ return const(value)
+
def LOAD_GLOBAL(self, nameindex):
- w_result = self.space.find_global(self.w_globals,
self.getname_u(nameindex))
+ w_result = self.find_global(self.w_globals, self.getname_u(nameindex))
self.pushvalue(w_result)
LOAD_NAME = LOAD_GLOBAL
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -2,7 +2,6 @@
with rpython.flowspace.flowcontext.
"""
-import __builtin__
from inspect import CO_NEWLOCALS
from rpython.flowspace.argument import CallSpec
@@ -74,17 +73,6 @@
hlop = op.simple_call(w_callable, *args.as_list())
return self.frame.do_op(hlop)
- def find_global(self, w_globals, varname):
- try:
- value = w_globals.value[varname]
- except KeyError:
- # not in the globals, now look in the built-ins
- try:
- value = getattr(__builtin__, varname)
- except AttributeError:
- raise FlowingError("global name '%s' is not defined" % varname)
- return const(value)
-
def build_flow(func, space=FlowObjSpace()):
"""
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit