diff python/testc3.py @ 157:8f3924b6076e

Added some code generator things
author Windel Bouwman
date Sun, 03 Mar 2013 18:14:35 +0100
parents b28a11c01dbe
children 9683a4cd848f
line wrap: on
line diff
--- a/python/testc3.py	Sun Mar 03 15:50:34 2013 +0100
+++ b/python/testc3.py	Sun Mar 03 18:14:35 2013 +0100
@@ -1,4 +1,4 @@
-import c3, time, ppci
+import c3, time, ppci, x86
 
 testsrc = """
 package test;
@@ -16,20 +16,24 @@
     var int zero = i - 2;
     if (i > 1)
     {
-       buf = b + 22 * i - 13 + (55 * 2 *9-2) / 44 - 1
+       buf = b + 22 * i - 13 + (55 * 2 *9-2) / 44 - 1;
     }
     else
     {
       ;;;
-    };
+    }
 
     t2(2, 3);
 }
 
 function int t2(u32 a, u32 b)
 {
+   if (a > 0)
+   {
+      a = 2 + t2(a - 1);
+   }
+
    return a + b;
-   a = 2;// + t2(2);
 }
 
 var int hahaa = 23 * 2;
@@ -57,6 +61,7 @@
    tc = c3.TypeChecker(diag)
    al = c3.Analyzer(diag)
    cg = c3.CodeGenerator()
+   x86gen = x86.X86CodeGen(diag)
    t1 = time.time()
    p.parseSource(src)
    t2 = time.time() 
@@ -77,8 +82,10 @@
    if ok:
       print('Generating code')
       i = cg.gencode(sema.mod)
+
       print(i)
       print(i.Globals)
+      x86gen.genBin(i)
    else:
       print('Not generating code')