Class TypeHelpers
Defines helper methods for bridging the gap between IL's implicit reference types and Flame's explicit box pointers.
Inheritance
Inherited Members
Namespace: Flame.Clr
Assembly: Flame.Clr.dll
Syntax
public static class TypeHelpers
Methods
| Improve this Doc View SourceBoxIfReferenceType(IType)
Takes a type, examines it and boxes it if it is a raw reference type. It is appropriate to call this method on the type of a value; IL values that happen to be reference types are implicitly boxed. This function hints that this implicit boxing is to be made explicit.
Declaration
public static IType BoxIfReferenceType(IType type)
Parameters
Type | Name | Description |
---|---|---|
IType | type | The type to box if it happens to be a reference type. |
Returns
Type | Description |
---|---|
IType | A box-pointer type if |
BoxReferenceTypes(IType)
Replaces all raw reference types with boxed reference types.
Declaration
public static IType BoxReferenceTypes(IType type)
Parameters
Type | Name | Description |
---|---|---|
IType | type | The type to completely box. |
Returns
Type | Description |
---|---|
IType | A boxed type. |
GetExtendedParameters(MethodDefinition)
Gets a method's extended parameter list, consists of the method's parameter list and an optional 'this' parameter as a prefix.
Declaration
public static IReadOnlyList<ParameterDefinition> GetExtendedParameters(MethodDefinition method)
Parameters
Type | Name | Description |
---|---|---|
Mono.Cecil.MethodDefinition | method | The method to examine. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<Mono.Cecil.ParameterDefinition> | A list of parameters. |
ImportReference(ModuleDefinition, IField)
Takes a Flame field and converts it to a Cecil field reference.
For this to work, field
cannot reference
non-Cecil types or methods.
Declaration
public static FieldReference ImportReference(this ModuleDefinition module, IField field)
Parameters
Type | Name | Description |
---|---|---|
Mono.Cecil.ModuleDefinition | module | The module to import |
IField | field | The field to convert to a field reference. |
Returns
Type | Description |
---|---|
Mono.Cecil.FieldReference | A field reference. |
ImportReference(ModuleDefinition, IMethod)
Takes a Flame method and converts it to a Cecil method reference.
For this to work, method
cannot reference
non-Cecil types or methods.
Declaration
public static MethodReference ImportReference(this ModuleDefinition module, IMethod method)
Parameters
Type | Name | Description |
---|---|---|
Mono.Cecil.ModuleDefinition | module | The module to import |
IMethod | method | The method to convert to a method reference. |
Returns
Type | Description |
---|---|
Mono.Cecil.MethodReference | A method reference. |
ImportReference(ModuleDefinition, IType)
Takes a Flame type and converts it to a Cecil type reference.
For this to work, type
cannot reference
non-Cecil types.
Declaration
public static TypeReference ImportReference(this ModuleDefinition module, IType type)
Parameters
Type | Name | Description |
---|---|---|
Mono.Cecil.ModuleDefinition | module | The module to import |
IType | type | The type to convert to a type reference. |
Returns
Type | Description |
---|---|
Mono.Cecil.TypeReference | A type reference. |
TryGetDelegateInvokeMethod(IType, out IMethod)
Gets the 'invoke' method of a delegate type, provided that it is indeed a delegate type.
Declaration
public static bool TryGetDelegateInvokeMethod(IType delegateType, out IMethod invokeMethod)
Parameters
Type | Name | Description |
---|---|---|
IType | delegateType | A type that may be a delegate type. |
IMethod | invokeMethod | The delegate type's 'invoke' method, provided that
|
Returns
Type | Description |
---|---|
System.Boolean |
|
UnboxIfPossible(IType)
Takes a type, examines it and unboxes it if it is a box pointer type.
Declaration
public static IType UnboxIfPossible(IType type)
Parameters
Type | Name | Description |
---|---|---|
IType | type | The type to unbox if it happens to be a box pointer type. |
Returns
Type | Description |
---|---|
IType |
|