diff python/c3/astnodes.py @ 150:4ae0e02599de

Added type check start and analyze phase
author Windel Bouwman
date Fri, 01 Mar 2013 16:53:22 +0100
parents 74241ca312cc
children b28a11c01dbe
line wrap: on
line diff
--- a/python/c3/astnodes.py	Fri Mar 01 11:43:52 2013 +0100
+++ b/python/c3/astnodes.py	Fri Mar 01 16:53:22 2013 +0100
@@ -17,22 +17,11 @@
                   children.append(mi)
       return children
 
-
-class Id(Node):
-   def __init__(self, tok, pub):
-      self.name = tok.val
-      self.is_public = pub
+class Designator(Node):
+   def __init__(self, tname):
+      self.tname = tname
    def __repr__(self):
-      return 'ID {0}'.format(self.name)
-
-# Selectors:
-class Designator(Node):
-   def __init__(self, obj, selectors, typ):
-      self.obj = obj
-      self.selectors = selectors
-      self.typ = typ
-   def __repr__(self):
-      return 'DESIGNATOR {0}, selectors {1}, type {2}'.format(self.obj, self.selectors, self.typ)
+      return 'DESIGNATOR {0}'.format(self.tname)
 
 """
 Type classes
@@ -109,13 +98,15 @@
    def __repr__(self):
       return 'VAR {0} : {1}'.format(self.name, self.typ)
 
-class Parameter(Node):
-   """ A parameter has a passing method, name and typ """
-   def __init__(self, name, typ):
+# Procedure types
+class Function(Symbol):
+   """ Actual implementation of a function """
+   def __init__(self, name, typ=None, block=None):
       self.name = name
+      self.body = block
       self.typ = typ
    def __repr__(self):
-      return 'PARAM {0} {1}'.format(self.name, self.typ)
+      return 'PROCEDURE {0} {1}'.format(self.name, self.typ)
 
 # Operations:
 class Unop(Node):
@@ -133,6 +124,12 @@
    def __repr__(self):
       return 'BINOP {0}'.format(self.op)
 
+class VariableUse(Node):
+   def __init__(self, target):
+      self.target = target
+   def __repr__(self):
+      return 'VAR USE {0}'.format(self.target)
+
 # Modules
 class Package(Node):
    def __init__(self, name):
@@ -140,16 +137,6 @@
    def __repr__(self):
       return 'PACKAGE {0}'.format(self.name)
 
-# Procedure types
-class Procedure(Symbol):
-   """ Actual implementation of a function """
-   def __init__(self, name, typ=None, block=None):
-      self.name = name
-      self.body = block
-      self.typ = typ
-   def __repr__(self):
-      return 'PROCEDURE {0} {1}'.format(self.name, self.typ)
-
 # Statements
 class CompoundStatement(Node):
    def __init__(self, statements):