示例#1
0
 def f():
     s = lltype.malloc(S)
     s.x = 42
     llop.bare_setfield(lltype.Void, s0, void('next'), s)
     llop.gc_writebarrier(lltype.Void, llmemory.cast_ptr_to_adr(s0))
     rgc.collect(0)
     return s0.next.x
示例#2
0
 def f():
     s = lltype.malloc(S)
     s.x = 42
     llop.bare_setfield(lltype.Void, s0, void('next'), s)
     llop.gc_writebarrier(lltype.Void, llmemory.cast_ptr_to_adr(s0))
     rgc.collect(0)
     return s0.next.x
示例#3
0
def test_llop_with_voids_interp():
    from rpython.rtyper.annlowlevel import LowLevelAnnotatorPolicy
    S = lltype.GcStruct('S', ('x', lltype.Signed), ('y', lltype.Signed))
    name_y = void('y')
    def llf():
        s = lltype.malloc(S)
        llop.bare_setfield(lltype.Void, s, void('x'), 3)
        llop.bare_setfield(lltype.Void, s, name_y, 2)
        return s.x + s.y
    res = interpret(llf, [], policy=LowLevelAnnotatorPolicy())
    assert res == 5
示例#4
0
def test_llop_with_voids_interp():
    from rpython.rtyper.annlowlevel import LowLevelAnnotatorPolicy
    S = lltype.GcStruct('S', ('x', lltype.Signed), ('y', lltype.Signed))
    name_y = void('y')

    def llf():
        s = lltype.malloc(S)
        llop.bare_setfield(lltype.Void, s, void('x'), 3)
        llop.bare_setfield(lltype.Void, s, name_y, 2)
        return s.x + s.y

    res = interpret(llf, [], policy=LowLevelAnnotatorPolicy())
    assert res == 5
示例#5
0
 def llf():
     s = lltype.malloc(S)
     llop.bare_setfield(lltype.Void, s, void('x'), 3)
     llop.bare_setfield(lltype.Void, s, name_y, 2)
     return s.x + s.y
示例#6
0
 def llf():
     s = lltype.malloc(S)
     llop.bare_setfield(lltype.Void, s, void('x'), 3)
     llop.bare_setfield(lltype.Void, s, name_y, 2)
     return s.x + s.y