Exemple #1
0
 /// <summary>
 /// Parses method annotations to fill up information
 /// </summary>
 /// <param name="readerState">Class reader state</param>
 internal void Parse(ClassReaderState readerState)
 {
     Signature = (GetAttribute(PredefinedAttributeNames.Signature)?.ParsedAttribute as SignatureAttribute)?.Value;
     {
         var attribute = GetAttribute(PredefinedAttributeNames.Code);
         if (attribute?.ParsedAttribute is CodeAttribute codeAttribute)
         {
             InstructionListConverter.ParseCodeAttribute(this, readerState, codeAttribute);
         }
     }
     {
         var attribute = GetAttribute(PredefinedAttributeNames.RuntimeInvisibleAnnotations);
         if (attribute != null)
         {
             InvisibleAnnotations = (attribute.ParsedAttribute as RuntimeInvisibleAnnotationsAttribute)?.Annotations;
         }
     }
     {
         var attribute = GetAttribute(PredefinedAttributeNames.RuntimeVisibleAnnotations);
         if (attribute != null)
         {
             VisibleAnnotations = (attribute.ParsedAttribute as RuntimeVisibleAnnotationsAttribute)?.Annotations;
         }
     }
     {
         var attribute = GetAttribute(PredefinedAttributeNames.Exceptions);
         if (attribute != null)
         {
             Throws = (attribute.ParsedAttribute as ExceptionsAttribute)?.ExceptionTable;
         }
     }
     AnnotationDefaultValue =
         (GetAttribute(PredefinedAttributeNames.AnnotationDefault)?.ParsedAttribute as AnnotationDefaultAttribute)?.Value;
     IsDeprecated = GetAttribute(PredefinedAttributeNames.Deprecated)?.ParsedAttribute != null;
 }
Exemple #2
0
        internal void Read(Stream stream, ClassReaderState classReaderState)
        {
            var pathSize = stream.ReadByteFully();

            Path.Capacity = pathSize;
            for (var i = 0; i < pathSize; i++)
            {
                Path.Add(new PathPart
                {
                    TypePathKind      = (TypePathKind)stream.ReadByteFully(),
                    TypeArgumentIndex = stream.ReadByteFully()
                });
            }
        }
Exemple #3
0
        internal static TypeAnnotationNode Parse(Stream stream, ClassReaderState readerState, AttributeScope scope)
        {
            var typeAnnotation = new TypeAnnotationNode
            {
                TargetType = (TargetType)stream.ReadByteFully()
            };

            typeAnnotation.Target = typeAnnotation.TargetType switch
            {
                TargetType.GenericClassOrInterfaceDeclaration when scope == AttributeScope.Class => (TypeAnnotationTarget) new TypeParameterTarget(),
                TargetType.GenericMethodOrConstructorDeclaration when scope == AttributeScope.Method => new TypeParameterTarget(),
                TargetType.ExtendsOrImplements when scope == AttributeScope.Class => new SupertypeTarget(),
                TargetType.TypeInBoundInGenericClassOrInterface when scope == AttributeScope.Class => new TypeParameterBoundTarget(),
                TargetType.TypeInBoundInGenericMethodOrConstructor when scope == AttributeScope.Method => new TypeParameterBoundTarget(),
                TargetType.FieldDeclaration when scope == AttributeScope.Field => new EmptyTarget(),
                TargetType.ReturnTypeOrNewObject when scope == AttributeScope.Method => new EmptyTarget(),
                TargetType.ReceiverTypeOfMethodOrConstructor when scope == AttributeScope.Method => new EmptyTarget(),
                TargetType.TypeInFormalParameterOfMethodOrConstructorOrLambda when scope == AttributeScope.Method => new FormalParameterTarget(),
                TargetType.ThrowsClause when scope == AttributeScope.Method => new ThrowsTarget(),
                TargetType.LocalVariableDeclaration when scope == AttributeScope.Code => new LocalvarTarget(),
                TargetType.ResourceVariableDeclaration when scope == AttributeScope.Code => new LocalvarTarget(),
                TargetType.ExceptionParameterDeclaration when scope == AttributeScope.Code => new CatchTarget(),
                TargetType.InstanceOfExpression when scope == AttributeScope.Code => new OffsetTarget(),
                TargetType.NewExpression when scope == AttributeScope.Code => new OffsetTarget(),
                TargetType.MethodReferenceExpressionNew when scope == AttributeScope.Code => new OffsetTarget(),
                TargetType.MethodReferenceExpressionIdentifier when scope == AttributeScope.Code => new OffsetTarget(),
                TargetType.CastExpression when scope == AttributeScope.Code => new TypeArgumentTarget(),
                TargetType.ArgumentForGenericConstructorInvocation when scope == AttributeScope.Code => new TypeArgumentTarget(),
                TargetType.ArgumentForGenericMethodInvocation when scope == AttributeScope.Code => new TypeArgumentTarget(),
                TargetType.ArgumentForGenericMethodReferenceExpressionNew when scope == AttributeScope.Code => new TypeArgumentTarget(),
                TargetType.ArgumentForGenericMethodReferenceExpressionIdentifier when scope == AttributeScope.Code => new TypeArgumentTarget(),
                _ => throw new ArgumentOutOfRangeException(nameof(TargetType))
            };
            typeAnnotation.Target.Read(stream, readerState);
            typeAnnotation.TypePath = new TypePath();
            typeAnnotation.TypePath.Read(stream, readerState);
            var elementValuePairsCount = Binary.BigEndian.ReadUInt16(stream);

            typeAnnotation.ElementValuePairs.Capacity = elementValuePairsCount;
            for (var i = 0; i < elementValuePairsCount; i++)
            {
                typeAnnotation.ElementValuePairs.Add(new ElementValuePair
                {
                    ElementName = readerState.ConstantPool
                                  .GetEntry <Utf8Entry>(Binary.BigEndian.ReadUInt16(stream)).String,
                    Value = ElementValue.Parse(stream, readerState)
                });
            }
            return(typeAnnotation);
        }
