*** empty log message ***

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@106 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 88fee293cb
commit a421adad08
  1. 16
      jode/jode/decompiler/ClassAnalyzer.java
  2. 3
      jode/jode/decompiler/CodeAnalyzer.java
  3. 47
      jode/jode/decompiler/FieldAnalyzer.java
  4. 54
      jode/jode/decompiler/MethodAnalyzer.java
  5. 1
      jode/jode/flow/VariableSet.java

@ -122,15 +122,23 @@ public class ClassAnalyzer implements Analyzer {
public Type getConstantType(int i)
throws ClassFormatError
{
int t = classType.getConstant(i).getTag();
switch(t) {
case ConstantPool.INTEGER: return Type.tInt ;
CpoolEntry constant = getConstant(i);
switch(constant.getTag()) {
case ConstantPool.INTEGER: {
int value = ((CpoolValue1)constant).getValue();
return ((value < Short.MIN_VALUE || value > Character.MAX_VALUE)
? Type.tInt
: (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE)
? Type.tRange(Type.tInt, Type.tChar)
: Type.tUInt);
}
case ConstantPool.FLOAT : return Type.tFloat ;
case ConstantPool.LONG : return Type.tLong ;
case ConstantPool.DOUBLE : return Type.tDouble;
case ConstantPool.STRING : return Type.tString;
default:
throw new ClassFormatError("invalid constant type: "+t);
throw new ClassFormatError("invalid constant type: "
+ constant.getTag());
}
}

@ -32,6 +32,7 @@ import gnu.bytecode.CodeAttr;
import gnu.bytecode.Attribute;
import gnu.bytecode.LocalVarsAttr;
import gnu.bytecode.CpoolClass;
import gnu.bytecode.Spy;
public class CodeAnalyzer implements Analyzer {
@ -94,7 +95,7 @@ public class CodeAnalyzer implements Analyzer {
}
handler = new TransformExceptionHandlers(instr);
short[] handlers = gnu.bytecode.Spy.getExceptionHandlers(bincode);
short[] handlers = Spy.getExceptionHandlers(bincode);
for (int i=0; i<handlers.length; i += 4) {
Type type = null;

@ -21,50 +21,57 @@ package jode;
import java.lang.reflect.*;
import gnu.bytecode.Attribute;
import gnu.bytecode.MiscAttr;
import gnu.bytecode.Spy;
public class FieldAnalyzer implements Analyzer {
ClassAnalyzer clazz;
int constantValue;
Field field;
JodeEnvironment env;
int modifiers;
Type type;
String fieldName;
ConstOperator constant;
public FieldAnalyzer(ClassAnalyzer cla, Field fd, JodeEnvironment e)
{
clazz = cla;
field = fd;
env = e;
}
public void analyze() {
Type.tType(field.getType()).useType();
constantValue = 0;
modifiers = fd.getModifiers();
type = Type.tType(fd.getType());
fieldName = fd.getName();
constant = null;
Attribute attribute =
Attribute.get(clazz.classType.getField(field.getName()),
Attribute.get(clazz.classType.getField(fieldName),
"ConstantValue");
if (attribute != null) {
byte[] data = gnu.bytecode.Spy.getAttribute((MiscAttr)attribute);
constantValue = (unsigned(data[0]) << 8) | unsigned(data[1]);
try {
int index = Spy.getAttributeStream((MiscAttr)attribute)
.readUnsignedShort();
constant = new ConstOperator
(type.intersection(cla.getConstantType(index)),
cla.getConstantString(index));
} catch (java.io.IOException ex) {
throw new AssertError("attribute too small");
}
}
}
private final int unsigned(byte value) {
if (value < 0)
return value + 256;
else
return value;
public void analyze() {
type.useType();
}
public void dumpSource(TabbedPrintWriter writer)
throws java.io.IOException
{
String modif = Modifier.toString(field.getModifiers());
String modif = Modifier.toString(modifiers);
if (modif.length() > 0)
writer.print(modif+" ");
writer.print(Type.tType(field.getType()).toString()
+ " " + field.getName());
if (constantValue != 0) {
writer.print(" = "+clazz.getConstantString(constantValue));
writer.print(type.toString() + " " + fieldName);
if (constant != null) {
writer.print(" = " + constant.toString());
}
writer.println(";");
}

@ -21,6 +21,9 @@ package jode;
import java.lang.reflect.Modifier;
import gnu.bytecode.Attribute;
import gnu.bytecode.CodeAttr;
import gnu.bytecode.CpoolClass;
import gnu.bytecode.Method;
import gnu.bytecode.MiscAttr;
import gnu.bytecode.Spy;
public class MethodAnalyzer implements Analyzer {
@ -33,52 +36,7 @@ public class MethodAnalyzer implements Analyzer {
MethodType methodType;
Type[] exceptions;
// private MethodAnalyzer(ClassAnalyzer cla, Method m, Constructor c,
// JodeEnvironment e)
// {
// classAnalyzer = cla;
// isConstructor = (c != null);
// env = e;
// this.modifiers = isConstructor
// ? c.getModifiers() : m.getModifiers();
// {
// Class[] exceptClasses = isConstructor
// ? c.getExceptionTypes() : m.getExceptionTypes();
// this.exceptions = new Type[exceptClasses.length];
// for (int i=0; i< exceptClasses.length; i++)
// exceptions[i] = Type.tType(exceptClasses[i]);
// }
// {
// Class[] paramTypes = (isConstructor
// ? c.getParameterTypes()
// : m.getParameterTypes());
// Class returnType = (isConstructor
// ? Void.TYPE : m.getReturnType());
// methodType = new MethodType
// (!isConstructor && Modifier.isStatic(modifiers),
// paramTypes, returnType);
// methodName = isConstructor ? "<init>" : m.getName();
// }
// gnu.bytecode.Method mdef;
// for (mdef = cla.classType.getMethods(); ; mdef = mdef.getNext()) {
// if (mdef.getName().equals(methodName)) {
// MethodType type = new MethodType(mdef.getStaticFlag(),
// mdef.getSignature());
// if (type.equals(methodType))
// break;
// }
// }
// Attribute attr = Attribute.get(mdef, "Code");
// if (attr != null && attr instanceof CodeAttr)
// code = new CodeAnalyzer(this, (CodeAttr) attr, env);
// }
public MethodAnalyzer(ClassAnalyzer cla, gnu.bytecode.Method mdef,
public MethodAnalyzer(ClassAnalyzer cla, Method mdef,
JodeEnvironment env) {
this.classAnalyzer = cla;
this.env = env;
@ -98,13 +56,13 @@ public class MethodAnalyzer implements Analyzer {
exceptions = new Type[0];
} else {
java.io.DataInputStream stream = Spy.getAttributeStream
((gnu.bytecode.MiscAttr) excattr);
((MiscAttr) excattr);
try {
int throwCount = stream.readUnsignedShort();
this.exceptions = new Type[throwCount];
for (int t=0; t< throwCount; t++) {
int idx = stream.readUnsignedShort();
gnu.bytecode.CpoolClass cpcls = (gnu.bytecode.CpoolClass)
CpoolClass cpcls = (CpoolClass)
classAnalyzer.getConstant(idx);
exceptions[t] = Type.tClass(cpcls.getName().getString());
}

@ -34,6 +34,7 @@ public class VariableSet extends java.util.Vector {
* Creates a new empty variable set
*/
public VariableSet() {
super(0, 0);
}
/**

Loading…
Cancel
Save