diff python/testc3.py @ 158:9683a4cd848f

Added some functions for code generation
author Windel Bouwman
date Fri, 08 Mar 2013 16:52:44 +0100
parents 8f3924b6076e
children 10330be89bc2
line wrap: on
line diff
--- a/python/testc3.py	Sun Mar 03 18:14:35 2013 +0100
+++ b/python/testc3.py	Fri Mar 08 16:52:44 2013 +0100
@@ -1,4 +1,5 @@
-import c3, time, ppci, x86
+import c3
+import time, ppci, x86, ir
 
 testsrc = """
 package test;
@@ -62,14 +63,8 @@
    al = c3.Analyzer(diag)
    cg = c3.CodeGenerator()
    x86gen = x86.X86CodeGen(diag)
-   t1 = time.time()
    p.parseSource(src)
-   t2 = time.time() 
-   print('parsetime: {0} [s]'.format(t2 - t1))
-   t2 = time.time() 
    tc.checkPackage(sema.mod)
-   t3 = time.time() 
-   print('checktime: {0} [s]'.format(t3 - t2))
    print('{0} errors'.format(len(diag.diags)))
 
    for d in diag.diags:
@@ -80,12 +75,18 @@
 
    ok = len(diag.diags) == 0
    if ok:
-      print('Generating code')
+      print('Generating ir-code')
       i = cg.gencode(sema.mod)
+      #ir.printIr(i)
+
+      print('generating x86 code')
 
-      print(i)
-      print(i.Globals)
       x86gen.genBin(i)
+
+      with open('dummydummy.asm', 'w') as f:
+         f.write('bits 64\n')
+         for a in x86gen.asm:
+            f.write(str(a) + '\n')
    else:
       print('Not generating code')