当前位置: 首页>>代码示例>>Python>>正文


Python longlong.getfloatstorage函数代码示例

本文整理汇总了Python中pypy.jit.codewriter.longlong.getfloatstorage函数的典型用法代码示例。如果您正苦于以下问题:Python getfloatstorage函数的具体用法?Python getfloatstorage怎么用?Python getfloatstorage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getfloatstorage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_execute_varargs

def test_execute_varargs():
    cpu = FakeCPU()
    descr = FakeCallDescr()
    argboxes = [BoxInt(99999), BoxInt(321), constfloat(2.25), ConstInt(123),
                BoxPtr(), boxfloat(5.5)]
    box = execute_varargs(cpu, FakeMetaInterp(), rop.CALL, argboxes, descr)
    assert box.getfloat() == 42.5
    assert cpu.fakecalled == (99999, descr, [321, 123],
                              [ConstPtr.value],
                              [longlong.getfloatstorage(2.25),
                               longlong.getfloatstorage(5.5)])
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:11,代码来源:test_executor.py

示例2: test_call_stubs

def test_call_stubs():
    c0 = GcCache(False)
    ARGS = [lltype.Char, lltype.Signed]
    RES = lltype.Char
    descr1 = get_call_descr(c0, ARGS, RES)
    def f(a, b):
        return 'c'

    call_stub = descr1.call_stub
    fnptr = llhelper(lltype.Ptr(lltype.FuncType(ARGS, RES)), f)

    res = call_stub(rffi.cast(lltype.Signed, fnptr), [1, 2], None, None)
    assert res == ord('c')

    ARRAY = lltype.GcArray(lltype.Signed)
    ARGS = [lltype.Float, lltype.Ptr(ARRAY)]
    RES = lltype.Float

    def f(a, b):
        return float(b[0]) + a

    fnptr = llhelper(lltype.Ptr(lltype.FuncType(ARGS, RES)), f)
    descr2 = get_call_descr(c0, ARGS, RES)
    a = lltype.malloc(ARRAY, 3)
    opaquea = lltype.cast_opaque_ptr(llmemory.GCREF, a)
    a[0] = 1
    res = descr2.call_stub(rffi.cast(lltype.Signed, fnptr),
                           [], [opaquea], [longlong.getfloatstorage(3.5)])
    assert longlong.getrealfloat(res) == 4.5
开发者ID:ieure,项目名称:pypy,代码行数:29,代码来源:test_descr.py

示例3: callback

 def callback(asm):
     c = ConstFloat(longlong.getfloatstorage(-42.5))
     loc = self.xrm.convert_to_imm(c)
     asm.mov(loc, xmm5)
     asm.regalloc_push(xmm5)
     asm.regalloc_pop(xmm0)
     asm.mc.CVTTSD2SI(eax, xmm0)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:7,代码来源:test_assembler.py

示例4: test_ResumeDataLoopMemo_other

def test_ResumeDataLoopMemo_other():
    memo = ResumeDataLoopMemo(FakeMetaInterpStaticData())
    const = ConstFloat(longlong.getfloatstorage(-1.0))
    tagged = memo.getconst(const)
    index, tagbits = untag(tagged)
    assert tagbits == TAGCONST
    assert memo.consts[index] is const
开发者ID:ieure,项目名称:pypy,代码行数:7,代码来源:test_resume.py

示例5: wrap

def wrap(cpu, value, in_const_box=False):
    if isinstance(lltype.typeOf(value), lltype.Ptr):
        if lltype.typeOf(value).TO._gckind == 'gc':
            value = lltype.cast_opaque_ptr(llmemory.GCREF, value)
            if in_const_box:
                return history.ConstPtr(value)
            else:
                return history.BoxPtr(value)
        else:
            adr = llmemory.cast_ptr_to_adr(value)
            value = heaptracker.adr2int(adr)
            # fall through to the end of the function
    elif isinstance(lltype.typeOf(value), ootype.OOType):
        value = ootype.cast_to_object(value)
        if in_const_box:
            return history.ConstObj(value)
        else:
            return history.BoxObj(value)
    elif isinstance(value, float):
        value = longlong.getfloatstorage(value)
        if in_const_box:
            return history.ConstFloat(value)
        else:
            return history.BoxFloat(value)
    elif isinstance(value, str) or isinstance(value, unicode):
        assert len(value) == 1     # must be a character
        value = ord(value)
    else:
        value = intmask(value)
    if in_const_box:
        return history.ConstInt(value)
    else:
        return history.BoxInt(value)
