Table of Contents

Class ValueFactory

Namespace
Echo.Platforms.AsmResolver.Emulation
Assembly
Echo.Platforms.AsmResolver.dll

Provides a service for querying information about- and constructing new values.

public class ValueFactory
Inheritance
ValueFactory
Inherited Members

Constructors

ValueFactory(ModuleDefinition, bool)

Creates a new value factory.

public ValueFactory(ModuleDefinition contextModule, bool is32Bit)

Parameters

contextModule ModuleDefinition

The manifest module to use for context.

is32Bit bool

A value indicating whether the environment is a 32-bit or 64-bit system.

Properties

ArrayHeaderSize

Gets the number of bytes prepended to the data of the array.

public uint ArrayHeaderSize { get; }

Property Value

uint

ArrayLengthOffset

Gets the offset within an array object that indexes the start of the Length field.

public uint ArrayLengthOffset { get; }

Property Value

uint

BitVectorPool

Gets the bitvector pool that this factory uses for creating and reusing bit vectors.

public BitVectorPool BitVectorPool { get; }

Property Value

BitVectorPool

ClrMockMemory

Gets the CLR mock memory used for managing method tables (types).

public ClrMockMemory ClrMockMemory { get; }

Property Value

ClrMockMemory

ContextModule

Gets the manifest module to use for context.

public ModuleDefinition ContextModule { get; }

Property Value

ModuleDefinition

DecimalType

Gets a reference to the decimal type.

public ITypeDescriptor DecimalType { get; }

Property Value

ITypeDescriptor

DelegateMethodPtrField

Get a reference to the Delegate _methodPtr field.

public IFieldDescriptor DelegateMethodPtrField { get; }

Property Value

IFieldDescriptor

DelegateTargetField

Get a reference to the Delegate _target field.

public IFieldDescriptor DelegateTargetField { get; }

Property Value

IFieldDescriptor

DelegateType

Gets a reference to the Delegate type.

public ITypeDescriptor DelegateType { get; }

Property Value

ITypeDescriptor

IndexOutOfRangeExceptionType

Gets a reference to the IndexOutOfRangeException type.

public ITypeDescriptor IndexOutOfRangeExceptionType { get; }

Property Value

ITypeDescriptor

InvalidCastExceptionType

Gets a reference to the InvalidCastException type.

public ITypeDescriptor InvalidCastExceptionType { get; }

Property Value

ITypeDescriptor

InvalidProgramExceptionType

Gets a reference to the InvalidProgramException type.

public ITypeDescriptor InvalidProgramExceptionType { get; }

Property Value

ITypeDescriptor

Is32Bit

Gets a value indicating whether the environment is a 32-bit or 64-bit system.

public bool Is32Bit { get; }

Property Value

bool

Marshaller

Gets the service responsible for marshalling values into stack slots and back.

public CliMarshaller Marshaller { get; }

Property Value

CliMarshaller

MissingMethodExceptionType

Gets a reference to the MissingMethodException type.

public ITypeDescriptor MissingMethodExceptionType { get; }

Property Value

ITypeDescriptor

NullReferenceExceptionType

Gets a reference to the NullReferenceException type.

public ITypeDescriptor NullReferenceExceptionType { get; }

Property Value

ITypeDescriptor

ObjectHeaderSize

Gets the size of an object header.

public uint ObjectHeaderSize { get; }

Property Value

uint

OverflowExceptionType

Gets a reference to the OverflowException type.

public ITypeDescriptor OverflowExceptionType { get; }

Property Value

ITypeDescriptor

PointerSize

Gets the size in bytes of a pointer in the current environment.

public uint PointerSize { get; }

Property Value

uint

StackOverflowExceptionType

Gets a reference to the StackOverflowException type.

public ITypeDescriptor StackOverflowExceptionType { get; }

Property Value

ITypeDescriptor

StringHeaderSize

Gets the number of bytes prepended to the characters of the string.

public uint StringHeaderSize { get; }

Property Value

uint

StringLengthOffset

Gets the offset within an string object that indexes the start of the Length field.

public uint StringLengthOffset { get; }

Property Value

uint

TypeInitializationExceptionType

Gets a reference to the TypeInitializationException type.

public TypeDefinition TypeInitializationExceptionType { get; }

Property Value

TypeDefinition

Methods

CreateBoolean(Trilean)

Creates a new 32-bit vector from the bit vector pool containing the boolean value.

public BitVector CreateBoolean(Trilean value)

Parameters

value Trilean

The value.

Returns

BitVector

The vector.

