com.android.dx.cf.attrib.AttLineNumberTable Java Examples
The following examples show how to use
com.android.dx.cf.attrib.AttLineNumberTable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StdAttributeFactory.java From Box with Apache License 2.0 | 5 votes |
/** * Parses a {@code LineNumberTable} attribute. */ private Attribute lineNumberTable(DirectClassFile cf, int offset, int length, ParseObserver observer) { if (length < 2) { return throwSeverelyTruncated(); } ByteArray bytes = cf.getBytes(); int count = bytes.getUnsignedShort(offset); // line_number_table_length if (observer != null) { observer.parsed(bytes, offset, 2, "line_number_table_length: " + Hex.u2(count)); } offset += 2; length -= 2; if (length != (count * 4)) { throwBadLength((count * 4) + 2); } LineNumberList list = new LineNumberList(count); for (int i = 0; i < count; i++) { int startPc = bytes.getUnsignedShort(offset); int lineNumber = bytes.getUnsignedShort(offset + 2); list.set(i, startPc, lineNumber); if (observer != null) { observer.parsed(bytes, offset, 4, Hex.u2(startPc) + " " + lineNumber); } offset += 4; } list.setImmutable(); return new AttLineNumberTable(list); }
Example #2
Source File: StdAttributeFactory.java From Box with Apache License 2.0 | 5 votes |
/** * Parses a {@code LineNumberTable} attribute. */ private Attribute lineNumberTable(DirectClassFile cf, int offset, int length, ParseObserver observer) { if (length < 2) { return throwSeverelyTruncated(); } ByteArray bytes = cf.getBytes(); int count = bytes.getUnsignedShort(offset); // line_number_table_length if (observer != null) { observer.parsed(bytes, offset, 2, "line_number_table_length: " + Hex.u2(count)); } offset += 2; length -= 2; if (length != (count * 4)) { throwBadLength((count * 4) + 2); } LineNumberList list = new LineNumberList(count); for (int i = 0; i < count; i++) { int startPc = bytes.getUnsignedShort(offset); int lineNumber = bytes.getUnsignedShort(offset + 2); list.set(i, startPc, lineNumber); if (observer != null) { observer.parsed(bytes, offset, 4, Hex.u2(startPc) + " " + lineNumber); } offset += 4; } list.setImmutable(); return new AttLineNumberTable(list); }
Example #3
Source File: StdAttributeFactory.java From J2ME-Loader with Apache License 2.0 | 5 votes |
/** * Parses a {@code LineNumberTable} attribute. */ private Attribute lineNumberTable(DirectClassFile cf, int offset, int length, ParseObserver observer) { if (length < 2) { return throwSeverelyTruncated(); } ByteArray bytes = cf.getBytes(); int count = bytes.getUnsignedShort(offset); // line_number_table_length if (observer != null) { observer.parsed(bytes, offset, 2, "line_number_table_length: " + Hex.u2(count)); } offset += 2; length -= 2; if (length != (count * 4)) { throwBadLength((count * 4) + 2); } LineNumberList list = new LineNumberList(count); for (int i = 0; i < count; i++) { int startPc = bytes.getUnsignedShort(offset); int lineNumber = bytes.getUnsignedShort(offset + 2); list.set(i, startPc, lineNumber); if (observer != null) { observer.parsed(bytes, offset, 4, Hex.u2(startPc) + " " + lineNumber); } offset += 4; } list.setImmutable(); return new AttLineNumberTable(list); }
Example #4
Source File: StdAttributeFactory.java From buck with Apache License 2.0 | 5 votes |
/** * Parses a {@code LineNumberTable} attribute. */ private Attribute lineNumberTable(DirectClassFile cf, int offset, int length, ParseObserver observer) { if (length < 2) { return throwSeverelyTruncated(); } ByteArray bytes = cf.getBytes(); int count = bytes.getUnsignedShort(offset); // line_number_table_length if (observer != null) { observer.parsed(bytes, offset, 2, "line_number_table_length: " + Hex.u2(count)); } offset += 2; length -= 2; if (length != (count * 4)) { throwBadLength((count * 4) + 2); } LineNumberList list = new LineNumberList(count); for (int i = 0; i < count; i++) { int startPc = bytes.getUnsignedShort(offset); int lineNumber = bytes.getUnsignedShort(offset + 2); list.set(i, startPc, lineNumber); if (observer != null) { observer.parsed(bytes, offset, 4, Hex.u2(startPc) + " " + lineNumber); } offset += 4; } list.setImmutable(); return new AttLineNumberTable(list); }
Example #5
Source File: ConcreteMethod.java From Box with Apache License 2.0 | 4 votes |
/** * Constructs an instance. * * @param method {@code non-null;} the method to be based on * @param classFile {@code non-null;} the class file that contains this method * @param keepLines whether to keep the line number information * (if any) * @param keepLocals whether to keep the local variable * information (if any) */ public ConcreteMethod(Method method, ClassFile classFile, boolean keepLines, boolean keepLocals) { this.method = method; this.classFile = classFile; AttributeList attribs = method.getAttributes(); this.attCode = (AttCode) attribs.findFirst(AttCode.ATTRIBUTE_NAME); AttributeList codeAttribs = attCode.getAttributes(); /* * Combine all LineNumberTable attributes into one, with the * combined result saved into the instance. The following code * isn't particularly efficient for doing merges, but as far * as I know, this situation rarely occurs "in the * wild," so there's not much point in optimizing for it. */ LineNumberList lnl = LineNumberList.EMPTY; if (keepLines) { for (AttLineNumberTable lnt = (AttLineNumberTable) codeAttribs.findFirst(AttLineNumberTable.ATTRIBUTE_NAME); lnt != null; lnt = (AttLineNumberTable) codeAttribs.findNext(lnt)) { lnl = LineNumberList.concat(lnl, lnt.getLineNumbers()); } } this.lineNumbers = lnl; LocalVariableList lvl = LocalVariableList.EMPTY; if (keepLocals) { /* * Do likewise (and with the same caveat) for * LocalVariableTable and LocalVariableTypeTable attributes. * This combines both of these kinds of attribute into a * single LocalVariableList. */ for (AttLocalVariableTable lvt = (AttLocalVariableTable) codeAttribs.findFirst( AttLocalVariableTable.ATTRIBUTE_NAME); lvt != null; lvt = (AttLocalVariableTable) codeAttribs.findNext(lvt)) { lvl = LocalVariableList.concat(lvl, lvt.getLocalVariables()); } LocalVariableList typeList = LocalVariableList.EMPTY; for (AttLocalVariableTypeTable lvtt = (AttLocalVariableTypeTable) codeAttribs.findFirst( AttLocalVariableTypeTable.ATTRIBUTE_NAME); lvtt != null; lvtt = (AttLocalVariableTypeTable) codeAttribs.findNext(lvtt)) { typeList = LocalVariableList.concat(typeList, lvtt.getLocalVariables()); } if (typeList.size() != 0) { lvl = LocalVariableList.mergeDescriptorsAndSignatures(lvl, typeList); } } this.localVariables = lvl; }
Example #6
Source File: ConcreteMethod.java From Box with Apache License 2.0 | 4 votes |
/** * Constructs an instance. * * @param method {@code non-null;} the method to be based on * @param classFile {@code non-null;} the class file that contains this method * @param keepLines whether to keep the line number information * (if any) * @param keepLocals whether to keep the local variable * information (if any) */ public ConcreteMethod(Method method, ClassFile classFile, boolean keepLines, boolean keepLocals) { this.method = method; this.classFile = classFile; AttributeList attribs = method.getAttributes(); this.attCode = (AttCode) attribs.findFirst(AttCode.ATTRIBUTE_NAME); AttributeList codeAttribs = attCode.getAttributes(); /* * Combine all LineNumberTable attributes into one, with the * combined result saved into the instance. The following code * isn't particularly efficient for doing merges, but as far * as I know, this situation rarely occurs "in the * wild," so there's not much point in optimizing for it. */ LineNumberList lnl = LineNumberList.EMPTY; if (keepLines) { for (AttLineNumberTable lnt = (AttLineNumberTable) codeAttribs.findFirst(AttLineNumberTable.ATTRIBUTE_NAME); lnt != null; lnt = (AttLineNumberTable) codeAttribs.findNext(lnt)) { lnl = LineNumberList.concat(lnl, lnt.getLineNumbers()); } } this.lineNumbers = lnl; LocalVariableList lvl = LocalVariableList.EMPTY; if (keepLocals) { /* * Do likewise (and with the same caveat) for * LocalVariableTable and LocalVariableTypeTable attributes. * This combines both of these kinds of attribute into a * single LocalVariableList. */ for (AttLocalVariableTable lvt = (AttLocalVariableTable) codeAttribs.findFirst( AttLocalVariableTable.ATTRIBUTE_NAME); lvt != null; lvt = (AttLocalVariableTable) codeAttribs.findNext(lvt)) { lvl = LocalVariableList.concat(lvl, lvt.getLocalVariables()); } LocalVariableList typeList = LocalVariableList.EMPTY; for (AttLocalVariableTypeTable lvtt = (AttLocalVariableTypeTable) codeAttribs.findFirst( AttLocalVariableTypeTable.ATTRIBUTE_NAME); lvtt != null; lvtt = (AttLocalVariableTypeTable) codeAttribs.findNext(lvtt)) { typeList = LocalVariableList.concat(typeList, lvtt.getLocalVariables()); } if (typeList.size() != 0) { lvl = LocalVariableList.mergeDescriptorsAndSignatures(lvl, typeList); } } this.localVariables = lvl; }
Example #7
Source File: ConcreteMethod.java From J2ME-Loader with Apache License 2.0 | 4 votes |
public ConcreteMethod(Method method, CstString sourceFile, boolean keepLines, boolean keepLocals) { this.method = method; this.sourceFile = sourceFile; AttributeList attribs = method.getAttributes(); this.attCode = (AttCode) attribs.findFirst(AttCode.ATTRIBUTE_NAME); AttributeList codeAttribs = attCode.getAttributes(); /* * Combine all LineNumberTable attributes into one, with the * combined result saved into the instance. The following code * isn't particularly efficient for doing merges, but as far * as I know, this situation rarely occurs "in the * wild," so there's not much point in optimizing for it. */ LineNumberList lineNumbers = LineNumberList.EMPTY; if (keepLines) { for (AttLineNumberTable lnt = (AttLineNumberTable) codeAttribs.findFirst(AttLineNumberTable.ATTRIBUTE_NAME); lnt != null; lnt = (AttLineNumberTable) codeAttribs.findNext(lnt)) { lineNumbers = LineNumberList.concat(lineNumbers, lnt.getLineNumbers()); } } this.lineNumbers = lineNumbers; LocalVariableList localVariables = LocalVariableList.EMPTY; if (keepLocals) { /* * Do likewise (and with the same caveat) for * LocalVariableTable and LocalVariableTypeTable attributes. * This combines both of these kinds of attribute into a * single LocalVariableList. */ for (AttLocalVariableTable lvt = (AttLocalVariableTable) codeAttribs.findFirst( AttLocalVariableTable.ATTRIBUTE_NAME); lvt != null; lvt = (AttLocalVariableTable) codeAttribs.findNext(lvt)) { localVariables = LocalVariableList.concat(localVariables, lvt.getLocalVariables()); } LocalVariableList typeList = LocalVariableList.EMPTY; for (AttLocalVariableTypeTable lvtt = (AttLocalVariableTypeTable) codeAttribs.findFirst( AttLocalVariableTypeTable.ATTRIBUTE_NAME); lvtt != null; lvtt = (AttLocalVariableTypeTable) codeAttribs.findNext(lvtt)) { typeList = LocalVariableList.concat(typeList, lvtt.getLocalVariables()); } if (typeList.size() != 0) { localVariables = LocalVariableList.mergeDescriptorsAndSignatures( localVariables, typeList); } } this.localVariables = localVariables; }
Example #8
Source File: ConcreteMethod.java From buck with Apache License 2.0 | 4 votes |
public ConcreteMethod(Method method, int accessFlags, CstString sourceFile, boolean keepLines, boolean keepLocals) { this.method = method; this.accSuper = (accessFlags & AccessFlags.ACC_SUPER) != 0; this.sourceFile = sourceFile; AttributeList attribs = method.getAttributes(); this.attCode = (AttCode) attribs.findFirst(AttCode.ATTRIBUTE_NAME); AttributeList codeAttribs = attCode.getAttributes(); /* * Combine all LineNumberTable attributes into one, with the * combined result saved into the instance. The following code * isn't particularly efficient for doing merges, but as far * as I know, this situation rarely occurs "in the * wild," so there's not much point in optimizing for it. */ LineNumberList lineNumbers = LineNumberList.EMPTY; if (keepLines) { for (AttLineNumberTable lnt = (AttLineNumberTable) codeAttribs.findFirst(AttLineNumberTable.ATTRIBUTE_NAME); lnt != null; lnt = (AttLineNumberTable) codeAttribs.findNext(lnt)) { lineNumbers = LineNumberList.concat(lineNumbers, lnt.getLineNumbers()); } } this.lineNumbers = lineNumbers; LocalVariableList localVariables = LocalVariableList.EMPTY; if (keepLocals) { /* * Do likewise (and with the same caveat) for * LocalVariableTable and LocalVariableTypeTable attributes. * This combines both of these kinds of attribute into a * single LocalVariableList. */ for (AttLocalVariableTable lvt = (AttLocalVariableTable) codeAttribs.findFirst( AttLocalVariableTable.ATTRIBUTE_NAME); lvt != null; lvt = (AttLocalVariableTable) codeAttribs.findNext(lvt)) { localVariables = LocalVariableList.concat(localVariables, lvt.getLocalVariables()); } LocalVariableList typeList = LocalVariableList.EMPTY; for (AttLocalVariableTypeTable lvtt = (AttLocalVariableTypeTable) codeAttribs.findFirst( AttLocalVariableTypeTable.ATTRIBUTE_NAME); lvtt != null; lvtt = (AttLocalVariableTypeTable) codeAttribs.findNext(lvtt)) { typeList = LocalVariableList.concat(typeList, lvtt.getLocalVariables()); } if (typeList.size() != 0) { localVariables = LocalVariableList.mergeDescriptorsAndSignatures( localVariables, typeList); } } this.localVariables = localVariables; }