Inheritance: MemberReference, IGenericParameterProvider, IGenericContext
コード例 #1
0
ファイル: Modifiers.cs プロジェクト: mayuki/Inazuma
		public OptionalModifierType (TypeReference modifierType, TypeReference type)
			: base (type)
		{
			Mixin.CheckModifier (modifierType, type);
			this.modifier_type = modifierType;
			this.etype = MD.ElementType.CModOpt;
		}
コード例 #2
0
ファイル: PropertyReference.cs プロジェクト: mayuki/Inazuma
		internal PropertyReference (string name, TypeReference propertyType)
			: base (name)
		{
			if (propertyType == null)
				throw new ArgumentNullException ("propertyType");

			property_type = propertyType;
		}
コード例 #3
0
ファイル: ParameterReference.cs プロジェクト: mayuki/Inazuma
		internal ParameterReference (string name, TypeReference parameterType)
		{
			if (parameterType == null)
				throw new ArgumentNullException ("parameterType");

			this.name = name ?? string.Empty;
			this.parameter_type = parameterType;
		}
コード例 #4
0
ファイル: FieldReference.cs プロジェクト: mayuki/Inazuma
		public FieldReference (string name, TypeReference fieldType, TypeReference declaringType)
			: this (name, fieldType)
		{
			if (declaringType == null)
				throw new ArgumentNullException("declaringType");

			this.DeclaringType = declaringType;
		}
コード例 #5
0
ファイル: EventReference.cs プロジェクト: mayuki/Inazuma
		protected EventReference (string name, TypeReference eventType)
			: base (name)
		{
			if (eventType == null)
				throw new ArgumentNullException ("eventType");

			event_type = eventType;
		}
コード例 #6
0
ファイル: FieldReference.cs プロジェクト: mayuki/Inazuma
		public FieldReference (string name, TypeReference fieldType)
			: base (name)
		{
			if (fieldType == null)
				throw new ArgumentNullException ("fieldType");

			this.field_type = fieldType;
			this.token = new MetadataToken (TokenType.MemberRef);
		}
コード例 #7
0
ファイル: Import.cs プロジェクト: mayuki/Inazuma
		TypeReference ImportTypeSpecification (TypeReference type, ImportGenericContext context)
		{
			switch (type.etype) {
			case ElementType.SzArray:
				var vector = (ArrayType) type;
				return new ArrayType (ImportType (vector.ElementType, context));
			case ElementType.Ptr:
				var pointer = (PointerType) type;
				return new PointerType (ImportType (pointer.ElementType, context));
			case ElementType.ByRef:
				var byref = (ByReferenceType) type;
				return new ByReferenceType (ImportType (byref.ElementType, context));
			case ElementType.Pinned:
				var pinned = (PinnedType) type;
				return new PinnedType (ImportType (pinned.ElementType, context));
			case ElementType.Sentinel:
				var sentinel = (SentinelType) type;
				return new SentinelType (ImportType (sentinel.ElementType, context));
			case ElementType.CModOpt:
				var modopt = (OptionalModifierType) type;
				return new OptionalModifierType (
					ImportType (modopt.ModifierType, context),
					ImportType (modopt.ElementType, context));
			case ElementType.CModReqD:
				var modreq = (RequiredModifierType) type;
				return new RequiredModifierType (
					ImportType (modreq.ModifierType, context),
					ImportType (modreq.ElementType, context));
			case ElementType.Array:
				var array = (ArrayType) type;
				var imported_array = new ArrayType (ImportType (array.ElementType, context));
				if (array.IsVector)
					return imported_array;

				var dimensions = array.Dimensions;
				var imported_dimensions = imported_array.Dimensions;

				imported_dimensions.Clear ();

				for (int i = 0; i < dimensions.Count; i++) {
					var dimension = dimensions [i];

					imported_dimensions.Add (new ArrayDimension (dimension.LowerBound, dimension.UpperBound));
				}

				return imported_array;
			case ElementType.GenericInst:
				var instance = (GenericInstanceType) type;
				var element_type = ImportType (instance.ElementType, context);
				var imported_instance = new GenericInstanceType (element_type);

				var arguments = instance.GenericArguments;
				var imported_arguments = imported_instance.GenericArguments;

				for (int i = 0; i < arguments.Count; i++)
					imported_arguments.Add (ImportType (arguments [i], context));

				return imported_instance;
			case ElementType.Var:
				var var_parameter = (GenericParameter) type;
				return context.TypeParameter (type.DeclaringType.FullName, var_parameter.Position);
			case ElementType.MVar:
				var mvar_parameter = (GenericParameter) type;
				return context.MethodParameter (mvar_parameter.DeclaringMethod.Name, mvar_parameter.Position);
			}

			throw new NotSupportedException (type.etype.ToString ());
		}
