print 'finished register allocation' for fun in funs: fun.code = RemoveStructuredControl().preorder(fun.code) if debug: print 'finished removing structured control' for fun in funs: print PrintVisitor3().preorder(fun) x86 = GenX86Visitor3().preorder(Stmt(funs)) if debug: print 'finished generating x86' string_header = '' #gotta put strings at the top of the file! for (key, value) in string_constants.items(): string_header += str(key) +':\n' + '.string "' + str(value) + '"\n' asm_file = open(splitext(input_file_name)[0] + '.s', 'w') print >>asm_file, (string_header + '.globl %smain' % fun_prefix) + x86 except EOFError: print "Could not open file %s." % sys.argv[1] #except Exception, e: print e.args[0] exit(-1)
print 'finished removing structured control' for fun in funs: print PrintVisitor3().preorder(fun) x86 = GenX86Visitor3().preorder(Stmt(funs)) if debug: print 'finished generating x86' x86 = ('.globl %smain' % fun_prefix) + x86 if len(string_constants.keys()) > 0: if sys.platform == 'darwin': strings = '''\n\t.cstring\n''' else: strings = '' for (var,str) in string_constants.items(): if sys.platform == 'darwin': strings += ('''%s:\n\t.ascii "%s\\0"\n''' % (var, str)) else: strings += ('''\n%s:\n\t.string "%s"\n''' % (var, str)) else: strings = '' x86 = strings + '\t.text\n' + x86 asm_file = open(splitext(input_file_name)[0] + '.s', 'w') print >>asm_file, x86 except EOFError: print "Could not open file %s." % sys.argv[1] except Exception, e: print e.args[0] exit(-1)