예제 #1
0
def rtype_instantiate(hop):
    hop.exception_cannot_occur()
    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))
        r_class = hop.args_r[0]
        return r_class._instantiate_runtime_class(hop, vtypeptr,
                                                  hop.r_result.lowleveltype)
    classdef = s_class.any_description().getuniqueclassdef()
    return rclass.rtype_new_instance(hop.rtyper, classdef, hop.llops)
예제 #2
0
파일: rbuiltin.py 프로젝트: charred/pypy
def rtype_instantiate(hop):
    hop.exception_cannot_occur()
    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.any_description().getuniqueclassdef()
    return rclass.rtype_new_instance(hop.rtyper, classdef, hop.llops)
예제 #3
0
def rtype_instantiate(hop):
    hop.exception_cannot_occur()
    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.any_description().getuniqueclassdef()
    return rclass.rtype_new_instance(hop.rtyper, classdef, hop.llops)
예제 #4
0
파일: rtyper.py 프로젝트: charred/pypy
 def translate_op_instantiate1(self, hop):
     from rpython.rtyper.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)