
jas.LineTableAttr Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jasmin Show documentation
Show all versions of jasmin Show documentation
Java Assembler Interface for the Soot framework
/**
* Line number table attributes are embedded into Code attributes
* and used for further debugging information.
* @see CodeAttr#setLineTable
* @author $Author: fqian $
* @version $Revision: 1.1 $
*/
package jas;
import java.io.*;
import java.util.*;
public class LineTableAttr
{
static CP attr = new AsciiCP("LineNumberTable");
Vector line, pc;
/**
* Note: A line table is associated with a method, so you
* need to create a new LineTableAttr for each method for which you add
* debugging information.
* @see CodeAttr#setLineTable
*/
public LineTableAttr()
{ line = new Vector(); pc = new Vector(); }
/**
* Add a pc to line number entry to the line table.
* @param Label to the location in the class file
* @param line Corresponding line number in the source file
*/
public void addEntry(Label l, int line)
{
pc.addElement(l);
this.line.addElement(new Integer(line));
}
void resolve(ClassEnv e)
{ e.addCPItem(attr); }
int size()
{ return
(2 + // name_idx
4 + // attr_len
2 + // line table len spec
4*(pc.size())); // table
}
void write(ClassEnv e, CodeAttr ce, DataOutputStream out)
throws IOException, jasError
{
out.writeShort(e.getCPIndex(attr));
out.writeInt(2 + 4*(pc.size()));
out.writeShort(pc.size());
for (Enumeration en = pc.elements(), ien = line.elements();
en.hasMoreElements();)
{
Label l = (Label)(en.nextElement());
Integer i = (Integer)(ien.nextElement());
l.writeOffset(ce, null, out);
out.writeShort((int) i.intValue());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy