view python/zcc.py @ 104:ed230e947dc6

Added hexviewer
author windel
date Sun, 30 Dec 2012 22:31:55 +0100
parents
children 6a303f835c6d
line wrap: on
line source

#!/usr/bin/python

import sys, os, argparse
from ppci.compilers import KsCompiler
from ppci.core import BitcodeWriter

if __name__ == '__main__':
   parser = argparse.ArgumentParser(description='K# to bitcode compiler')
   parser.add_argument('source', type=str, help='the source file to build')
   args = parser.parse_args()

   print(args)
   try:
      with open(args.source, 'r') as f:
         src = f.read()
   except IOError:
      print('Failed to load {0}'.format(args.project))
      sys.exit(3)
   c = KsCompiler()
   module = c.compilesource(src)

   with open('sjaak.bc', 'wb') as f:
      BitcodeWriter().WriteModuleToFile(module, f)