开发者ID:ieure,项目名称:pypy,代码行数:33,代码来源:warmstate.py

示例6: test_assemble_float_consts

def test_assemble_float_consts():
    ssarepr = SSARepr("test")
    ssarepr.insns = [
        ('float_return', Register('float', 13)),
        ('float_return', Constant(18.0, lltype.Float)),
        ('float_return', Constant(-4.0, lltype.Float)),
        ('float_return', Constant(128.1, lltype.Float)),
        ]
    assembler = Assembler()
    jitcode = assembler.assemble(ssarepr)
    assert jitcode.code == ("\x00\x0D"
                            "\x00\xFF"
                            "\x00\xFE"
                            "\x00\xFD")
    assert assembler.insns == {'float_return/f': 0}
    assert jitcode.constants_f == [longlong.getfloatstorage(18.0),
                                   longlong.getfloatstorage(-4.0),
                                   longlong.getfloatstorage(128.1)]
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:18,代码来源:test_assembler.py

示例7: _prepare_args

 def _prepare_args(self, args, floats, ints):
     local_floats = list(floats)
     local_ints = list(ints)
     expected_result = 0.0
     for i in range(len(args)):
         x = args[i]
         if x[0] == 'f':
             x = local_floats.pop()
             t = longlong.getfloatstorage(x)
             self.cpu.set_future_value_float(i, t)
         else:
             x = local_ints.pop()
             self.cpu.set_future_value_int(i, x)
         expected_result += x
     return expected_result
开发者ID:ieure,项目名称:pypy,代码行数:15,代码来源:calling_convention_test.py

示例8: set_future_value

def set_future_value(cpu, j, value, typecode):
    if typecode == 'ref':
        refvalue = cpu.ts.cast_to_ref(value)
        cpu.set_future_value_ref(j, refvalue)
    elif typecode == 'int':
        intvalue = lltype.cast_primitive(lltype.Signed, value)
        cpu.set_future_value_int(j, intvalue)
    elif typecode == 'float':
        if lltype.typeOf(value) is lltype.Float:
            value = longlong.getfloatstorage(value)
        else:
            assert longlong.is_longlong(lltype.typeOf(value))
            value = rffi.cast(lltype.SignedLongLong, value)
        cpu.set_future_value_float(j, value)
    else:
        assert False
开发者ID:ieure,项目名称:pypy,代码行数:16,代码来源:warmstate.py

示例9: _prepare_args

 def _prepare_args(self, args, floats, ints):
     local_floats = list(floats)
     local_ints = list(ints)
     expected_result = 0.0
     arguments = []
     for i in range(len(args)):
         x = args[i]
         if x[0] == 'f':
             x = local_floats.pop()
             t = longlong.getfloatstorage(x)
             arguments.append(t)
         else:
             x = local_ints.pop()
             arguments.append(x)
         expected_result += x
     return arguments, expected_result
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:16,代码来源:calling_convention_test.py