コード例 #8
0
ファイル: Modifiers.cs プロジェクト: mayuki/Inazuma
		public static void CheckModifier (TypeReference modifierType, TypeReference type)
		{
			if (modifierType == null)
				throw new ArgumentNullException ("modifierType");
			if (type == null)
				throw new ArgumentNullException ("type");
		}
コード例 #9
0
ファイル: ParameterDefinition.cs プロジェクト: mayuki/Inazuma
		public ParameterDefinition (TypeReference parameterType)
			: this (string.Empty, ParameterAttributes.None, parameterType)
		{
		}
コード例 #10
0
ファイル: CallSite.cs プロジェクト: mayuki/Inazuma
		public CallSite (TypeReference returnType)
			: this ()
		{
			if (returnType == null)
				throw new ArgumentNullException ("returnType");

			this.signature.ReturnType = returnType;
		}
コード例 #11
0
ファイル: FieldDefinition.cs プロジェクト: mayuki/Inazuma
		public FieldDefinition (string name, FieldAttributes attributes, TypeReference fieldType)
			: base (name, fieldType)
		{
			this.attributes = (ushort) attributes;
		}
コード例 #12
0
ファイル: TypeSystem.cs プロジェクト: mayuki/Inazuma
		TypeReference LookupSystemType (ref TypeReference reference, string name, ElementType element_type)
		{
			lock (module.SyncRoot) {
				if (reference != null)
					return reference;
				var type = LookupType ("System", name);
				type.etype = element_type;
				return reference = type;
			}
		}
コード例 #13
0
ファイル: SentinelType.cs プロジェクト: mayuki/Inazuma
		public SentinelType (TypeReference type)
			: base (type)
		{
			Mixin.CheckType (type);
			this.etype = MD.ElementType.Sentinel;
		}
コード例 #14
0
ファイル: Import.cs プロジェクト: mayuki/Inazuma
		public TypeReference ImportType (TypeReference type, ImportGenericContext context)
		{
			if (type.IsTypeSpecification ())
				return ImportTypeSpecification (type, context);

			var reference = new TypeReference (
				type.Namespace,
				type.Name,
				module,
				ImportScope (type.Scope),
				type.IsValueType);

			MetadataSystem.TryProcessPrimitiveTypeReference (reference);

			if (type.IsNested)
				reference.DeclaringType = ImportType (type.DeclaringType, context);

			if (type.HasGenericParameters)
				ImportGenericParameters (reference, type);

			return reference;
		}
コード例 #15
0
ファイル: Import.cs プロジェクト: mayuki/Inazuma
		public TypeReference ImportType (Type type, ImportGenericContext context, ImportGenericKind import_kind)
		{
			if (IsTypeSpecification (type) || ImportOpenGenericType (type, import_kind))
				return ImportTypeSpecification (type, context);

			var reference = new TypeReference (
				string.Empty,
				type.Name,
				module,
				ImportScope (type.Assembly),
				type.IsValueType);

			reference.etype = ImportElementType (type);

			if (IsNestedType (type))
				reference.DeclaringType = ImportType (type.DeclaringType, context, import_kind);
			else
				reference.Namespace = type.Namespace ?? string.Empty;

			if (type.IsGenericType)
				ImportGenericParameters (reference, type.GetGenericArguments ());

			return reference;
		}
コード例 #16
0
ファイル: TypeDefinition.cs プロジェクト: mayuki/Inazuma
		public TypeDefinition (string @namespace, string name, TypeAttributes attributes, TypeReference baseType) :
			this (@namespace, name, attributes)
		{
			this.BaseType = baseType;
		}
コード例 #17
0
ファイル: TypeSpecification.cs プロジェクト: mayuki/Inazuma
		public static void CheckType (TypeReference type)
		{
			if (type == null)
				throw new ArgumentNullException ("type");
		}
コード例 #18
0
ファイル: TypeSpecification.cs プロジェクト: mayuki/Inazuma
		internal TypeSpecification (TypeReference type)
			: base (null, null)
		{
			this.element_type = type;
			this.token = new MetadataToken (TokenType.TypeSpec);
		}
