Class ObjectEncoder<TObj, TPtr>
Encodes in-memory objects.
Inherited Members
Namespace: Flame.Llvm
Assembly: Flame.Llvm.dll
Syntax
public abstract class ObjectEncoder<TObj, TPtr> : ObjectMarshal<TObj>
Type Parameters
Name | Description |
---|---|
TObj | The type of a decoded object. |
TPtr | The type of a pointer to an encoded object. |
Constructors
| Improve this Doc View SourceObjectEncoder(ModuleBuilder, LLVMTargetDataRef)
Creates an object encoder.
Declaration
public ObjectEncoder(ModuleBuilder compiledModule, LLVMTargetDataRef target)
Parameters
Type | Name | Description |
---|---|---|
ModuleBuilder | compiledModule | A compiled LLVM module to inspect for type data layouts. |
LLVMSharp.LLVMTargetDataRef | target | A target data layout to use for determining the precise layout of data types. |
Properties
| Improve this Doc View SourceEncodedObjects
Gets a mapping of objects to their encoded versions.
Declaration
public IReadOnlyDictionary<TObj, TPtr> EncodedObjects { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyDictionary<TObj, TPtr> | A mapping of objects to their encoded versions. |
Methods
| Improve this Doc View SourceAllocateBuffer(Int32)
Allocates a GC-managed buffer of a particular size.
Declaration
public abstract TPtr AllocateBuffer(int size)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | size | The size of the buffer to allocate. |
Returns
Type | Description |
---|---|
TPtr | A pointer to the buffer. |
CreateObject(IType)
Creates an object of a particular type.
Declaration
public TPtr CreateObject(IType type)
Parameters
Type | Name | Description |
---|---|---|
IType | type | The object to create. |
Returns
Type | Description |
---|---|
TPtr | An address to the object. |
Encode(TObj, TPtr)
Encodes a particular value and writes its encoded representation to a buffer.
Declaration
public void Encode(TObj value, TPtr buffer)
Parameters
Type | Name | Description |
---|---|---|
TObj | value | A value to encode. |
TPtr | buffer | A buffer to write |
EncodeBoxPointer(TObj, IType)
Declaration
protected TPtr EncodeBoxPointer(TObj box, IType elementType)
Parameters
Type | Name | Description |
---|---|---|
TObj | box | |
IType | elementType |
Returns
Type | Description |
---|---|
TPtr |
EncodePointer(TPtr, TPtr)
Stores a pointer at a particular address.
Declaration
public abstract void EncodePointer(TPtr address, TPtr value)
Parameters
Type | Name | Description |
---|---|---|
TPtr | address | An address to write |
TPtr | value | A value to write to |
GetFieldValues(TObj)
Gets a mapping of an object's fields to their values..
Declaration
public abstract IReadOnlyDictionary<IField, TObj> GetFieldValues(TObj value)
Parameters
Type | Name | Description |
---|---|---|
TObj | value | An object. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyDictionary<IField, TObj> | A mapping of |
GetGlobalAddress(LLVMValueRef)
Gets the address of a global variable in memory.
Declaration
public abstract TPtr GetGlobalAddress(LLVMValueRef value)
Parameters
Type | Name | Description |
---|---|---|
LLVMSharp.LLVMValueRef | value | The global variable to query. |
Returns
Type | Description |
---|---|
TPtr | An address to |
IndexPointer(TPtr, Int32)
Adds an offset to a pointer.
Declaration
public abstract TPtr IndexPointer(TPtr pointer, int offset)
Parameters
Type | Name | Description |
---|---|---|
TPtr | pointer | A base pointer. |
System.Int32 | offset | An offset to add to |
Returns
Type | Description |
---|---|
TPtr | A modified pointer. |
InitializeObject(TPtr, IType)
Initializes an object at a particular address.
Declaration
public void InitializeObject(TPtr address, IType type)
Parameters
Type | Name | Description |
---|---|---|
TPtr | address | The object to initialize. |
IType | type | The type of the object to initialize. |
LoadBoxPointer(TObj)
Loads the value stored at a particular box pointer.
Declaration
public abstract TObj LoadBoxPointer(TObj pointer)
Parameters
Type | Name | Description |
---|---|---|
TObj | pointer | The pointer whose value is to be loaded. |
Returns
Type | Description |
---|---|
TObj | The value stored at the pointer. |
RegisterEncoded(TObj, TPtr)
Declaration
protected void RegisterEncoded(TObj box, TPtr address)
Parameters
Type | Name | Description |
---|---|---|
TObj | box | |
TPtr | address |
TryEncodePrimitive(TObj, TPtr)
Tries to encode a primitive value.
Declaration
public abstract bool TryEncodePrimitive(TObj value, TPtr buffer)
Parameters
Type | Name | Description |
---|---|---|
TObj | value | The primitive value to encode. |
TPtr | buffer | A buffer to write |
Returns
Type | Description |
---|---|
System.Boolean |
|
TypeOf(TObj)
Gets the type of a particular value.
Declaration
public abstract IType TypeOf(TObj value)
Parameters
Type | Name | Description |
---|---|---|
TObj | value | The type of a value. |
Returns
Type | Description |
---|---|
IType | A type. |