示例#1
0
 def write_boxes(virtualizable, boxes):
     virtualizable = cast_gcref_to_vtype(virtualizable)
     i = 0
     for FIELDTYPE, fieldname in unroll_static_fields:
         x = unwrap(FIELDTYPE, boxes[i])
         setattr(virtualizable, fieldname, x)
         i = i + 1
     for ARRAYITEMTYPE, fieldname in unroll_array_fields:
         lst = getattr(virtualizable, fieldname)
         for j in range(len(lst)):
             lst[j] = unwrap(ARRAYITEMTYPE, boxes[i])
             i = i + 1
     assert len(boxes) == i + 1
示例#2
0
 def write_boxes(virtualizable, boxes):
     virtualizable = cast_gcref_to_vtype(virtualizable)
     i = 0
     for FIELDTYPE, fieldname in unroll_static_fields:
         x = unwrap(FIELDTYPE, boxes[i])
         setattr(virtualizable, fieldname, x)
         i = i + 1
     for ARRAYITEMTYPE, fieldname in unroll_array_fields:
         lst = getattr(virtualizable, fieldname)
         for j in range(getlength(lst)):
             x = unwrap(ARRAYITEMTYPE, boxes[i])
             setarrayitem(lst, j, x)
             i = i + 1
     assert len(boxes) == i + 1
示例#3
0
 def check_boxes(virtualizable, boxes):
     virtualizable = cast_gcref_to_vtype(virtualizable)
     # for debugging
     i = 0
     for FIELDTYPE, fieldname in unroll_static_fields:
         x = unwrap(FIELDTYPE, boxes[i])
         assert getattr(virtualizable, fieldname) == x
         i = i + 1
     for ARRAYITEMTYPE, fieldname in unroll_array_fields:
         lst = getattr(virtualizable, fieldname)
         for j in range(len(lst)):
             assert lst[j] == unwrap(ARRAYITEMTYPE, boxes[i])
             i = i + 1
     assert len(boxes) == i + 1
示例#4
0
def test_unwrap():
    S = lltype.GcStruct('S')
    RS = lltype.Struct('S')
    p = lltype.malloc(S)
    po = lltype.cast_opaque_ptr(llmemory.GCREF, p)
    assert unwrap(lltype.Void, InputArgInt(42)) is None
    assert unwrap(lltype.Signed, InputArgInt(42)) == 42
    assert unwrap(lltype.Char, InputArgInt(42)) == chr(42)
    assert unwrap(lltype.Float, boxfloat(42.5)) == 42.5
    assert unwrap(lltype.Ptr(S), InputArgRef(po)) == p
    assert unwrap(lltype.Ptr(RS), InputArgInt(0)) == lltype.nullptr(RS)
示例#5
0
def test_unwrap():
    S = lltype.GcStruct('S')
    RS = lltype.Struct('S')
    p = lltype.malloc(S)
    po = lltype.cast_opaque_ptr(llmemory.GCREF, p)
    assert unwrap(lltype.Void, BoxInt(42)) is None
    assert unwrap(lltype.Signed, BoxInt(42)) == 42
    assert unwrap(lltype.Char, BoxInt(42)) == chr(42)
    assert unwrap(lltype.Float, boxfloat(42.5)) == 42.5
    assert unwrap(lltype.Ptr(S), BoxPtr(po)) == p
    assert unwrap(lltype.Ptr(RS), BoxInt(0)) == lltype.nullptr(RS)
示例#6
0
 def setfield(objbox, valuebox):
     obj = objbox.getref(TYPE)
     value = unwrap(T, valuebox)
     setattr(obj, fieldname, value)
示例#7
0
 def setarrayitem(arraybox, ibox, valuebox):
     array = arraybox.getref(ARRAY)
     i = ibox.getint()
     value = unwrap(TYPE, valuebox)
     array.ll_setitem_fast(i, value)
示例#8
0
文件: runner.py 项目: sota/pypy
 def setfield(objbox, valuebox):
     obj = objbox.getref(TYPE)
     value = unwrap(T, valuebox)
     setattr(obj, fieldname, value)
示例#9
0
文件: runner.py 项目: sota/pypy
 def setarrayitem(arraybox, ibox, valuebox):
     array = arraybox.getref(ARRAY)
     i = ibox.getint()
     value = unwrap(TYPE, valuebox)
     array.ll_setitem_fast(i, value)