From 58142d16838c9c55c82c36c8e105ac04e832836e Mon Sep 17 00:00:00 2001 From: jochen Date: Wed, 28 Oct 1998 18:24:52 +0000 Subject: [PATCH] Simplified git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@91 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/expr/ConstructorOperator.java | 21 ++++++++------------- jode/jode/expr/InvokeOperator.java | 15 ++++++++++----- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/jode/jode/expr/ConstructorOperator.java b/jode/jode/expr/ConstructorOperator.java index 5bea45e..0195ed9 100644 --- a/jode/jode/expr/ConstructorOperator.java +++ b/jode/jode/expr/ConstructorOperator.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(); } diff --git a/jode/jode/expr/InvokeOperator.java b/jode/jode/expr/InvokeOperator.java index a8fe352..8de1101 100644 --- a/jode/jode/expr/InvokeOperator.java +++ b/jode/jode/expr/InvokeOperator.java @@ -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(""); + return methodName.equals(""); } 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++) {