diff python/zcc.py @ 288:a747a45dcd78

Various styling work
author Windel Bouwman
date Thu, 21 Nov 2013 14:26:13 +0100
parents 1c7c1e619be8
children bd2593de3ff8
line wrap: on
line diff
--- a/python/zcc.py	Thu Nov 21 11:57:27 2013 +0100
+++ b/python/zcc.py	Thu Nov 21 14:26:13 2013 +0100
@@ -36,7 +36,8 @@
 parser.add_argument('--hexfile', help='Output hexfile', type=argparse.FileType('w'))
 parser.add_argument('--log', help='Log level (INFO,DEBUG)', type=logLevel)
 
-def zcc(srcs, outs, diag, dumpir=False, do_optimize=False):
+
+def zcc(srcs, imps, outs, diag, dumpir=False):
     """
         Compile sources into output stream.
         Sources is an iterable of open files.
@@ -44,32 +45,31 @@
     logging.info('Zcc started')
     # Front end:
     c3b = c3.Builder(diag)
-    imps = []
     for ircode in c3b.build(srcs, imps):
-        print(ircode)
         if not ircode:
             return
 
         # Optimization passes:
-        if do_optimize:
-            optimize(ircode)
-
+        optimize(ircode)
+        
         if dumpir:
             ircode.dump()
 
+        # TODO select target here!
         # Code generation:
-        cg = codegenarm.ArmCodeGenerator(outs)
-        obj = cg.generate(ircode)
-    return True
+        codegenarm.ArmCodeGenerator(outs).generate(ircode)
+    return c3b.ok
+
 
 def main(args):
     logging.basicConfig(format=logformat, level=args.log)
     src = args.source
+    imps = getattr(args, 'import')
     diag = ppci.DiagnosticsManager()
     outs = outstream.TextOutputStream()
 
     # Invoke compiler:
-    res = zcc(src, outs, diag, dumpir=args.dumpir, do_optimize=args.optimize)
+    res = zcc(src, imps, outs, diag, dumpir=args.dumpir)
     if not res:
         diag.printErrors(src)
         return 1
@@ -90,8 +90,7 @@
         hf.save(args.hexfile)
     return 0
 
+
 if __name__ == '__main__':
     arguments = parser.parse_args()
-    print(arguments)
     sys.exit(main(arguments))
-