C# Class IronPython.Runtime.Types.NewTypeMaker

Python class hierarchy is represented using the __class__ field in the object. It does not use the CLI type system for pure Python types. However, Python types which inherit from a CLI type, or from a builtin Python type which is implemented in the engine by a CLI type, do have to use the CLI type system to interoperate with the CLI world. This means that objects of different Python types, but with the same CLI base type, can use the same CLI type - they will just have different values for the __class__ field. The easiest way to inspect the functionality implemented by NewTypeMaker is to persist the generated IL using "ipy.exe -X:SaveAssemblies", and then inspect the persisted IL using ildasm.
Afficher le fichier Open project: jschementi/iron Class Usage Examples

Private Properties

Свойство Type Description
AddBaseMethods void
AddDebugView void
AddPropertyInfo Microsoft.Scripting.Actions.ExtensionPropertyTracker
AddPublicProperty void
CallBaseConstructor void
CanOverrideMethod bool
CreateNewType System.Type
CreateSuperCallHelper System.Reflection.Emit.MethodBuilder
CreateVTableEventOverride void
CreateVTableGetterOverride System.Reflection.Emit.MethodBuilder
CreateVTableMethodOverride System.Reflection.Emit.MethodBuilder
CreateVTableSetterOverride System.Reflection.Emit.MethodBuilder
DefineExplicitInterfaceImplementation ILGen
DefineHelperInterface void
DefineInterfaces void
DefineMethodOverride ILGen
DefineMethodOverride ILGen
DefineMethodOverride ILGen
DefineVTableMethodOverride void
DoInterfaceType void
EmitBaseClassCallCheckForEvents System.Reflection.Emit.LocalBuilder
EmitBaseClassCallCheckForProperties System.Reflection.Emit.LocalBuilder
EmitBaseMethodDispatch void
EmitClrCallStub void
EmitCodeContext void
EmitConvertFromObject void
EmitGetDict void
EmitInt void
EmitNonInheritedMethodLookup System.Reflection.Emit.LocalBuilder
EmitSetDict void
FinishType System.Type
GetBaseName IEnumerable
GetBaseTypeForMethod IronPython.Runtime.Types.PythonType
GetCCtor ILGen
GetName string
GetOriginalIndex int
GetOverriddenMethods IList
GetOverriddenProperties IList
GetOverrideCtorSignature System.Reflection.ParameterInfo[]
ImplementCTDOverride void
ImplementConstructors void
ImplementCustomTypeDescriptor void
ImplementDynamicObject void
ImplementIPythonObject void
ImplementInterface void
ImplementProtectedFieldAccessors void
ImplementPythonEquals void
ImplementPythonObject void
ImplementType string[]>.Dictionary
ImplementWeakReference void
MakeSiteSignature System.Type[]
NewTypeMaker System
OverrideBaseMethod void
OverrideConstructor void
OverrideMethods void
OverrideSpecialName void
SaveType KeyValuePair>
StoreOverriddenField void
StoreOverriddenMethod void
StoreOverriddenProperty void
TryOverrideProperty bool

Méthodes publiques

Méthode Description
GetNewType ( string typeName, PythonTuple bases ) : Type
IsInstanceType ( Type type ) : bool

Is this a type used for instances Python types (and not for the types themselves)?

LoadNewTypes ( Assembly asm ) : void

Loads any available new types from the provided assembly and makes them available via the GetNewType API.

SaveNewTypes ( string assemblyName, IList types ) : void

Private Methods

Méthode Description
AddBaseMethods ( Type finishedType, string[]>.Dictionary specialNames ) : void
AddDebugView ( ) : void
AddPropertyInfo ( Type baseType, string propName, MethodInfo get, MethodInfo set ) : Microsoft.Scripting.Actions.ExtensionPropertyTracker
AddPublicProperty ( MethodInfo mi, PropertyBuilder>.Dictionary overridden, MethodBuilder mb, PropertyInfo foundProperty ) : void
CallBaseConstructor ( ConstructorInfo parentConstructor, ParameterInfo pis, ParameterInfo overrideParams, ILGen il ) : void
CanOverrideMethod ( MethodInfo mi ) : bool
CreateNewType ( ) : Type
CreateSuperCallHelper ( MethodInfo mi ) : MethodBuilder

Creates a method for doing a base method dispatch. This is used to support super(type, obj) calls.

CreateVTableEventOverride ( MethodInfo mi, string name ) : void
CreateVTableGetterOverride ( MethodInfo mi, string name ) : MethodBuilder
CreateVTableMethodOverride ( MethodInfo mi, string name ) : MethodBuilder
CreateVTableSetterOverride ( MethodInfo mi, string name ) : MethodBuilder
DefineExplicitInterfaceImplementation ( MethodInfo baseMethod, MethodBuilder &builder ) : ILGen
DefineHelperInterface ( Type intf ) : void

Defines an interface on the type that forwards all calls to a helper method in UserType. The method names all will have Helper appended to them to get the name for UserType. The UserType version should take 1 extra parameter (self).

