comparison python/zcc.py @ 104:ed230e947dc6

Added hexviewer
author windel
date Sun, 30 Dec 2012 22:31:55 +0100
parents
children 6a303f835c6d
comparison
equal deleted inserted replaced
103:28a35161ef23 104:ed230e947dc6
1 #!/usr/bin/python
2
3 import sys, os, argparse
4 from ppci.compilers import KsCompiler
5 from ppci.core import BitcodeWriter
6
7 if __name__ == '__main__':
8 parser = argparse.ArgumentParser(description='K# to bitcode compiler')
9 parser.add_argument('source', type=str, help='the source file to build')
10 args = parser.parse_args()
11
12 print(args)
13 try:
14 with open(args.source, 'r') as f:
15 src = f.read()
16 except IOError:
17 print('Failed to load {0}'.format(args.project))
18 sys.exit(3)
19 c = KsCompiler()
20 module = c.compilesource(src)
21
22 with open('sjaak.bc', 'wb') as f:
23 BitcodeWriter().WriteModuleToFile(module, f)
24
25
26