Beispiel #1
0
 def f():
     s = lltype.malloc(S)
     s.x = 42
     llop.bare_setfield(lltype.Void, s0, void('next'), s)
     llop.gc_assume_young_pointers(lltype.Void,
                                   llmemory.cast_ptr_to_adr(s0))
     rgc.collect(0)
     return s0.next.x
Beispiel #2
0
def test_llop_with_voids_interp():
    from pypy.rpython.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
Beispiel #3
0
def test_llop_with_voids_interp():
    from pypy.rpython.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
Beispiel #4
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
Beispiel #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