From b6258d36b6534d521e9cdf1307665c38e5ae409d Mon Sep 17 00:00:00 2001 From: Melody Horn Date: Thu, 5 Nov 2020 01:27:58 -0700 Subject: compile based on the fancy new AST --- tests/test_hello_world.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/test_hello_world.py b/tests/test_hello_world.py index 594ab4f..0377392 100644 --- a/tests/test_hello_world.py +++ b/tests/test_hello_world.py @@ -1,12 +1,12 @@ import unittest -from crowbar_reference_compiler import compile_to_ssa, parse_header, parse_implementation, scan +from crowbar_reference_compiler import build_ast, build_ssa, parse_header, parse_implementation, scan class TestHelloWorld(unittest.TestCase): def test_ssa(self): code = r""" -include "stdio.hro"; +//include "stdio.hro"; int32 main() { printf("Hello, world!\n"); @@ -15,14 +15,17 @@ int32 main() { """ tokens = scan(code) parse_tree = parse_implementation(tokens) - actual_ssa = compile_to_ssa(parse_tree) + ast = build_ast(parse_tree, []) + actual_ssa = build_ssa(ast) expected_ssa = r""" data $data0 = { b "Hello, world!\n", b 0 } export function w $main() { @start - call $printf(l $data0, ...) - ret 0 + %t0 =l copy $data0 + call $printf(l %t0, ...) + %t1 =w copy 0 + ret %t1 } """.strip() self.assertEqual(expected_ssa, actual_ssa) -- cgit v1.2.3