diff gen/irstate.h @ 113:27b9f749d9fe trunk

[svn r117] Initial working implementation of interfaces. Groundwork for all the different types of class/interface casts laid out.
author lindquist
date Sat, 24 Nov 2007 06:33:00 +0100
parents 288fe1029e1f
children fd7ad91fd713
line wrap: on
line diff
--- a/gen/irstate.h	Thu Nov 22 22:30:10 2007 +0100
+++ b/gen/irstate.h	Sat Nov 24 06:33:00 2007 +0100
@@ -8,6 +8,7 @@
 #include <list>
 
 #include "root.h"
+#include "aggregate.h"
 
 // global ir state for current module
 struct IRState;
@@ -20,6 +21,7 @@
 struct FuncDeclaration;
 struct Module;
 struct TypeStruct;
+struct BaseClass;
 
 /*
 struct LLVMValue
@@ -39,6 +41,32 @@
     IRScope(llvm::BasicBlock* b, llvm::BasicBlock* e);
 };
 
+struct IRInterface : Object
+{
+    BaseClass* base;
+    ClassDeclaration* decl;
+
+    const llvm::StructType* vtblTy;
+    llvm::ConstantStruct* vtblInit;
+    llvm::GlobalVariable* vtbl;
+
+    const llvm::StructType* infoTy;
+    llvm::ConstantStruct* infoInit;
+    llvm::Constant* info;
+
+    IRInterface(BaseClass* b, const llvm::StructType* vt)
+    {
+        base = b;
+        decl = b->base;
+        vtblTy = vt;
+        vtblInit = NULL;
+        vtbl = NULL;
+        infoTy = NULL;
+        infoInit = NULL;
+        info = NULL;
+    }
+};
+
 // represents a struct or class
 struct IRStruct : Object
 {
@@ -54,6 +82,8 @@
 
     typedef std::multimap<unsigned, Offset> OffsetMap;
     typedef std::vector<VarDeclaration*> VarDeclVector;
+    typedef std::map<ClassDeclaration*, IRInterface*> InterfaceMap;
+    typedef InterfaceMap::iterator InterfaceIter;
 
 public:
     IRStruct(Type*);
@@ -63,6 +93,10 @@
     OffsetMap offsets;
     VarDeclVector defaultFields;
 
+    InterfaceMap interfaces;
+    const llvm::ArrayType* interfaceInfosTy;
+    llvm::GlobalVariable* interfaceInfos;
+
     bool defined;
     bool constinited;
 };