view python/ppci/core/llvmtype.py @ 110:9e552d34bd60

Work on compiler
author Windel Bouwman
date Fri, 04 Jan 2013 15:25:58 +0100
parents 1544e7a4aa98
children
line wrap: on
line source


def Enum(**enums):
   return type('Enum', (), enums)

typeID = Enum(Void=0, Double=3, Integer=10, Function=11, Struct=12, Array=13, Pointer=14, Vector=15)

class llvmType:
   def __init__(self, tid):
      self.tid = tid
      
class IntegerType(llvmType):
   def __init__(self, bits):
      super().__init__(typeID.Integer)
      self.bits = bits

class FunctionType(llvmType):
   def __init__(self, resultType, parameterTypes):
      super().__init__(typeID.Function)
      assert type(parameterTypes) is list
      self.resultType = resultType
      self.returnType = resultType
      self.parameterTypes = parameterTypes

# Default types:
i8 = IntegerType(8)
i16 = IntegerType(16)
i32 = IntegerType(32)
void = llvmType(typeID.Void)