예제 #1
0
    def do(self, src, imports=None):
        mod = python_to_ir(io.StringIO(src), imports=imports)
        f = io.StringIO()
        irutils.print_module(mod, file=f)

        # Round trip test:
        irutils.read_module(io.StringIO(f.getvalue()))
예제 #2
0
from ppci.lang.python import python_to_ir
from ppci.irutils import verify_module, print_module
from ppci.api import ir_to_object, link, cc, objcopy
from ppci.utils.reporting import HtmlReportGenerator

# logging.basicConfig(level=logging.INFO)


def puts(txt: str):
    pass


with open('mandelbrot_compilation_report.html',
          'w') as f, HtmlReportGenerator(f) as reporter:
    with open('mandelbrot.py', 'r') as f:
        mod = python_to_ir(f, imports={'puts': puts})

    with open('mandelbrot.py', 'r') as f:
        src = list(f)

    reporter.annotate_source(src, mod)

verify_module(mod)
# print_module(mod)

obj_py = ir_to_object([mod], 'x86_64')
# print(obj_py)

c_glue = """

void mandelbrot();
예제 #3
0
 def test_snippet2(self):
     imports = {'myprint': (None, (int, ))}
     mod = python_to_ir(io.StringIO(src2), imports=imports)
     f = io.StringIO()
     irutils.print_module(mod, file=f)
예제 #4
0
 def test_snippet3(self):
     python_to_ir(io.StringIO(src3))
예제 #5
0
 def test_snippet1(self):
     python_to_ir(io.StringIO(src1))