|
|
|
@ -21,48 +21,21 @@ package jode.decompiler; |
|
|
|
|
import java.io.*; |
|
|
|
|
import jode.Decompiler; |
|
|
|
|
import jode.type.Type; |
|
|
|
|
import jode.bytecode.AttributeInfo; |
|
|
|
|
import jode.bytecode.ConstantPool; |
|
|
|
|
import jode.bytecode.LocalVariableInfo; |
|
|
|
|
|
|
|
|
|
public class LocalVariableTable { |
|
|
|
|
LocalVariableRangeList[] locals; |
|
|
|
|
|
|
|
|
|
public LocalVariableTable(int size, ConstantPool constantPool, |
|
|
|
|
AttributeInfo attr) { |
|
|
|
|
|
|
|
|
|
locals = new LocalVariableRangeList[size]; |
|
|
|
|
for (int i=0; i<size; i++) |
|
|
|
|
public LocalVariableTable(int maxLocals, LocalVariableInfo[] lvt) { |
|
|
|
|
locals = new LocalVariableRangeList[maxLocals]; |
|
|
|
|
for (int i=0; i < maxLocals; i++) |
|
|
|
|
locals[i] = new LocalVariableRangeList(i); |
|
|
|
|
|
|
|
|
|
DataInputStream stream = new DataInputStream |
|
|
|
|
(new ByteArrayInputStream(attr.getContents())); |
|
|
|
|
try { |
|
|
|
|
int count = stream.readUnsignedShort(); |
|
|
|
|
for (int i=0; i < count; i++) { |
|
|
|
|
int start = stream.readUnsignedShort(); |
|
|
|
|
int end = start + stream.readUnsignedShort(); |
|
|
|
|
int nameIndex = stream.readUnsignedShort(); |
|
|
|
|
int typeIndex = stream.readUnsignedShort(); |
|
|
|
|
if (nameIndex == 0 || typeIndex == 0 |
|
|
|
|
|| constantPool.getTag(nameIndex) != constantPool.UTF8 |
|
|
|
|
|| constantPool.getTag(typeIndex) != constantPool.UTF8) { |
|
|
|
|
// This is probably an evil lvt as created by HashJava
|
|
|
|
|
// simply ignore it.
|
|
|
|
|
if (Decompiler.showLVT) |
|
|
|
|
Decompiler.err.println("Illegal entry, ignoring LVT"); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
String name = constantPool.getUTF8(nameIndex); |
|
|
|
|
Type type = Type.tType(constantPool.getUTF8(typeIndex)); |
|
|
|
|
int slot = stream.readUnsignedShort(); |
|
|
|
|
locals[slot].addLocal(start, end-start, name, type); |
|
|
|
|
if (Decompiler.showLVT) |
|
|
|
|
Decompiler.err.println("\t"+name + ": " + type |
|
|
|
|
+" range "+start+" - "+end |
|
|
|
|
+" slot "+slot); |
|
|
|
|
} |
|
|
|
|
} catch (IOException ex) { |
|
|
|
|
ex.printStackTrace(Decompiler.err); |
|
|
|
|
for (int i=0; i<lvt.length; i++) { |
|
|
|
|
int length = (lvt[i].end.addr + lvt[i].end.length |
|
|
|
|
- lvt[i].start.addr); |
|
|
|
|
locals[lvt[i].slot].addLocal(lvt[i].start.addr, length, |
|
|
|
|
lvt[i].name, Type.tType(lvt[i].type)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|