diff gen/irstate.h @ 73:b706170e24a9 trunk

[svn r77] Fixed foreach on slice. Fixed some nested function problems when accessing outer function parameters. Major changes to handling of structs. Initial support for unions. Probably more...
author lindquist
date Wed, 31 Oct 2007 03:11:32 +0100
parents 28e99b04a132
children 3587401b6eeb
line wrap: on
line diff
--- a/gen/irstate.h	Mon Oct 29 03:28:12 2007 +0100
+++ b/gen/irstate.h	Wed Oct 31 03:11:32 2007 +0100
@@ -4,13 +4,14 @@
 #include <stack>
 #include <vector>
 #include <deque>
+#include <map>
 
 #include "root.h"
 
 // global ir state for current module
 struct IRState;
 extern IRState* gIR;
-extern llvm::TargetData* gTargetData;
+extern const llvm::TargetData* gTargetData;
 
 struct TypeFunction;
 struct TypeStruct;
@@ -40,20 +41,28 @@
 // represents a struct or class
 struct IRStruct
 {
-    typedef std::vector<const llvm::Type*> TypeVector;
-    typedef std::vector<llvm::Constant*> ConstantVector;
-    typedef std::vector<FuncDeclaration*> FuncDeclVec;
+    struct Offset
+    {
+        VarDeclaration* var;
+        llvm::Constant* init;
+
+        Offset(VarDeclaration* v, llvm::Constant* i)
+        : var(v), init(i) {}
+    };
+
+    typedef std::vector<FuncDeclaration*> FuncDeclVector;
+    typedef std::multimap<unsigned, Offset> OffsetMap;
 
 public:
     IRStruct();
     IRStruct(Type*);
 
     Type* type;
-    TypeVector fields;
-    ConstantVector inits;
     llvm::PATypeHolder recty;
-    FuncDeclVec funcs;
+    FuncDeclVector funcs;
     bool queueFuncs;
+
+    OffsetMap offsets;
 };
 
 // represents a finally block