コード例 #19
0
ファイル: GenericInstanceType.cs プロジェクト: mayuki/Inazuma
		public GenericInstanceType (TypeReference type)
			: base (type)
		{
			base.IsValueType = type.IsValueType;
			this.etype = MD.ElementType.GenericInst;
		}
コード例 #20
0
ファイル: MetadataSystem.cs プロジェクト: mayuki/Inazuma
		public static void TryProcessPrimitiveTypeReference (TypeReference type)
		{
			if (type.Namespace != "System")
				return;

			var scope = type.scope;
			if (scope == null || scope.MetadataScopeType != MetadataScopeType.AssemblyNameReference)
				return;

			Row<ElementType, bool> primitive_data;
			if (!TryGetPrimitiveData (type, out primitive_data))
				return;

			type.etype = primitive_data.Col1;
			type.IsValueType = primitive_data.Col2;
		}
コード例 #21
0
ファイル: TypeSystem.cs プロジェクト: mayuki/Inazuma
		TypeReference LookupSystemValueType (ref TypeReference typeRef, string name, ElementType element_type)
		{
			lock (module.SyncRoot) {
				if (typeRef != null)
					return typeRef;
				var type = LookupType ("System", name);
				type.etype = element_type;
				type.IsValueType = true;
				return typeRef = type;
			}
		}
コード例 #22
0
ファイル: MetadataSystem.cs プロジェクト: mayuki/Inazuma
		static bool TryGetPrimitiveData (TypeReference type, out Row<ElementType, bool> primitive_data)
		{
			if (primitive_value_types == null)
				InitializePrimitives ();

			return primitive_value_types.TryGetValue (type.Name, out primitive_data);
		}
コード例 #23
0
ファイル: MethodDefinition.cs プロジェクト: mayuki/Inazuma
		public MethodDefinition (string name, MethodAttributes attributes, TypeReference returnType)
			: base (name, returnType)
		{
			this.attributes = (ushort) attributes;
			this.HasThis = !this.IsStatic;
			this.token = new MetadataToken (TokenType.Method);
		}
コード例 #24
0
ファイル: MetadataSystem.cs プロジェクト: mayuki/Inazuma
		public void AddTypeReference (TypeReference type)
		{
			TypeReferences [type.token.RID - 1] = type;
		}
コード例 #25
0
ファイル: ClassLoader.cs プロジェクト: mayuki/Inazuma
 public MethodTable LoadTypeFromTypeRef(TypeReference typeRef)
 {
     return LoadType(typeRef.Resolve()); // TODO: improve performance
 }
コード例 #26
0
ファイル: ArrayType.cs プロジェクト: mayuki/Inazuma
		public ArrayType (TypeReference type)
			: base (type)
		{
			Mixin.CheckType (type);
			this.etype = MD.ElementType.Array;
		}
コード例 #27
0
ファイル: ParameterDefinition.cs プロジェクト: mayuki/Inazuma
		internal ParameterDefinition (TypeReference parameterType, IMethodSignature method)
			: this (string.Empty, ParameterAttributes.None, parameterType)
		{
			this.method = method;
		}
コード例 #28
0
ファイル: ArrayType.cs プロジェクト: mayuki/Inazuma
		public ArrayType (TypeReference type, int rank)
			: this (type)
		{
			Mixin.CheckType (type);

			if (rank == 1)
				return;

			dimensions = new Collection<ArrayDimension> (rank);
			for (int i = 0; i < rank; i++)
				dimensions.Add (new ArrayDimension ());
			this.etype = MD.ElementType.Array;
		}
コード例 #29
0
ファイル: ParameterDefinition.cs プロジェクト: mayuki/Inazuma
		public ParameterDefinition (string name, ParameterAttributes attributes, TypeReference parameterType)
			: base (name, parameterType)
		{
			this.attributes = (ushort) attributes;
			this.token = new MetadataToken (TokenType.Param);
		}
コード例 #30
0
ファイル: Modifiers.cs プロジェクト: mayuki/Inazuma
		public RequiredModifierType (TypeReference modifierType, TypeReference type)
			: base (type)
		{
			Mixin.CheckModifier (modifierType, type);
			this.modifier_type = modifierType;
			this.etype = MD.ElementType.CModReqD;
		}