Exemplo n.º 1
0
 /// <summary>
 ///     Puts the type_path JVMS structure corresponding to the given TypePath into the given
 ///     ByteVector.
 /// </summary>
 /// <param name="typePath">
 ///     a TypePath instance, or
 ///     <literal>null</literal>
 ///     for empty paths.
 /// </param>
 /// <param name="output">where the type path must be put.</param>
 internal static void Put(TypePath typePath, ByteVector output)
 {
     if (typePath == null)
     {
         output.PutByte(0);
     }
     else
     {
         var length = typePath.typePathContainer[typePath.typePathOffset] * 2 + 1;
         output.PutByteArray(typePath.typePathContainer, typePath.typePathOffset, length);
     }
 }
Exemplo n.º 2
0
 /// <summary>Visits an annotation on a type in the class signature.</summary>
 /// <param name="typeRef">
 ///     a reference to the annotated type. The sort of this type reference must be
 ///     <see cref="TypeReference.Class_Type_Parameter" />
 ///     ,
 ///     <see cref="TypeReference.Class_Type_Parameter_Bound" />
 ///     or
 ///     <see cref="TypeReference.Class_Extends" />
 ///     . See
 ///     <see cref="TypeReference" />
 ///     .
 /// </param>
 /// <param name="typePath">
 ///     the path to the annotated type argument, wildcard bound, array element type, or
 ///     static inner type within 'typeRef'. May be
 ///     <literal>null</literal>
 ///     if the annotation targets
 ///     'typeRef' as a whole.
 /// </param>
 /// <param name="descriptor">the class descriptor of the annotation class.</param>
 /// <param name="visible">
 ///     <literal>true</literal>
 ///     if the annotation is visible at runtime.
 /// </param>
 /// <returns>
 ///     a visitor to visit the annotation values, or
 ///     <literal>null</literal>
 ///     if this visitor is not
 ///     interested in visiting this annotation.
 /// </returns>
 public virtual AnnotationVisitor VisitTypeAnnotation(int typeRef, TypePath typePath
                                                      , string descriptor, bool visible)
 {
     if (api < VisitorAsmApiVersion.Asm5)
     {
         throw new NotSupportedException("This feature requires ASM5");
     }
     if (cv != null)
     {
         return(cv.VisitTypeAnnotation(typeRef, typePath, descriptor, visible));
     }
     return(null);
 }
Exemplo n.º 3
0
        /* useNamedValues = */
        /// <summary>
        ///     Creates a new
        ///     <see cref="AnnotationWriter" />
        ///     using named values.
        /// </summary>
        /// <param name="symbolTable">
        ///     where the constants used in this AnnotationWriter must be stored.
        /// </param>
        /// <param name="typeRef">
        ///     a reference to the annotated type. The sort of this type reference must be
        ///     <see cref="TypeReference.Class_Type_Parameter" />
        ///     ,
        ///     <see cref="TypeReference.Class_Type_Parameter_Bound" />
        ///     or
        ///     <see cref="TypeReference.Class_Extends" />
        ///     . See
        ///     <see cref="TypeReference" />
        ///     .
        /// </param>
        /// <param name="typePath">
        ///     the path to the annotated type argument, wildcard bound, array element type, or
        ///     static inner type within 'typeRef'. May be
        ///     <literal>null</literal>
        ///     if the annotation targets
        ///     'typeRef' as a whole.
        /// </param>
        /// <param name="descriptor">the class descriptor of the annotation class.</param>
        /// <param name="previousAnnotation">
        ///     the previously visited annotation of the
        ///     Runtime[In]Visible[Type]Annotations attribute to which this annotation belongs, or
        ///     <literal>null</literal>
        ///     in other cases (e.g. nested or array annotations).
        /// </param>
        /// <returns>
        ///     a new
        ///     <see cref="AnnotationWriter" />
        ///     for the given type annotation reference and descriptor.
        /// </returns>
        internal static AnnotationWriter Create(SymbolTable symbolTable, int typeRef, TypePath
                                                typePath, string descriptor, AnnotationWriter previousAnnotation)
        {
            // Create a ByteVector to hold a 'type_annotation' JVMS structure.
            // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.20.
            var typeAnnotation = new ByteVector();

            // Write target_type, target_info, and target_path.
            TypeReference.PutTarget(typeRef, typeAnnotation);
            TypePath.Put(typePath, typeAnnotation);
            // Write type_index and reserve space for num_element_value_pairs.
            typeAnnotation.PutShort(symbolTable.AddConstantUtf8(descriptor)).PutShort(0);
            return(new AnnotationWriter(symbolTable, true, typeAnnotation, previousAnnotation
                                        ));
        }
Exemplo n.º 4
0
 /// <summary>Visits an annotation on a type in the record component signature.</summary>
 /// <param name="typeRef">
 ///     a reference to the annotated type. The sort of this type reference must be
 ///     <see cref="TypeReference.Class_Type_Parameter" />
 ///     ,
 ///     <see cref="TypeReference.Class_Type_Parameter_Bound" />
 ///     or
 ///     <see cref="TypeReference.Class_Extends" />
 ///     . See
 ///     <see cref="TypeReference" />
 ///     .
 /// </param>
 /// <param name="typePath">
 ///     the path to the annotated type argument, wildcard bound, array element type, or
 ///     static inner type within 'typeRef'. May be
 ///     <literal>null</literal>
 ///     if the annotation targets
 ///     'typeRef' as a whole.
 /// </param>
 /// <param name="descriptor">the class descriptor of the annotation class.</param>
 /// <param name="visible">
 ///     <literal>true</literal>
 ///     if the annotation is visible at runtime.
 /// </param>
 /// <returns>
 ///     a visitor to visit the annotation values, or
 ///     <literal>null</literal>
 ///     if this visitor is not
 ///     interested in visiting this annotation.
 /// </returns>
 //  [Obsolete(@"this API is experimental.")]
 public virtual AnnotationVisitor VisitTypeAnnotationExperimental(int typeRef, TypePath
                                                                  typePath, string descriptor, bool visible)
 {
     if (delegate_ != null)
     {
         return(delegate_.VisitTypeAnnotationExperimental(typeRef, typePath, descriptor, visible
                                                          ));
     }
     return(null);
 }
Exemplo n.º 5
0
 public override AnnotationVisitor VisitTypeAnnotationExperimental(int typeRef, TypePath
                                                                   typePath, string descriptor, bool visible)
 {
     if (visible)
     {
         return(lastRuntimeVisibleTypeAnnotation = AnnotationWriter.Create(symbolTable, typeRef
                                                                           , typePath, descriptor, lastRuntimeVisibleTypeAnnotation));
     }
     return(lastRuntimeInvisibleTypeAnnotation = AnnotationWriter.Create(symbolTable,
                                                                         typeRef, typePath, descriptor, lastRuntimeInvisibleTypeAnnotation));
 }