[pypy-commit] pypy default: merge
fijal
noreply at buildbot.pypy.org
Sun Sep 21 10:21:56 CEST 2014
Author: Maciej Fijalkowski <fijall at gmail.com>
Branch:
Changeset: r73628:b6c3792d707a
Date: 2014-09-21 10:09 +0200
http://bitbucket.org/pypy/pypy/changeset/b6c3792d707a/
Log: merge
diff --git a/rpython/rtyper/lltypesystem/lltype.py b/rpython/rtyper/lltypesystem/lltype.py
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -1,16 +1,17 @@
-from types import NoneType, MethodType
import weakref
+from types import MethodType, NoneType
+
+from rpython.annotator.bookkeeper import analyzer_for, immutablevalue
from rpython.annotator.model import (
- SomeInteger, SomeBool, SomeObject, AnnotatorError)
+ AnnotatorError, SomeBool, SomeInteger, SomeObject)
+from rpython.rlib.objectmodel import Symbolic
from rpython.rlib.rarithmetic import (
- r_int, r_uint, intmask, r_singlefloat, r_ulonglong, r_longlong,
- r_longfloat, r_longlonglong, base_int, normalizedinttype, longlongmask,
- longlonglongmask, maxint, is_valid_int, is_emulated_long)
-from rpython.rlib.objectmodel import Symbolic
+ base_int, intmask, is_emulated_long, is_valid_int, longlonglongmask,
+ longlongmask, maxint, normalizedinttype, r_int, r_longfloat, r_longlong,
+ r_longlonglong, r_singlefloat, r_uint, r_ulonglong)
+from rpython.rtyper.extregistry import ExtRegistryEntry
+from rpython.tool import leakfinder
from rpython.tool.identity_dict import identity_dict
-from rpython.tool import leakfinder
-from rpython.annotator.bookkeeper import analyzer_for, immutablevalue
-from rpython.rtyper.extregistry import ExtRegistryEntry
class State(object):
pass
@@ -313,14 +314,12 @@
except KeyError:
return ContainerType.__getattr__(self, name)
-
def _nofield(self, name):
raise AttributeError('struct %s has no field %r' % (self._name,
name))
def _names_without_voids(self):
- names_without_voids = [name for name in self._names if self._flds[name] is not Void]
- return names_without_voids
+ return [name for name in self._names if self._flds[name] is not Void]
def _str_fields_without_voids(self):
return ', '.join(['%s: %s' % (name, self._flds[name])
@@ -576,8 +575,10 @@
_gckind = 'raw'
def __init__(self, tag, hints={}):
- """ if hints['render_structure'] is set, the type is internal and not considered
- to come from somewhere else (it should be rendered as a structure) """
+ """If hints['render_structure'] is set, the type is internal and
+ not considered to come from somewhere else (it should be
+ rendered as a structure)
+ """
self.tag = tag
self.__name__ = tag
self.hints = frozendict(hints)
@@ -675,7 +676,8 @@
_numbertypes = {int: Number("Signed", int, intmask)}
_numbertypes[r_int] = _numbertypes[int]
-_numbertypes[r_longlonglong] = Number("SignedLongLongLong", r_longlonglong, longlonglongmask)
+_numbertypes[r_longlonglong] = Number("SignedLongLongLong", r_longlonglong,
+ longlonglongmask)
if r_longlong is not r_int:
_numbertypes[r_longlong] = Number("SignedLongLong", r_longlong,
longlongmask)
@@ -702,8 +704,8 @@
UnsignedLongLong = build_number("UnsignedLongLong", r_ulonglong)
Float = Primitive("Float", 0.0) # C type 'double'
-SingleFloat = Primitive("SingleFloat", r_singlefloat(0.0)) # C type 'float'
-LongFloat = Primitive("LongFloat", r_longfloat(0.0)) # C type 'long double'
+SingleFloat = Primitive("SingleFloat", r_singlefloat(0.0)) # 'float'
+LongFloat = Primitive("LongFloat", r_longfloat(0.0)) # 'long double'
r_singlefloat._TYPE = SingleFloat
Char = Primitive("Char", '\x00')
@@ -876,9 +878,11 @@
@analyzer_for(cast_primitive)
def ann_cast_primitive(T, s_v):
- from rpython.rtyper.llannotation import annotation_to_lltype, ll_to_annotation
+ from rpython.rtyper.llannotation import (
+ annotation_to_lltype, ll_to_annotation)
assert T.is_constant()
- return ll_to_annotation(cast_primitive(T.const, annotation_to_lltype(s_v)._defl()))
+ return ll_to_annotation(cast_primitive(T.const,
+ annotation_to_lltype(s_v)._defl()))
def _cast_whatever(TGT, value):
@@ -905,7 +909,8 @@
elif TGT == llmemory.Address and isinstance(ORIG, Ptr):
return llmemory.cast_ptr_to_adr(value)
elif TGT == Signed and isinstance(ORIG, Ptr) and ORIG.TO._gckind == 'raw':
- return llmemory.cast_adr_to_int(llmemory.cast_ptr_to_adr(value), 'symbolic')
+ return llmemory.cast_adr_to_int(llmemory.cast_ptr_to_adr(value),
+ 'symbolic')
raise TypeError("don't know how to cast from %r to %r" % (ORIG, TGT))
@@ -1176,8 +1181,8 @@
except DelayedPointer:
return True # assume it's not a delayed null
- # _setobj, _getobj and _obj0 are really _internal_ implementations details of _ptr,
- # use _obj if necessary instead !
+ # _setobj, _getobj and _obj0 are really _internal_ implementations
+ # details of _ptr, use _obj if necessary instead !
def _setobj(self, pointing_to, solid=False):
if pointing_to is None:
obj0 = None
@@ -1244,12 +1249,12 @@
if T1 == T2:
setattr(self._obj, field_name, val)
else:
- raise TypeError("%r instance field %r:\n"
- "expects %r\n"
- " got %r" % (self._T, field_name, T1, T2))
+ raise TypeError(
+ "%r instance field %r:\nexpects %r\n got %r" %
+ (self._T, field_name, T1, T2))
return
- raise AttributeError("%r instance has no field %r" % (self._T,
- field_name))
+ raise AttributeError("%r instance has no field %r" %
+ (self._T, field_name))
def __getitem__(self, i): # ! can only return basic or ptr !
if isinstance(self._T, (Array, FixedSizeArray)):
@@ -1266,7 +1271,8 @@
if isinstance(self._T, (Array, FixedSizeArray)):
T1 = self._T.OF
if isinstance(T1, ContainerType):
- raise TypeError("cannot directly assign to container array items")
+ raise TypeError("cannot directly assign to container array "
+ "items")
T2 = typeOf(val)
if T2 != T1:
from rpython.rtyper.lltypesystem import rffi
@@ -1316,7 +1322,8 @@
from rpython.rtyper.lltypesystem import rffi
if isinstance(self._T, FuncType):
if len(args) != len(self._T.ARGS):
- raise TypeError("calling %r with wrong argument number: %r" % (self._T, args))
+ raise TypeError("calling %r with wrong argument number: %r" %
+ (self._T, args))
for i, a, ARG in zip(range(len(self._T.ARGS)), args, self._T.ARGS):
if typeOf(a) != ARG:
# ARG could be Void
@@ -1415,11 +1422,13 @@
raise RuntimeError("widening to trash: %r" % self)
PARENTTYPE = struc._parent_type
if getattr(parent, PARENTTYPE._names[0]) != struc:
- raise InvalidCast(CURTYPE, PTRTYPE) # xxx different exception perhaps?
+ # xxx different exception perhaps?
+ raise InvalidCast(CURTYPE, PTRTYPE)
struc = parent
u -= 1
if PARENTTYPE != PTRTYPE.TO:
- raise RuntimeError("widening %r inside %r instead of %r" % (CURTYPE, PARENTTYPE, PTRTYPE.TO))
+ raise RuntimeError("widening %r inside %r instead of %r" %
+ (CURTYPE, PARENTTYPE, PTRTYPE.TO))
return _ptr(PTRTYPE, struc, solid=self._solid)
def _cast_to_int(self, check=True):
@@ -1430,7 +1439,9 @@
return obj # special case for cast_int_to_ptr() results
obj = normalizeptr(self, check)._getobj(check)
if isinstance(obj, int):
- return obj # special case for cast_int_to_ptr() results put into opaques
+ # special case for cast_int_to_ptr() results put into
+ # opaques
+ return obj
if getattr(obj, '_read_directly_intval', False):
return obj.intval # special case for _llgcopaque
result = intmask(obj._getid())
@@ -1468,7 +1479,8 @@
"""XXX A nice docstring here"""
T = typeOf(val)
if isinstance(T, ContainerType):
- if self._T._gckind == 'gc' and T._gckind == 'raw' and not isinstance(T, OpaqueType):
+ if (self._T._gckind == 'gc' and T._gckind == 'raw' and
+ not isinstance(T, OpaqueType)):
val = _interior_ptr(T, self._obj, [offset])
else:
val = _ptr(Ptr(T), val, solid=self._solid)
@@ -1531,12 +1543,14 @@
setattr(example, s_attr.const, v_lltype._defl())
def call(self, args):
- from rpython.rtyper.llannotation import annotation_to_lltype, ll_to_annotation
+ from rpython.rtyper.llannotation import (
+ annotation_to_lltype, ll_to_annotation)
args_s, kwds_s = args.unpack()
if kwds_s:
raise Exception("keyword arguments to call to a low-level fn ptr")
info = 'argument to ll function pointer call'
- llargs = [annotation_to_lltype(s_arg, info)._defl() for s_arg in args_s]
+ llargs = [annotation_to_lltype(s_arg, info)._defl()
+ for s_arg in args_s]
v = self.ll_ptrtype._example()(*llargs)
return ll_to_annotation(v)
@@ -1593,7 +1607,6 @@
return val
-
assert not '__dict__' in dir(_interior_ptr)
class _container(object):
@@ -1721,11 +1734,13 @@
__slots__ = ('_hash_cache_', '_compilation_info')
- def __new__(self, TYPE, n=None, initialization=None, parent=None, parentindex=None):
+ def __new__(self, TYPE, n=None, initialization=None, parent=None,
+ parentindex=None):
my_variety = _struct_variety(TYPE._names)
return object.__new__(my_variety)
- def __init__(self, TYPE, n=None, initialization=None, parent=None, parentindex=None):
+ def __init__(self, TYPE, n=None, initialization=None, parent=None,
+ parentindex=None):
_parentable.__init__(self, TYPE)
if n is not None and TYPE._arrayfld is None:
raise TypeError("%r is not variable-sized" % (TYPE,))
@@ -1734,9 +1749,11 @@
first, FIRSTTYPE = TYPE._first_struct()
for fld, typ in TYPE._flds.items():
if fld == TYPE._arrayfld:
- value = _array(typ, n, initialization=initialization, parent=self, parentindex=fld)
+ value = _array(typ, n, initialization=initialization,
+ parent=self, parentindex=fld)
else:
- value = typ._allocate(initialization=initialization, parent=self, parentindex=fld)
+ value = typ._allocate(initialization=initialization,
+ parent=self, parentindex=fld)
setattr(self, fld, value)
if parent is not None:
self._setparentstructure(parent, parentindex)
@@ -1795,7 +1812,8 @@
__slots__ = ('items',)
- def __init__(self, TYPE, n, initialization=None, parent=None, parentindex=None):
+ def __init__(self, TYPE, n, initialization=None, parent=None,
+ parentindex=None):
if not is_valid_int(n):
raise TypeError("array length must be an int")
if n < 0:
@@ -1964,7 +1982,8 @@
if not key._was_freed():
newcache[key] = value
except RuntimeError:
- pass # ignore "accessing subxxx, but already gc-ed parent"
+ # ignore "accessing subxxx, but already gc-ed parent"
+ pass
if newcache:
_subarray._cache[T] = newcache
else:
@@ -2020,8 +2039,10 @@
attrs.setdefault('_name', '?')
attrs.setdefault('_callable', None)
self.__dict__.update(attrs)
- if '_callable' in attrs and hasattr(attrs['_callable'], '_compilation_info'):
- self.__dict__['compilation_info'] = attrs['_callable']._compilation_info
+ if '_callable' in attrs and hasattr(attrs['_callable'],
+ '_compilation_info'):
+ self.__dict__['compilation_info'] = \
+ attrs['_callable']._compilation_info
def __repr__(self):
return '<%s>' % (self,)
@@ -2126,8 +2147,8 @@
return _ptr(Ptr(T), o, solid)
@analyzer_for(malloc)
-def ann_malloc(s_T, s_n=None, s_flavor=None, s_zero=None, s_track_allocation=None,
- s_add_memory_pressure=None):
+def ann_malloc(s_T, s_n=None, s_flavor=None, s_zero=None,
+ s_track_allocation=None, s_add_memory_pressure=None):
assert (s_n is None or s_n.knowntype == int
or issubclass(s_n.knowntype, base_int))
assert s_T.is_constant()
@@ -2303,7 +2324,8 @@
@analyzer_for(runtime_type_info)
def ann_runtime_type_info(s_p):
- assert isinstance(s_p, SomePtr), "runtime_type_info of non-pointer: %r" % s_p
+ assert isinstance(s_p, SomePtr), \
+ "runtime_type_info of non-pointer: %r" % s_p
return SomePtr(typeOf(runtime_type_info(s_p.ll_ptrtype._example())))
More information about the pypy-commit
mailing list