def builtin_test(oopspec_name, args, RESTYPE, expected): v_result = varoftype(RESTYPE) tr = Transformer(FakeCPU(), FakeCallControl()) tr.immutable_arrays = {} tr.vable_array_vars = {} if '/' in oopspec_name: oopspec_name, property = oopspec_name.split('/') def force_flags(op): if property == 'NONNEG': return True if property == 'NEG': return False raise ValueError(property) tr._get_list_nonneg_canraise_flags = force_flags op = SpaceOperation('direct_call', [Constant("myfunc", lltype.Void)] + args, v_result) try: oplist = tr._handle_list_call(op, oopspec_name, args) except NotSupported: assert expected is NotSupported else: assert expected is not NotSupported assert oplist is not None flattener = GraphFlattener(None, fake_regallocs()) if not isinstance(oplist, list): oplist = [oplist] for op1 in oplist: flattener.serialize_op(op1) assert_format(flattener.ssarepr, expected)
def test_descr(self): class FooDescr(AbstractDescr): def __repr__(self): return 'hi_there!' op = SpaceOperation('foobar', [FooDescr()], None) flattener = GraphFlattener(None, fake_regallocs()) flattener.serialize_op(op) assert_format(flattener.ssarepr, """ foobar hi_there! """)
def test_arg_sublist_1(self): v1 = varoftype(lltype.Signed) v2 = varoftype(lltype.Char) v3 = varoftype(rclass.OBJECTPTR) v4 = varoftype(lltype.Ptr(rstr.STR)) v5 = varoftype(lltype.Float) op = SpaceOperation('residual_call_ir_f', [Constant(12345, lltype.Signed), # function ptr ListOfKind('int', [v1, v2]), # int args ListOfKind('ref', [v3, v4])], # ref args v5) # result flattener = GraphFlattener(None, fake_regallocs()) flattener.serialize_op(op) assert_format(flattener.ssarepr, """ residual_call_ir_f $12345, I[%i0, %i1], R[%r0, %r1] -> %f0 """)