Example #1
0
def rtype_instantiate(hop):
    s_class = hop.args_s[0]
    assert isinstance(s_class, annmodel.SomePBC)
    if len(s_class.descriptions) != 1:
        # instantiate() on a variable class
        vtypeptr, = hop.inputargs(rclass.get_type_repr(hop.rtyper))
        v_inst = hop.gendirectcall(ll_instantiate, vtypeptr)
        return hop.genop('cast_pointer', [v_inst],    # v_type implicit in r_result
                         resulttype = hop.r_result.lowleveltype)

    classdef = s_class.descriptions.keys()[0].getuniqueclassdef()
    return rclass.rtype_new_instance(hop.rtyper, classdef, hop.llops)
Example #2
0
File: rtyper.py Project: ieure/pypy
 def translate_op_instantiate1(self, hop):
     from pypy.rpython.lltypesystem import rclass
     if not isinstance(hop.s_result, annmodel.SomeInstance):
         raise TyperError("instantiate1 got s_result=%r" % (hop.s_result,))
     classdef = hop.s_result.classdef
     return rclass.rtype_new_instance(self, classdef, hop.llops)
Example #3
0
 def translate_op_instantiate1(self, hop):
     from pypy.rpython.lltypesystem import rclass
     if not isinstance(hop.s_result, annmodel.SomeInstance):
         raise TyperError("instantiate1 got s_result=%r" % (hop.s_result, ))
     classdef = hop.s_result.classdef
     return rclass.rtype_new_instance(self, classdef, hop.llops)