diff options
Diffstat (limited to 'lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h')
-rw-r--r-- | lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h | 47 |
1 files changed, 37 insertions, 10 deletions
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 @@ struct MethodInfo : public Annotation { 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 @@ static AnnotationID BreakpointAID( 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 |