Esempio n. 1
0
def test_typeOf_const(x):
    a = RPythonAnnotator()
    bk = a.bookkeeper
    rtyper = RPythonTyper(a)
    s_x = bk.immutablevalue(x)
    r_x = rtyper.getrepr(s_x)
    assert typeOf(r_x.convert_const(x)) == r_x.lowleveltype
Esempio n. 2
0
def test_typeOf_const(x):
    a = RPythonAnnotator()
    bk = a.bookkeeper
    rtyper = RPythonTyper(a)
    s_x = bk.immutablevalue(x)
    r_x = rtyper.getrepr(s_x)
    assert typeOf(r_x.convert_const(x)) == r_x.lowleveltype
Esempio n. 3
0
def test_ll_get_dict_item():
    """
    Tests the low-level implementation of get_dict_item.
    """
    from rpython.annotator.annrpython import RPythonAnnotator
    from rpython.annotator.model import SomeTuple, SomeInteger, SomeString

    from rpython.rtyper.rtyper import RPythonTyper
    from rpython.rtyper.rmodel import inputconst
    from rpython.rtyper.annlowlevel import llstr, hlstr

    from rpython.rtyper.lltypesystem import lltype, rffi
    from rpython.rtyper.lltypesystem import rordereddict, rstr

    dummykeyobj = None
    dummyvalueobj = None

    def _get_str_dict():
        # STR -> lltype.Signed
        DICT = rordereddict.get_ll_dict(
            lltype.Ptr(rstr.STR),
            lltype.Signed,
            ll_fasthash_function=rstr.LLHelpers.ll_strhash,
            ll_hash_function=rstr.LLHelpers.ll_strhash,
            ll_eq_function=rstr.LLHelpers.ll_streq,
            dummykeyobj=dummykeyobj,
            dummyvalueobj=dummyvalueobj)
        return DICT

    s_tuple = SomeTuple([SomeString(), SomeInteger()])
    DICT = _get_str_dict()

    ll_d = rordereddict.ll_newdict(DICT)
    a = RPythonAnnotator()
    rtyper = RPythonTyper(a)
    a.translator.rtyper = rtyper
    r_tuple = rtyper.getrepr(s_tuple)
    cTUPLE = inputconst(lltype.Void, r_tuple.lowleveltype)
    s_tuple = rtyper.annotation(cTUPLE)
    rtyper.call_all_setups()

    for i in range(20):
        rordereddict.ll_dict_setitem(ll_d, llstr(str(i)), i)
    for i in range(20):
        element = ll_get_dict_item(s_tuple.const, ll_d, i)
        assert (str(i), i) == (hlstr(element.item0), element.item1)
Esempio n. 4
0
def test_ll_get_dict_item():
    """
    Tests the low-level implementation of get_dict_item.
    """
    from rpython.annotator.annrpython import RPythonAnnotator
    from rpython.annotator.model import SomeTuple, SomeInteger, SomeString

    from rpython.rtyper.rtyper import RPythonTyper
    from rpython.rtyper.rmodel import inputconst
    from rpython.rtyper.annlowlevel import llstr, hlstr

    from rpython.rtyper.lltypesystem import lltype, rffi
    from rpython.rtyper.lltypesystem import rordereddict, rstr

    dummykeyobj = None
    dummyvalueobj = None

    def _get_str_dict():
        # STR -> lltype.Signed
        DICT = rordereddict.get_ll_dict(lltype.Ptr(rstr.STR), lltype.Signed,
                            ll_fasthash_function=rstr.LLHelpers.ll_strhash,
                            ll_hash_function=rstr.LLHelpers.ll_strhash,
                            ll_eq_function=rstr.LLHelpers.ll_streq,
                            dummykeyobj=dummykeyobj,
                            dummyvalueobj=dummyvalueobj)
        return DICT
    s_tuple = SomeTuple([SomeString(), SomeInteger()])
    DICT = _get_str_dict()

    ll_d = rordereddict.ll_newdict(DICT)
    a = RPythonAnnotator()
    rtyper = RPythonTyper(a)
    a.translator.rtyper = rtyper
    r_tuple = rtyper.getrepr(s_tuple)
    cTUPLE = inputconst(lltype.Void, r_tuple.lowleveltype)
    s_tuple = rtyper.annotation(cTUPLE)
    rtyper.call_all_setups()

    for i in range(20):
        rordereddict.ll_dict_setitem(ll_d, llstr(str(i)), i)
    for i in range(20):
        element = ll_get_dict_item(s_tuple.const, ll_d, i)
        assert (str(i), i) == (hlstr(element.item0), element.item1)