Example #1
0
def test_cast_instance_to_base_ptr():
    class A:
        def __init__(self, x, y):
            self.x = x
            self.y = y

    def f(x, y):
        a = A(x, y)
        a1 = cast_instance_to_base_ptr(a)
        return a1

    res = interpret(f, [5, 10])
    assert typeOf(res) == base_ptr_lltype()
    assert fishllattr(res, 'x') == 5
    assert fishllattr(res, 'y') == 10
Example #2
0
def test_cast_instance_to_base_ptr():
    class A:
        def __init__(self, x, y):
            self.x = x
            self.y = y

    def f(x, y):
        a = A(x, y)
        a1 = cast_instance_to_base_ptr(a)
        return a1

    res = interpret(f, [5, 10])
    assert typeOf(res) == base_ptr_lltype()
    assert fishllattr(res, 'x') == 5
    assert fishllattr(res, 'y') == 10
Example #3
0
def _inputvars(vars):
    newvars = []
    if not isinstance(vars, list):
        n = vars.ll_length()
        for i in range(n):
            v = vars.ll_getitem_fast(i)
            if not v:
                v = dummy_placeholder
            else:
                v = fishllattr(v, 'v', v)
            newvars.append(v)
    else:
        for v in vars:
            if not v:
                v = dummy_placeholder
            else:
                v = getattr(v, 'v', v)
            newvars.append(v)
    res = []
    for v1 in newvars:
        v = _from_opaque(v1)
        assert isinstance(v, (flowmodel.Constant, flowmodel.Variable))
        res.append(v)
    return res
Example #4
0
def _inputvars(vars):
    newvars = []
    if not isinstance(vars, list):
        n = vars.ll_length()
        for i in range(n):
            v = vars.ll_getitem_fast(i)
            if not v:
                v = dummy_placeholder
            else:
                v = fishllattr(v, 'v', v)
            newvars.append(v)
    else:
        for v in vars:
            if not v:
                v = dummy_placeholder
            else:
                v = getattr(v, 'v', v)
            newvars.append(v)
    res = []
    for v1 in newvars:
        v = _from_opaque(v1)
        assert isinstance(v, (flowmodel.Constant, flowmodel.Variable))
        res.append(v)
    return res
Example #5
0
 def reveal(gv):
     if hasattr(gv, 'v'):
         v = gv.v
     else:
         v = fishllattr(gv, 'v')
     return llimpl.reveal(v)
Example #6
0
 def reveal(gv):
     if hasattr(gv, 'v'):
         v = gv.v
     else:
         v = fishllattr(gv, 'v')
     return llimpl.reveal(v)