/// <summary> /// Puts the Runtime[In]Visible[Type]Annotations attributes containing the given annotations and /// all their <i>predecessors</i> (see /// <see cref="previousAnnotation" /> /// in the given ByteVector. /// Annotations are put in the same order they have been visited. /// </summary> /// <param name="symbolTable"> /// where the constants used in the AnnotationWriter instances are stored. /// </param> /// <param name="lastRuntimeVisibleAnnotation"> /// The last runtime visible annotation of a field, method or /// class. The previous ones can be accessed with the /// <see cref="previousAnnotation" /> /// field. May be /// <literal>null</literal> /// . /// </param> /// <param name="lastRuntimeInvisibleAnnotation"> /// The last runtime invisible annotation of this a field, /// method or class. The previous ones can be accessed with the /// <see cref="previousAnnotation" /> /// field. May be /// <literal>null</literal> /// . /// </param> /// <param name="lastRuntimeVisibleTypeAnnotation"> /// The last runtime visible type annotation of this a /// field, method or class. The previous ones can be accessed with the /// <see cref="previousAnnotation" /> /// field. May be /// <literal>null</literal> /// . /// </param> /// <param name="lastRuntimeInvisibleTypeAnnotation"> /// The last runtime invisible type annotation of a /// field, method or class field. The previous ones can be accessed with the /// <see cref="previousAnnotation" /> /// field. May be /// <literal>null</literal> /// . /// </param> /// <param name="output">where the attributes must be put.</param> internal static void PutAnnotations(SymbolTable symbolTable, AnnotationWriter lastRuntimeVisibleAnnotation , AnnotationWriter lastRuntimeInvisibleAnnotation, AnnotationWriter lastRuntimeVisibleTypeAnnotation , AnnotationWriter lastRuntimeInvisibleTypeAnnotation, ByteVector output) { if (lastRuntimeVisibleAnnotation != null) { lastRuntimeVisibleAnnotation.PutAnnotations(symbolTable.AddConstantUtf8(Constants .Runtime_Visible_Annotations), output); } if (lastRuntimeInvisibleAnnotation != null) { lastRuntimeInvisibleAnnotation.PutAnnotations(symbolTable.AddConstantUtf8(Constants .Runtime_Invisible_Annotations), output); } if (lastRuntimeVisibleTypeAnnotation != null) { lastRuntimeVisibleTypeAnnotation.PutAnnotations(symbolTable.AddConstantUtf8(Constants .Runtime_Visible_Type_Annotations), output); } if (lastRuntimeInvisibleTypeAnnotation != null) { lastRuntimeInvisibleTypeAnnotation.PutAnnotations(symbolTable.AddConstantUtf8(Constants .Runtime_Invisible_Type_Annotations), output); } }
/// <summary> /// Puts the content of the record component generated by this RecordComponentWriter into the given /// ByteVector. /// </summary> /// <param name="output">where the record_component_info structure must be put.</param> internal void PutRecordComponentInfo(ByteVector output) { output.PutShort(nameIndex).PutShort(descriptorIndex); // Compute and put the attributes_count field. // For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS. var attributesCount = 0; if (signatureIndex != 0) { ++attributesCount; } if (accessFlags.HasFlagFast(AccessFlags.Deprecated)) { ++attributesCount; } if (lastRuntimeVisibleAnnotation != null) { ++attributesCount; } if (lastRuntimeInvisibleAnnotation != null) { ++attributesCount; } if (lastRuntimeVisibleTypeAnnotation != null) { ++attributesCount; } if (lastRuntimeInvisibleTypeAnnotation != null) { ++attributesCount; } if (firstAttribute != null) { attributesCount += firstAttribute.GetAttributeCount(); } output.PutShort(attributesCount); Attribute.PutAttributes(symbolTable, accessFlags, signatureIndex, output); AnnotationWriter.PutAnnotations(symbolTable, lastRuntimeVisibleAnnotation, lastRuntimeInvisibleAnnotation , lastRuntimeVisibleTypeAnnotation, lastRuntimeInvisibleTypeAnnotation, output); if (firstAttribute != null) { firstAttribute.PutAttributes(symbolTable, output); } }
/// <summary> /// Puts the content of the field_info JVMS structure generated by this FieldWriter into the given /// ByteVector. /// </summary> /// <param name="output">where the field_info structure must be put.</param> internal void PutFieldInfo(ByteVector output) { var useSyntheticAttribute = symbolTable.GetMajorVersion() < OpcodesConstants.V1_5; // Put the access_flags, name_index and descriptor_index fields. var mask = useSyntheticAttribute ? AccessFlags.Synthetic : 0; output.PutShort((int)(accessFlags & ~mask)).PutShort(nameIndex).PutShort(descriptorIndex ); // Compute and put the attributes_count field. // For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS. var attributesCount = 0; if (constantValueIndex != 0) { ++attributesCount; } if (accessFlags.HasFlagFast(AccessFlags.Synthetic) && useSyntheticAttribute) { ++attributesCount; } if (signatureIndex != 0) { ++attributesCount; } if (accessFlags.HasFlagFast(AccessFlags.Deprecated)) { ++attributesCount; } if (lastRuntimeVisibleAnnotation != null) { ++attributesCount; } if (lastRuntimeInvisibleAnnotation != null) { ++attributesCount; } if (lastRuntimeVisibleTypeAnnotation != null) { ++attributesCount; } if (lastRuntimeInvisibleTypeAnnotation != null) { ++attributesCount; } if (firstAttribute != null) { attributesCount += firstAttribute.GetAttributeCount(); } output.PutShort(attributesCount); // Put the field_info attributes. // For ease of reference, we use here the same attribute order as in Section 4.7 of the JVMS. if (constantValueIndex != 0) { output.PutShort(symbolTable.AddConstantUtf8(Constants.Constant_Value)).PutInt(2) .PutShort(constantValueIndex); } Attribute.PutAttributes(symbolTable, accessFlags, signatureIndex, output); AnnotationWriter.PutAnnotations(symbolTable, lastRuntimeVisibleAnnotation, lastRuntimeInvisibleAnnotation , lastRuntimeVisibleTypeAnnotation, lastRuntimeInvisibleTypeAnnotation, output); if (firstAttribute != null) { firstAttribute.PutAttributes(symbolTable, output); } }