# HG changeset patch # User Windel Bouwman # Date 1374591002 -7200 # Node ID ef683881c64e1f7ff10532df48e6a2c374aea390 # Parent c9496541868432c7823e4fd8c4e3068d9e84c1f0 Remove various files diff -r c94965418684 -r ef683881c64e python/bouncing_cube.py --- a/python/bouncing_cube.py Mon Jul 22 22:56:51 2013 +0200 +++ b/python/bouncing_cube.py Tue Jul 23 16:50:02 2013 +0200 @@ -298,7 +298,7 @@ state = newstate t += dt - print state[6,0], t, ' ', (t/endtime)*100.0, '%' + print(state[6,0], t, ' ', (t/endtime)*100.0, '%') return states @@ -394,11 +394,11 @@ et = 20.0 dt = 0.04 -print 'starting integration... endtime =', et, ' stepsize =', dt +print('starting integration... endtime =', et, ' stepsize =', dt) t0 = time.time() states = simulate(et, dt) t1 = time.time() -print 'That was heavy, it took me ', t1-t0, ' seconds!' +print('That was heavy, it took me ', t1-t0, ' seconds!') app = QApplication(sys.argv) w = W(states, dt) w.show() diff -r c94965418684 -r ef683881c64e python/codegenarm.py --- a/python/codegenarm.py Mon Jul 22 22:56:51 2013 +0200 +++ b/python/codegenarm.py Tue Jul 23 16:50:02 2013 +0200 @@ -88,7 +88,6 @@ self.imms.append((lname, ins.value)) self.emit(arm.str_sprel(arm.r0, arm.MemSpRel(self.addStack(ins.target)))) elif type(ins) is ir.Store: - print('STORE', ins, self.localVars) # Load value in r0: self.loadStack(arm.r0, ins.value) # store in memory: @@ -96,7 +95,7 @@ #self.getGlobal(arm.r1, ins.location) # Horrible hack with localVars if ins.location in self.localVars: - print('local', ins.location) + # The value was alloc'ed self.emit(arm.str_sprel(arm.r0, arm.MemSpRel(self.getStack(ins.location)))) else: self.loadStack(arm.r1, ins.location) diff -r c94965418684 -r ef683881c64e python/elffile.py --- a/python/elffile.py Mon Jul 22 22:56:51 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -import struct -import collections - -class ElfFile: - def __init__(self, f): - self.f = f - self.parse() - def parse(self): - self.parseHeader() - @property - def ElfClass(self): - return classes[self.ei_class] - def parseHeader(self): - # Parse identifier - e_ident = self.f.read(16) - ELFMAGIC = bytes([0x7f]) + b'ELF' - assert e_ident[0:4] == ELFMAGIC - self.ei_class = e_ident[4] - # Change the class of this object in some strange way: - self.__class__ = classes[self.ei_class] - print('ELF class: ', self.ElfClass) - assert self.ei_class in classes.keys() - self.ei_data = e_ident[5] - print('ei_data:', self.ei_data) - ei_version = e_ident[6] - assert ei_version == 1 - - # rest of the ELF header: - e_type = self.readHalf() - e_machine = self.readHalf() - e_version = self.readWord() - e_entry = self.readAddr() - self.e_phoff = self.readOff() - self.e_shoff = self.readOff() - self.e_flags = self.readWord() - e_ehsize = self.readHalf() - self.e_phentsize = self.readHalf() - self.e_phnum = self.readHalf() - self.e_shentsize = self.readHalf() - self.e_shnum = self.readHalf() - self.e_shstrndx = self.readHalf() - - assert e_ehsize == self.HEADERSIZE - print('program header size', self.e_phentsize, self.e_phnum) - print('section header size', self.e_shentsize, self.e_shnum) - print('string index:', self.e_shstrndx) - def readFmt(self, fmt): - size = struct.calcsize(fmt) - return struct.unpack(fmt, self.f.read(size)) - def readHalf(self): - return self.readFmt('= base do - d := d * base - end; - while d <> 0 do - dgt := num div d; - num := num mod d; - d := d div base; - putchar(48 + dgt) - end - end WriteNum; - - begin - a := 1; - while a < 26 - do - putchar(65+a); - a := a * 2 - end; - end lcfos. - """ - pc = Compiler() - pc.compilesource(source) - def testSource2(self): - source = """ - module lcfos; - var - a, b : integer; - arr: array 30 of integer; - arr2: array 10, 12 of integer; - procedure t2*() : integer; - begin - a := 2; - while a < 5 do - b := arr[a-1] + arr[a-2]; - arr2[a,2] := b; - arr2[a,3] := arr2[a,2] + arr2[a,2]*3 + b; - arr[a] := b; - a := a + 1; - end; - return b - end t2; - begin - b := 12; - arr[0] := 1; - arr[1] := 1; - end lcfos. - """ - pc = Compiler() - mod = pc.compilesource(source) - def testSource5(self): - source = """ - module lcfos; - procedure WriteLn() : integer; - const zzz = 13; - var - a, b, c: integer; - begin - a := 2; - b := 7; - c := 10 * a + b*10*a; - return c - end WriteLn; - begin end lcfos. - """ - pc = Compiler() - pc.compilesource(source) - def tstForStatement(self): - source = """ - module fortest; - var - a,b,c : integer; - begin - c := 0; - for a := 1 to 10 by 1 do - b := a + 15; - c := c + b * a; - end; - end fortest. - """ - pc = Compiler() - pc.compilesource(source) - def testSourceIfAndWhilePattern(self): - source = """ - module lcfos; - procedure WriteLn() : integer; - const zzz = 13; - var - a, b, c: integer; - begin - a := 1; - b := 2; - if a * 3 > b then - c := 10*a + b*10*a*a*a*b; - else - c := 13; - end; - while a < 101 do - a := a + 1; - c := c + 2; - end; - return c - end WriteLn; - begin end lcfos. - """ - pc = Compiler() - pc.compilesource(source) - - def testPattern1(self): - """ Test if expression can be compiled into byte code """ - src = "12*13+33-12*2*3" - tokens = lexer.tokenize(src) - ast = Parser(tokens).parseExpression() - code = CodeGenerator().genexprcode(ast) - - def testProject(self): - p = Project('test.xml', isnew=True) - p.name = "Test project" - p.files.append('main.mod') - p.files.append('test.mod') - p.save('test.xml') - - q = Project('test.xml') - - assert(p.name == q.name) - assert(p.files == q.files) - # TODO: remove test.xml test file - os.remove('test.xml') - -if __name__ == '__main__': - unittest.main() - diff -r c94965418684 -r ef683881c64e python/testc3.py --- a/python/testc3.py Mon Jul 22 22:56:51 2013 +0200 +++ b/python/testc3.py Tue Jul 23 16:50:02 2013 +0200 @@ -487,6 +487,6 @@ self.assertEqual(1, len(ircode.Functions)) if __name__ == '__main__': - unittest.main() + unittest.main() diff -r c94965418684 -r ef683881c64e python/testcg.py --- a/python/testcg.py Mon Jul 22 22:56:51 2013 +0200 +++ b/python/testcg.py Tue Jul 23 16:50:02 2013 +0200 @@ -25,6 +25,7 @@ obj = self.cg.generate(m) self.assertTrue(obj) + class testArmCodeGeneration(unittest.TestCase): def testStack(self): s = outstream.OutputStream() @@ -37,7 +38,8 @@ bb.addInstruction(ir.Store(v, v2)) m.check() cg.generate(m) - s.dump() + #s.dump() if __name__ == '__main__': unittest.main() + diff -r c94965418684 -r ef683881c64e python/testir.py --- a/python/testir.py Mon Jul 22 22:56:51 2013 +0200 +++ b/python/testir.py Tue Jul 23 16:50:02 2013 +0200 @@ -93,10 +93,14 @@ cgenx86 = x86.X86CodeGenSimple(diag) ir = builder.build(testsrc) diag.printErrors(testsrc) - #ir.dump() + ir.dump() + ir.check() cf = transform.ConstantFolder() + ir.check() dcd = transform.DeadCodeDeleter() + ir.check() m2r = transform.Mem2RegPromotor() + ir.check() clr = transform.CleanPass() ir.check() cf.run(ir)