CreateNativeInteger(bool)

Creates a new native integer bit vector.

public BitVector CreateNativeInteger(bool initialize)

Parameters

initialize bool

true if the value should be set to 0, false if the integer should remain unknown.

Returns

BitVector

The constructed bit vector.

CreateNativeInteger(long)

Creates a new native integer bit vector.

public BitVector CreateNativeInteger(long value)

Parameters

value long

The value to initialize the integer with.

Returns

BitVector

The constructed bit vector.

CreateNull()

Creates a new native integer bit vector containing the null reference.

public BitVector CreateNull()

Returns

BitVector

The constructed bit vector.

CreateValue(TypeSignature, bool)

Creates a new bit vector that can be used to represent an instance of the provided type.

public BitVector CreateValue(TypeSignature type, bool initialize)

Parameters

type TypeSignature

The type to represent.

initialize bool

true if the value should be set to 0, false if the value should remain unknown.

Returns

BitVector

The constructed bit vector.

GetArrayElementOffset(TypeSignature, long)

Calculates the offset to the element within an array.

public long GetArrayElementOffset(TypeSignature elementType, long index)

Parameters

elementType TypeSignature

The element type.

index long

The element's index.

Returns

long

The offset, relative to the start of an array object.

GetArrayObjectSize(ITypeDescriptor, int)

Computes the total size of an array object.

public uint GetArrayObjectSize(ITypeDescriptor elementType, int elementCount)

Parameters

elementType ITypeDescriptor

The type of elements the array stores.

elementCount int

The number of elements.

Returns

uint

The total size in bytes.

GetFieldMemoryLayout(IFieldDescriptor)

Obtains memory layout information of a field.

public FieldMemoryLayout GetFieldMemoryLayout(IFieldDescriptor field)

Parameters

field IFieldDescriptor

The field.

Returns

FieldMemoryLayout

The memory layout information.

Exceptions

ArgumentException

Occurs when the field could not be resolved.

GetObjectSize(ITypeDescriptor)

Computes the total size of an object.

public uint GetObjectSize(ITypeDescriptor type)

Parameters

type ITypeDescriptor

The type of object to measure.

Returns

uint

The total size in bytes.

GetStringObjectSize(int)

Computes the total size of a string object.

public uint GetStringObjectSize(int length)

Parameters

length int

The number of characters in the string.

Returns

uint

The total size in bytes.

GetTypeContentsMemoryLayout(ITypeDescriptor)

Obtains the memory layout of a type in the current environment. If the provided type is a reference type, then it will measure the size of the contents behind the object reference.

public TypeMemoryLayout GetTypeContentsMemoryLayout(ITypeDescriptor type)

Parameters

type ITypeDescriptor

The type to measure.

Returns

TypeMemoryLayout

The measured layout.

Exceptions

ArgumentOutOfRangeException

Occurs when the type could not be measured.

GetTypeValueMemoryLayout(ITypeDescriptor)

Obtains the memory layout of a type in the current environment. If the provided type is a reference type, then it will measure the object reference itself, and not the contents behind the reference.

public TypeMemoryLayout GetTypeValueMemoryLayout(ITypeDescriptor type)

Parameters

type ITypeDescriptor

The type to measure.

Returns

TypeMemoryLayout

The measured layout.

Exceptions

ArgumentOutOfRangeException

Occurs when the type could not be measured.

RentBoolean(Trilean)

Rents a 32-bit vector from the bit vector pool containing the boolean value.

public BitVector RentBoolean(Trilean value)

Parameters

value Trilean

The value.

Returns

BitVector

The vector

RentNativeInteger(bool)

Rents a native integer bit vector from the bit vector pool.

public BitVector RentNativeInteger(bool initialize)

Parameters

initialize bool

true if the value should be set to 0, false if the integer should remain unknown.

Returns

BitVector

The rented bit vector.

RentNativeInteger(long)

Rents a native integer bit vector from the bit vector pool.

public BitVector RentNativeInteger(long value)

Parameters

value long

The value to initialize the integer with.

Returns

BitVector

The rented bit vector.

RentNull()

Rents a new native integer bit vector containing the null reference.

public BitVector RentNull()

Returns

BitVector

The constructed bit vector.

RentValue(TypeSignature, bool)

Rents a bit vector from the pool that can be used to represent an instance of the provided type.

public BitVector RentValue(TypeSignature type, bool initialize)

Parameters

type TypeSignature

The type to represent.

initialize bool

true if the value should be set to 0, false if the value should remain unknown.

Returns

BitVector

The rented bit vector.