comparison python/c3/typecheck.py @ 215:c1ccb1cb4cef

Major changes in c3 frontend
author Windel Bouwman
date Fri, 05 Jul 2013 13:00:03 +0200
parents 46d62dadd61b
children 3f6c30a5d234
comparison
equal deleted inserted replaced
214:6875360e8390 215:c1ccb1cb4cef
10 return False 10 return False
11 11
12 class TypeChecker: 12 class TypeChecker:
13 def __init__(self, diag): 13 def __init__(self, diag):
14 self.diag = diag 14 self.diag = diag
15 self.visitor = Visitor(self.precheck, self.check2)
16 def error(self, msg, loc): 15 def error(self, msg, loc):
17 """ Wrapper that registers the message and marks the result invalid """ 16 """ Wrapper that registers the message and marks the result invalid """
18 self.diag.error(msg, loc) 17 self.diag.error(msg, loc)
19 self.ok = False 18 self.ok = False
20 def checkPackage(self, pkg): 19 def checkPackage(self, pkg):
21 self.ok = True 20 self.ok = True
22 self.visitor.visit(pkg) 21 visitor = Visitor()
22 visitor.visit(pkg, f_post=self.check2)
23 return self.ok 23 return self.ok
24 def precheck(self, sym):
25 pass
26 def check2(self, sym): 24 def check2(self, sym):
27 if type(sym) is Function: 25 if type(sym) is Function:
28 pass 26 pass
29 elif type(sym) in [IfStatement, WhileStatement]: 27 elif type(sym) in [IfStatement, WhileStatement]:
30 if not equalTypes(sym.condition.typ, boolType): 28 if not equalTypes(sym.condition.typ, boolType):