Represents type which may not have built metadata.
コード例 #1
0
		public FieldDefinition( TypeDefinition declaringType, string fieldName, TypeDefinition fieldType )
		{
			this.DeclaringType = declaringType;
			this.FieldName = fieldName;
			this.FieldType = fieldType;
			this._runtimeField = null;
		}
コード例 #2
0
		public SinglelStepILConstruct( TypeDefinition contextType, string description, bool isTerminating, Action<TracingILGenerator> instruction )
			: base( contextType )
		{
			this._description = description;
			this._instruction = instruction;
			this._isTerminating = isTerminating;
		}
コード例 #3
0
		public VariableILConstruct( string name, TypeDefinition valueType )
			: base( valueType )
		{
			Contract.Assert( name != null );
			this._isLocal = true;
			this._name = name;
			this._index = -1;
		}
コード例 #4
0
		public VariableILConstruct( string name, TypeDefinition valueType, int parameterIndex )
			: base( valueType )
		{
			Contract.Assert( name != null );
			this._isLocal = false;
			this._name = name;
			this._index = parameterIndex;
		}
コード例 #5
0
		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();
		}
コード例 #6
0
		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() );
		}
コード例 #7
0
		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;
		}
コード例 #8
0
		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() );
		}
コード例 #9
0
		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;
		}
コード例 #10
0
ファイル: TypeDefinition.cs プロジェクト: msgpack/msgpack-cli
		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 );
		}
コード例 #11
0
		public static ParameterCodeDomConstruct Parameter( TypeDefinition type, string name )
		{
			return new ParameterCodeDomConstruct( type, name );
		}
コード例 #12
0
		public static ExpressionCodeDomConstruct Expression( TypeDefinition contextType, CodeExpression expression )
		{
			return new ExpressionCodeDomConstruct( contextType, expression );
		}
コード例 #13
0
		public ExpressionCodeDomConstruct( TypeDefinition contextType, CodeExpression dom )
			: base( contextType )
		{
			this._dom = dom;
		}
コード例 #14
0
		public SequenceILConstruct( TypeDefinition contextType, IEnumerable<ILConstruct> statements )
			: base( contextType )
		{
			this._statements = statements.ToArray();
		}
コード例 #15
0
		protected CodeDomConstruct( TypeDefinition contextType )
		{
			this._contextType = contextType;
		}
コード例 #16
0
		public ConstructorDefinition( TypeDefinition declaringType, params TypeDefinition[] parameterTypes )
		{
			this.DeclaringType = declaringType;
			this._runtimeConstructor = null;
			this.ParameterTypes = parameterTypes.ToArray();
		}
コード例 #17
0
		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;
		}
コード例 #18
0
ファイル: TypeDefinition.cs プロジェクト: msgpack/msgpack-cli
		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
				);

		}
コード例 #19
0
ファイル: TypeDefinition.cs プロジェクト: msgpack/msgpack-cli
		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;
		}
コード例 #20
0
		protected ContextfulILConstruct( TypeDefinition contextType )
			: base( contextType )
		{
		}
コード例 #21
0
ファイル: TypeDefinition.cs プロジェクト: msgpack/msgpack-cli
		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 );
		}
コード例 #22
0
		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;
			}
		}
コード例 #23
0
		public VariableCodeDomConstruct( TypeDefinition type, string name )
			: base( type )
		{
			this._type = CodeDomSerializerBuilder.ToCodeTypeReference( type );
			this._name = name;
		}
コード例 #24
0
		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;
		}
コード例 #25
0
		public static CodeDomConstruct Variable( TypeDefinition type, string name )
		{
			return new VariableCodeDomConstruct( type, name );
		}