Ejemplo n.º 1
0
        /// <summary>
        /// Read a list of attributes
        /// </summary>
        private void ReadAttributes(ConstantPool cp, IModifiableAttributeProvider provider)
        {
            var count = stream.ReadU2();

            for (var i = 0; i < count; i++)
            {
                var nameIndex = stream.ReadU2();
                var name      = cp.GetEntry <ConstantPoolUtf8>(nameIndex).Value;
                var length    = stream.ReadU4();

                Attribute attr;
                int       tmp;
                switch (name)
                {
                case CodeAttribute.AttributeName:
                    attr = ReadCodeAttribute((MethodDefinition)provider, cp);
                    break;

                case ConstantValueAttribute.AttributeName:
                    tmp  = stream.ReadU2();
                    attr = new ConstantValueAttribute(((IConstantPoolValue)cp[tmp]).Value);
                    break;

                case ExceptionsAttribute.AttributeName:
                    attr = ReadExceptionsAttribute(cp);
                    break;

                case InnerClassesAttribute.AttributeName:
                    attr = ReadInnerClassesAttribute(cp);
                    break;

                case SyntheticAttribute.AttributeName:
                    attr = new SyntheticAttribute();
                    break;

                case SourceFileAttribute.AttributeName:
                    tmp  = stream.ReadU2();
                    attr = new SourceFileAttribute(cp.GetEntry <ConstantPoolUtf8>(tmp).Value);
                    break;

                case LineNumberTableAttribute.AttributeName:
                    attr = ReadLineNumberTableAttribute();
                    break;

                case LocalVariableTableAttribute.AttributeName:
                    attr = ReadLocalVariableTableAttribute(cp);
                    break;

                case DeprecatedAttribute.AttributeName:
                    attr = new DeprecatedAttribute();
                    break;

                case OverrideAttribute.AttributeName:
                    attr = new OverrideAttribute();
                    break;

                case SignatureAttribute.AttributeName:
                    tmp  = stream.ReadU2();
                    attr = new SignatureAttribute(cp.GetEntry <ConstantPoolUtf8>(tmp).Value);
                    break;

                case RuntimeVisibleAnnotationsAttribute.AttributeName:
                    attr = new RuntimeVisibleAnnotationsAttribute(ReadAnnotationsAttribute(cp));
                    break;

                case RuntimeInvisibleAnnotationsAttribute.AttributeName:
                    attr = new RuntimeInvisibleAnnotationsAttribute(ReadAnnotationsAttribute(cp));
                    break;

                case RuntimeVisibleParameterAnnotationsAttribute.AttributeName:
                    attr = new RuntimeVisibleParameterAnnotationsAttribute(ReadAnnotationsAttribute(cp));
                    break;

                case RuntimeInvisibleParameterAnnotationsAttribute.AttributeName:
                    attr = new RuntimeInvisibleParameterAnnotationsAttribute(ReadAnnotationsAttribute(cp));
                    break;

                case AnnotationDefaultAttribute.AttributeName:
                    attr = new AnnotationDefaultAttribute(ReadElementValue(cp));
                    break;

                default:
                    stream.Skip(length);
                    attr = new UnknownAttribute(name);
                    break;
                }
                provider.Add(attr);
            }
            provider.AttributesLoaded();
        }
Ejemplo n.º 2
0
 public static object[] unescapeInvalidSurrogates(object[] def)
 {
     return((object[])AnnotationDefaultAttribute.Unescape(def));
 }