[pypy-commit] pypy kill-someobject: merge
fijal
noreply at buildbot.pypy.org
Mon Oct 8 15:59:11 CEST 2012
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: kill-someobject
Changeset: r57934:c1fe98cd5a58
Date: 2012-10-08 15:58 +0200
http://bitbucket.org/pypy/pypy/changeset/c1fe98cd5a58/
Log: merge
diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -63,7 +63,7 @@
# whatever size a long has, make it big enough for a pointer.
return _get_bitsize(_long_typecode)
-# exported for now for testing array values.
+# exported for now for testing array values.
# might go into its own module.
def get_long_pattern(x):
"""get the bit pattern for a long, adjusted to pointer size"""
@@ -72,7 +72,7 @@
# used in tests for ctypes and for genc and friends
# to handle the win64 special case:
is_emulated_long = _long_typecode != 'l'
-
+
LONG_BIT = _get_long_bit()
LONG_MASK = (2**LONG_BIT)-1
LONG_TEST = 2**(LONG_BIT-1)
@@ -289,7 +289,7 @@
y = long(other)
return self._widen(other, x + y)
__radd__ = __add__
-
+
def __sub__(self, other):
x = long(self)
y = long(other)
@@ -299,7 +299,7 @@
y = long(self)
x = long(other)
return self._widen(other, x - y)
-
+
def __mul__(self, other):
x = long(self)
if not isinstance(other, (int, long)):
@@ -403,22 +403,26 @@
res = pow(x, y, m)
return self._widen(other, res)
+
class signed_int(base_int):
SIGNED = True
+
def __new__(klass, val=0):
- if type(val) is float:
+ if isinstance(val, (float, str)):
val = long(val)
- if val > klass.MASK>>1 or val < -(klass.MASK>>1)-1:
- raise OverflowError("%s does not fit in signed %d-bit integer"%(val, klass.BITS))
+ if val > klass.MASK >> 1 or val < -(klass.MASK >> 1) - 1:
+ raise OverflowError("%s does not fit in signed %d-bit integer" % (val, klass.BITS))
if val < 0:
val = ~ ((~val) & klass.MASK)
return super(signed_int, klass).__new__(klass, val)
typemap = {}
+
class unsigned_int(base_int):
SIGNED = False
+
def __new__(klass, val=0):
- if isinstance(val, (float, long)):
+ if isinstance(val, (float, long, str)):
val = long(val)
return super(unsigned_int, klass).__new__(klass, val & klass.MASK)
typemap = {}
@@ -450,7 +454,7 @@
def compute_annotation(self):
from pypy.annotation import model as annmodel
return annmodel.SomeInteger(knowntype=int_type)
-
+
class ForTypeEntry(extregistry.ExtRegistryEntry):
_about_ = int_type
@@ -462,7 +466,7 @@
v_result, = hop.inputargs(hop.r_result.lowleveltype)
hop.exception_cannot_occur()
return v_result
-
+
return int_type
class BaseIntValueEntry(extregistry.ExtRegistryEntry):
@@ -471,7 +475,7 @@
def compute_annotation(self):
from pypy.annotation import model as annmodel
return annmodel.SomeInteger(knowntype=r_ulonglong)
-
+
class BaseIntTypeEntry(extregistry.ExtRegistryEntry):
_about_ = base_int
@@ -591,7 +595,7 @@
""" Convert little->big endian and the opposite
"""
from pypy.rpython.lltypesystem import lltype, rffi
-
+
T = lltype.typeOf(arg)
# XXX we cannot do arithmetics on small ints
if isinstance(arg, base_int):
diff --git a/pypy/rpython/lltypesystem/rbuiltin.py b/pypy/rpython/lltypesystem/rbuiltin.py
--- a/pypy/rpython/lltypesystem/rbuiltin.py
+++ b/pypy/rpython/lltypesystem/rbuiltin.py
@@ -1,11 +1,9 @@
-from pypy.tool.pairtype import pairtype
from pypy.annotation import model as annmodel
-from pypy.rpython.lltypesystem import lltype
-from pypy.rpython.lltypesystem import rclass
+from pypy.rlib import objectmodel
+from pypy.rpython.lltypesystem import lltype, rclass
from pypy.rpython.lltypesystem.rdict import rtype_r_dict
-from pypy.rlib import objectmodel
-from pypy.rpython.rmodel import TyperError, Constant
-from pypy.rpython.rbool import bool_repr
+from pypy.rpython.rmodel import TyperError
+
def rtype_builtin_isinstance(hop):
hop.exception_cannot_occur()
@@ -87,6 +85,6 @@
BUILTIN_TYPER[weakref.ref] = rtype_weakref_create
BUILTIN_TYPER[llmemory.weakref_create] = rtype_weakref_create
-BUILTIN_TYPER[llmemory.weakref_deref ] = rtype_weakref_deref
+BUILTIN_TYPER[llmemory.weakref_deref] = rtype_weakref_deref
BUILTIN_TYPER[llmemory.cast_ptr_to_weakrefptr] = rtype_cast_ptr_to_weakrefptr
BUILTIN_TYPER[llmemory.cast_weakrefptr_to_ptr] = rtype_cast_weakrefptr_to_ptr
diff --git a/pypy/rpython/rbuiltin.py b/pypy/rpython/rbuiltin.py
--- a/pypy/rpython/rbuiltin.py
+++ b/pypy/rpython/rbuiltin.py
@@ -1,17 +1,12 @@
-from pypy.tool.pairtype import pairtype
from pypy.annotation import model as annmodel
from pypy.objspace.flow.model import Constant
-from pypy.rpython.lltypesystem import lltype, rclass, llmemory
-from pypy.rpython import rint, raddress
from pypy.rlib import rarithmetic, objectmodel
+from pypy.rpython import raddress, rptr, extregistry
from pypy.rpython.error import TyperError
-from pypy.rpython.rmodel import Repr, IntegerRepr, inputconst
-from pypy.rpython.rrange import rtype_builtin_range, rtype_builtin_xrange
-from pypy.rpython.rrange import rtype_builtin_enumerate
-from pypy.rpython import rstr
-from pypy.rpython import rptr
-from pypy.tool import sourcetools
-from pypy.rpython import extregistry
+from pypy.rpython.lltypesystem import lltype, llmemory
+from pypy.rpython.rmodel import Repr
+from pypy.tool.pairtype import pairtype
+
class __extend__(annmodel.SomeBuiltin):
def rtyper_makerepr(self, rtyper):
@@ -80,7 +75,7 @@
kwds_i = {}
for i, key in enumerate(keywords):
index = arguments.keywords_w[i]
- kwds_i['i_'+key] = index
+ kwds_i['i_' + key] = index
return hop, kwds_i
@@ -303,7 +298,7 @@
r_func, nimplicitarg = r_callable.get_r_implfunc()
s_callable = r_callable.get_s_callable()
- nbargs = len(hop.args_s) - 1 + nimplicitarg
+ nbargs = len(hop.args_s) - 1 + nimplicitarg
s_sigs = r_func.get_s_signatures((nbargs, (), False, False))
if len(s_sigs) != 1:
raise TyperError("cannot hlinvoke callable %r with not uniform"
@@ -332,7 +327,7 @@
# collect all functions
-import __builtin__, exceptions
+import __builtin__
BUILTIN_TYPER = {}
for name, value in globals().items():
if name.startswith('rtype_builtin_'):
@@ -384,7 +379,7 @@
hop.has_implicit_exception(MemoryError) # record that we know about it
hop.exception_is_here()
- return hop.genop(opname, vlist, resulttype = hop.r_result.lowleveltype)
+ return hop.genop(opname, vlist, resulttype=hop.r_result.lowleveltype)
def rtype_free(hop, i_flavor, i_track_allocation=None):
vlist = [hop.inputarg(hop.args_r[0], arg=0)]
@@ -504,7 +499,7 @@
elif ORIG == llmemory.Address:
return llops.genop('cast_adr_to_ptr', [v_value], resulttype = TGT)
elif isinstance(ORIG, lltype.Primitive):
- v_value = gen_cast(llops, lltype.Signed, v_value)
+ v_value = gen_cast(llops, lltype.Signed, v_value)
return llops.genop('cast_int_to_ptr', [v_value], resulttype=TGT)
elif TGT == llmemory.Address and isinstance(ORIG, lltype.Ptr):
return llops.genop('cast_ptr_to_adr', [v_value], resulttype = TGT)
@@ -632,7 +627,7 @@
flags = {'flavor': flavor}
cflags = hop.inputconst(lltype.Void, flags)
return hop.genop('free', [vinst, cflags])
-
+
BUILTIN_TYPER[objectmodel.free_non_gc_object] = rtype_free_non_gc_object
# keepalive_until_here
@@ -682,4 +677,3 @@
BUILTIN_TYPER[llmemory.cast_adr_to_ptr] = rtype_cast_adr_to_ptr
BUILTIN_TYPER[llmemory.cast_adr_to_int] = rtype_cast_adr_to_int
BUILTIN_TYPER[llmemory.cast_int_to_adr] = rtype_cast_int_to_adr
-
More information about the pypy-commit
mailing list