Ejemplo n.º 1
0
Archivo: Method.cs Proyecto: xcorail/ql
 /// <summary>
 /// Adds an appropriate label ID to the trap builder <paramref name="tb"/>
 /// for the type <paramref name="type"/> belonging to the signature of method
 /// <paramref name="method"/>.
 ///
 /// For methods without type parameters this will always add the key of the
 /// corresponding type.
 ///
 /// For methods with type parameters, this will add the key of the
 /// corresponding type if the type does *not* contain one of the method
 /// type parameters, otherwise it will add a textual representation of
 /// the type. This distinction is required because type parameter IDs
 /// refer to their declaring methods.
 ///
 /// Example:
 ///
 /// <code>
 /// int Count&lt;T&gt;(IEnumerable<T> items)
 /// </code>
 ///
 /// The label definitions for <code>Count</code> (<code>#4</code>) and <code>T</code>
 /// (<code>#5</code>) will look like:
 ///
 /// <code>
 /// #1=&lt;label for System.Int32&gt;
 /// #2=&lt;label for type containing Count&gt;
 /// #3=&lt;label for IEnumerable`1&gt;
 /// #4=@"{#1} {#2}.Count`2(#3<T>);method"
 /// #5=@"{#4}T;typeparameter"
 /// </code>
 ///
 /// Note how <code>int</code> is referenced in the label definition <code>#3</code> for
 /// <code>Count</code>, while <code>T[]</code> is represented textually in order
 /// to make the reference to <code>#3</code> in the label definition <code>#4</code> for
 /// <code>T</code> valid.
 /// </summary>
 protected static void AddSignatureTypeToId(Context cx, ITrapBuilder tb, IMethodSymbol method, ITypeSymbol type)
 {
     if (type.ContainsTypeParameters(cx, method))
     {
         type.BuildTypeId(cx, tb, (cx0, tb0, type0) => AddSignatureTypeToId(cx, tb0, method, type0));
     }
     else
     {
         tb.Append(Type.Create(cx, type));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds an appropriate label ID to the trap builder <paramref name="trapFile"/>
 /// for the type <paramref name="type"/> belonging to the signature of method
 /// <paramref name="method"/>.
 ///
 /// For methods without type parameters this will always add the key of the
 /// corresponding type.
 ///
 /// For methods with type parameters, this will add the key of the
 /// corresponding type if the type does *not* contain one of the method
 /// type parameters, otherwise it will add a textual representation of
 /// the type. This distinction is required because type parameter IDs
 /// refer to their declaring methods.
 ///
 /// Example:
 ///
 /// <code>
 /// int Count&lt;T&gt;(IEnumerable<T> items)
 /// </code>
 ///
 /// The label definitions for <code>Count</code> (<code>#4</code>) and <code>T</code>
 /// (<code>#5</code>) will look like:
 ///
 /// <code>
 /// #1=&lt;label for System.Int32&gt;
 /// #2=&lt;label for type containing Count&gt;
 /// #3=&lt;label for IEnumerable`1&gt;
 /// #4=@"{#1} {#2}.Count`2(#3<T>);method"
 /// #5=@"{#4}T;typeparameter"
 /// </code>
 ///
 /// Note how <code>int</code> is referenced in the label definition <code>#3</code> for
 /// <code>Count</code>, while <code>T[]</code> is represented textually in order
 /// to make the reference to <code>#3</code> in the label definition <code>#4</code> for
 /// <code>T</code> valid.
 /// </summary>
 protected static void AddSignatureTypeToId(Context cx, TextWriter trapFile, IMethodSymbol method, ITypeSymbol type)
 {
     if (type.ContainsTypeParameters(cx, method))
     {
         type.BuildTypeId(cx, trapFile, (cx0, tb0, type0) => AddSignatureTypeToId(cx, tb0, method, type0));
     }
     else
     {
         trapFile.WriteSubId(Type.Create(cx, type));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructs a unique string for this type symbol.
 ///
 /// The supplied action <paramref name="subTermAction"/> is applied to the
 /// syntactic sub terms of this type (if any).
 /// </summary>
 /// <param name="cx">The extraction context.</param>
 /// <param name="trapFile">The trap builder used to store the result.</param>
 /// <param name="symbolBeingDefined">The outer symbol being defined (to avoid recursive ids).</param>
 /// <param name="constructUnderlyingTupleType">Whether to build a type ID for the underlying `System.ValueTuple` struct in the case of tuple types.</param>
 public static void BuildTypeId(this ITypeSymbol type, Context cx, TextWriter trapFile, ISymbol symbolBeingDefined, bool constructUnderlyingTupleType = false) =>
 type.BuildTypeId(cx, trapFile, symbolBeingDefined, true, constructUnderlyingTupleType);
Ejemplo n.º 4
0
 /// <summary>
 /// Adds an appropriate label ID to the trap builder <paramref name="trapFile"/>
 /// for the type <paramref name="type"/> belonging to the signature of method
 /// <paramref name="method"/>.
 ///
 /// For methods without type parameters this will always add the key of the
 /// corresponding type.
 ///
 /// For methods with type parameters, this will add the key of the
 /// corresponding type if the type does *not* contain one of the method
 /// type parameters, otherwise it will add a textual representation of
 /// the type. This distinction is required because type parameter IDs
 /// refer to their declaring methods.
 ///
 /// Example:
 ///
 /// <code>
 /// int Count&lt;T&gt;(IEnumerable<T> items)
 /// </code>
 ///
 /// The label definitions for <code>Count</code> (<code>#4</code>) and <code>T</code>
 /// (<code>#5</code>) will look like:
 ///
 /// <code>
 /// #1=&lt;label for System.Int32&gt;
 /// #2=&lt;label for type containing Count&gt;
 /// #3=&lt;label for IEnumerable`1&gt;
 /// #4=@"{#1} {#2}.Count`2(#3<T>);method"
 /// #5=@"{#4}T;typeparameter"
 /// </code>
 ///
 /// Note how <code>int</code> is referenced in the label definition <code>#3</code> for
 /// <code>Count</code>, while <code>T[]</code> is represented textually in order
 /// to make the reference to <code>#3</code> in the label definition <code>#4</code> for
 /// <code>T</code> valid.
 /// </summary>
 protected static void AddSignatureTypeToId(Context cx, TextWriter trapFile, IMethodSymbol method, ITypeSymbol type, ISymbol symbolBeingDefined)
 {
     type.BuildTypeId(cx, trapFile, false, symbolBeingDefined, (cx0, tb0, type0, g) => AddSignatureTypeToId(cx, tb0, method, type0, g));
 }