Exemple #4
0
        internal override void Read(Stream stream, ClassReaderState readerState)
        {
            var tableSize = Binary.BigEndian.ReadUInt16(stream);

            Table.Capacity = tableSize;
            for (var i = 0; i < tableSize; i++)
            {
                Table.Add(new TableEntry
                {
                    StartPc = Binary.BigEndian.ReadUInt16(stream),
                    Length  = Binary.BigEndian.ReadUInt16(stream),
                    Index   = Binary.BigEndian.ReadUInt16(stream)
                });
            }
        }
Exemple #5
0
        internal static AnnotationNode Parse(Stream stream, ClassReaderState readerState)
        {
            var annotation = new AnnotationNode
            {
                Type = TypeDescriptor.Parse(readerState.ConstantPool
                                            .GetEntry <Utf8Entry>(Binary.BigEndian.ReadUInt16(stream)).String)
            };
            var elementValuePairsCount = Binary.BigEndian.ReadUInt16(stream);

            annotation.ElementValuePairs.Capacity = elementValuePairsCount;
            for (var i = 0; i < elementValuePairsCount; i++)
            {
                annotation.ElementValuePairs.Add(new ElementValuePair
                {
                    ElementName = readerState.ConstantPool
                                  .GetEntry <Utf8Entry>(Binary.BigEndian.ReadUInt16(stream)).String,
                    Value = ElementValue.Parse(stream, readerState)
                });
            }
            return(annotation);
        }
Exemple #6
0
        internal void Parse(ClassReaderState readerState)
        {
            SourceFile           = (GetAttribute(PredefinedAttributeNames.SourceFile)?.ParsedAttribute as SourceFileAttribute)?.Value;
            SourceDebugExtension = (GetAttribute(PredefinedAttributeNames.SourceDebugExtension)?.ParsedAttribute as SourceFileAttribute)?.Value;
            Signature            = (GetAttribute(PredefinedAttributeNames.Signature)?.ParsedAttribute as SignatureAttribute)?.Value;
            {
                var attribute = GetAttribute(PredefinedAttributeNames.RuntimeInvisibleAnnotations);
                if (attribute != null)
                {
                    InvisibleAnnotations = (attribute.ParsedAttribute as RuntimeInvisibleAnnotationsAttribute)?.Annotations;
                }
            }
            {
                var attribute = GetAttribute(PredefinedAttributeNames.RuntimeVisibleAnnotations);
                if (attribute != null)
                {
                    VisibleAnnotations = (attribute.ParsedAttribute as RuntimeVisibleAnnotationsAttribute)?.Annotations;
                }
            }
            IsDeprecated    = GetAttribute(PredefinedAttributeNames.Deprecated)?.ParsedAttribute != null;
            EnclosingMethod = GetAttribute(PredefinedAttributeNames.EnclosingMethod)?.ParsedAttribute as EnclosingMethodAttribute;
            {
                var attribute = GetAttribute(PredefinedAttributeNames.InnerClasses);
                if (attribute != null)
                {
                    InnerClasses = (attribute.ParsedAttribute as InnerClassesAttribute)?.Classes;
                }
            }

            foreach (var method in Methods)
            {
                method.Parse(readerState);
            }

            foreach (var field in Fields)
            {
                field.Parse(readerState);
            }
        }
