C# Class Monobjc.Generators.CodeGenerator

Base class for .NET code generator.
Afficher le fichier Open project: Monobjc/monobjc

Méthodes protégées

Méthode Description
CodeGenerator ( DynamicAssembly assembly, bool is64Bits )

Initializes a new instance of the CodeGenerator class.

CreateLocalBuilderForInvocationResult ( ILGenerator generator, Type returnType, Type nativeReturnType ) : LocalBuilder

Creates a local builder to store the result of the invocation.

CreateLocalVariableForByRefParameters ( ILGenerator generator, ParameterInfo parameterInfos ) : ByRefParameter[]

Emit local variable for each by-ref parameters. These variables will hold the result until the marshalling occurs.

EmitLoadArgument ( ILGenerator generator, int index ) : void
EmitManagedToNativeMarshallingForByRefParameters ( ILGenerator generator, Type nativeParameterTypes, ByRefParameter byRefLocalVariables ) : void

Emit the code needed to marshal back the local variables to by-ref parameters.

EmitNativeToManagedMarshallingForByRefParameters ( ILGenerator generator, Type nativeParameterTypes, ByRefParameter byRefLocalVariables ) : void

For by-ref parameters passed as reference (without [out] attribute), we first set the value of local variables

EmitParametersLoadingOnStack ( ILGenerator generator, Type parameterTypes, Type nativeParameterTypes, ByRefParameter byRefLocalVariables, int parameterOffset ) : void

Genenerate optimized IL for stacking parameters : - For the third or fourth parameter, use the short OpCode - For all the parameters left, use the long OpCode

GetReturnType ( MethodBase methodBase ) : Type

Gets the return type of the method base.

GetUniqueName ( MethodBase methodBase ) : String

Gets a unique name of the method base.

UnwrapResultOfInvocation ( ILGenerator generator, LocalBuilder result, Type returnType, Type nativeReturnType, bool hasByRef ) : void

Unwraps the result of invocation.

Private Methods

Méthode Description
DefineProxyDelegateFieldInfo ( TypeBuilder typeBuilder, MethodTuple methodTuple ) : FieldInfo

Defines the proxy delegate field info.

DefineStaticConstructor ( TypeBuilder typeBuilder, IEnumerable methodTuples ) : void

Defines a static constructor.

EmitManagedToNativeMarshallingCast ( ILGenerator generator, LocalBuilder local, Type localType, int i ) : void
EmitNativeToManagedMarshallingCast ( ILGenerator generator, Type localType ) : void

Emits the native to managed marshalling cast.

Method Details

CodeGenerator() protected méthode

Initializes a new instance of the CodeGenerator class.
protected CodeGenerator ( DynamicAssembly assembly, bool is64Bits )
assembly DynamicAssembly The assembly.
is64Bits bool

CreateLocalBuilderForInvocationResult() protected static méthode

Creates a local builder to store the result of the invocation.
protected static CreateLocalBuilderForInvocationResult ( ILGenerator generator, Type returnType, Type nativeReturnType ) : LocalBuilder
generator ILGenerator The IL generator.
returnType Type The return type.
nativeReturnType Type The native return type.
Résultat LocalBuilder

CreateLocalVariableForByRefParameters() protected static méthode

Emit local variable for each by-ref parameters. These variables will hold the result until the marshalling occurs.
protected static CreateLocalVariableForByRefParameters ( ILGenerator generator, ParameterInfo parameterInfos ) : ByRefParameter[]
generator ILGenerator
parameterInfos ParameterInfo
Résultat ByRefParameter[]

EmitLoadArgument() protected static méthode

protected static EmitLoadArgument ( ILGenerator generator, int index ) : void
generator ILGenerator
index int
Résultat void

EmitManagedToNativeMarshallingForByRefParameters() protected méthode

Emit the code needed to marshal back the local variables to by-ref parameters.
protected EmitManagedToNativeMarshallingForByRefParameters ( ILGenerator generator, Type nativeParameterTypes, ByRefParameter byRefLocalVariables ) : void
generator ILGenerator
nativeParameterTypes Type
byRefLocalVariables ByRefParameter
Résultat void

EmitNativeToManagedMarshallingForByRefParameters() protected méthode

For by-ref parameters passed as reference (without [out] attribute), we first set the value of local variables
protected EmitNativeToManagedMarshallingForByRefParameters ( ILGenerator generator, Type nativeParameterTypes, ByRefParameter byRefLocalVariables ) : void
generator ILGenerator
nativeParameterTypes Type
byRefLocalVariables ByRefParameter
Résultat void

EmitParametersLoadingOnStack() protected static méthode

Genenerate optimized IL for stacking parameters : - For the third or fourth parameter, use the short OpCode - For all the parameters left, use the long OpCode
protected static EmitParametersLoadingOnStack ( ILGenerator generator, Type parameterTypes, Type nativeParameterTypes, ByRefParameter byRefLocalVariables, int parameterOffset ) : void
generator ILGenerator
parameterTypes Type
nativeParameterTypes Type
byRefLocalVariables ByRefParameter
parameterOffset int
Résultat void

GetReturnType() protected static méthode

Gets the return type of the method base.
protected static GetReturnType ( MethodBase methodBase ) : Type
methodBase MethodBase
Résultat Type

GetUniqueName() protected static méthode

Gets a unique name of the method base.
protected static GetUniqueName ( MethodBase methodBase ) : String
methodBase MethodBase
Résultat String

UnwrapResultOfInvocation() protected static méthode

Unwraps the result of invocation.
protected static UnwrapResultOfInvocation ( ILGenerator generator, LocalBuilder result, Type returnType, Type nativeReturnType, bool hasByRef ) : void
generator ILGenerator Generator.
result LocalBuilder Result.
returnType Type Return type.
nativeReturnType Type Native return type.
hasByRef bool If set to true has by reference.
Résultat void