示例10: emit_const

 def emit_const(self, const, kind, allow_short=False):
     value = const.value
     if kind == 'int':
         TYPE = const.concretetype
         if isinstance(TYPE, lltype.Ptr):
             assert TYPE.TO._gckind == 'raw'
             self.see_raw_object(value)
             value = llmemory.cast_ptr_to_adr(value)
             TYPE = llmemory.Address
         if TYPE == llmemory.Address:
             value = heaptracker.adr2int(value)
         if TYPE is lltype.SingleFloat:
             value = longlong.singlefloat2int(value)
         if not isinstance(value, (llmemory.AddressAsInt,
                                   ComputedIntSymbolic)):
             value = lltype.cast_primitive(lltype.Signed, value)
             if allow_short:
                 try:
                     short_num = -128 <= value <= 127
                 except TypeError:    # "Symbolics cannot be compared!"
                     short_num = False
                 if short_num:
                     # emit the constant as a small integer
                     self.code.append(chr(value & 0xFF))
                     return True
         constants = self.constants_i
     elif kind == 'ref':
         value = lltype.cast_opaque_ptr(llmemory.GCREF, value)
         constants = self.constants_r
     elif kind == 'float':
         if const.concretetype == lltype.Float:
             value = longlong.getfloatstorage(value)
         else:
             assert longlong.is_longlong(const.concretetype)
             value = rffi.cast(lltype.SignedLongLong, value)
         constants = self.constants_f
     else:
         raise AssemblerError('unimplemented %r in %r' %
                              (const, self.ssareprname))
     key = (kind, Constant(value))
     if key not in self.constants_dict:
         constants.append(value)
         self.constants_dict[key] = 256 - len(constants)
     # emit the constant normally, as one byte that is an index in the
     # list of constants
     self.code.append(chr(self.constants_dict[key]))
     return False
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:47,代码来源:assembler.py

示例11: test_make_set_future_values

def test_make_set_future_values():
    future_values = {}
    class FakeCPU:
        def set_future_value_int(self, j, value):
            future_values[j] = "int", value
        def set_future_value_float(self, j, value):
            future_values[j] = "float", value
    class FakeWarmRunnerDesc:
        cpu = FakeCPU()
        memory_manager = None
    class FakeJitDriverSD:
        _red_args_types = ["int", "float"]
        virtualizable_info = None
    #
    state = WarmEnterState(FakeWarmRunnerDesc(), FakeJitDriverSD())
    set_future_values = state.make_set_future_values()
    set_future_values(5, 42.5)
    assert future_values == {
        0: ("int", 5),
        1: ("float", longlong.getfloatstorage(42.5)),
    }
    assert set_future_values is state.make_set_future_values()
开发者ID:gorakhargosh,项目名称:pypy,代码行数:22,代码来源:test_warmstate.py

示例12: _run_with_blackhole

def _run_with_blackhole(testself, args):
    from pypy.jit.metainterp.blackhole import BlackholeInterpBuilder
    cw = testself.cw
    blackholeinterpbuilder = BlackholeInterpBuilder(cw)
    blackholeinterp = blackholeinterpbuilder.acquire_interp()
    count_i = count_r = count_f = 0
    for value in args:
        T = lltype.typeOf(value)
        if T == lltype.Signed:
            blackholeinterp.setarg_i(count_i, value)
            count_i += 1
        elif T == llmemory.GCREF:
            blackholeinterp.setarg_r(count_r, value)
            count_r += 1
        elif T == lltype.Float:
            value = longlong.getfloatstorage(value)
            blackholeinterp.setarg_f(count_f, value)
            count_f += 1
        else:
            raise TypeError(T)
    [jitdriver_sd] = cw.callcontrol.jitdrivers_sd
    blackholeinterp.setposition(jitdriver_sd.mainjitcode, 0)
    blackholeinterp.run()
    return blackholeinterp._final_result_anytype()
开发者ID:gorakhargosh,项目名称:pypy,代码行数:24,代码来源:support.py

示例13: test_functions

def test_functions():
    xll = longlong.getfloatstorage(3.5)
    assert longlong.getrealfloat(xll) == 3.5
    assert isinstance(longlong.gethash(xll), int)
开发者ID:ieure,项目名称:pypy,代码行数:4,代码来源:test_longlong.py

示例14: convert_to_floatstorage

 def convert_to_floatstorage(arg):
     from pypy.jit.codewriter import longlong
     return longlong.getfloatstorage(float(arg))
开发者ID:gorakhargosh,项目名称:pypy,代码行数:3,代码来源:oparser_model.py

示例15: test_functions

def test_functions():
    xll = longlong.getfloatstorage(3.5)
    assert longlong.getrealfloat(xll) == 3.5
    assert is_valid_int(longlong.gethash(xll))
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:4,代码来源:test_longlong.py


注:本文中的pypy.jit.codewriter.longlong.getfloatstorage函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。