public override void Visit(IGenericMethodParameterReference genericMethodParameterReference) { if (Process(genericMethodParameterReference)) { visitor.Visit(genericMethodParameterReference); } base.Visit(genericMethodParameterReference); }
public override ITypeReference Rewrite(IGenericMethodParameterReference genericMethodParameterReference) { Contract.Assume(genericMethodParameterReference.Index < this.genericArguments.Length); var genArg = this.genericArguments[genericMethodParameterReference.Index]; Contract.Assume(genArg != null); return(genArg); }
public override ITypeReference Rewrite(IGenericMethodParameterReference genericMethodParameterReference) { if (this.sourceMethod != null && MemberHelper.MethodsAreEquivalent(genericMethodParameterReference.DefiningMethod.ResolvedMethod, this.sourceMethod)) { return(this.targetMethodGenericParameters[genericMethodParameterReference.Index]); } return(genericMethodParameterReference); }
public override ITypeReference Rewrite(IGenericMethodParameterReference genericMethodParameterReference) { IGenericTypeParameter targetType; if (this.genericParameterMapping.TryGetValue(genericMethodParameterReference.InternedKey, out targetType)) { return(targetType); } return(base.Rewrite(genericMethodParameterReference)); }
/// <summary> /// Visit a type reference. /// </summary> /// <param name="typeReference"></param> /// <returns></returns> public override ITypeReference Visit(ITypeReference typeReference) { IGenericMethodParameterReference genericMethodParameterReference = typeReference as IGenericMethodParameterReference; if (genericMethodParameterReference != null) { IGenericTypeParameter targetType; if (this.mapping.TryGetValue(genericMethodParameterReference.InternedKey, out targetType)) { return(targetType); } } return(base.Visit(typeReference)); }
public override void TraverseChildren(IGenericMethodParameterReference genericMethodParameterReference) { var typ = genericMethodParameterReference.ResolvedType; if (typ == Dummy.Type) { this.EmitError(genericMethodParameterReference, ErrorCode.GenericMethodParameterResolution); } else if ((typ.Name != genericMethodParameterReference.Name && !genericMethodParameterReference.Name.Value.StartsWith("!")) || typ.Index != genericMethodParameterReference.Index) { this.EmitError(genericMethodParameterReference, ErrorCode.GenericMethodParameterResolution); } base.TraverseChildren(genericMethodParameterReference); }
public override void TraverseChildren(IGenericMethodParameterReference genericMethodParameterReference) { base.TraverseChildren(genericMethodParameterReference); }
public override void Visit(IGenericMethodParameterReference genericMethodParameterReference) { var genericMethod = this.mapper.GetMethod(genericMethodParameterReference.DefiningMethod); this.result = genericMethod.GetGenericArguments()[genericMethodParameterReference.Index]; }
public override void TraverseChildren(IGenericMethodParameterReference genericMethodParameterReference) { MethodEnter(genericMethodParameterReference); base.TraverseChildren(genericMethodParameterReference); MethodExit(); }
public override void Visit(IGenericMethodParameterReference genericMethodParameterReference) { if(Process(genericMethodParameterReference)){visitor.Visit(genericMethodParameterReference);} base.Visit(genericMethodParameterReference); }
public virtual void Visit(IGenericMethodParameterReference genericMethodParameterReference) { }
/// <summary> /// Rewrites the given generic method parameter reference. /// </summary> public override ITypeReference Rewrite(IGenericMethodParameterReference genericMethodParameterReference) { if (this.genericMethodParameterMap != null && this.isInsideAnonymousMethod) { IGenericParameterReference referenceToSubstitute; if (this.genericMethodParameterMap.TryGetValue(genericMethodParameterReference.Index, out referenceToSubstitute)) return referenceToSubstitute; Contract.Assume(false); } return base.Rewrite(genericMethodParameterReference); }
/// <summary> /// Visit a genericMethodParameterReference. Do not copy if it is a genericMethodParameter. /// </summary> /// <param name="genericMethodParameterReference"></param> /// <returns></returns> public override IGenericMethodParameterReference Visit(IGenericMethodParameterReference genericMethodParameterReference) { return(genericMethodParameterReference); }
public override ITypeReference Rewrite(IGenericMethodParameterReference genericMethodParameterReference) { if (this.sourceMethod != null && MemberHelper.MethodsAreEquivalent(genericMethodParameterReference.DefiningMethod.ResolvedMethod, this.sourceMethod)) return this.targetMethodGenericParameters[genericMethodParameterReference.Index]; return genericMethodParameterReference; }
/// <summary> /// Traverses the children of the generic method parameter reference. /// </summary> public virtual void TraverseChildren(IGenericMethodParameterReference genericMethodParameterReference) { Contract.Requires(genericMethodParameterReference != null); this.TraverseChildren((IGenericParameterReference)genericMethodParameterReference); if (this.stopTraversal) return; this.Traverse(genericMethodParameterReference.DefiningMethod); }
/// <summary> /// Traverses the generic method parameter reference. /// </summary> public void Traverse(IGenericMethodParameterReference genericMethodParameterReference) { Contract.Requires(genericMethodParameterReference != null); if (!this.objectsThatHaveAlreadyBeenTraversed.Add(genericMethodParameterReference)) return; if (this.preorderVisitor != null) this.preorderVisitor.Visit(genericMethodParameterReference); if (this.stopTraversal) return; this.TraverseChildren(genericMethodParameterReference); if (this.stopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(genericMethodParameterReference); }
public override void Visit(IGenericMethodParameterReference genericMethodParameterReference) { allElements.Add(new InvokInfo(Traverser, "IGenericMethodParameterReference", genericMethodParameterReference)); }
/// <summary> /// Rewrites the given generic method parameter reference. /// </summary> public virtual ITypeReference Rewrite(IGenericMethodParameterReference genericMethodParameterReference) { return genericMethodParameterReference; }
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()); }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Performs some computation with the given generic method parameter reference. /// </summary> /// <param name="genericMethodParameterReference"></param> public virtual void Visit(IGenericMethodParameterReference genericMethodParameterReference) { }
public void Visit(IGenericMethodParameterReference genericMethodParameterReference) { this.traverser.Traverse(genericMethodParameterReference); }
/// <summary> /// Performs some computation with the given generic method parameter reference. /// </summary> /// <param name="genericMethodParameterReference"></param> public virtual void Visit(IGenericMethodParameterReference genericMethodParameterReference) //^ ensures this.path.Count == old(this.path.Count); { }
public virtual void onMetadataElement(IGenericMethodParameterReference genericMethodParameterReference) { }
public override ITypeReference Rewrite(IGenericMethodParameterReference genericMethodParameterReference) { IGenericParameterReference referenceToSubstitute; if (this.genericMethodParameterMap.TryGetValue(genericMethodParameterReference.Index, out referenceToSubstitute)) return referenceToSubstitute; Contract.Assume(false); //An anonymous delegate body should not be able to reference generic method type parameters that are not defined by the containing method. return base.Rewrite(genericMethodParameterReference); }
public void Visit(IGenericMethodParameterReference genericMethodParameterReference) { throw new NotImplementedException(); }
/// <summary> /// Performs some computation with the given generic method parameter reference. /// </summary> public void Visit(IGenericMethodParameterReference genericMethodParameterReference) { this.Visit((IGenericParameterReference)genericMethodParameterReference); }
/// <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 ITypeReference Rewrite(IGenericMethodParameterReference genericMethodParameterReference) { IGenericTypeParameter targetType; if (this.genericParameterMapping.TryGetValue(genericMethodParameterReference.InternedKey, out targetType)) return targetType; return base.Rewrite(genericMethodParameterReference); }
/// <summary> /// Visit a genericMethodParameterReference. Do not copy if it is a genericMethodParameter. /// </summary> /// <param name="genericMethodParameterReference"></param> /// <returns></returns> public override IGenericMethodParameterReference Visit(IGenericMethodParameterReference genericMethodParameterReference) { return genericMethodParameterReference; }
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> /// Rewrites the given generic method parameter reference. /// </summary> /// <param name="genericMethodParameterReference"></param> /// <returns></returns> public override ITypeReference Rewrite(IGenericMethodParameterReference genericMethodParameterReference) { var result = this.TryMap(genericMethodParameterReference); return result ?? base.Rewrite(genericMethodParameterReference); }