comparison python/c3/typecheck.py @ 170:4348da5ca307

Cleanup of ir dir
author Windel Bouwman
date Fri, 29 Mar 2013 17:33:17 +0100
parents 49f1ab80d040
children 46d62dadd61b
comparison
equal deleted inserted replaced
169:ee0d30533dae 170:4348da5ca307
59 else: 59 else:
60 self.diag.error('Unknown literal type', sym.loc) 60 self.diag.error('Unknown literal type', sym.loc)
61 elif type(sym) is Binop: 61 elif type(sym) is Binop:
62 if sym.op in ['+', '-', '*', '/']: 62 if sym.op in ['+', '-', '*', '/']:
63 if equalTypes(sym.a.typ, sym.b.typ): 63 if equalTypes(sym.a.typ, sym.b.typ):
64 sym.typ = sym.a.typ 64 if equalTypes(sym.a.typ, intType):
65 sym.typ = sym.a.typ
66 else:
67 self.diag.error('Can only add integers', sym.loc)
68 sym.typ = intType
65 else: 69 else:
66 # assume void here? TODO: throw exception! 70 # assume void here? TODO: throw exception!
67 sym.typ = intType 71 sym.typ = intType
68 self.diag.error('Types unequal', sym.loc) 72 self.diag.error('Types unequal', sym.loc)
69 elif sym.op in ['>', '<']: 73 elif sym.op in ['>', '<', '==', '<=', '>=']:
70 sym.typ = boolType 74 sym.typ = boolType
71 if not equalTypes(sym.a.typ, sym.b.typ): 75 if not equalTypes(sym.a.typ, sym.b.typ):
72 self.diag.error('Types unequal', sym.loc) 76 self.diag.error('Types unequal', sym.loc)
73 elif sym.op in ['or', 'and']: 77 elif sym.op in ['or', 'and']:
74 sym.typ = boolType 78 sym.typ = boolType