diff python/c3/typecheck.py @ 228:7f18ed9b6b7e

Removal of emptystatement class
author Windel Bouwman
date Sat, 13 Jul 2013 11:12:24 +0200
parents 82dfe6a32717
children 88a1e0baef65
line wrap: on
line diff
--- a/python/c3/typecheck.py	Fri Jul 12 17:42:39 2013 +0200
+++ b/python/c3/typecheck.py	Sat Jul 13 11:12:24 2013 +0200
@@ -3,7 +3,10 @@
 from .visitor import Visitor
 
 def equalTypes(a, b):
-    """ Compare types a and b for equality. Not equal until proven otherwise. """
+    """ 
+        Compare types a and b for equality.
+        Not equal until proven otherwise.
+    """
     # Recurse into named types:
     if type(a) is DefinedType:
         return equalTypes(a.typ, b)
@@ -38,7 +41,9 @@
         self.diag = diag
 
     def error(self, msg, loc):
-        """ Wrapper that registers the message and marks the result invalid """
+        """ 
+            Wrapper that registers the message and marks the result invalid 
+        """
         self.diag.error(msg, loc)
         self.ok = False
 
@@ -62,7 +67,6 @@
         elif type(sym) is ReturnStatement:
             pass
         elif type(sym) is FunctionCall:
-         if sym.proc:
             # Check arguments:
             ngiv = len(sym.args)
             ptypes = sym.proc.typ.parametertypes
@@ -75,8 +79,6 @@
                      self.error('Got {0}, expected {1}'.format(a.typ, at), a.loc)
             # determine return type:
             sym.typ = sym.proc.typ.returntype
-         else:
-            sym.typ = intType
         elif type(sym) is VariableUse:
             sym.lvalue = True
             if type(sym.target) is Variable:
@@ -171,7 +173,7 @@
         elif type(sym) is Constant:
             if not equalTypes(sym.typ, sym.value.typ):
                 self.error('Cannot assign {0} to {1}'.format(sym.value.typ, sym.typ), sym.loc)
-        elif type(sym) in [EmptyStatement, CompoundStatement, Package, Function, FunctionType, ExpressionStatement, DefinedType]:
+        elif type(sym) in [CompoundStatement, Package, Function, FunctionType, ExpressionStatement, DefinedType]:
          pass
         else:
             raise Exception('Unknown type check {0}'.format(sym))