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; package jode.decompiler;
import jode.*; import jode.Decompiler;
import jode.type.Type;
import jode.bytecode.*; import jode.bytecode.*;
import jode.flow.FlowBlock; import jode.flow.FlowBlock;
import jode.flow.TransformExceptionHandlers; import jode.flow.TransformExceptionHandlers;
@ -38,23 +39,17 @@ public class CodeAnalyzer implements Analyzer {
FlowBlock methodHeader; FlowBlock methodHeader;
BytecodeInfo code; BytecodeInfo code;
MethodAnalyzer method; MethodAnalyzer method;
public JodeEnvironment env; ImportHandler imports;
Vector allLocals = new Vector(); Vector allLocals = new Vector();
LocalInfo[] param; LocalInfo[] param;
LocalVariableTable lvt; LocalVariableTable lvt;
/**
* Get the method.
* @return The method to which this code belongs.
*/
public MethodAnalyzer getMethod() {return method;}
public CodeAnalyzer(MethodAnalyzer ma, MethodInfo minfo, public CodeAnalyzer(MethodAnalyzer ma, MethodInfo minfo,
AttributeInfo codeattr, JodeEnvironment e) AttributeInfo codeattr, ImportHandler i)
{ {
method = ma; method = ma;
env = e; imports = i;
DataInputStream stream = new DataInputStream DataInputStream stream = new DataInputStream
(new ByteArrayInputStream(codeattr.getContents())); (new ByteArrayInputStream(codeattr.getContents()));
@ -229,7 +224,7 @@ public class CodeAnalyzer implements Analyzer {
while (enum.hasMoreElements()) { while (enum.hasMoreElements()) {
LocalInfo li = (LocalInfo)enum.nextElement(); LocalInfo li = (LocalInfo)enum.nextElement();
if (!li.isShadow()) if (!li.isShadow())
li.getType().useType(); imports.useType(li.getType());
} }
for (int i=0; i < param.length; i++) { for (int i=0; i < param.length; i++) {
for (int j=0; j < i; j++) { for (int j=0; j < i; j++) {
@ -278,11 +273,6 @@ public class CodeAnalyzer implements Analyzer {
return param[nr]; return param[nr];
} }
public void useClass(String clazz)
{
env.useClass(clazz);
}
public String getTypeString(Type type) { public String getTypeString(Type type) {
return method.classAnalyzer.getTypeString(type); return method.classAnalyzer.getTypeString(type);
} }
@ -294,4 +284,14 @@ public class CodeAnalyzer implements Analyzer {
public ClassInfo getClazz() { public ClassInfo getClazz() {
return method.classAnalyzer.clazz; 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; package jode.decompiler;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import jode.*; import jode.type.*;
import jode.bytecode.FieldInfo; import jode.bytecode.FieldInfo;
import jode.bytecode.AttributeInfo; import jode.bytecode.AttributeInfo;
import jode.bytecode.ClassFormatException; import jode.bytecode.ClassFormatException;
@ -29,7 +29,7 @@ import jode.expr.ConstOperator;
public class FieldAnalyzer implements Analyzer { public class FieldAnalyzer implements Analyzer {
ClassAnalyzer clazz; ClassAnalyzer clazz;
JodeEnvironment env; ImportHandler imports;
int modifiers; int modifiers;
Type type; Type type;
String fieldName; String fieldName;
@ -38,10 +38,10 @@ public class FieldAnalyzer implements Analyzer {
boolean analyzedSynthetic = false; boolean analyzedSynthetic = false;
public FieldAnalyzer(ClassAnalyzer cla, FieldInfo fd, public FieldAnalyzer(ClassAnalyzer cla, FieldInfo fd,
JodeEnvironment e) ImportHandler i)
{ {
clazz = cla; clazz = cla;
env = e; imports = i;
modifiers = fd.getModifiers(); modifiers = fd.getModifiers();
type = fd.getType(); type = fd.getType();
@ -83,7 +83,7 @@ public class FieldAnalyzer implements Analyzer {
} }
public void analyze() { public void analyze() {
type.useType(); imports.useType(type);
} }
public void dumpSource(TabbedPrintWriter writer) public void dumpSource(TabbedPrintWriter writer)
@ -97,7 +97,8 @@ public class FieldAnalyzer implements Analyzer {
if (modif.length() > 0) if (modif.length() > 0)
writer.print(modif+" "); writer.print(modif+" ");
writer.print(type.toString() + " " + fieldName); writer.printType(type);
writer.print(" " + fieldName);
if (constant != null) { if (constant != null) {
writer.print(" = " + constant.simplify().toString()); writer.print(" = " + constant.simplify().toString());
} }

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

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

Loading…
Cancel
Save