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

refactor ir
author Windel Bouwman
date Sat, 31 Aug 2013 17:58:54 +0200
parents 6ed3d3a82a63
children 05184b95fa16
line wrap: on
line diff
--- a/python/c3/astnodes.py	Tue Aug 20 18:56:02 2013 +0200
+++ b/python/c3/astnodes.py	Sat Aug 31 17:58:54 2013 +0200
@@ -42,14 +42,17 @@
 """
 
 class Type(Node):
-   def isType(self, b):
-      return isType(self, b)
+    def isType(self, b):
+        return isType(self, b)
+
 
 class BaseType(Type):
-  def __init__(self, name):
-    self.name = name
-  def __repr__(self):
-    return '{}'.format(self.name)
+    def __init__(self, name):
+        self.name = name
+
+    def __repr__(self):
+        return '{}'.format(self.name)
+
 
 class FunctionType(Type):
    def __init__(self, parametertypes, returntype):
@@ -59,6 +62,7 @@
       params = ', '.join([str(v) for v in self.parametertypes])
       return '{1} f({0})'.format(params, self.returntype)
 
+
 class PointerType(Type):
     def __init__(self, ptype):
         assert isinstance(ptype, Type) or isinstance(ptype, Designator)
@@ -102,6 +106,7 @@
     def __repr__(self):
         return 'STRUCT'
 
+
 class DefinedType(Type):
     def __init__(self, name, typ, loc):
         assert isinstance(name, str)
@@ -116,32 +121,51 @@
 # Variables, parameters, local variables, constants:
 class Symbol(Node):
     def __init__(self, name):
-      self.name = name
-      self.refs = []
+        self.name = name
+        self.refs = []
+
     def addRef(self, r):
-      self.refs.append(r)
+        self.refs.append(r)
+
     @property
     def References(self):
-      return self.refs
+        return self.refs
+
 
 class Constant(Symbol):
     def __init__(self, name, typ, value):
-      super().__init__(name)
-      self.typ = typ
-      self.value = value
+        super().__init__(name)
+        self.typ = typ
+        self.value = value
+
     def __repr__(self):
-      return 'CONSTANT {0} = {1}'.format(self.name, self.value)
+        return 'CONSTANT {0} = {1}'.format(self.name, self.value)
+
 
 class Variable(Symbol):
-   def __init__(self, name, typ):
-      super().__init__(name)
-      self.typ = typ
-      self.ival = None
-      self.isLocal = False
-      self.isReadOnly = False
-      self.isParameter = False
-   def __repr__(self):
-      return 'Var {} [{}]'.format(self.name, self.typ)
+    def __init__(self, name, typ):
+        super().__init__(name)
+        self.typ = typ
+        self.ival = None
+        self.isLocal = False
+        self.isReadOnly = False
+        self.isParameter = False
+
+    def __repr__(self):
+        return 'Var {} [{}]'.format(self.name, self.typ)
+
+
+class LocalVariable(Variable):
+    def __init__(self, name, typ):
+        super().__init__(name, typ)
+        self.isLocal = True
+
+
+class FormalParameter(Variable):
+    def __init__(self, name, typ):
+        super().__init__(name, typ)
+        self.isParameter = True
+
 
 # Procedure types
 class Function(Symbol):