from  compyler.codeObjectAssembler import codeObjectAssembler
from pyasm.x86cpToCoff import CpToCoff
from pyasm.x86asm import manglePythonNames

testMod = """
a = 1
b = 2
print "I am awesome"
print "No I'm not"
#print a + b


def foo(a):
    print a

class bar:
    def baz(self,a):
        print a
        

foo("This is the ultimate module")

"""

co = compile(testMod,"","exec")
coa = codeObjectAssembler()

assem = coa.assembleCodeObject(co,name="module:testmod")
manglePythonNames(assem)

coff = CpToCoff(assem,"-defaultlib:LIBC -defaultlib:OLDNAMES ").makeReleaseCoff()
f = file("testmod.obj","wb")
coff.WriteToFile(f)
f.close()
