diff python/c3/typecheck.py @ 272:e64bae57cda8

refactor ir
author Windel Bouwman
date Sat, 31 Aug 2013 17:58:54 +0200
parents c4370696ccc7
children 1c7c1e619be8
line wrap: on
line diff
--- a/python/c3/typecheck.py	Tue Aug 20 18:56:02 2013 +0200
+++ b/python/c3/typecheck.py	Sat Aug 31 17:58:54 2013 +0200
@@ -33,7 +33,7 @@
                     return False
             return True
         else:
-            raise Exception('Type compare not implemented')
+            raise Exception('Type compare for {} not implemented'.format(type(a)))
     return False
 
 def canCast(fromT, toT):
@@ -99,7 +99,7 @@
             sym.typ = sym.proc.typ.returntype
         elif type(sym) is VariableUse:
             sym.lvalue = True
-            if type(sym.target) is Variable:
+            if isinstance(sym.target, Variable):
                 sym.typ = sym.target.typ
             else:
                 print('warning {} has no target, defaulting to int'.format(sym))
@@ -172,7 +172,7 @@
                    self.error('Must be {0}'.format(boolType), sym.b.loc)
             else:
                 raise Exception('Unknown binop {0}'.format(sym.op))
-        elif type(sym) is Variable:
+        elif isinstance(sym, Variable):
             # check initial value type:
             # TODO
             pass