/// <summary> /// Gets a type's encoded size in bytes. /// </summary> /// <param name="type">A type.</param> /// <param name="metadataSize">The object's metadata size.</param> /// <returns>The type's size in bytes, including the size of the metadata.</returns> public int SizeOfWithMetadata(IType type, out int metadataSize) { var ext = GCInterface.GetMetadataExtendedType(CompiledModule.ImportType(type), CompiledModule); metadataSize = (int)LLVM.OffsetOfElement(Target, ext, 1); return((int)LLVM.StoreSizeOfType(Target, ext)); }
/// <summary> /// Creates an object marshal. /// </summary> /// <param name="compiledModule"> /// A compiled LLVM module to inspect for type data layouts. /// </param> /// <param name="target"> /// A target data layout to use for determining the precise layout of data types. /// </param> public ObjectMarshal(ModuleBuilder compiledModule, LLVMTargetDataRef target) { this.CompiledModule = compiledModule; this.Target = target; var ext = GCInterface.GetMetadataExtendedType( LLVM.StructTypeInContext(CompiledModule.Context, new LLVMTypeRef[] { }, false), CompiledModule); MetadataSize = (int)LLVM.OffsetOfElement(Target, ext, 1); }