[pypy-svn] r13019 - pypy/branch/rpython-refactoring
arigo at codespeak.net
arigo at codespeak.net
Thu Jun 2 22:54:31 CEST 2005
Author: arigo
Date: Thu Jun 2 22:54:31 2005
New Revision: 13019
Added:
pypy/branch/rpython-refactoring/
- copied from r13002, pypy/dist/pypy/rpython/
Modified:
pypy/branch/rpython-refactoring/rbool.py
pypy/branch/rpython-refactoring/rfloat.py
pypy/branch/rpython-refactoring/rint.py
pypy/branch/rpython-refactoring/robject.py
pypy/branch/rpython-refactoring/rtyper.py
Log:
Intermediate branch check-in for the pypy/rpython subdirectory only.
XXX Describe the refactoring in a later check-in
Modified: pypy/branch/rpython-refactoring/rbool.py
==============================================================================
--- pypy/dist/pypy/rpython/rbool.py (original)
+++ pypy/branch/rpython-refactoring/rbool.py Thu Jun 2 22:54:31 2005
@@ -1,30 +1,19 @@
from pypy.annotation.pairtype import pairtype
-from pypy.annotation.model import SomeFloat, SomeInteger, SomeBool, SomePBC
+from pypy.annotation import model as annmodel
from pypy.rpython.lltype import Signed, Unsigned, Bool, Float
-from pypy.rpython.rtyper import TyperError
+from pypy.rpython.rmodel import Repr, TyperError, IntegerRepr, BoolRepr
debug = False
-class __extend__(pairtype(SomeBool, SomeInteger)):
+class __extend__(annmodel.SomeBool):
+ def rtyper_makerepr(self, rtyper):
+ return bool_repr
- def rtype_convert_from_to((s_from, s_to), v, llops):
- if s_to.unsigned:
- if debug: print 'explicit cast_bool_to_uint'
- return llops.genop('cast_bool_to_uint', [v], resulttype=Unsigned)
- else:
- if debug: print 'explicit cast_bool_to_int'
- return llops.genop('cast_bool_to_int', [v], resulttype=Signed)
-
-
-class __extend__(pairtype(SomeBool, SomeFloat)):
-
- def rtype_convert_from_to((s_from, s_to), v, llops):
- if debug: print 'explicit cast_bool_to_float'
- return llops.genop('cast_bool_to_float', [v], resulttype=Float)
+bool_repr = BoolRepr()
-class __extend__(SomeBool):
+class __extend__(BoolRepr):
def rtype_is_true(_, hop):
vlist = hop.inputargs(Bool)
@@ -37,3 +26,15 @@
def rtype_float(_, hop):
vlist = hop.inputargs(Float)
return vlist[0]
+
+#
+# _________________________ Conversions _________________________
+
+class __extend__(pairtype(BoolRepr, IntegerRepr)):
+ def convert_from_to((r_from, r_to), v, llops):
+ if r_to.lowleveltype == Unsigned:
+ if debug: print 'explicit cast_bool_to_uint'
+ return llops.genop('cast_bool_to_uint', [v], resulttype=Unsigned)
+ else:
+ if debug: print 'explicit cast_bool_to_int'
+ return llops.genop('cast_bool_to_int', [v], resulttype=Signed)
Modified: pypy/branch/rpython-refactoring/rfloat.py
==============================================================================
--- pypy/dist/pypy/rpython/rfloat.py (original)
+++ pypy/branch/rpython-refactoring/rfloat.py Thu Jun 2 22:54:31 2005
@@ -1,12 +1,20 @@
from pypy.annotation.pairtype import pairtype
-from pypy.annotation.model import SomeFloat, SomeInteger, SomeBool, SomePBC
+from pypy.annotation import model as annmodel
from pypy.rpython.lltype import Signed, Unsigned, Bool, Float, Void
-from pypy.rpython.rtyper import TyperError
+from pypy.rpython.rmodel import Repr, TyperError, FloatRepr
+from pypy.rpython.rmodel import IntegerRepr, BoolRepr
debug = False
-class __extend__(pairtype(SomeFloat, SomeFloat)):
+class __extend__(annmodel.SomeFloat):
+ def rtyper_makerepr(self, rtyper):
+ return float_repr
+
+float_repr = FloatRepr()
+
+
+class __extend__(pairtype(FloatRepr, FloatRepr)):
#Arithmetic
@@ -64,7 +72,7 @@
return _rtype_compare_template(hop, 'ge')
-#Helpers SomeFloat,Somefloat
+#Helpers FloatRepr,FloatRepr
def _rtype_template(hop, func):
vlist = hop.inputargs(Float, Float)
@@ -74,47 +82,9 @@
vlist = hop.inputargs(Float, Float)
return hop.genop('float_'+func, vlist, resulttype=Bool)
-
-#
-
-## XXX we have probably no implicit casts from float to integer
-##class __extend__(pairtype(SomeFloat, SomeInteger)):
-
-## def rtype_convert_from_to((s_from, s_to), v):
-## if s_to.unsigned:
-## if debug: print 'explicit cast_float_to_uint'
-## return direct_op('cast_float_to_uint', [v], resulttype=Unsigned)
-## else:
-## if debug: print 'explicit cast_float_to_int'
-## return direct_op('cast_float_to_int', [v], resulttype=Signed)
-
-
#
-class __extend__(pairtype(SomeInteger, SomeFloat)):
-
- def rtype_convert_from_to((s_from, s_to), v, llops):
- if s_from.unsigned:
- if debug: print 'explicit cast_uint_to_float'
- return llops.genop('cast_uint_to_float', [v], resulttype=Float)
- else:
- if debug: print 'explicit cast_int_to_float'
- return llops.genop('cast_int_to_float', [v], resulttype=Float)
-
-
-#
-
-## XXX we have probably no implicit casts from float to bool
-##class __extend__(pairtype(SomeFloat, SomeBool)):
-
-## def rtype_convert_from_to((s_from, s_to), v):
-## if debug: print 'explicit cast_float_to_bool'
-## return direct_op('cast_float_to_bool', [v], resulttype=Bool) #XXX or can 'float_is_true' be reused here?
-
-
-#
-
-class __extend__(SomeFloat):
+class __extend__(FloatRepr):
def rtype_is_true(_, hop):
vlist = hop.inputargs(Float)
@@ -133,3 +103,20 @@
return hop.genop('cast_float_to_int', vlist, resulttype=Signed)
rtype_float = rtype_pos
+
+#
+# _________________________ Conversions _________________________
+
+class __extend__(pairtype(IntegerRepr, FloatRepr)):
+ def convert_from_to((r_from, r_to), v, llops):
+ if r_from.unsigned:
+ if debug: print 'explicit cast_uint_to_float'
+ return llops.genop('cast_uint_to_float', [v], resulttype=Float)
+ else:
+ if debug: print 'explicit cast_int_to_float'
+ return llops.genop('cast_int_to_float', [v], resulttype=Float)
+
+class __extend__(pairtype(BoolRepr, FloatRepr)):
+ def convert_from_to(_, v, llops):
+ if debug: print 'explicit cast_bool_to_float'
+ return llops.genop('cast_bool_to_float', [v], resulttype=Float)
Modified: pypy/branch/rpython-refactoring/rint.py
==============================================================================
--- pypy/dist/pypy/rpython/rint.py (original)
+++ pypy/branch/rpython-refactoring/rint.py Thu Jun 2 22:54:31 2005
@@ -1,18 +1,29 @@
from pypy.annotation.pairtype import pairtype
-from pypy.annotation.model import SomeFloat, SomeInteger, SomeBool, SomePBC
-from pypy.annotation.model import SomeObject
+from pypy.annotation import model as annmodel
from pypy.rpython.lltype import Signed, Unsigned, Bool, Float, Void
-from pypy.rpython.rtyper import TyperError
-from pypy.rpython.robject import PyObjPtr
+from pypy.rpython.rmodel import Repr, TyperError, IntegerRepr
+from pypy.rpython.robject import PyObjRepr
debug = False
-class __extend__(pairtype(SomeInteger, SomeInteger)):
+class __extend__(annmodel.SomeInteger):
+ def rtyper_makerepr(self, rtyper):
+ if self.unsigned:
+ return unsigned_repr
+ else:
+ return signed_repr
+
+signed_repr = IntegerRepr()
+unsigned_repr = IntegerRepr()
+unsigned_repr.lowleveltype = Unsigned
+
+
+class __extend__(pairtype(IntegerRepr, IntegerRepr)):
- def rtype_convert_from_to((s_from, s_to), v, llops):
- if s_from.unsigned != s_to.unsigned:
- if s_to.unsigned:
+ def convert_from_to((r_from, r_to), v, llops):
+ if r_from.lowleveltype != r_to.lowleveltype:
+ if r_to.lowleveltype == Unsigned:
if debug: print 'explicit cast_int_to_uint'
return llops.genop('cast_int_to_uint', [v], resulttype=Unsigned)
else:
@@ -148,10 +159,14 @@
#
-class __extend__(SomeInteger):
+class __extend__(IntegerRepr):
- def rtype_is_true(s_int, hop):
- if s_int.unsigned:
+ def rtype_float(_, hop):
+ vlist = hop.inputargs(Float)
+ return vlist[0]
+
+ def rtype_is_true(self, hop):
+ if self.lowleveltype == Unsigned:
vlist = hop.inputargs(Unsigned)
return hop.genop('uint_is_true', vlist, resulttype=Bool)
else:
@@ -210,28 +225,22 @@
return vlist[0]
#
+# _________________________ Conversions _________________________
-class __extend__(pairtype(SomeObject, SomeInteger)):
-
- def rtype_convert_from_to((s_obj, s_int), v, llops):
- if s_obj.lowleveltype() != PyObjPtr:
- return NotImplemented
- if s_int.unsigned:
+class __extend__(pairtype(PyObjRepr, IntegerRepr)):
+ def convert_from_to((r_from, r_to), v, llops):
+ if r_to.lowleveltype == Unsigned:
return llops.gencapicall('PyLong_AsUnsignedLong', [v],
resulttype=Unsigned)
else:
return llops.gencapicall('PyInt_AsLong', [v],
resulttype=Signed)
-
-class __extend__(pairtype(SomeInteger, SomeObject)):
-
- def rtype_convert_from_to((s_int, s_obj), v, llops):
- if s_obj.lowleveltype() != PyObjPtr:
- return NotImplemented
- if s_int.unsigned:
+class __extend__(pairtype(IntegerRepr, PyObjRepr)):
+ def convert_from_to((r_from, r_to), v, llops):
+ if r_from.lowleveltype == Unsigned:
return llops.gencapicall('PyLong_FromUnsignedLong', [v],
resulttype=PyObjPtr)
else:
return llops.gencapicall('PyInt_FromLong', [v],
- resulttype=PyObjPtr)
+ resulttype=PyObjRepr)
Modified: pypy/branch/rpython-refactoring/robject.py
==============================================================================
--- pypy/dist/pypy/rpython/robject.py (original)
+++ pypy/branch/rpython-refactoring/robject.py Thu Jun 2 22:54:31 2005
@@ -1,72 +1,27 @@
from pypy.annotation.pairtype import pair, pairtype
-from pypy.annotation.model import SomeObject, annotation_to_lltype
from pypy.annotation import model as annmodel
from pypy.rpython.lltype import PyObject, GcPtr, Void, Bool
-from pypy.rpython.rtyper import TyperError, inputconst
-from pypy.rpython import rclass
+from pypy.rpython.rmodel import Repr, TyperError
+#from pypy.rpython import rclass
-PyObjPtr = GcPtr(PyObject)
-
-
-def missing_rtype_operation(args, hop):
- raise TyperError("unimplemented operation: '%s' on %r" % (
- hop.spaceop.opname, args))
-
-for opname in annmodel.UNARY_OPERATIONS:
- setattr(SomeObject, 'rtype_' + opname, missing_rtype_operation)
-for opname in annmodel.BINARY_OPERATIONS:
- setattr(pairtype(SomeObject, SomeObject),
- 'rtype_' + opname, missing_rtype_operation)
-
-
-class __extend__(SomeObject):
-
- def lowleveltype(s_obj):
- try:
- return annotation_to_lltype(s_obj)
- except ValueError:
- if s_obj.is_constant():
- return Void
- elif s_obj.knowntype is type:
- return rclass.TYPEPTR
- else:
- return PyObjPtr
-
- def rtype_getattr(s_obj, hop):
- s_attr = hop.args_s[1]
- if s_attr.is_constant() and isinstance(s_attr.const, str):
- attr = s_attr.const
- try:
- s_obj.find_method(attr) # just to check it is here
- except AttributeError:
- raise TyperError("no method %s on %r" % (attr, s_obj))
- else:
- # implement methods (of a known name) as just their 'self'
- return hop.inputarg(s_obj, arg=0)
+class __extend__(annmodel.SomeObject):
+ def rtyper_makerepr(self, rtyper):
+ if self.is_constant():
+ return constobj_repr
+ if self.knowntype is type:
+ return rclass.type_repr
else:
- raise TyperError("getattr() with a non-constant attribute name")
+ return pyobj_repr
- def rtype_is_true(s_obj, hop):
- if hasattr(s_obj, "rtype_len"):
- vlen = s_obj.rtype_len(hop)
- return hop.genop('int_is_true', [vlen], resulttype=Bool)
- else:
- return hop.inputconst(Bool, True)
- def rtype_nonzero(s_obj, hop):
- return s_obj.rtype_is_true(hop) # can call a subclass' rtype_is_true()
+class PyObjRepr(Repr):
+ lowleveltype = GcPtr(PyObject)
+pyobj_repr = PyObjRepr()
-class __extend__(pairtype(SomeObject, SomeObject)):
- def rtype_convert_from_to((s_from, s_to), v, llops):
- FROM = s_from.lowleveltype()
- TO = s_to.lowleveltype()
- if (PyObjPtr == FROM == TO) or (rclass.TYPEPTR == FROM == TO):
- return v
- elif FROM == Void and s_from.is_constant() and s_to.contains(s_from):
- # convert from a constant to a non-constant
- return inputconst(TO, s_from.const)
- else:
- return NotImplemented
+class ConstObjRepr(Repr):
+ lowleveltype = Void
+
+constobj_repr = ConstObjRepr()
Modified: pypy/branch/rpython-refactoring/rtyper.py
==============================================================================
--- pypy/dist/pypy/rpython/rtyper.py (original)
+++ pypy/branch/rpython-refactoring/rtyper.py Thu Jun 2 22:54:31 2005
@@ -3,31 +3,68 @@
from pypy.annotation import model as annmodel
from pypy.objspace.flow.model import Variable, Constant, Block, Link
from pypy.objspace.flow.model import SpaceOperation
-from pypy.rpython.lltype import Void, LowLevelType, NonGcPtr, ContainerType
+from pypy.rpython.lltype import Signed, Unsigned, Float, Char, Bool, Void
+from pypy.rpython.lltype import LowLevelType, NonGcPtr, ContainerType
from pypy.rpython.lltype import FuncType, functionptr, typeOf
from pypy.tool.sourcetools import func_with_new_name, valid_identifier
from pypy.translator.unsimplify import insert_empty_block
+from pypy.rpython.rmodel import Repr, inputconst, TyperError
+debug = False
+crash_on_first_typeerror = False
+
# XXX copied from pypy.translator.typer and modified.
# We'll remove pypy.translator.typer at some point.
# It also borrows a bit from pypy.translator.annrpython.
-class TyperError(Exception):
- def __str__(self):
- result = Exception.__str__(self)
- if hasattr(self, 'where'):
- result += '\n.. %r\n.. %r' % self.where
- return result
-
-
class RPythonTyper:
def __init__(self, annotator):
self.annotator = annotator
+ self.reprs_by_id = {}
+ self.reprs_by_content = {}
self.specialized_ll_functions = {}
self.rclassdefs = {}
self.typererror = None
+ # make the primitive_to_repr constant mapping
+ self.primitive_to_repr = {}
+ for s_primitive, lltype in annmodel.annotation_to_ll_map:
+ r = self.getrepr(s_primitive)
+ self.primitive_to_repr[r.lowleveltype] = r
+
+ def getrepr(self, s_obj):
+ # s_objs are not hashable... try hard to find a hash anyway
+ try:
+ return self.reprs_by_id[id(s_obj)]
+ except KeyError:
+ key = [s_obj.__class__]
+ items = s_obj.__dict__.items()
+ items.sort()
+ for name, value in items:
+ key.append(name)
+ key.append(Constant(value))
+ key = tuple(key)
+ try:
+ result = self.reprs_by_content[key]
+ except KeyError:
+ # here is the code that actually builds a Repr instance
+ result = s_obj.rtyper_makerepr(self)
+ assert not isinstance(result.lowleveltype, ContainerType), (
+ "missing a GcPtr or NonGcPtr in the type specification "
+ "of %s:\n%r" % (s_obj, result.lowleveltype))
+ self.reprs_by_content[key] = result
+ self.reprs_by_id[id(s_obj)] = result
+ return result
+
+ def binding(self, var):
+ s_obj = self.annotator.binding(var, True)
+ if s_obj is None:
+ s_obj = annmodel.SomeObject()
+ return s_obj
+
+ def bindingrepr(self, var):
+ return self.getrepr(self.binding(var))
def specialize(self):
"""Main entry point: specialize all annotated blocks of the program."""
@@ -49,9 +86,7 @@
def setconcretetype(self, v):
assert isinstance(v, Variable)
- s_value = self.annotator.binding(v, True)
- if s_value is not None:
- v.concretetype = s_value.lowleveltype()
+ v.concretetype = self.bindingrepr(v).lowleveltype
def specialize_block(self, block):
# give the best possible types to the input args
@@ -69,6 +104,7 @@
self.translate_hl_to_ll(hop, varmapping)
except TyperError, e:
self.gottypererror(e, block, op, newops)
+ return # cannot continue this block: no op.result.concretetype
block.operations[:] = newops
# multiple renamings (v1->v2->v3->...) are possible
@@ -93,16 +129,16 @@
for i in range(len(link.args)):
a1 = link.args[i]
a2 = link.target.inputargs[i]
- s_a2 = self.annotator.binding(a2)
+ r_a2 = self.bindingrepr(a2)
if isinstance(a1, Constant):
- link.args[i] = inputconst(s_a2.lowleveltype(), a1.value)
+ link.args[i] = inputconst(r_a2, a1.value)
continue # the Constant was typed, done
- s_a1 = self.annotator.binding(a1)
- if s_a1 == s_a2:
+ r_a1 = self.bindingrepr(a1)
+ if r_a1 == r_a2:
continue # no conversion needed
newops = LowLevelOpList(self)
try:
- a1 = newops.convertvar(a1, s_a1, s_a2)
+ a1 = newops.convertvar(a1, r_a1, r_a2)
except TyperError, e:
self.gottypererror(e, block, link, newops)
@@ -120,6 +156,8 @@
link.args[i] = a1
def translate_hl_to_ll(self, hop, varmapping):
+ if debug:
+ print hop.spaceop.opname, hop.args_s
op = hop.spaceop
translate_meth = getattr(self, 'translate_op_'+op.opname,
self.missing_operation)
@@ -135,31 +173,35 @@
# op.result here. We have to replace resultvar with op.result
# in all generated operations.
resulttype = resultvar.concretetype
- op.result.concretetype = hop.s_result.lowleveltype()
+ op.result.concretetype = hop.r_result.lowleveltype
if op.result.concretetype != resulttype:
raise TyperError("inconsistent type for the result of '%s':\n"
- "annotator says %r\n"
- " rtyper says %r" % (op.opname,
- op.result.concretetype,
- resulttype))
+ "annotator says %s,\n"
+ "whose lltype is %r\n"
+ "but rtype* says %r" % (
+ op.opname, hop.s_result,
+ op.result.concretetype, resulttype))
while resultvar in varmapping:
resultvar = varmapping[resultvar]
varmapping[resultvar] = op.result
else:
# translate_meth() returned a Constant
+ assert isinstance(resultvar, Constant)
if not hop.s_result.is_constant():
raise TyperError("the annotator doesn't agree that '%s' "
"returns a constant" % op.opname)
if resultvar.value != hop.s_result.const:
raise TyperError("constant mismatch: %r vs %r" % (
resultvar.value, hop.s_result.const))
- op.result.concretetype = hop.s_result.lowleveltype()
+ op.result.concretetype = hop.r_result.lowleveltype
def gottypererror(self, e, block, position, llops):
"""Record a TyperError without crashing immediately.
Put a 'TyperError' operation in the graph instead.
"""
e.where = (block, position)
+ if crash_on_first_typeerror:
+ raise
if self.typererror is None:
self.typererror = sys.exc_info()
c1 = inputconst(Void, Exception.__str__(e))
@@ -172,16 +214,16 @@
for opname in annmodel.UNARY_OPERATIONS:
exec """
def translate_op_%s(self, hop):
- s_arg1 = hop.args_s[0]
- return s_arg1.rtype_%s(hop)
+ r_arg1 = hop.args_r[0]
+ return r_arg1.rtype_%s(hop)
""" % (opname, opname) in globals(), loc
# All binary operations
for opname in annmodel.BINARY_OPERATIONS:
exec """
def translate_op_%s(self, hop):
- s_arg1 = hop.args_s[0]
- s_arg2 = hop.args_s[1]
- return pair(s_arg1, s_arg2).rtype_%s(hop)
+ r_arg1 = hop.args_r[0]
+ r_arg2 = hop.args_r[1]
+ return pair(r_arg1, r_arg2).rtype_%s(hop)
""" % (opname, opname) in globals(), loc
_registeroperations(locals())
@@ -213,22 +255,6 @@
# ____________________________________________________________
-def inputconst(type, value):
- """Return a Constant with the given value, of the requested type.
- 'type' can be a SomeXxx annotation or a low-level type.
- """
- if isinstance(type, LowLevelType):
- lowleveltype = type
- else:
- lowleveltype = type.lowleveltype()
- assert not isinstance(lowleveltype, ContainerType), (
- "missing a GcPtr or NonGcPtr in the type specification of %r" %
- (lowleveltype,))
- c = Constant(value)
- c.concretetype = lowleveltype
- return c
-
-# ____________________________________________________________
class HighLevelOp:
nb_popped = 0
@@ -238,28 +264,32 @@
self.spaceop = spaceop
self.nb_args = len(spaceop.args)
self.llops = llops
- self.args_s = [rtyper.annotator.binding(a) for a in spaceop.args]
- self.s_result = rtyper.annotator.binding(spaceop.result)
+ self.args_s = [rtyper.binding(a) for a in spaceop.args]
+ self.s_result = rtyper.binding(spaceop.result)
+ self.args_r = [rtyper.getrepr(s_a) for s_a in self.args_s]
+ self.r_result = rtyper.getrepr(self.s_result)
def inputarg(self, converted_to, arg):
"""Returns the arg'th input argument of the current operation,
as a Variable or Constant converted to the requested type.
- 'converted_to' can be a SomeXxx annotation or a primitive low-level
+ 'converted_to' should be a Repr instance or a Primitive low-level
type.
"""
v = self.spaceop.args[self.nb_popped + arg]
if isinstance(v, Constant):
return inputconst(converted_to, v.value)
+ assert hasattr(v, 'concretetype')
s_binding = self.args_s[arg]
- if s_binding is None:
- s_binding = annmodel.SomeObject()
if s_binding.is_constant():
return inputconst(converted_to, s_binding.const)
- if isinstance(converted_to, LowLevelType):
- converted_to = annmodel.lltype_to_annotation(converted_to)
- return self.llops.convertvar(v, s_binding, converted_to)
+ if not isinstance(converted_to, Repr):
+ converted_to = self.rtyper.primitive_to_repr[converted_to]
+ r_binding = self.args_r[arg]
+ return self.llops.convertvar(v, r_binding, converted_to)
+
+ inputconst = staticmethod(inputconst) # export via the HighLevelOp class
def inputargs(self, *converted_to):
assert len(converted_to) == self.nb_args, (
@@ -270,8 +300,6 @@
vars.append(self.inputarg(converted_to[i], i))
return vars
- inputconst = staticmethod(inputconst) # export via the HighLevelOp class
-
def genop(self, opname, args_v, resulttype=None):
return self.llops.genop(opname, args_v, resulttype)
@@ -282,6 +310,7 @@
"Return and discard the first argument."
self.nb_popped += 1
self.nb_args -= 1
+ self.args_r.pop(0)
return self.args_s.pop(0)
# ____________________________________________________________
@@ -293,13 +322,13 @@
def __init__(self, rtyper):
self.rtyper = rtyper
- def convertvar(self, v, s_from, s_to):
+ def convertvar(self, v, r_from, r_to):
assert isinstance(v, Variable)
- if s_from != s_to:
- v = pair(s_from, s_to).rtype_convert_from_to(v, self)
+ if r_from != r_to:
+ v = pair(r_from, r_to).convert_from_to(v, self)
if v is NotImplemented:
- raise TyperError("don't know how to convert from %r to %r" % (
- s_from, s_to))
+ raise TyperError("don't know how to convert from %r to %r" %
+ (r_from, r_to))
return v
def genop(self, opname, args_v, resulttype=None):
@@ -309,20 +338,21 @@
vresult.concretetype = Void
return None
else:
+ if isinstance(resulttype, Repr):
+ resulttype = resulttype.lowleveltype
+ assert isinstance(resulttype, LowLevelType)
vresult.concretetype = resulttype
return vresult
def gendirectcall(self, ll_function, *args_v):
- annotator = self.rtyper.annotator
+ rtyper = self.rtyper
spec_key = [ll_function]
spec_name = [ll_function.func_name]
args_s = []
for v in args_v:
- s_value = annotator.binding(v, True)
- if s_value is None:
- s_value = annmodel.SomeObject()
+ r_value = rtyper.bindingrepr(v)
if v.concretetype == Void:
- if not s_value.is_constant():
+ if not r_value.s_obj.is_constant():
raise TyperError("non-constant variable of type Void")
key = s_value.const # specialize by constant value
args_s.append(s_value)
@@ -362,5 +392,8 @@
# _______________________________________________________________________
# this has the side-effect of registering the unary and binary operations
-from pypy.rpython import robject, rlist, rptr, rbuiltin, rint, rbool, rfloat
-from pypy.rpython import rpbc, rstr, riter
+# and the rtyper_chooserepr() methods
+#from pypy.rpython import robject, rlist, rptr, rbuiltin, rint, rbool, rfloat
+#from pypy.rpython import rpbc, rstr, riter
+
+from pypy.rpython import robject, rint, rbool, rfloat
More information about the Pypy-commit
mailing list