public OptionalModifierType (TypeReference modifierType, TypeReference type) : base (type) { Mixin.CheckModifier (modifierType, type); this.modifier_type = modifierType; this.etype = MD.ElementType.CModOpt; }
internal PropertyReference (string name, TypeReference propertyType) : base (name) { if (propertyType == null) throw new ArgumentNullException ("propertyType"); property_type = propertyType; }
internal ParameterReference (string name, TypeReference parameterType) { if (parameterType == null) throw new ArgumentNullException ("parameterType"); this.name = name ?? string.Empty; this.parameter_type = parameterType; }
public FieldReference (string name, TypeReference fieldType, TypeReference declaringType) : this (name, fieldType) { if (declaringType == null) throw new ArgumentNullException("declaringType"); this.DeclaringType = declaringType; }
protected EventReference (string name, TypeReference eventType) : base (name) { if (eventType == null) throw new ArgumentNullException ("eventType"); event_type = eventType; }
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); }
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 ()); }
public static void CheckModifier (TypeReference modifierType, TypeReference type) { if (modifierType == null) throw new ArgumentNullException ("modifierType"); if (type == null) throw new ArgumentNullException ("type"); }
public ParameterDefinition (TypeReference parameterType) : this (string.Empty, ParameterAttributes.None, parameterType) { }
public CallSite (TypeReference returnType) : this () { if (returnType == null) throw new ArgumentNullException ("returnType"); this.signature.ReturnType = returnType; }
public FieldDefinition (string name, FieldAttributes attributes, TypeReference fieldType) : base (name, fieldType) { this.attributes = (ushort) attributes; }
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; } }
public SentinelType (TypeReference type) : base (type) { Mixin.CheckType (type); this.etype = MD.ElementType.Sentinel; }
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; }
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; }
public TypeDefinition (string @namespace, string name, TypeAttributes attributes, TypeReference baseType) : this (@namespace, name, attributes) { this.BaseType = baseType; }
public static void CheckType (TypeReference type) { if (type == null) throw new ArgumentNullException ("type"); }
internal TypeSpecification (TypeReference type) : base (null, null) { this.element_type = type; this.token = new MetadataToken (TokenType.TypeSpec); }
public GenericInstanceType (TypeReference type) : base (type) { base.IsValueType = type.IsValueType; this.etype = MD.ElementType.GenericInst; }
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; }
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; } }
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); }
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); }
public void AddTypeReference (TypeReference type) { TypeReferences [type.token.RID - 1] = type; }
public MethodTable LoadTypeFromTypeRef(TypeReference typeRef) { return LoadType(typeRef.Resolve()); // TODO: improve performance }
public ArrayType (TypeReference type) : base (type) { Mixin.CheckType (type); this.etype = MD.ElementType.Array; }
internal ParameterDefinition (TypeReference parameterType, IMethodSignature method) : this (string.Empty, ParameterAttributes.None, parameterType) { this.method = method; }
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; }
public ParameterDefinition (string name, ParameterAttributes attributes, TypeReference parameterType) : base (name, parameterType) { this.attributes = (ushort) attributes; this.token = new MetadataToken (TokenType.Param); }
public RequiredModifierType (TypeReference modifierType, TypeReference type) : base (type) { Mixin.CheckModifier (modifierType, type); this.modifier_type = modifierType; this.etype = MD.ElementType.CModReqD; }