From a421adad084c51242018121559eee31a2a4a7821 Mon Sep 17 00:00:00 2001 From: jochen Date: Thu, 29 Oct 1998 12:00:10 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@106 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/decompiler/ClassAnalyzer.java | 16 +++++-- jode/jode/decompiler/CodeAnalyzer.java | 3 +- jode/jode/decompiler/FieldAnalyzer.java | 47 ++++++++++++--------- jode/jode/decompiler/MethodAnalyzer.java | 54 +++--------------------- jode/jode/flow/VariableSet.java | 1 + 5 files changed, 48 insertions(+), 73 deletions(-) diff --git a/jode/jode/decompiler/ClassAnalyzer.java b/jode/jode/decompiler/ClassAnalyzer.java index 3f5e7f9..e25876c 100644 --- a/jode/jode/decompiler/ClassAnalyzer.java +++ b/jode/jode/decompiler/ClassAnalyzer.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()); } } diff --git a/jode/jode/decompiler/CodeAnalyzer.java b/jode/jode/decompiler/CodeAnalyzer.java index 9c540bb..cc66f6c 100644 --- a/jode/jode/decompiler/CodeAnalyzer.java +++ b/jode/jode/decompiler/CodeAnalyzer.java @@ -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 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(";"); } diff --git a/jode/jode/decompiler/MethodAnalyzer.java b/jode/jode/decompiler/MethodAnalyzer.java index 130dc00..06bae1a 100644 --- a/jode/jode/decompiler/MethodAnalyzer.java +++ b/jode/jode/decompiler/MethodAnalyzer.java @@ -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 ? "" : 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()); } diff --git a/jode/jode/flow/VariableSet.java b/jode/jode/flow/VariableSet.java index 56c0b22..8081bad 100644 --- a/jode/jode/flow/VariableSet.java +++ b/jode/jode/flow/VariableSet.java @@ -34,6 +34,7 @@ public class VariableSet extends java.util.Vector { * Creates a new empty variable set */ public VariableSet() { + super(0, 0); } /**