public static CodeAttributeParser ParseData(ClassFile cFile, byte[] data) { int pos = 0; CodeAttributeParser res = new CodeAttributeParser(); res.MaxStack = Utils.ReadUShort(data, ref pos); res.MaxLocals = Utils.ReadUShort(data, ref pos); res.CodeLength = Utils.ReadUInt(data, ref pos); res.Code = new byte[res.CodeLength]; for (int i = 0; i < res.CodeLength; ++i) { res.Code[i] = data[pos++]; } res.ExceptionTableLength = Utils.ReadUShort(data, ref pos); res.ExceptionTable = new ExceptionTableDescription[res.ExceptionTableLength]; for (int i = 0; i < res.ExceptionTableLength; ++i) { res.ExceptionTable[i] = ExceptionTableDescription.ParseData(data, ref pos); } res.AttributesCount = Utils.ReadUShort(data, ref pos); res.Attributes = new AttributeDescription[res.AttributesCount]; for (int i = 0; i < res.AttributesCount; ++i) { res.Attributes[i] = AttributeDescription.ParseData(data, ref pos); } res.AttributeParsers = AttributeParser.GenerateAttributeMap(cFile, res.Attributes); return(res); }
public static ExceptionTableDescription ParseData(byte[] data, ref int pos) { ExceptionTableDescription res = new ExceptionTableDescription(); res.StartPC = Utils.ReadUShort(data, ref pos); res.EndPC = Utils.ReadUShort(data, ref pos); res.HandlerPC = Utils.ReadUShort(data, ref pos); res.CatchType = Utils.ReadUShort(data, ref pos); return(res); }