public FieldDefinition( TypeDefinition declaringType, string fieldName, TypeDefinition fieldType ) { this.DeclaringType = declaringType; this.FieldName = fieldName; this.FieldType = fieldType; this._runtimeField = null; }
public SinglelStepILConstruct( TypeDefinition contextType, string description, bool isTerminating, Action<TracingILGenerator> instruction ) : base( contextType ) { this._description = description; this._instruction = instruction; this._isTerminating = isTerminating; }
public VariableILConstruct( string name, TypeDefinition valueType ) : base( valueType ) { Contract.Assert( name != null ); this._isLocal = true; this._name = name; this._index = -1; }
public VariableILConstruct( string name, TypeDefinition valueType, int parameterIndex ) : base( valueType ) { Contract.Assert( name != null ); this._isLocal = false; this._name = name; this._index = parameterIndex; }
public ConstructorDefinition( ConstructorInfo runtimeConstructor, IEnumerable<TypeDefinition> parameterTypes ) { #if DEBUG Contract.Assert( runtimeConstructor.DeclaringType != null, "runtimeConstructor.DeclaringType != null" ); #endif // DEBUG this.DeclaringType = runtimeConstructor.DeclaringType; this._runtimeConstructor = runtimeConstructor; this.ParameterTypes = parameterTypes.ToArray(); }
internal static TypeDefinition GetDelegateTypeDefinition( TypeDefinition returnType, TypeDefinition[] parameterTypes ) { var typeDefinition = FindDelegateType( returnType, parameterTypes ); return returnType.TryGetRuntimeType() == typeof( void ) ? parameterTypes.Length == 0 ? typeDefinition : TypeDefinition.GenericReferenceType( typeDefinition, parameterTypes ) : TypeDefinition.GenericReferenceType( typeDefinition, parameterTypes.Concat( new[] { returnType } ).ToArray() ); }
public BinaryOperatorILConstruct( string @operator, TypeDefinition resultType, ILConstruct left, ILConstruct right, Action<TracingILGenerator, ILConstruct, ILConstruct> operation, Action<TracingILGenerator, ILConstruct, ILConstruct, Label> branchOperation ) : base( resultType ) { ValidateContextTypeMatch( left, right ); this._operator = @operator; this._left = left; this._right = right; this._operation = operation; this._branchOperation = branchOperation; }
internal static Type GetResolvedDelegateType( TypeDefinition returnType, TypeDefinition[] parameterTypes ) { var typeDefinition = FindDelegateType( returnType, parameterTypes ); return returnType.TryGetRuntimeType() == typeof( void ) ? parameterTypes.Length == 0 ? typeDefinition : typeDefinition.MakeGenericType( parameterTypes.Select( t => t.ResolveRuntimeType() ).ToArray() ) : typeDefinition.MakeGenericType( parameterTypes.Select( t => t.ResolveRuntimeType() ).Concat( new[] { returnType.ResolveRuntimeType() } ).ToArray() ); }
public static Type FindDelegateType( TypeDefinition returnType, TypeDefinition[] parameterTypes ) { var typeName = "System." + ( returnType.TryGetRuntimeType() == typeof( void ) ? "Action" : "Func" ); if ( returnType.TryGetRuntimeType() == typeof( void ) && parameterTypes.Length > 0 ) { typeName += "`" + parameterTypes.Length.ToString( "D", CultureInfo.InvariantCulture ); } else { typeName += "`" + ( parameterTypes.Length + 1 ).ToString( "D", CultureInfo.InvariantCulture ); } var type = Type.GetType( typeName, false ); if ( type == null ) { // Try get from System.Core.dll type = typeof( Enumerable ).GetAssembly().GetType( typeName ); } return type; }
public static TypeDefinition Array( TypeDefinition elementType ) { return elementType.HasRuntimeTypeFully() ? new TypeDefinition( elementType.ResolveRuntimeType().MakeArrayType(), elementType.ResolveRuntimeType().FullName + "[]", elementType, Flags.HasRuntimeType ) : new TypeDefinition( null, elementType.TypeName, elementType, Flags.Array ); }
public static ParameterCodeDomConstruct Parameter( TypeDefinition type, string name ) { return new ParameterCodeDomConstruct( type, name ); }
public static ExpressionCodeDomConstruct Expression( TypeDefinition contextType, CodeExpression expression ) { return new ExpressionCodeDomConstruct( contextType, expression ); }
public ExpressionCodeDomConstruct( TypeDefinition contextType, CodeExpression dom ) : base( contextType ) { this._dom = dom; }
public SequenceILConstruct( TypeDefinition contextType, IEnumerable<ILConstruct> statements ) : base( contextType ) { this._statements = statements.ToArray(); }
protected CodeDomConstruct( TypeDefinition contextType ) { this._contextType = contextType; }
public ConstructorDefinition( TypeDefinition declaringType, params TypeDefinition[] parameterTypes ) { this.DeclaringType = declaringType; this._runtimeConstructor = null; this.ParameterTypes = parameterTypes.ToArray(); }
public MethodDefinition( string name, TypeDefinition[] genericArguments, TypeDefinition declaringType, bool isStatic, TypeDefinition returnType, params TypeDefinition[] parameterTypes ) { this.MethodName = name; this.DeclaringType = declaringType; this.IsStatic = isStatic; this._runtimeMethod = null; this._genericArguments = genericArguments; this.ReturnType = returnType; this.ParameterTypes = parameterTypes; }
private static TypeDefinition Generic( bool isValueType, Type definition, TypeDefinition[] arguments ) { #if DEBUG Contract.Assert( definition.FullName.Contains( "`" ), definition.FullName + " does not have ` mark." ); #endif // DEBUG return new TypeDefinition( definition, definition.FullName.Remove( definition.FullName.IndexOf( '`' ) ), null, isValueType ? Flags.ValueType : Flags.None, arguments ); }
private TypeDefinition( Type runtimeType, string name, TypeDefinition elementType, Flags flags, params TypeDefinition[] genericArguments ) { #if DEBUG Contract.Assert( runtimeType == null || !runtimeType.GetIsGenericTypeDefinition() || runtimeType.GetGenericTypeParameters().Length == genericArguments.Length, runtimeType?.GetFullName() + " == <" + String.Join( ", ", genericArguments.Select( t => t.ToString() ).ToArray() ) + ">" ); #endif // DEBUG this.TypeName = name; this._runtimeType = runtimeType; this._flags = flags; this.ElementType = elementType; this.GenericArguments = genericArguments ?? EmptyArray; }
protected ContextfulILConstruct( TypeDefinition contextType ) : base( contextType ) { }
public static TypeDefinition ManagedReference( TypeDefinition elementType ) { return elementType.HasRuntimeTypeFully() ? new TypeDefinition( elementType.ResolveRuntimeType().MakeByRefType(), elementType.ResolveRuntimeType().FullName, elementType, Flags.HasRuntimeType ) : new TypeDefinition( null, elementType.TypeName, elementType, Flags.Ref ); }
public MethodDefinition( MethodInfo runtimeMethod, Type @interface, IEnumerable<TypeDefinition> parameterTypes ) { #if DEBUG Contract.Assert( runtimeMethod.DeclaringType != null, "runtimeMethod.DeclaringType != null" ); #endif // DEBUG this.MethodName = runtimeMethod.Name; this.DeclaringType = runtimeMethod.DeclaringType; this.IsStatic = runtimeMethod.IsStatic; this._runtimeMethod = runtimeMethod; this.ReturnType = runtimeMethod.ReturnType; this.ParameterTypes = parameterTypes.ToArray(); if ( runtimeMethod.Name.Contains( "." ) && !runtimeMethod.GetIsPublic() ) { // should be explicit interface impl. this.Interface = @interface; } }
public VariableCodeDomConstruct( TypeDefinition type, string name ) : base( type ) { this._type = CodeDomSerializerBuilder.ToCodeTypeReference( type ); this._name = name; }
public FieldDefinition( FieldInfo runtimeField ) { #if DEBUG Contract.Assert( runtimeField.DeclaringType != null, "runtimeField.DeclaringType != null" ); #endif // DEBUG this.DeclaringType = runtimeField.DeclaringType; this.FieldName = runtimeField.Name; this.FieldType = runtimeField.FieldType; this._runtimeField = runtimeField; }
public static CodeDomConstruct Variable( TypeDefinition type, string name ) { return new VariableCodeDomConstruct( type, name ); }