[pypy-svn] pypy jit-tagged: Fix this file, which is not fully tested and not really used any more.
arigo
commits-noreply at bitbucket.org
Mon Dec 20 13:20:46 CET 2010
Author: Armin Rigo <arigo at tunes.org>
Branch: jit-tagged
Changeset: r40142:8d6652c4c2a5
Date: 2010-12-20 10:05 +0100
http://bitbucket.org/pypy/pypy/changeset/8d6652c4c2a5/
Log: Fix this file, which is not fully tested and not really used any more.
(Fix it anyway to prevent source code rotting.)
diff --git a/pypy/tool/sourcetools.py b/pypy/tool/sourcetools.py
--- a/pypy/tool/sourcetools.py
+++ b/pypy/tool/sourcetools.py
@@ -216,9 +216,11 @@
# ____________________________________________________________
-def func_with_new_name(func, newname):
+def func_with_new_name(func, newname, globals=None):
"""Make a renamed copy of a function."""
- f = new.function(func.func_code, func.func_globals,
+ if globals is None:
+ globals = func.func_globals
+ f = new.function(func.func_code, globals,
newname, func.func_defaults,
func.func_closure)
if func.func_dict:
diff --git a/pypy/objspace/std/smallintobject.py b/pypy/objspace/std/smallintobject.py
--- a/pypy/objspace/std/smallintobject.py
+++ b/pypy/objspace/std/smallintobject.py
@@ -5,7 +5,6 @@
from pypy.objspace.std import intobject
from pypy.objspace.std.model import registerimplementation, W_Object
from pypy.objspace.std.register_all import register_all
-from pypy.objspace.std.noneobject import W_NoneObject
from pypy.objspace.std.intobject import W_IntObject
from pypy.rlib.objectmodel import UnboxedValue
from pypy.tool.sourcetools import func_with_new_name
@@ -40,11 +39,22 @@
if "__Int" in name:
new_name = name.replace("Int", "SmallInt")
# Copy the function, so the annotator specializes it for
- # W_SmallIntObject.
- ns[new_name] = func_with_new_name(func, new_name)
+ # W_SmallIntObject. Also replaces the func_globals with ns.
+ # The effect we get is as if the source code of the function
+ # was copied in smallintobject.py.
+ ns[new_name] = func_with_new_name(func, new_name, globals=ns)
ns["get_integer"] = ns["pos__SmallInt"] = ns["int__SmallInt"]
ns["get_negint"] = ns["neg__SmallInt"]
copy_multimethods(globals())
+# extra imports needed because we switch the func_globals above
+from pypy.interpreter.error import OperationError
+from pypy.objspace.std.multimethod import FailedToImplementArgs
+from pypy.rlib.rarithmetic import ovfcheck, ovfcheck_lshift, LONG_BIT, r_uint
+from pypy.objspace.std.inttype import wrapint
+from pypy.objspace.std.intobject import _impl_int_int_pow
+from pypy.objspace.std.noneobject import W_NoneObject
+from pypy.rlib.rbigint import rbigint
+
register_all(vars())
More information about the Pypy-commit
mailing list