comparison python/c3/analyse.py @ 166:da0087b82fbe

Improved type checking
author Windel Bouwman
date Fri, 22 Mar 2013 16:15:31 +0100
parents 8104fc8b5e90
children 0b5b2ee6b435
comparison
equal deleted inserted replaced
165:598d3888a11c 166:da0087b82fbe
20 msg = 'Cannot resolve name {0}'.format(d.tname) 20 msg = 'Cannot resolve name {0}'.format(d.tname)
21 self.diag.error(msg, d.loc) 21 self.diag.error(msg, d.loc)
22 def a1(self, sym): 22 def a1(self, sym):
23 pass 23 pass
24 def analyze(self, sym): 24 def analyze(self, sym):
25 if type(sym) is Variable: 25 if type(sym) in [Variable, Constant]:
26 sym.typ = self.resolveDesignator(sym.typ, sym) 26 sym.typ = self.resolveDesignator(sym.typ, sym)
27 elif type(sym) is VariableUse: 27 elif type(sym) is VariableUse:
28 sym.target = self.resolveDesignator(sym.target, sym) 28 sym.target = self.resolveDesignator(sym.target, sym)
29 elif type(sym) is ProcedureCall: 29 elif type(sym) is ProcedureCall:
30 sym.proc = self.resolveDesignator(sym.proc, sym) 30 sym.proc = self.resolveDesignator(sym.proc, sym)
31 elif type(sym) is FunctionType: 31 elif type(sym) is FunctionType:
32 sym.returntype = self.resolveDesignator(sym.returntype) 32 sym.returntype = self.resolveDesignator(sym.returntype)
33 elif type(sym) is Constant:
34 print(sym)
35 33