|
|
@ -20,13 +20,11 @@ |
|
|
|
package jode.expr; |
|
|
|
package jode.expr; |
|
|
|
import jode.decompiler.CodeAnalyzer; |
|
|
|
import jode.decompiler.CodeAnalyzer; |
|
|
|
import jode.decompiler.ClassAnalyzer; |
|
|
|
import jode.decompiler.ClassAnalyzer; |
|
|
|
import jode.MethodType; |
|
|
|
import jode.decompiler.TabbedPrintWriter; |
|
|
|
import jode.Decompiler; |
|
|
|
import jode.Decompiler; |
|
|
|
import jode.Type; |
|
|
|
|
|
|
|
import jode.ArrayType; |
|
|
|
|
|
|
|
import jode.ClassInterfacesType; |
|
|
|
|
|
|
|
import jode.bytecode.*; |
|
|
|
import jode.bytecode.*; |
|
|
|
import jode.jvm.*; |
|
|
|
import jode.jvm.*; |
|
|
|
|
|
|
|
import jode.type.*; |
|
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
|
import java.lang.reflect.InvocationTargetException; |
|
|
|
|
|
|
|
|
|
|
|
public final class InvokeOperator extends Operator |
|
|
|
public final class InvokeOperator extends Operator |
|
|
@ -50,7 +48,7 @@ public final class InvokeOperator extends Operator |
|
|
|
this.staticFlag = staticFlag; |
|
|
|
this.staticFlag = staticFlag; |
|
|
|
this.specialFlag = specialFlag; |
|
|
|
this.specialFlag = specialFlag; |
|
|
|
if (staticFlag) |
|
|
|
if (staticFlag) |
|
|
|
clazz.useType(); |
|
|
|
codeAnalyzer.useType(clazz); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -97,12 +95,6 @@ public final class InvokeOperator extends Operator |
|
|
|
+ methodType.getParameterTypes().length; |
|
|
|
+ methodType.getParameterTypes().length; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int getOperandPriority(int i) { |
|
|
|
|
|
|
|
if (!isStatic() && i == 0) |
|
|
|
|
|
|
|
return 950; |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Type getOperandType(int i) { |
|
|
|
public Type getOperandType(int i) { |
|
|
|
if (!isStatic()) { |
|
|
|
if (!isStatic()) { |
|
|
|
if (i == 0) |
|
|
|
if (i == 0) |
|
|
@ -144,32 +136,68 @@ public final class InvokeOperator extends Operator |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String toString(String[] operands) { |
|
|
|
public void dumpExpression(TabbedPrintWriter writer, |
|
|
|
String object = specialFlag |
|
|
|
Expression[] operands) |
|
|
|
? (operands[0].equals("this") |
|
|
|
throws java.io.IOException { |
|
|
|
? (/* XXX check if this is a private or final method. */ |
|
|
|
boolean opIsThis = |
|
|
|
isThis() ? "" : "super") |
|
|
|
(!staticFlag |
|
|
|
: (/* XXX check if this is a private or final method. */ |
|
|
|
&& operands[0] instanceof LocalLoadOperator |
|
|
|
isThis() ? operands[0] : "NON VIRTUAL " + operands[0])) |
|
|
|
&& (((LocalLoadOperator) operands[0]).getLocalInfo() |
|
|
|
: (isStatic() |
|
|
|
.equals(codeAnalyzer.getParamInfo(0))) |
|
|
|
? (isThis() ? "" : clazz.toString()) |
|
|
|
&& !codeAnalyzer.getMethod().isStatic()); |
|
|
|
: (operands[0].equals("this") ? "" |
|
|
|
int arg = 1; |
|
|
|
: operands[0].equals("null") |
|
|
|
|
|
|
|
? "((" + clazz.toString() + ") null)" |
|
|
|
if (specialFlag) { |
|
|
|
: operands[0])); |
|
|
|
if (opIsThis) { |
|
|
|
|
|
|
|
if (isThis()) { |
|
|
|
int arg = isStatic() ? 0 : 1; |
|
|
|
/* XXX check if this is a private or final method. */ |
|
|
|
String method = isConstructor() |
|
|
|
} else { |
|
|
|
? (object.length() == 0 ? "this" : object) |
|
|
|
/* XXX check that this is the first defined |
|
|
|
: (object.length() == 0 ? methodName : object + "." + methodName); |
|
|
|
* super method. */ |
|
|
|
|
|
|
|
writer.print("super"); |
|
|
|
StringBuffer params = new StringBuffer(); |
|
|
|
opIsThis = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
/* XXX check if this is a private or final method. */ |
|
|
|
|
|
|
|
if (!isThis()) { |
|
|
|
|
|
|
|
writer.print("(NON VIRTUAL "); |
|
|
|
|
|
|
|
writer.printType(clazz); |
|
|
|
|
|
|
|
writer.print(")"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
operands[0].dumpExpression(writer, 950); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (staticFlag) { |
|
|
|
|
|
|
|
arg = 0; |
|
|
|
|
|
|
|
if (!isThis()) |
|
|
|
|
|
|
|
writer.printType(clazz); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (!opIsThis) { |
|
|
|
|
|
|
|
int minPriority = 950; /* field access */ |
|
|
|
|
|
|
|
if (operands[0].getType() instanceof NullType) { |
|
|
|
|
|
|
|
writer.print("("); |
|
|
|
|
|
|
|
writer.printType(clazz); |
|
|
|
|
|
|
|
writer.print(") "); |
|
|
|
|
|
|
|
minPriority = 700; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
operands[0].dumpExpression(writer, minPriority); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isConstructor()) { |
|
|
|
|
|
|
|
if (opIsThis) |
|
|
|
|
|
|
|
writer.print("this"); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (!opIsThis) |
|
|
|
|
|
|
|
writer.print("."); |
|
|
|
|
|
|
|
writer.print(methodName); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
writer.print("("); |
|
|
|
for (int i=0; i < methodType.getParameterTypes().length; i++) { |
|
|
|
for (int i=0; i < methodType.getParameterTypes().length; i++) { |
|
|
|
if (i>0) |
|
|
|
if (i>0) |
|
|
|
params.append(", "); |
|
|
|
writer.print(", "); |
|
|
|
params.append(operands[arg++]); |
|
|
|
operands[arg++].dumpExpression(writer, 0); |
|
|
|
} |
|
|
|
} |
|
|
|
return method+"("+params+")"; |
|
|
|
writer.print(")"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|