comparison python/c3/codegenerator.py @ 172:5a7d37d615ee

Added function to IR
author Windel Bouwman
date Thu, 04 Apr 2013 17:58:37 +0200
parents 3eb9b9e2958d
children 3eb06f5fb987
comparison
equal deleted inserted replaced
171:3eb9b9e2958d 172:5a7d37d615ee
18 if type(s) is astnodes.Variable: 18 if type(s) is astnodes.Variable:
19 # TODO 19 # TODO
20 pass 20 pass
21 elif type(s) is astnodes.Function: 21 elif type(s) is astnodes.Function:
22 # TODO: handle arguments 22 # TODO: handle arguments
23 # TODO handle return? 23 f = self.builder.newFunc(s.name)
24 self.builder.setFunc(f)
24 bb = self.builder.newBB() 25 bb = self.builder.newBB()
26 f.entry = bb
25 self.builder.setBB(bb) 27 self.builder.setBB(bb)
26 self.genCode(s.body) 28 self.genCode(s.body)
29 # TODO handle return?
27 self.builder.addIns(ir.Return()) 30 self.builder.addIns(ir.Return())
31 self.builder.setFunc(None)
28 else: 32 else:
29 print(s) 33 print(s)
30 34
31 def genCode(self, code): 35 def genCode(self, code):
32 if type(code) is astnodes.CompoundStatement: 36 if type(code) is astnodes.CompoundStatement: