Implement global variables.  Struct and Pointer initializers are not implemented yet though


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@818 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h b/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h
index bdcffd8..f6a2726 100644
--- a/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h
+++ b/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h
@@ -25,20 +25,19 @@
   MethodInfo(Method *M);
   vector<unsigned> NumPlaneElements;
 
+
+  // Create - Factory function to allow MethodInfo annotations to be
+  // created on demand.
+  //
+  static Annotation *Create(AnnotationID AID, const Annotable *O, void *) {
+    assert(AID == MethodInfoAID);
+    return new MethodInfo(cast<Method>((Value*)O));  // Simply invoke the ctor
+  }
+
 private:
   unsigned getValueSlot(const Value *V);
 };
 
-// CreateMethodInfo - Factory function to allow MethodInfo annotations to be
-// created on demand.
-//
-inline static Annotation *CreateMethodInfo(AnnotationID AID, const Annotable *O,
-					   void *) {
-  assert(AID == MethodInfoAID);
-  return new MethodInfo((Method*)O);  // Simply invoke the ctor
-}
-
-
 //===----------------------------------------------------------------------===//
 // Support for the SlotNumber annotation
 //===----------------------------------------------------------------------===//
@@ -89,4 +88,32 @@
 	            AnnotationManager::getID("Interpreter::Breakpoint"));
 // Just use an Annotation directly, Breakpoint is currently just a marker
 
+
+//===----------------------------------------------------------------------===//
+// Support for the GlobalAddress annotation
+//===----------------------------------------------------------------------===//
+
+// This annotation (attached only to GlobalValue objects) is used to hold the
+// address of the chunk of memory that represents a global value.  For Method's,
+// this pointer is the Method object pointer that represents it.  For global
+// variables, this is the dynamically allocated (and potentially initialized)
+// chunk of memory for the global.  This annotation is created on demand.
+//
+static AnnotationID GlobalAddressAID(
+	            AnnotationManager::getID("Interpreter::GlobalAddress"));
+
+struct GlobalAddress : public Annotation {
+  void *Ptr;   // The pointer itself
+  bool Delete; // Should I delete them memory on destruction?
+
+  GlobalAddress(void *ptr, bool d) : Annotation(GlobalAddressAID), Ptr(ptr), 
+                                     Delete(d) {}
+  ~GlobalAddress() { if (Delete) free(Ptr); }
+  
+  // Create - Factory function to allow GlobalAddress annotations to be
+  // created on demand.
+  //
+  static Annotation *Create(AnnotationID AID, const Annotable *O, void *);
+};
+
 #endif