git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@91 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent a6081f9aa6
commit 58142d1683
  1. 21
      jode/jode/expr/ConstructorOperator.java
  2. 15
      jode/jode/expr/InvokeOperator.java

@ -21,15 +21,13 @@ package jode;
import gnu.bytecode.CpoolRef; import gnu.bytecode.CpoolRef;
public class ConstructorOperator extends Operator { public class ConstructorOperator extends Operator {
CpoolRef field;
MethodType methodType; MethodType methodType;
Type classType; Type classType;
public ConstructorOperator(Type type, CpoolRef field) { public ConstructorOperator(Type type, MethodType methodType) {
super(type, 0); super(type, 0);
methodType = new MethodType(field.getNameAndType(). this.classType = type;
getType().getString()); this.methodType = methodType;
this.field = field;
} }
public int getPriority() { public int getPriority() {
@ -37,30 +35,27 @@ public class ConstructorOperator extends Operator {
} }
public int getOperandCount() { public int getOperandCount() {
return 1 + methodType.getArgumentTypes().length; return methodType.getArgumentTypes().length;
} }
public int getOperandPriority(int i) { public int getOperandPriority(int i) {
if (i == 0)
return 950;
return 0; return 0;
} }
public Type getOperandType(int i) { public Type getOperandType(int i) {
if (i == 0) return methodType.getArgumentTypes()[i];
return type;
return methodType.getArgumentTypes()[i-1];
} }
public void setOperandType(Type types[]) { public void setOperandType(Type types[]) {
} }
public String toString(String[] operands) { public String toString(String[] operands) {
StringBuffer result = new StringBuffer(operands[0]).append("("); StringBuffer result =
new StringBuffer("new ").append(classType.toString()).append("(");
for (int i=0; i < methodType.getArgumentTypes().length; i++) { for (int i=0; i < methodType.getArgumentTypes().length; i++) {
if (i>0) if (i>0)
result.append(", "); result.append(", ");
result.append(operands[i+1]); result.append(operands[i]);
} }
return result.append(")").toString(); return result.append(")").toString();
} }

@ -25,17 +25,19 @@ public final class InvokeOperator extends Operator {
boolean staticFlag; boolean staticFlag;
boolean specialFlag; boolean specialFlag;
MethodType methodType; MethodType methodType;
String methodName;
Type classType; Type classType;
CpoolRef field; CpoolRef field;
public InvokeOperator(CodeAnalyzer codeAnalyzer, public InvokeOperator(CodeAnalyzer codeAnalyzer,
boolean staticFlag, boolean specialFlag, boolean staticFlag, boolean specialFlag,
CpoolRef field) { CpoolRef field) {
super(Type.tError, 0); super(Type.tUnknown, 0);
methodType = new MethodType(field.getNameAndType(). methodType = new MethodType(field.getNameAndType().
getType().getString()); getType().getString());
methodName = field.getNameAndType().getName().getString();
classType = Type.tClass(field.getCpoolClass().getName().getString()); classType = Type.tClass(field.getCpoolClass().getName().getString());
setType(methodType.getReturnType()); this.type = methodType.getReturnType();
this.codeAnalyzer = codeAnalyzer; this.codeAnalyzer = codeAnalyzer;
this.staticFlag = staticFlag; this.staticFlag = staticFlag;
this.specialFlag = specialFlag; this.specialFlag = specialFlag;
@ -56,6 +58,10 @@ public final class InvokeOperator extends Operator {
return methodType; return methodType;
} }
public String getMethodName() {
return methodName;
}
public Type getClassType() { public Type getClassType() {
return classType; return classType;
} }
@ -87,7 +93,7 @@ public final class InvokeOperator extends Operator {
} }
public boolean isConstructor() { public boolean isConstructor() {
return field.getNameAndType().getName().getString().equals("<init>"); return methodName.equals("<init>");
} }
public String toString(String[] operands) { public String toString(String[] operands) {
@ -109,8 +115,7 @@ public final class InvokeOperator extends Operator {
if (isConstructor()) if (isConstructor())
method = (object.length() == 0 ? "this" : object); method = (object.length() == 0 ? "this" : object);
else else
method = (object.length() == 0 ? "" : object + ".") method = (object.length() == 0 ? "" : object + ".") + methodName;
+ field.getNameAndType().getName().getString();
StringBuffer params = new StringBuffer(); StringBuffer params = new StringBuffer();
for (int i=0; i < methodType.getArgumentTypes().length; i++) { for (int i=0; i < methodType.getArgumentTypes().length; i++) {

Loading…
Cancel
Save