Exemple #7
0
 /// <summary>
 /// Parses field annotations to fill up information
 /// </summary>
 /// <param name="readerState">Class reader state</param>
 internal void Parse(ClassReaderState readerState)
 {
     Signature = (GetAttribute(PredefinedAttributeNames.Signature)?.ParsedAttribute as SignatureAttribute)?.Value;
     {
         var attribute = GetAttribute(PredefinedAttributeNames.RuntimeInvisibleAnnotations);
         if (attribute != null)
         {
             InvisibleAnnotations = (attribute.ParsedAttribute as RuntimeInvisibleAnnotationsAttribute)?.Annotations;
         }
     }
     {
         var attribute = GetAttribute(PredefinedAttributeNames.RuntimeVisibleAnnotations);
         if (attribute != null)
         {
             VisibleAnnotations = (attribute.ParsedAttribute as RuntimeVisibleAnnotationsAttribute)?.Annotations;
         }
     }
     ConstantValue =
         (GetAttribute(PredefinedAttributeNames.ConstantValue)?.ParsedAttribute as
          ConstantValueAttribute)?.Value;
     IsDeprecated = GetAttribute(PredefinedAttributeNames.Deprecated)?.ParsedAttribute != null;
 }
Exemple #8
0
 internal override void Read(Stream stream, ClassReaderState readerState)
 {
 }
Exemple #9
0
 public SignatureAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope)
 {
     return(new SignatureAttribute
     {
         Value = readerState.ConstantPool.GetEntry <Utf8Entry>(Binary.BigEndian.ReadUInt16(attributeDataStream)).String
     });
 }
Exemple #10
0
        public EnclosingMethodAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope)
        {
            var attribute = new EnclosingMethodAttribute
            {
                Class = new ClassName(readerState.ConstantPool
                                      .GetEntry <ClassEntry>(Binary.BigEndian.ReadUInt16(attributeDataStream)).Name.String)
            };

            var nameAndTypeEntryIndex = Binary.BigEndian.ReadUInt16(attributeDataStream);

            if (nameAndTypeEntryIndex == 0)
            {
                return(attribute);
            }

            var nameAndTypeEntry = readerState.ConstantPool.GetEntry <NameAndTypeEntry>(nameAndTypeEntryIndex);

            attribute.MethodName       = nameAndTypeEntry.Name.String;
            attribute.MethodDescriptor = MethodDescriptor.Parse(nameAndTypeEntry.Descriptor.String);

            return(attribute);
        }
Exemple #11
0
 internal override void Read(Stream stream, ClassReaderState readerState)
 {
     Offset = Binary.BigEndian.ReadUInt16(stream);
 }
Exemple #12
0
 public SourceDebugExtensionAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope)
 {
     return(new SourceDebugExtensionAttribute
     {
         Value = ModifiedUtf8Helper.Decode(attributeDataStream.ReadBytes(attributeDataLength))
     });
 }
Exemple #13
0
 public AnnotationDefaultAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope)
 {
     return(new AnnotationDefaultAttribute
     {
         Value = ElementValue.Parse(attributeDataStream, readerState)
     });
 }
Exemple #14
0
 internal override void Read(Stream stream, ClassReaderState readerState)
 {
     ExceptionTableIndex = Binary.BigEndian.ReadUInt16(stream);
 }
