public static CompileAttribute ReadAttribute(EndianBinaryReader reader, List<CompileConstant> constants) { short nameIndex = reader.ReadInt16(); int attributeLength = reader.ReadInt32(); var nameConstant = constants[nameIndex] as CompileConstantUtf8; if (nameConstant == null) throw new InvalidOperationException(); var name = new string(new JavaTextEncoding().GetChars(nameConstant.Value)); switch (name) { case "ConstantValue": return new CompileAttributeConstantValue().Read(reader, constants, attributeLength); case "Code": return new CompileAttributeCode().Read(reader, constants, attributeLength); case "Exceptions": return new CompileAttributeExceptions().Read(reader, constants, attributeLength); case "InnerClasses": return new CompileAttributeInnerClasses().Read(reader, constants, attributeLength); case "Synthetic": return new CompileAttributeSynthetic().Read(reader, constants, attributeLength); case "SourceFile": return new CompileAttributeSourceFile().Read(reader, constants, attributeLength); case "LineNumberTable": return new CompileAttributeLineNumberTable().Read(reader, constants, attributeLength); case "LocalVariableTable": return new CompileAttributeLocalVariableTable().Read(reader, constants, attributeLength); case "Deprecated": return new CompileAttributeDeprecated().Read(reader, constants, attributeLength); case "StackMapTable": return new CompileAttributeStackMapTable().Read(reader, constants, attributeLength); case "EnclosingMethod": return new CompileAttributeEnclosingMethod().Read(reader, constants, attributeLength); case "Signature": return new CompileAttributeSignature().Read(reader, constants, attributeLength); case "SourceDebugExtension": return new CompileAttributeSourceDebugExtension().Read(reader, constants, attributeLength); case "LocalVariableTypeTable": return new CompileAttributeLocalVariableTypeTable().Read(reader, constants, attributeLength); case "RuntimeVisibleAnnotations": return new CompileAttributeRuntimeVisibleAnnotations().Read(reader, constants, attributeLength); case "RuntimeInvisibleAnnotations": return new CompileAttributeRuntimeInvisibleAnnotations().Read(reader, constants, attributeLength); case "RuntimeVisibleParameterAnnotations": return new CompileAttributeRuntimeVisibleParameterAnnotations().Read(reader, constants, attributeLength); case "RuntimeInvisibleParameterAnnotations": return new CompileAttributeRuntimeInvisibleParameterAnnotations().Read(reader, constants, attributeLength); default: return new CompileAttributeGeneric(name).Read(reader, constants, attributeLength); } }
public override CompileConstant Read(EndianBinaryReader reader) { Value = reader.ReadInt32(); return this; }
public override CompileAttribute Read(EndianBinaryReader reader, List<CompileConstant> constants, int length) { MaxStack = reader.ReadInt16(); MaxLocals = reader.ReadInt16(); int codeLength = reader.ReadInt32(); Code = reader.ReadBytes(codeLength); ExceptionTable = new List<ExceptionTableEntry>(); short exceptionCount = reader.ReadInt16(); for (int i = 0; i < exceptionCount; i++) { var exception = new ExceptionTableEntry(); exception.StartPC = reader.ReadInt16(); exception.EndPC = reader.ReadInt16(); exception.HandlerPC = reader.ReadInt16(); exception.CatchType = reader.ReadInt16(); ExceptionTable.Add(exception); } Attributes = new List<CompileAttribute>(); short attributeCount = reader.ReadInt16(); for (int i = 0; i < attributeCount; i++) { Attributes.Add(ReadAttribute(reader, constants)); } return this; }