示例#1
0
def get_float_tests(cpu):
    if not cpu.supports_floats:
        py.test.skip("requires float support from the backend")
    for opnum, args, rettype, retvalue in (
            list(_float_binary_operations()) +
            list(_float_comparison_operations()) +
            list(_float_unary_operations())):
        boxargs = []
        for x in args:
            if isinstance(x, float):
                boxargs.append(boxfloat(x))
            else:
                boxargs.append(InputArgInt(x))
        yield opnum, boxargs, rettype, retvalue
        if len(args) > 1:
            assert len(args) == 2
            yield opnum, [boxargs[0],
                          wrap_constant(boxargs[1].getvalue())
                          ], rettype, retvalue
            yield opnum, [wrap_constant(boxargs[0].getvalue()),
                          boxargs[1]], rettype, retvalue
            if (isinstance(args[0], float) and isinstance(args[1], float)
                    and args[0] == args[1]):
                commonbox = boxfloat(args[0])
                yield opnum, [commonbox, commonbox], rettype, retvalue
示例#2
0
 def do(self, opnum, argboxes, descr=None):
     self.fakemetainterp._got_exc = None
     op = ResOperation(opnum, argboxes, descr)
     result = _execute_arglist(self.cpu, self.fakemetainterp,
                               opnum, argboxes, descr)
     if result is not None:
         c_result = wrap_constant(result)
         op.copy_value_from(c_result)
     self.loop.operations.append(op)
     return op
示例#3
0
def get_float_tests(cpu):
    if not cpu.supports_floats:
        py.test.skip("requires float support from the backend")
    for opnum, args, rettype, retvalue in (
            list(_float_binary_operations()) +
            list(_float_comparison_operations()) +
            list(_float_unary_operations())):
        boxargs = []
        for x in args:
            if isinstance(x, float):
                boxargs.append(boxfloat(x))
            else:
                boxargs.append(InputArgInt(x))
        yield opnum, boxargs, rettype, retvalue
        if len(args) > 1:
            assert len(args) == 2
            yield opnum, [boxargs[0], wrap_constant(boxargs[1].getvalue())], rettype, retvalue
            yield opnum, [wrap_constant(boxargs[0].getvalue()), boxargs[1]], rettype, retvalue
            if (isinstance(args[0], float) and
                isinstance(args[1], float) and
                args[0] == args[1]):
                commonbox = boxfloat(args[0])
                yield opnum, [commonbox, commonbox], rettype, retvalue
示例#4
0
 def do(self, opnum, argboxes, descr=None):
     self.fakemetainterp._got_exc = None
     op = ResOperation(opnum, argboxes, descr)
     if opnum != rop.ZERO_PTR_FIELD:
         result = _execute_arglist(self.cpu, self.fakemetainterp,
                                   opnum, argboxes, descr)
         if result is not None:
             c_result = wrap_constant(result)
             op.copy_value_from(c_result)
     else:
         import ctypes
         addr = self.cpu.cast_gcref_to_int(argboxes[0].getref_base())
         offset = argboxes[1].getint()
         assert (offset % ctypes.sizeof(ctypes.c_long)) == 0
         ptr = ctypes.cast(addr, ctypes.POINTER(ctypes.c_long))
         ptr[offset / ctypes.sizeof(ctypes.c_long)] = 0
     self.loop.operations.append(op)
     return op