git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@91 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 27 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;
public class ConstructorOperator extends Operator {
CpoolRef field;
MethodType methodType;
Type classType;
public ConstructorOperator(Type type, CpoolRef field) {
public ConstructorOperator(Type type, MethodType methodType) {
super(type, 0);
methodType = new MethodType(field.getNameAndType().
getType().getString());
this.field = field;
this.classType = type;
this.methodType = methodType;
}
public int getPriority() {
@ -37,30 +35,27 @@ public class ConstructorOperator extends Operator {
}
public int getOperandCount() {
return 1 + methodType.getArgumentTypes().length;
return methodType.getArgumentTypes().length;
}
public int getOperandPriority(int i) {
if (i == 0)
return 950;
return 0;
}
public Type getOperandType(int i) {
if (i == 0)
return type;
return methodType.getArgumentTypes()[i-1];
return methodType.getArgumentTypes()[i];
}
public void setOperandType(Type types[]) {
}
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++) {
if (i>0)
result.append(", ");
result.append(operands[i+1]);
result.append(operands[i]);
}
return result.append(")").toString();
}

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

Loading…
Cancel
Save