def test_llop_fold(): assert llop.int_add(lltype.Signed, 10, 2) == 12 assert llop.int_add(lltype.Signed, -6, -7) == -13 S1 = lltype.GcStruct('S1', ('x', lltype.Signed), hints={'immutable': True}) s1 = lltype.malloc(S1) s1.x = 123 assert llop.getfield(lltype.Signed, s1, 'x') == 123 S2 = lltype.GcStruct('S2', ('x', lltype.Signed)) s2 = lltype.malloc(S2) s2.x = 123 py.test.raises(TypeError, "llop.getfield(lltype.Signed, s2, 'x')")
def llf(x, y): return llop.int_add(lltype.Signed, x, y)
def f(x): i = llop.int_invert(lltype.Signed, x) i = llop.int_add(lltype.Signed, x, 1) return llop.int_neg(lltype.Signed, i)