DefineInterfaces ( ) : void
DefineMethodOverride ( MethodAttributes extra, MethodInfo decl, MethodBuilder &impl ) : ILGen
DefineMethodOverride ( MethodAttributes extra, Type type, string name, MethodInfo &decl, MethodBuilder &impl ) : ILGen
DefineMethodOverride ( MethodInfo decl, MethodBuilder &impl ) : ILGen
DefineVTableMethodOverride ( MethodInfo mi, MethodBuilder &impl, ILGen &il ) : void
DoInterfaceType ( Type interfaceType, bool>.Dictionary doneTypes, string[]>.Dictionary specialNames ) : void
EmitBaseClassCallCheckForEvents ( ILGen il, MethodInfo baseMethod, string name ) : LocalBuilder

Emits code to check if the class has overridden this specific function. For example: MyDerivedType.SomeVirtualFunction = ... or class MyDerivedType(MyBaseType): def SomeVirtualFunction(self, ...):

EmitBaseClassCallCheckForProperties ( ILGen il, MethodInfo baseMethod, string name ) : LocalBuilder

Emits code to check if the class has overridden this specific function. For example: MyDerivedType.SomeVirtualFunction = ... or class MyDerivedType(MyBaseType): def SomeVirtualFunction(self, ...):

EmitBaseMethodDispatch ( MethodInfo mi, ILGen il ) : void

Loads all the incoming arguments and forwards them to mi which has the same signature and then returns the result

EmitClrCallStub ( ILGen il, MethodInfo mi, LocalBuilder callTarget ) : void

Generates stub to receive the CLR call and then call the dynamic language code. This code is same as StubGenerator.cs in the Microsoft.Scripting, except it accepts ILGen instead of Compiler.

EmitCodeContext ( ILGen il, bool context ) : void
EmitConvertFromObject ( ILGen il, Type toType ) : void

Emit code to convert object to a given type. This code is semantically equivalent to PythonBinder.EmitConvertFromObject, except this version accepts ILGen whereas PythonBinder accepts Compiler. The Binder will chagne soon and the two will merge.

EmitGetDict ( ILGen gen ) : void
EmitInt ( ILGenerator ilg, int iVal ) : void
EmitNonInheritedMethodLookup ( string name, ILGen il ) : LocalBuilder

Emits the call to lookup a member defined in the user's type. Returns the local which stores the resulting value and leaves a value on the stack indicating the success of the lookup.

EmitSetDict ( ILGen gen ) : void
FinishType ( ) : Type
GetBaseName ( MethodInfo mi, string[]>.Dictionary specialNames ) : IEnumerable
GetBaseTypeForMethod ( MethodInfo mi ) : IronPython.Runtime.Types.PythonType
GetCCtor ( ) : ILGen
GetName ( ) : string
GetOriginalIndex ( ParameterInfo pis, ParameterInfo overrideParams, int i ) : int

Gets the position for the parameter which we are overriding.

GetOverriddenMethods ( Type type, string name ) : IList

Called from PythonTypeOps - the BuiltinFunction._function lock must be held.

GetOverriddenProperties ( Type type, string name ) : IList
GetOverrideCtorSignature ( ParameterInfo original ) : System.Reflection.ParameterInfo[]
ImplementCTDOverride ( MethodInfo m ) : void
ImplementConstructors ( ) : void
ImplementCustomTypeDescriptor ( ) : void
ImplementDynamicObject ( ) : void
ImplementIPythonObject ( ) : void
ImplementInterface ( Type interfaceType ) : void
ImplementProtectedFieldAccessors ( string[]>.Dictionary specialNames ) : void
ImplementPythonEquals ( ) : void
ImplementPythonObject ( ) : void
ImplementType ( ) : string[]>.Dictionary
ImplementWeakReference ( ) : void
MakeSiteSignature ( int nargs ) : System.Type[]
NewTypeMaker ( NewTypeInfo typeInfo ) : System
OverrideBaseMethod ( MethodInfo mi, string[]>.Dictionary specialNames ) : void
OverrideConstructor ( ConstructorInfo parentConstructor ) : void
OverrideMethods ( Type type, string[]>.Dictionary specialNames ) : void

Overrides methods - this includes all accessible virtual methods as well as protected non-virtual members including statics and non-statics.

OverrideSpecialName ( MethodInfo mi, string[]>.Dictionary specialNames, PropertyBuilder>.Dictionary overridden ) : void
SaveType ( Microsoft.Scripting.Generation.AssemblyGen ag, string name ) : KeyValuePair>
StoreOverriddenField ( MethodInfo mi, string newName ) : void
StoreOverriddenMethod ( MethodInfo mi, string newName ) : void
StoreOverriddenProperty ( MethodInfo mi, string newName ) : void
TryOverrideProperty ( MethodInfo mi, string[]>.Dictionary specialNames, PropertyBuilder>.Dictionary overridden ) : bool

Method Details

GetNewType() public static méthode

public static GetNewType ( string typeName, PythonTuple bases ) : Type
typeName string
bases PythonTuple
Résultat System.Type

IsInstanceType() public static méthode

Is this a type used for instances Python types (and not for the types themselves)?
public static IsInstanceType ( Type type ) : bool
type System.Type
Résultat bool

LoadNewTypes() public static méthode

Loads any available new types from the provided assembly and makes them available via the GetNewType API.
public static LoadNewTypes ( Assembly asm ) : void
asm System.Reflection.Assembly
Résultat void

SaveNewTypes() public static méthode

public static SaveNewTypes ( string assemblyName, IList types ) : void
assemblyName string
types IList
Résultat void