Allocator

Allocator allocates and manages memory related to the various constructors used by the objects in DotNetPELib.   When the Allocator object is destroyed, all objects allocated through it will be destructed and then destroyed.   The main DotNetPELib class PELib derives from allocator, and may be used interchangeably with it.

Following is a summary of the supported allocators.   These generally related to constructors on a one to one basis.

        AssemblyDef *AllocateAssemblyDef(std::string Name, bool External, Byte *KeyToken = 0);
        Namespace *AllocateNamespace(std::string Name);
        Class *AllocateClass(std::string Name, Qualifiers Flags, int Pack, int Size);
        Method *AllocateMethod(MethodSignature *Prototype, Qualifiers flags, bool entry = false);
        Field *AllocateField(std::string Name, Type *tp, Qualifiers Flags);
        Property *AllocateProperty(PELib & peLib, std::string name, Type *type, std::vector<Type *>& indices, bool hasSetter = true, DataContainer *parent = nullptr);
        Property *AllocateProperty();
        Enum *AllocateEnum(std::string Name, Qualifiers Flags, Field::ValueSize Size);
        Operand *AllocateOperand();
        Operand *AllocateOperand(Value *V);
        Operand *AllocateOperand(longlong Value, Operand::OpSize Size);
        Operand *AllocateOperand(int Value, Operand::OpSize Size) {
            return AllocateOperand((longlong)Value, Size);
        }
        Operand *AllocateOperand(unsigned Value, Operand::OpSize Size) {
            return AllocateOperand((longlong)Value, Size);
        }
        Operand *AllocateOperand(double Value, Operand::OpSize Size);
        Operand *AllocateOperand(std::string Value, bool);
        Operand *AllocateOperand(std::string Value);
        Instruction *AllocateInstruction(Instruction::iop Op, Operand *Operand = nullptr);
        Instruction *AllocateInstruction(Instruction::iop Op, std::string Text);
        Instruction *AllocateInstruction(Instruction::iseh type, bool begin, Type *catchType=nullptr);
        Value *AllocateValue(std::string name, Type *tp);
        Local *AllocateLocal(std::string name, Type *tp);
        Param *AllocateParam(std::string name, Type *tp);
        FieldName *AllocateFieldName(Field *F);
        MethodName *AllocateMethodName(MethodSignature *M);
        MethodSignature *AllocateMethodSignature(std::string Name, int Flags, DataContainer *Container);
        Type *AllocateType(Type::BasicType Tp, int PointerLevel);
        Type *AllocateType(DataContainer *clsref);
        Type *AllocateType(MethodSignature *methodref);
        BoxedType *AllocateBoxedType(Type::BasicType Tp);
        Byte *AllocateBytes(size_t sz);