public override void Visit(IGenericTypeParameterReference genericTypeParameterReference) { var definingType = genericTypeParameterReference.DefiningType; int index = genericTypeParameterReference.Index; //This index does not account for any inherited generic parameters. See if any containing types contain typeBuilder parameters and adjust the index. while (true) { var nestedType = definingType as INestedTypeReference; if (nestedType == null) { break; } definingType = nestedType.ContainingType; var genericTypeInstance = definingType as IGenericTypeInstanceReference; if (genericTypeInstance != null) { index += (int)IteratorHelper.EnumerableCount(genericTypeInstance.GenericArguments); } } //The defining typeBuilder may actually be a containing typeBuilder of the typeBuilder that contains the reference we are mapping here. //In that case, the System.Type object obtained below will probably be a different object than the one that would //be obtained by looking at the (consolidated) typeBuilder parameter list of the System.Type object that contains the reference. //We assume that this does not matter, however, since a Reflection typeBuilder parameter does not keep (visible) track of the typeBuilder which //it parameterizes. var genericType = this.mapper.GetType(definingType); this.result = genericType.GetGenericArguments()[genericTypeParameterReference.Index]; }
public override void Visit(IGenericTypeParameterReference genericTypeParameterReference) { if (Process(genericTypeParameterReference)) { visitor.Visit(genericTypeParameterReference); } base.Visit(genericTypeParameterReference); }
public override ITypeReference Rewrite(IGenericTypeParameterReference genericTypeParameterReference) { if (this.sourceType != null && TypeHelper.TypesAreEquivalent(genericTypeParameterReference.DefiningType, this.sourceType)) { return(this.targetMethodGenericParameters[genericTypeParameterReference.Index]); } return(genericTypeParameterReference); }
public override void TraverseChildren(IGenericTypeParameterReference genericTypeParameterReference) { var typ = genericTypeParameterReference.ResolvedType; if (typ == Dummy.GenericTypeParameter) { this.EmitError(genericTypeParameterReference, ErrorCode.GenericTypeParameterResolution); } else if ((typ.Name != genericTypeParameterReference.Name && !genericTypeParameterReference.Name.Value.StartsWith("!")) || typ.Index != genericTypeParameterReference.Index) { this.EmitError(genericTypeParameterReference, ErrorCode.GenericTypeParameterResolution); } base.TraverseChildren(genericTypeParameterReference); }
public override void Visit(IGenericTypeParameterReference genericTypeParameterReference) { var definingType = genericTypeParameterReference.DefiningType; int index = genericTypeParameterReference.Index; //This index does not account for any inherited generic parameters. See if any containing types contain typeBuilder parameters and adjust the index. while (true) { var nestedType = definingType as INestedTypeReference; if (nestedType == null) break; definingType = nestedType.ContainingType; var genericTypeInstance = definingType as IGenericTypeInstanceReference; if (genericTypeInstance != null) index += (int)IteratorHelper.EnumerableCount(genericTypeInstance.GenericArguments); } //The defining typeBuilder may actually be a containing typeBuilder of the typeBuilder that contains the reference we are mapping here. //In that case, the System.Type object obtained below will probably be a different object than the one that would //be obtained by looking at the (consolidated) typeBuilder parameter list of the System.Type object that contains the reference. //We assume that this does not matter, however, since a Reflection typeBuilder parameter does not keep (visible) track of the typeBuilder which //it parameterizes. var genericType = this.mapper.GetType(definingType); this.result = genericType.GetGenericArguments()[genericTypeParameterReference.Index]; }
/// <summary> /// Rewrites the given generic type parameter reference. /// </summary> /// <param name="genericTypeParameterReference"></param> /// <returns></returns> public override ITypeReference Rewrite(IGenericTypeParameterReference genericTypeParameterReference) { var result = this.TryMap(genericTypeParameterReference); return result ?? base.Rewrite(genericTypeParameterReference); }
public override void TraverseChildren(IGenericTypeParameterReference genericTypeParameterReference) { MethodEnter(genericTypeParameterReference); base.TraverseChildren(genericTypeParameterReference); MethodExit(); }
public override ITypeReference Rewrite(IGenericTypeParameterReference genericTypeParameterReference) { return(this.genericArgumentsMap.Find(genericTypeParameterReference.InternedKey) ?? genericTypeParameterReference); }
public virtual void Visit(IGenericTypeParameterReference genericTypeParameterReference) { }
/// <summary> /// Visit a genericTypeParameterReference. Do not copy if it is a generic type parameter. /// </summary> public override IGenericTypeParameterReference Visit(IGenericTypeParameterReference genericTypeParameterReference) { return(genericTypeParameterReference); }
public override ITypeReference Rewrite(IGenericTypeParameterReference genericTypeParameterReference) { if (this.sourceType != null && TypeHelper.TypesAreEquivalent(genericTypeParameterReference.DefiningType, this.sourceType)) return this.targetMethodGenericParameters[genericTypeParameterReference.Index]; return genericTypeParameterReference; }
/// <summary> /// Traverses the generic type parameter reference. /// </summary> public void Traverse(IGenericTypeParameterReference genericTypeParameterReference) { Contract.Requires(genericTypeParameterReference != null); if (!this.objectsThatHaveAlreadyBeenTraversed.Add(genericTypeParameterReference)) return; if (this.preorderVisitor != null) this.preorderVisitor.Visit(genericTypeParameterReference); if (this.stopTraversal) return; this.TraverseChildren(genericTypeParameterReference); if (this.stopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(genericTypeParameterReference); }
/// <summary> /// Rewrites the given generic type parameter reference. /// </summary> public virtual ITypeReference Rewrite(IGenericTypeParameterReference genericTypeParameterReference) { return genericTypeParameterReference; }
public override ITypeReference Rewrite(IGenericTypeParameterReference genericTypeParameterReference) { if (genericTypeParameterReference.DefiningType.ResolvedType == this.sourceType) return this.targetTypeGenericParameters[genericTypeParameterReference.Index]; return base.Rewrite(genericTypeParameterReference); }
public override string GetTypeName(ITypeReference type, NameFormattingOptions formattingOptions) { Contract.Requires(type != null); Contract.Ensures(Contract.Result <string>() != null); if (type is Dummy) { return("Microsoft.Cci.DummyTypeReference"); } if ((formattingOptions & NameFormattingOptions.UseTypeKeywords) != 0) { switch (type.TypeCode) { case PrimitiveTypeCode.Boolean: return("Boolean"); case PrimitiveTypeCode.Char: return("Char"); case PrimitiveTypeCode.Float32: return("Float"); case PrimitiveTypeCode.Float64: return("Double"); case PrimitiveTypeCode.Int16: return("Short"); case PrimitiveTypeCode.Int32: return("Integer"); case PrimitiveTypeCode.Int64: return("Long"); case PrimitiveTypeCode.Int8: return("SByte"); case PrimitiveTypeCode.String: return("String"); case PrimitiveTypeCode.UInt16: return("UShort"); case PrimitiveTypeCode.UInt32: return("UInteger"); case PrimitiveTypeCode.UInt64: return("ULong"); case PrimitiveTypeCode.UInt8: return("Byte"); case PrimitiveTypeCode.Void: { Contract.Assert(false); throw new InvalidOperationException(); } case PrimitiveTypeCode.NotPrimitive: if (TypeHelper.TypesAreEquivalent(type, type.PlatformType.SystemDecimal)) { return("Decimal"); } if (TypeHelper.TypesAreEquivalent(type, type.PlatformType.SystemObject)) { return("Object"); } break; } } IArrayTypeReference /*?*/ arrayType = type as IArrayTypeReference; if (arrayType != null) { return(this.GetArrayTypeName(arrayType, formattingOptions)); } IFunctionPointerTypeReference /*?*/ functionPointerType = type as IFunctionPointerTypeReference; if (functionPointerType != null) { return(this.GetFunctionPointerTypeName(functionPointerType, formattingOptions)); } IGenericTypeParameterReference /*?*/ genericTypeParam = type as IGenericTypeParameterReference; if (genericTypeParam != null) { return(this.GetGenericTypeParameterName(genericTypeParam, formattingOptions)); } IGenericMethodParameterReference /*?*/ genericMethodParam = type as IGenericMethodParameterReference; if (genericMethodParam != null) { return(this.GetGenericMethodParameterName(genericMethodParam, formattingOptions)); } IGenericTypeInstanceReference /*?*/ genericInstance = type as IGenericTypeInstanceReference; if (genericInstance != null) { return(this.GetGenericTypeInstanceName(genericInstance, formattingOptions)); } INestedTypeReference /*?*/ ntTypeDef = type as INestedTypeReference; if (ntTypeDef != null) { return(this.GetNestedTypeName(ntTypeDef, formattingOptions)); } INamespaceTypeReference /*?*/ nsTypeDef = type as INamespaceTypeReference; if (nsTypeDef != null) { return(this.GetNamespaceTypeName(nsTypeDef, formattingOptions)); } IPointerTypeReference /*?*/ pointerType = type as IPointerTypeReference; if (pointerType != null) { return(this.GetPointerTypeName(pointerType, formattingOptions)); } IManagedPointerTypeReference /*?*/ managedPointerType = type as IManagedPointerTypeReference; if (managedPointerType != null) { return(this.GetManagedPointerTypeName(managedPointerType, formattingOptions)); } IModifiedTypeReference /*?*/ modifiedType = type as IModifiedTypeReference; if (modifiedType != null) { return(this.GetModifiedTypeName(modifiedType, formattingOptions)); } if (type.ResolvedType != type && !(type.ResolvedType is Dummy)) { return(this.GetTypeName(type.ResolvedType, formattingOptions)); } return("unknown type: " + type.GetType().ToString()); }
public override void Visit(IGenericTypeParameterReference genericTypeParameterReference) { allElements.Add(new InvokInfo(Traverser, "IGenericTypeParameterReference", genericTypeParameterReference)); }
/// <summary> /// Visit a genericTypeParameterReference. Do not copy if it is a generic type parameter. /// </summary> public override IGenericTypeParameterReference Visit(IGenericTypeParameterReference genericTypeParameterReference) { return genericTypeParameterReference; }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Performs some computation with the given generic type parameter reference. /// </summary> /// <param name="genericTypeParameterReference"></param> public virtual void Visit(IGenericTypeParameterReference genericTypeParameterReference) { }
public override void TraverseChildren(IGenericTypeParameterReference genericTypeParameterReference) { base.TraverseChildren(genericTypeParameterReference); }
public override void Visit(IGenericTypeParameterReference genericTypeParameterReference) { if(Process(genericTypeParameterReference)){visitor.Visit(genericTypeParameterReference);} base.Visit(genericTypeParameterReference); }
/// <summary> /// Traverses the children of the generic type parameter reference. /// </summary> public virtual void TraverseChildren(IGenericTypeParameterReference genericTypeParameterReference) { Contract.Requires(genericTypeParameterReference != null); this.TraverseChildren((IGenericParameterReference)genericTypeParameterReference); if (this.stopTraversal) return; this.Traverse(genericTypeParameterReference.DefiningType); }
public override void TraverseChildren(IGenericTypeParameterReference genericTypeParameterReference) { base.TraverseChildren(genericTypeParameterReference); }
public void Visit(IGenericTypeParameterReference genericTypeParameterReference) { this.traverser.Traverse(genericTypeParameterReference); }
/// <summary> /// Performs some computation with the given generic type parameter reference. /// </summary> /// <param name="genericTypeParameterReference"></param> public virtual void Visit(IGenericTypeParameterReference genericTypeParameterReference) //^ ensures this.path.Count == old(this.path.Count); { }
/// <summary> /// Performs some computation with the given generic type parameter reference. /// </summary> public void Visit(IGenericTypeParameterReference genericTypeParameterReference) { this.Visit((IGenericParameterReference)genericTypeParameterReference); }
public virtual void onMetadataElement(IGenericTypeParameterReference genericTypeParameterReference) { }
/// <summary> /// Use this routine, rather than ITypeReference.Dispatch, to call the appropriate derived overload of an ITypeReference. /// The former routine will call Visit(INamespaceTypeDefinition) rather than Visit(INamespaceTypeReference), etc., /// in the case where a definition is used as a reference to itself. /// </summary> /// <param name="typeReference">A reference to a type definition. Note that a type definition can serve as a reference to itself.</param> protected void DispatchAsReference(ITypeReference typeReference) { INamespaceTypeReference namespaceTypeReference = typeReference.AsNamespaceTypeReference; if (namespaceTypeReference != null) { this.Visit(namespaceTypeReference); return; } IGenericTypeInstanceReference genericTypeInstanceReference = typeReference.AsGenericTypeInstanceReference; if (genericTypeInstanceReference != null) { this.Visit(genericTypeInstanceReference); return; } INestedTypeReference nestedTypeReference = typeReference.AsNestedTypeReference; if (nestedTypeReference != null) { this.Visit(nestedTypeReference); return; } IArrayTypeReference arrayTypeReference = typeReference as IArrayTypeReference; if (arrayTypeReference != null) { this.Visit(arrayTypeReference); return; } IGenericTypeParameterReference genericTypeParameterReference = typeReference.AsGenericTypeParameterReference; if (genericTypeParameterReference != null) { this.Visit(genericTypeParameterReference); return; } IGenericMethodParameterReference genericMethodParameterReference = typeReference.AsGenericMethodParameterReference; if (genericMethodParameterReference != null) { this.Visit(genericMethodParameterReference); return; } IPointerTypeReference pointerTypeReference = typeReference as IPointerTypeReference; if (pointerTypeReference != null) { this.Visit(pointerTypeReference); return; } IModifiedTypeReference modifiedTypeReference = typeReference as IModifiedTypeReference; if (modifiedTypeReference != null) { this.Visit(modifiedTypeReference); return; } }
public override void TraverseChildren(IGenericTypeParameterReference genericTypeParameterReference) { MethodEnter(genericTypeParameterReference); base.TraverseChildren(genericTypeParameterReference); MethodExit(); }
public virtual void onMetadataElement(IGenericTypeParameterReference genericTypeParameterReference) { }
public void Visit(IGenericTypeParameterReference genericTypeParameterReference) { throw new NotImplementedException(); }
private static void WriteType(ITypeReference type, TextWriter writer, bool omitOutermostTypeFormals) { Contract.Requires(type != null); Contract.Requires(writer != null); IArrayType array = type as IArrayType; if (array != null) { Contract.Assume(array.ElementType != null, "lack of CCI2 contracts"); WriteType(array.ElementType, writer); writer.Write("["); if (array.Rank > 1) { for (int i = 0; i < array.Rank; i++) { if (i > 0) { writer.Write(","); } writer.Write("0:"); } } writer.Write("]"); return; } IManagedPointerTypeReference reference = type as IManagedPointerTypeReference;; if (reference != null) { Contract.Assume(reference.TargetType != null, "lack of CCI2 contracts"); var referencedType = reference.TargetType; WriteType(referencedType, writer); writer.Write("@"); return; } IPointerTypeReference pointer = type as IPointerTypeReference; if (pointer != null) { Contract.Assume(pointer.TargetType != null, "lack of CCI2 contracts"); WriteType(pointer.TargetType, writer); writer.Write("*"); return; } IModifiedTypeReference modref = type as IModifiedTypeReference; if (modref != null) { Contract.Assume(modref.UnmodifiedType != null, "lack of CCI2 contracts"); Contract.Assume(modref.CustomModifiers != null, "lack of CCI2 contracts"); WriteType(modref.UnmodifiedType, writer); foreach (var modifier in modref.CustomModifiers) { Contract.Assume(modifier != null, "lack of collection contracts and CCI2 contracts"); Contract.Assume(modifier.Modifier != null, "lack of CCI2 contracts"); if (modifier.IsOptional) { writer.Write("!"); } else { writer.Write("|"); } WriteType(modifier.Modifier, writer); } return; } IGenericTypeParameterReference gtp = type as IGenericTypeParameterReference; if (gtp != null) { writer.Write("`"); writer.Write(gtp.Index); return; } IGenericMethodParameterReference gmp = type as IGenericMethodParameterReference; if (gmp != null) { writer.Write("``"); writer.Write(gmp.Index); return; } IGenericTypeInstanceReference instance = type as IGenericTypeInstanceReference; if (instance != null) { Contract.Assume(instance.GenericType != null, "lack of CCI2 contracts"); Contract.Assume(instance.GenericArguments != null, "lack of CCI2 contracts"); WriteType(instance.GenericType, writer, true); writer.Write("{"); var first = true; foreach (var arg in instance.GenericArguments) { Contract.Assume(arg != null, "lack of collection and CCI2 contracts"); if (first) { first = false; } else { writer.Write(","); } WriteType(arg, writer); } writer.Write("}"); return; } // namespace or nested INamedTypeReference named = (INamedTypeReference)type; INestedTypeReference nested = type as INestedTypeReference; if (nested != null) { Contract.Assume(nested.ContainingType != null, "lack of CCI2 contracts"); // names of nested types begin with outer type name WriteType(nested.ContainingType, writer); writer.Write("."); // continue to write type sig } INamespaceTypeReference nt = type as INamespaceTypeReference; if (nt != null) { Contract.Assume(nt.ContainingUnitNamespace != null, "lack of CCI2 contracts"); WriteNamespaceAndSeparator(nt.ContainingUnitNamespace, writer); // continue to write type sig } // name writer.Write(named.Name.Value); // generic parameters if (omitOutermostTypeFormals) { return; } if (named.GenericParameterCount > 0) { writer.Write("`{0}", named.GenericParameterCount); } }
/// <summary> /// Traverses the children of the generic type parameter reference. /// </summary> public virtual void TraverseChildren(IGenericTypeParameterReference genericTypeParameterReference) { this.TraverseChildren((IGenericParameterReference)genericTypeParameterReference); if (this.stopTraversal) return; this.Traverse(genericTypeParameterReference.DefiningType); }