Exemple #15
0
        public CodeAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope)
        {
            var maxStack  = Binary.BigEndian.ReadUInt16(attributeDataStream);
            var maxLocals = Binary.BigEndian.ReadUInt16(attributeDataStream);
            var code      = new byte[Binary.BigEndian.ReadUInt32(attributeDataStream)];

            attributeDataStream.Read(code);
            var attribute = new CodeAttribute
            {
                MaxStack  = maxStack,
                MaxLocals = maxLocals,
                Code      = code
            };

            var exceptionTableSize = Binary.BigEndian.ReadUInt16(attributeDataStream);

            attribute.ExceptionTable.Capacity = exceptionTableSize;
            for (var i = 0; i < exceptionTableSize; i++)
            {
                var exceptionTableEntry = new CodeAttribute.ExceptionTableEntry
                {
                    StartPc   = Binary.BigEndian.ReadUInt16(attributeDataStream),
                    EndPc     = Binary.BigEndian.ReadUInt16(attributeDataStream),
                    HandlerPc = Binary.BigEndian.ReadUInt16(attributeDataStream)
                };
                var catchTypeIndex = Binary.BigEndian.ReadUInt16(attributeDataStream);

                if (catchTypeIndex != 0)
                {
                    exceptionTableEntry.CatchType = new ClassName(readerState.ConstantPool
                                                                  .GetEntry <ClassEntry>(catchTypeIndex)
                                                                  .Name.String);
                }

                attribute.ExceptionTable.Add(exceptionTableEntry);
            }

            var attributesCount = Binary.BigEndian.ReadUInt16(attributeDataStream);

            attribute.Attributes.Capacity = attributesCount;
            for (var i = 0; i < attributesCount; i++)
            {
                attribute.Attributes.Add(ClassFile.ParseAttribute(attributeDataStream, readerState, AttributeScope.Code));
            }

            return(attribute);
        }
        public LocalVariableTypeTableAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope)
        {
            var attribute = new LocalVariableTypeTableAttribute();

            var localVariableTypeTableSize = Binary.BigEndian.ReadUInt16(attributeDataStream);

            attribute.LocalVariableTypeTable.Capacity = localVariableTypeTableSize;
            for (var i = 0; i < localVariableTypeTableSize; i++)
            {
                attribute.LocalVariableTypeTable.Add(new LocalVariableTypeTableAttribute.LocalVariableTypeTableEntry
                {
                    StartPc   = Binary.BigEndian.ReadUInt16(attributeDataStream),
                    Length    = Binary.BigEndian.ReadUInt16(attributeDataStream),
                    Name      = readerState.ConstantPool.GetEntry <Utf8Entry>(Binary.BigEndian.ReadUInt16(attributeDataStream)).String,
                    Signature = readerState.ConstantPool.GetEntry <Utf8Entry>(Binary.BigEndian.ReadUInt16(attributeDataStream)).String,
                    Index     = Binary.BigEndian.ReadUInt16(attributeDataStream)
                });
            }

            return(attribute);
        }
 public SyntheticAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope) => new SyntheticAttribute();
Exemple #18
0
 internal override void Read(Stream stream, ClassReaderState readerState)
 {
     SupertypeIndex = Binary.BigEndian.ReadUInt16(stream);
 }
        public MethodParametersAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope)
        {
            var attribute = new MethodParametersAttribute();

            var exceptionTableSize = attributeDataStream.ReadByteFully();

            attribute.Parameters.Capacity = exceptionTableSize;
            for (var i = 0; i < exceptionTableSize; i++)
            {
                attribute.Parameters.Add(new MethodParametersAttribute.Parameter
                {
                    Name   = readerState.ConstantPool.GetEntry <Utf8Entry>(Binary.BigEndian.ReadUInt16(attributeDataStream)).String,
                    Access = (ClassAccessModifiers)Binary.BigEndian.ReadUInt16(attributeDataStream)
                });
            }

            return(attribute);
        }
