diff python/ir/module.py @ 157:8f3924b6076e

Added some code generator things
author Windel Bouwman
date Sun, 03 Mar 2013 18:14:35 +0100
parents 1b4a85bdd99c
children 9683a4cd848f
line wrap: on
line diff
--- a/python/ir/module.py	Sun Mar 03 15:50:34 2013 +0100
+++ b/python/ir/module.py	Sun Mar 03 18:14:35 2013 +0100
@@ -1,5 +1,33 @@
 from .symboltable import SymbolTable
 
+# Types:
+class Type:
+   def __init__(self):
+      pass
+      
+class IntegerType(Type):
+   def __init__(self, bits):
+      super().__init__()
+      self.bits = bits
+
+class VoidType(Type):
+   pass
+
+class FunctionType(Type):
+   def __init__(self, resultType, parameterTypes):
+      super().__init__()
+      assert type(parameterTypes) is list
+      self.resultType = resultType
+      self.parameterTypes = parameterTypes
+
+# Default types:
+i8 = IntegerType(8)
+i16 = IntegerType(16)
+i32 = IntegerType(32)
+void = VoidType()
+
+# IR-Structures:
+
 class Module:
    """ Main container for a piece of code. Contains globals and functions. """
    def __init__(self, name):
@@ -23,10 +51,8 @@
       self.name = name
       self.functiontype = functiontype
 
-      self.module.Functions.append(self)
       self.basicblocks = []
       self.arguments = []
-      # Construct formal arguments depending on function type
    BasicBlocks = property(lambda self: self.basicblocks)
    Arguments = property(lambda self: self.arguments)
    ReturnType = property(lambda self: self.functiontype.returnType)