JodeEnvironment removed (ImportHandler)

Types moved to jode.type


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@592 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 3373b08a91
commit 553ddf518b
  1. 32
      jode/jode/decompiler/CodeAnalyzer.java
  2. 13
      jode/jode/decompiler/FieldAnalyzer.java
  3. 20
      jode/jode/decompiler/MethodAnalyzer.java
  4. 16
      jode/jode/decompiler/Opcodes.java

@ -18,7 +18,8 @@
*/
package jode.decompiler;
import jode.*;
import jode.Decompiler;
import jode.type.Type;
import jode.bytecode.*;
import jode.flow.FlowBlock;
import jode.flow.TransformExceptionHandlers;
@ -38,23 +39,17 @@ public class CodeAnalyzer implements Analyzer {
FlowBlock methodHeader;
BytecodeInfo code;
MethodAnalyzer method;
public JodeEnvironment env;
ImportHandler imports;
Vector allLocals = new Vector();
LocalInfo[] param;
LocalVariableTable lvt;
/**
* Get the method.
* @return The method to which this code belongs.
*/
public MethodAnalyzer getMethod() {return method;}
public CodeAnalyzer(MethodAnalyzer ma, MethodInfo minfo,
AttributeInfo codeattr, JodeEnvironment e)
AttributeInfo codeattr, ImportHandler i)
{
method = ma;
env = e;
imports = i;
DataInputStream stream = new DataInputStream
(new ByteArrayInputStream(codeattr.getContents()));
@ -229,7 +224,7 @@ public class CodeAnalyzer implements Analyzer {
while (enum.hasMoreElements()) {
LocalInfo li = (LocalInfo)enum.nextElement();
if (!li.isShadow())
li.getType().useType();
imports.useType(li.getType());
}
for (int i=0; i < param.length; i++) {
for (int j=0; j < i; j++) {
@ -278,11 +273,6 @@ public class CodeAnalyzer implements Analyzer {
return param[nr];
}
public void useClass(String clazz)
{
env.useClass(clazz);
}
public String getTypeString(Type type) {
return method.classAnalyzer.getTypeString(type);
}
@ -294,4 +284,14 @@ public class CodeAnalyzer implements Analyzer {
public ClassInfo getClazz() {
return method.classAnalyzer.clazz;
}
/**
* Get the method.
* @return The method to which this code belongs.
*/
public MethodAnalyzer getMethod() {return method;}
public void useType(Type type) {
imports.useType(type);
}
}

@ -19,7 +19,7 @@
package jode.decompiler;
import java.lang.reflect.Modifier;
import jode.*;
import jode.type.*;
import jode.bytecode.FieldInfo;
import jode.bytecode.AttributeInfo;
import jode.bytecode.ClassFormatException;
@ -29,7 +29,7 @@ import jode.expr.ConstOperator;
public class FieldAnalyzer implements Analyzer {
ClassAnalyzer clazz;
JodeEnvironment env;
ImportHandler imports;
int modifiers;
Type type;
String fieldName;
@ -38,10 +38,10 @@ public class FieldAnalyzer implements Analyzer {
boolean analyzedSynthetic = false;
public FieldAnalyzer(ClassAnalyzer cla, FieldInfo fd,
JodeEnvironment e)
ImportHandler i)
{
clazz = cla;
env = e;
imports = i;
modifiers = fd.getModifiers();
type = fd.getType();
@ -83,7 +83,7 @@ public class FieldAnalyzer implements Analyzer {
}
public void analyze() {
type.useType();
imports.useType(type);
}
public void dumpSource(TabbedPrintWriter writer)
@ -97,7 +97,8 @@ public class FieldAnalyzer implements Analyzer {
if (modif.length() > 0)
writer.print(modif+" ");
writer.print(type.toString() + " " + fieldName);
writer.printType(type);
writer.print(" " + fieldName);
if (constant != null) {
writer.print(" = " + constant.simplify().toString());
}

@ -20,13 +20,16 @@
package jode.decompiler;
import jode.bytecode.MethodInfo;
import jode.bytecode.AttributeInfo;
import jode.*;
import jode.type.Type;
import jode.type.*;
import jode.AssertError;
import jode.Decompiler;
import java.lang.reflect.Modifier;
import java.io.*;
public class MethodAnalyzer implements Analyzer {
JodeEnvironment env;
ImportHandler imports;
CodeAnalyzer code = null;
ClassAnalyzer classAnalyzer;
boolean isConstructor;
@ -40,9 +43,9 @@ public class MethodAnalyzer implements Analyzer {
Type[] exceptions;
public MethodAnalyzer(ClassAnalyzer cla, MethodInfo minfo,
JodeEnvironment env) {
ImportHandler imports) {
this.classAnalyzer = cla;
this.env = env;
this.imports = imports;
this.modifiers = minfo.getModifiers();
this.methodType = minfo.getType();
this.methodName = minfo.getName();
@ -54,7 +57,7 @@ public class MethodAnalyzer implements Analyzer {
AttributeInfo codeattr = minfo.findAttribute("Code");
if (codeattr != null) {
code = new CodeAnalyzer(this, minfo, codeattr, env);
code = new CodeAnalyzer(this, minfo, codeattr, imports);
}
AttributeInfo excattr = minfo.findAttribute("Exceptions");
@ -135,10 +138,10 @@ public class MethodAnalyzer implements Analyzer {
}
for (int i= 0; i< exceptions.length; i++)
exceptions[i].useType();
imports.useType(exceptions[i]);
if (!isConstructor)
methodType.getReturnType().useType();
imports.useType(methodType.getReturnType());
if (!Decompiler.immediateOutput || isSynthetic) {
if (Decompiler.isVerbose)
@ -196,8 +199,7 @@ public class MethodAnalyzer implements Analyzer {
writer.print(""); /* static block */
else {
if (isConstructor)
writer.print(env.classString(classAnalyzer.
getClazz().getName()));
writer.print(imports.getClassString(classAnalyzer.getClazz()));
else
writer.print(getReturnType().toString()
+ " " + methodName);

@ -18,8 +18,8 @@
*/
package jode.decompiler;
import jode.Type;
import jode.MethodType;
import jode.type.Type;
import jode.type.MethodType;
import jode.expr.*;
import jode.flow.*;
import jode.bytecode.*;
@ -197,7 +197,7 @@ public abstract class Opcodes implements jode.bytecode.Opcodes {
int operation = Operator.ADD_OP;
if (value < 0) {
value = -value;
operation = Operator.NEG_OP;
operation = Operator.SUB_OP;
}
LocalInfo li = ca.getLocalInfo(instr.addr, instr.localSlot);
li.setType(Type.tUInt);
@ -228,7 +228,7 @@ public abstract class Opcodes implements jode.bytecode.Opcodes {
return createNormal
(ca, instr, new CompareToIntOperator
(types[3][(opcode-(opc_lcmp-3))/2],
(opcode-(opc_lcmp-3))%2));
(opcode == opc_fcmpg || opcode == opc_dcmpg)));
case opc_ifeq: case opc_ifne:
return createIfGoto
(ca, instr,
@ -320,7 +320,7 @@ public abstract class Opcodes implements jode.bytecode.Opcodes {
}
case opc_new: {
Type type = Type.tType((String) instr.objData);
type.useType();
ca.useType(type);
return createNormal(ca, instr, new NewOperator(type));
}
case opc_arraylength:
@ -332,13 +332,13 @@ public abstract class Opcodes implements jode.bytecode.Opcodes {
new ThrowBlock(new NopOperator(Type.tUObject)));
case opc_checkcast: {
Type type = Type.tType((String) instr.objData);
type.useType();
ca.useType(type);
return createNormal
(ca, instr, new CheckCastOperator(type));
}
case opc_instanceof: {
Type type = Type.tType((String) instr.objData);
type.useType();
ca.useType(type);
return createNormal
(ca, instr, new InstanceOfOperator(type));
}
@ -350,7 +350,7 @@ public abstract class Opcodes implements jode.bytecode.Opcodes {
new MonitorExitOperator());
case opc_multianewarray: {
Type type = Type.tType((String) instr.objData);
type.useType();
ca.useType(type);
int dimension = instr.intData;
return createNormal(ca, instr,
new NewArrayOperator(type, dimension));

Loading…
Cancel
Save