Search in sources :

Example 1 with LineNumberTable_attribute

use of com.sun.tools.classfile.LineNumberTable_attribute in project jdk8u_jdk by JetBrains.

the class AnnotationsElementVisitor method visitLineNumberTable.

@Override
public Element visitLineNumberTable(LineNumberTable_attribute lnt, Element p) {
    String name = x.getCpString(lnt.attribute_name_index);
    for (LineNumberTable_attribute.Entry e : lnt.line_number_table) {
        Element l = new Element(name);
        l.setAttr("bci", "" + e.start_pc);
        l.setAttr("line", "" + e.line_number);
        l.trimToSize();
        p.add(l);
    }
    // already added to parent
    return null;
}
Also used : Element(xmlkit.XMLKit.Element) LineNumberTable_attribute(com.sun.tools.classfile.LineNumberTable_attribute)

Example 2 with LineNumberTable_attribute

use of com.sun.tools.classfile.LineNumberTable_attribute in project ceylon-compiler by ceylon.

the class SourceWriter method setLineMap.

private void setLineMap(Code_attribute attr) {
    SortedMap<Integer, SortedSet<Integer>> map = new TreeMap<Integer, SortedSet<Integer>>();
    SortedSet<Integer> allLines = new TreeSet<Integer>();
    for (Attribute a : attr.attributes) {
        if (a instanceof LineNumberTable_attribute) {
            LineNumberTable_attribute t = (LineNumberTable_attribute) a;
            for (LineNumberTable_attribute.Entry e : t.line_number_table) {
                int start_pc = e.start_pc;
                int line = e.line_number;
                SortedSet<Integer> pcLines = map.get(start_pc);
                if (pcLines == null) {
                    pcLines = new TreeSet<Integer>();
                    map.put(start_pc, pcLines);
                }
                pcLines.add(line);
                allLines.add(line);
            }
        }
    }
    lineMap = map;
    lineList = new ArrayList<Integer>(allLines);
}
Also used : Attribute(com.sun.tools.classfile.Attribute) TreeSet(java.util.TreeSet) TreeMap(java.util.TreeMap) SortedSet(java.util.SortedSet) LineNumberTable_attribute(com.sun.tools.classfile.LineNumberTable_attribute)

Aggregations

LineNumberTable_attribute (com.sun.tools.classfile.LineNumberTable_attribute)2 Attribute (com.sun.tools.classfile.Attribute)1 SortedSet (java.util.SortedSet)1 TreeMap (java.util.TreeMap)1 TreeSet (java.util.TreeSet)1 Element (xmlkit.XMLKit.Element)1