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

refactor ir
author Windel Bouwman
date Sat, 31 Aug 2013 17:58:54 +0200
parents 521567d17388
children a747a45dcd78
line wrap: on
line diff
--- a/python/c3/scope.py	Tue Aug 20 18:56:02 2013 +0200
+++ b/python/c3/scope.py	Sat Aug 31 17:58:54 2013 +0200
@@ -7,8 +7,8 @@
         self.parent = parent
 
     def __iter__(self):
-      # Iterate in a deterministic manner:
-      return iter(self.Constants + self.Variables + self.Functions)
+        # Iterate in a deterministic manner:
+        return iter(self.Constants + self.Variables + self.Functions)
 
     @property
     def Syms(self):
@@ -21,33 +21,34 @@
 
     @property
     def Variables(self):
-        return [s for s in self.Syms if type(s) is astnodes.Variable]
+        return [s for s in self.Syms if isinstance(s, astnodes.Variable)]
 
     @property
     def Functions(self):
         return [s for s in self.Syms if type(s) is astnodes.Function]
 
     def getSymbol(self, name):
-      if name in self.symbols:
-         return self.symbols[name]
-      # Look for symbol:
-      if self.parent:
-         return self.parent.getSymbol(name)
-      raise CompilerException("Symbol {0} not found".format(name), name.loc)
+        if name in self.symbols:
+            return self.symbols[name]
+        # Look for symbol:
+        if self.parent:
+            return self.parent.getSymbol(name)
+        raise CompilerException("Symbol {0} not found".format(name), name.loc)
 
     def hasSymbol(self, name):
-      if name in self.symbols:
-         return True
-      if self.parent:
-         return self.parent.hasSymbol(name)
-      return False
+        if name in self.symbols:
+            return True
+        if self.parent:
+            return self.parent.hasSymbol(name)
+        return False
 
     def addSymbol(self, sym):
-      self.symbols[sym.name] = sym
+        self.symbols[sym.name] = sym
 
     def __repr__(self):
         return 'Scope with {} symbols'.format(len(self.symbols))
 
+
 # buildin types:
 intType = astnodes.BaseType('int')
 intType.bytesize = 4