Exemple #20
0
        public ExceptionsAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope)
        {
            var attribute = new ExceptionsAttribute();

            var count = Binary.BigEndian.ReadUInt16(attributeDataStream);

            attribute.ExceptionTable.Capacity = count;
            for (var i = 0; i < count; i++)
            {
                attribute.ExceptionTable.Add(new ClassName(readerState.ConstantPool
                                                           .GetEntry <ClassEntry>(Binary.BigEndian.ReadUInt16(attributeDataStream)).Name.String));
            }

            return(attribute);
        }
        public LineNumberTableAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope)
        {
            var attribute = new LineNumberTableAttribute();

            var exceptionTableSize = Binary.BigEndian.ReadUInt16(attributeDataStream);

            attribute.LineNumberTable.Capacity = exceptionTableSize;
            for (var i = 0; i < exceptionTableSize; i++)
            {
                attribute.LineNumberTable.Add(new LineNumberTableAttribute.LineNumberTableEntry
                {
                    StartPc    = Binary.BigEndian.ReadUInt16(attributeDataStream),
                    LineNumber = Binary.BigEndian.ReadUInt16(attributeDataStream)
                });
            }

            return(attribute);
        }
Exemple #22
0
 public DeprecatedAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope) => new DeprecatedAttribute();
        public RuntimeVisibleParameterAnnotationsAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope)
        {
            var attribute = new RuntimeVisibleParameterAnnotationsAttribute();

            var parametersCount = attributeDataStream.ReadByteFully();

            attribute.Parameters.Capacity = parametersCount;
            for (var i = 0; i < parametersCount; i++)
            {
                var parameter        = new ParameterAnnotations();
                var annotationsCount = Binary.BigEndian.ReadUInt16(attributeDataStream);
                parameter.Annotations.Capacity = annotationsCount;
                for (var j = 0; j < annotationsCount; j++)
                {
                    parameter.Annotations.Add(AnnotationNode.Parse(attributeDataStream, readerState));
                }
                attribute.Parameters.Add(parameter);
            }

            return(attribute);
        }
 internal override void Read(Stream stream, ClassReaderState readerState)
 {
     Offset            = Binary.BigEndian.ReadUInt16(stream);
     TypeArgumentIndex = stream.ReadByteFully();
 }
Exemple #25
0
        private static StackMapTableAttribute.VerificationElement ReadVerificationElement(Stream stream, ClassReaderState readerState)
        {
            var verificationElementType = (StackMapTableAttribute.VerificationElementType)stream.ReadByteFully();

            return(verificationElementType switch
            {
                StackMapTableAttribute.VerificationElementType.Top => (StackMapTableAttribute.VerificationElement) new StackMapTableAttribute.SimpleVerificationElement(verificationElementType),
                StackMapTableAttribute.VerificationElementType.Integer => new StackMapTableAttribute.SimpleVerificationElement(verificationElementType),
                StackMapTableAttribute.VerificationElementType.Float => new StackMapTableAttribute.SimpleVerificationElement(verificationElementType),
                StackMapTableAttribute.VerificationElementType.Long => new StackMapTableAttribute.SimpleVerificationElement(verificationElementType),
                StackMapTableAttribute.VerificationElementType.Double => new StackMapTableAttribute.SimpleVerificationElement(verificationElementType),
                StackMapTableAttribute.VerificationElementType.Null => new StackMapTableAttribute.SimpleVerificationElement(verificationElementType),
                StackMapTableAttribute.VerificationElementType.UnitializedThis => new StackMapTableAttribute.SimpleVerificationElement(verificationElementType),
                StackMapTableAttribute.VerificationElementType.Object => new StackMapTableAttribute.ObjectVerificationElement
                {
                    ObjectClass = new ClassName(readerState.ConstantPool
                                                .GetEntry <ClassEntry>(Binary.BigEndian.ReadUInt16(stream))
                                                .Name.String)
                },
                StackMapTableAttribute.VerificationElementType.Unitialized => new StackMapTableAttribute.UninitializedVerificationElement
                {
                    NewInstructionOffset = Binary.BigEndian.ReadUInt16(stream)
                },
                _ => throw new ArgumentOutOfRangeException(nameof(verificationElementType))
            });
Exemple #26
0
        public InnerClassesAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope)
        {
            var attribute = new InnerClassesAttribute();

            var classesCount = Binary.BigEndian.ReadUInt16(attributeDataStream);

            attribute.Classes.Capacity = classesCount;
            for (var i = 0; i < classesCount; i++)
            {
                var innerClass = new InnerClass
                {
                    InnerClassName = new ClassName(readerState.ConstantPool
                                                   .GetEntry <ClassEntry>(Binary.BigEndian.ReadUInt16(attributeDataStream)).Name.String)
                };
                var outerClassIndex = Binary.BigEndian.ReadUInt16(attributeDataStream);
                if (outerClassIndex != 0)
                {
                    innerClass.OuterClassName = new ClassName(readerState.ConstantPool
                                                              .GetEntry <ClassEntry>(outerClassIndex).Name.String);
                }
                var innerNameIndex = Binary.BigEndian.ReadUInt16(attributeDataStream);
                if (innerNameIndex != 0)
                {
                    innerClass.InnerName = readerState.ConstantPool
                                           .GetEntry <Utf8Entry>(innerNameIndex).String;
                }
                innerClass.Access = (ClassAccessModifiers)Binary.BigEndian.ReadUInt16(attributeDataStream);
                attribute.Classes.Add(innerClass);
            }

            return(attribute);
        }
 internal override void Read(Stream stream, ClassReaderState readerState)
 {
     TypeParameterIndex = stream.ReadByteFully();
 }
