use Reference

MethodType changed


git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@494 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 6cd193db25
commit a5db396a49
  1. 74
      jode/jode/expr/InvokeOperator.java

@ -1,18 +1,18 @@
/* /* InvokeOperator Copyright (C) 1998-1999 Jochen Hoenicke.
* InvokeOperator (c) 1998 Jochen Hoenicke
* *
* You may distribute under the terms of the GNU General Public License. * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
* *
* IN NO EVENT SHALL JOCHEN HOENICKE BE LIABLE TO ANY PARTY FOR DIRECT, * This program is distributed in the hope that it will be useful,
* INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF * but WITHOUT ANY WARRANTY; without even the implied warranty of
* THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF JOCHEN HOENICKE * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * GNU General Public License for more details.
* *
* JOCHEN HOENICKE SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT * You should have received a copy of the GNU General Public License
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A * along with this program; see the file COPYING. If not, write to
* PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
* BASIS, AND JOCHEN HOENICKE HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
* SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
* *
* $Id$ * $Id$
*/ */
@ -29,23 +29,25 @@ import jode.jvm.*;
public final class InvokeOperator extends Operator public final class InvokeOperator extends Operator
implements MatchableOperator { implements MatchableOperator {
CodeAnalyzer codeAnalyzer; CodeAnalyzer codeAnalyzer;
boolean staticFlag;
boolean specialFlag; boolean specialFlag;
MethodType methodType; MethodType methodType;
String methodName; String methodName;
Type classType; ClassInfo clazz;
public InvokeOperator(CodeAnalyzer codeAnalyzer, public InvokeOperator(CodeAnalyzer codeAnalyzer,
boolean specialFlag, Type classType, boolean staticFlag, boolean specialFlag,
MethodType methodType, String methodName) { Reference reference) {
super(Type.tUnknown, 0); super(Type.tUnknown, 0);
this.methodType = methodType; this.methodType = (MethodType) Type.tType(reference.getType());
this.methodName = methodName; this.methodName = reference.getName();
this.classType = classType; this.clazz = ClassInfo.forName(reference.getClazz());
this.type = methodType.getReturnType(); this.type = methodType.getReturnType();
this.codeAnalyzer = codeAnalyzer; this.codeAnalyzer = codeAnalyzer;
this.staticFlag = staticFlag;
this.specialFlag = specialFlag; this.specialFlag = specialFlag;
if (methodType.isStatic()) if (staticFlag)
classType.useType(); Type.tClass(clazz.getName()).useType();
} }
/** /**
@ -67,8 +69,8 @@ public final class InvokeOperator extends Operator
|| loadop instanceof GetFieldOperator); || loadop instanceof GetFieldOperator);
} }
public boolean isStatic() { public final boolean isStatic() {
return methodType.isStatic(); return staticFlag;
} }
public MethodType getMethodType() { public MethodType getMethodType() {
@ -80,7 +82,7 @@ public final class InvokeOperator extends Operator
} }
public Type getClassType() { public Type getClassType() {
return classType; return Type.tClass(clazz.getName());
} }
public int getPriority() { public int getPriority() {
@ -88,18 +90,18 @@ public final class InvokeOperator extends Operator
} }
public int getOperandCount() { public int getOperandCount() {
return (methodType.isStatic()?0:1) return (isStatic()?0:1)
+ methodType.getParameterTypes().length; + methodType.getParameterTypes().length;
} }
public int getOperandPriority(int i) { public int getOperandPriority(int i) {
if (!methodType.isStatic() && i == 0) if (!isStatic() && i == 0)
return 950; return 950;
return 0; return 0;
} }
public Type getOperandType(int i) { public Type getOperandType(int i) {
if (!methodType.isStatic()) { if (!isStatic()) {
if (i == 0) if (i == 0)
return getClassType(); return getClassType();
i--; i--;
@ -120,8 +122,7 @@ public final class InvokeOperator extends Operator
* allow super class * allow super class
*/ */
public boolean isThis() { public boolean isThis() {
return (classType.equals(Type.tClass(codeAnalyzer.getClazz(). return (clazz == codeAnalyzer.getClazz());
getName())));
} }
/** /**
@ -129,8 +130,7 @@ public final class InvokeOperator extends Operator
* @XXX check, if its the first super class that implements the method. * @XXX check, if its the first super class that implements the method.
*/ */
public boolean isSuperOrThis() { public boolean isSuperOrThis() {
return ((jode.ClassInterfacesType)classType).getClazz().superClassOf return clazz.superClassOf(codeAnalyzer.getClazz());
(codeAnalyzer.getClazz());
} }
public String toString(String[] operands) { public String toString(String[] operands) {
@ -140,13 +140,14 @@ public final class InvokeOperator extends Operator
isThis() ? "" : "super") isThis() ? "" : "super")
: (/* XXX check if this is a private or final method. */ : (/* XXX check if this is a private or final method. */
isThis() ? operands[0] : "NON VIRTUAL " + operands[0])) isThis() ? operands[0] : "NON VIRTUAL " + operands[0]))
: (methodType.isStatic() : (isStatic()
? (isThis() ? "" : classType.toString()) ? (isThis() ? "" : clazz.toString())
: (operands[0].equals("this") ? "" : (operands[0].equals("this") ? ""
: operands[0].equals("null") ? "((" + classType + ") null)" : operands[0].equals("null")
? "((" + clazz.getName() + ") null)"
: operands[0])); : operands[0]));
int arg = methodType.isStatic() ? 0 : 1; int arg = isStatic() ? 0 : 1;
String method = isConstructor() String method = isConstructor()
? (object.length() == 0 ? "this" : object) ? (object.length() == 0 ? "this" : object)
: (object.length() == 0 ? methodName : object + "." + methodName); : (object.length() == 0 ? methodName : object + "." + methodName);
@ -165,9 +166,8 @@ public final class InvokeOperator extends Operator
* @return true if this is the magic class$ method, false otherwise. * @return true if this is the magic class$ method, false otherwise.
*/ */
public boolean isGetClass() { public boolean isGetClass() {
if (!classType.equals(Type.tClass(codeAnalyzer.getClazz().getName()))) return isThis()
return false; && codeAnalyzer.getClassAnalyzer()
return codeAnalyzer.getClassAnalyzer()
.getMethod(methodName, methodType).isGetClass(); .getMethod(methodName, methodType).isGetClass();
} }

Loading…
Cancel
Save