Exemplo n.º 1
0
def test_disable_logic():
    def f(x, y):
        return x + y

    t = Translation(f, [int, int])
    t.disable(['backendopt'])
    t.source_c()

    assert 'backendopt' not in t.driver.done
Exemplo n.º 2
0
def test_disable_logic():

    def f(x,y):
        return x+y

    t = Translation(f, [int, int])
    t.disable(['backendopt'])
    t.source_c()

    assert 'backendopt' not in t.driver.done
Exemplo n.º 3
0
def test_simple_source():
    def f(x, y):
        return x,y

    t = Translation(f, [int, int], backend='c')
    t.annotate()
    t.source()
    assert 'source_c' in t.driver.done

    t = Translation(f, [int, int])
    t.source_c()
    assert 'source_c' in t.driver.done

    t = Translation(f, [int, int])
    py.test.raises(Exception, "t.source()")
Exemplo n.º 4
0
def test_simple_source():
    def f(x, y):
        return x,y

    t = Translation(f, [int, int], backend='c')
    t.annotate()
    t.source()
    assert 'source_c' in t.driver.done

    t = Translation(f, [int, int])
    t.source_c()
    assert 'source_c' in t.driver.done

    t = Translation(f, [int, int])
    py.test.raises(Exception, "t.source()")
Exemplo n.º 5
0
def get_generated_c_source(fn, types):
    """Return the generated C source for fn."""
    t = Translation(fn, types, backend="c")
    t.annotate()
    merge_if_blocks(t.driver.translator.graphs[0])
    c_filename_path = t.source_c()
    return t.driver.cbuilder.c_source_filename.join('..',
                              'rpython_translator_c_test.c').read()
Exemplo n.º 6
0
def get_generated_c_source(fn, types):
    """Return the generated C source for fn."""
    t = Translation(fn, types, backend="c")
    t.annotate()
    merge_if_blocks(t.driver.translator.graphs[0])
    c_filename_path = t.source_c()
    return t.driver.cbuilder.c_source_filename.join(
        '..', 'rpython_translator_c_test.c').read()
Exemplo n.º 7
0
def test_inhibit_tail_call():
    def foobar_fn(n):
        return 42
    foobar_fn._dont_inline_ = True
    def main(n):
        return foobar_fn(n)
    #
    t = Translation(main, [int], backend="c")
    t.rtype()
    t.context._graphof(foobar_fn).inhibit_tail_call = True
    t.source_c()
    lines = t.driver.cbuilder.c_source_filename.join('..',
                              'rpython_translator_c_test_test_genc.c').readlines()
    for i, line in enumerate(lines):
        if '= pypy_g_foobar_fn' in line:
            break
    else:
        assert 0, "the call was not found in the C source"
    assert 'PYPY_INHIBIT_TAIL_CALL();' in lines[i+1]