Exemple #28
0
        internal static ElementValue Parse(Stream stream, ClassReaderState readerState)
        {
            var elementValue = new ElementValue
            {
                Tag = (ElementValueTag)stream.ReadByteFully()
            };

            switch (elementValue.Tag)
            {
            case ElementValueTag.Byte:
            case ElementValueTag.Character:
            case ElementValueTag.Integer:
            case ElementValueTag.Short:
            case ElementValueTag.Boolean:
                elementValue.ConstValue = readerState.ConstantPool.GetEntry <IntegerEntry>(Binary.BigEndian.ReadUInt16(stream)).Value;
                break;

            case ElementValueTag.Double:
                elementValue.ConstValue = readerState.ConstantPool.GetEntry <DoubleEntry>(Binary.BigEndian.ReadUInt16(stream)).Value;
                break;

            case ElementValueTag.Float:
                elementValue.ConstValue = readerState.ConstantPool.GetEntry <FloatEntry>(Binary.BigEndian.ReadUInt16(stream)).Value;
                break;

            case ElementValueTag.Long:
                elementValue.ConstValue = readerState.ConstantPool.GetEntry <LongEntry>(Binary.BigEndian.ReadUInt16(stream)).Value;
                break;

            case ElementValueTag.String:
                elementValue.ConstValue = readerState.ConstantPool.GetEntry <Utf8Entry>(Binary.BigEndian.ReadUInt16(stream)).String;
                break;

            case ElementValueTag.Enum:
                elementValue.EnumConstValue = new EnumConstValueType
                {
                    TypeName = TypeDescriptor.Parse(readerState.ConstantPool
                                                    .GetEntry <Utf8Entry>(Binary.BigEndian.ReadUInt16(stream)).String),
                    ConstName = readerState.ConstantPool.GetEntry <Utf8Entry>(Binary.BigEndian.ReadUInt16(stream))
                                .String
                };
                break;

            case ElementValueTag.Class:
                elementValue.Class = TypeDescriptor.Parse(readerState.ConstantPool
                                                          .GetEntry <Utf8Entry>(Binary.BigEndian.ReadUInt16(stream)).String, true);
                break;

            case ElementValueTag.Annotation:
                elementValue.AnnotationNode = AnnotationNode.Parse(stream, readerState);
                break;

            case ElementValueTag.Array:
                var arraySize = Binary.BigEndian.ReadUInt16(stream);
                elementValue.ArrayValue = new List <ElementValue>(arraySize);
                for (var i = 0; i < arraySize; i++)
                {
                    elementValue.ArrayValue.Add(Parse(stream, readerState));
                }
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(elementValue.Tag));
            }

            return(elementValue);
        }
Exemple #29
0
        public RuntimeVisibleTypeAnnotationsAttribute Parse(Stream attributeDataStream, uint attributeDataLength, ClassReaderState readerState, AttributeScope scope)
        {
            var attribute = new RuntimeVisibleTypeAnnotationsAttribute();

            var annotationsCount = Binary.BigEndian.ReadUInt16(attributeDataStream);

            attribute.Annotations.Capacity = annotationsCount;
            for (var i = 0; i < annotationsCount; i++)
            {
                attribute.Annotations.Add(TypeAnnotationNode.Parse(attributeDataStream, readerState, scope));
            }

            return(attribute);
        }
Exemple #30
0
 internal abstract void Read(Stream stream, ClassReaderState readerState);