src.org.python.compiler.LineNumberTable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jython Show documentation
Show all versions of jython Show documentation
Jython is an implementation of the high-level, dynamic, object-oriented
language Python written in 100% Pure Java, and seamlessly integrated with
the Java platform. It thus allows you to run Python on any Java platform.
// Copyright 2001 Finn Bock
package org.python.compiler;
import java.util.Vector;
import java.io.DataOutputStream;
import java.io.IOException;
/**
* @Deprecated Not used. Delete in 2.6.
*/
public class LineNumberTable {
int attName;
Vector lines;
public LineNumberTable() throws IOException {
lines = new Vector();
}
public void write(DataOutputStream stream) throws IOException {
stream.writeShort(attName);
int n = lines.size();
stream.writeInt(n * 2 + 2);
stream.writeShort(n / 2);
for (int i = 0; i < n; i += 2) {
Short startpc = lines.elementAt(i);
Short lineno = lines.elementAt(i+1);
stream.writeShort(startpc.shortValue());
stream.writeShort(lineno.shortValue());
}
}
public void addLine(int startpc, int lineno) {
lines.addElement(new Short((short) startpc));
lines.addElement(new Short((short) lineno));
}
public int length() {
return lines.size() * 2 + 8;
}
}