comparison python/c3/semantics.py @ 167:0b5b2ee6b435

Added 2 unit tests
author Windel Bouwman
date Fri, 22 Mar 2013 17:40:13 +0100
parents 598d3888a11c
children ee0d30533dae
comparison
equal deleted inserted replaced
166:da0087b82fbe 167:0b5b2ee6b435
34 p.parameter = True 34 p.parameter = True
35 self.addSymbol(p) 35 self.addSymbol(p)
36 return p 36 return p
37 def actOnFuncDef2(self, parameters, returntype, body): 37 def actOnFuncDef2(self, parameters, returntype, body):
38 self.curFunc.body = body 38 self.curFunc.body = body
39 self.curFunc.typ = astnodes.FunctionType(parameters, returntype) 39 paramtypes = [p.typ for p in parameters]
40 self.curFunc.typ = astnodes.FunctionType(paramtypes, returntype)
40 self.curFunc = None 41 self.curFunc = None
41 self.curScope = self.curScope.parent 42 self.curScope = self.curScope.parent
42 def actOnType(self, tok): 43 def actOnType(self, tok):
43 # Try to lookup type, in case of failure return void 44 # Try to lookup type, in case of failure return void
44 pass 45 pass
61 return vu 62 return vu
62 def actOnAssignment(self, lval, rval, loc): 63 def actOnAssignment(self, lval, rval, loc):
63 a = astnodes.Assignment(lval, rval) 64 a = astnodes.Assignment(lval, rval)
64 a.loc = loc 65 a.loc = loc
65 return a 66 return a
67 def actOnFunctionCall(self, func, args, loc):
68 fc = astnodes.FunctionCall(func, args)
69 fc.loc = loc
70 return fc
66 def actOnIfStatement(self, cond, yes, no, loc): 71 def actOnIfStatement(self, cond, yes, no, loc):
67 i = astnodes.IfStatement(cond, yes, no) 72 i = astnodes.IfStatement(cond, yes, no)
68 i.loc = loc 73 i.loc = loc
69 return i 74 return i