use reference

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@495 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent a5db396a49
commit 7cbfee8e50
  1. 50
      jode/jode/expr/PutFieldOperator.java

@ -1,42 +1,41 @@
/* /* PutFieldOperator Copyright (C) 1998-1999 Jochen Hoenicke.
* PutFieldOperator (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$
*/ */
package jode.expr; package jode.expr;
import jode.Type; import jode.Type;
import jode.bytecode.Reference;
import jode.decompiler.CodeAnalyzer; import jode.decompiler.CodeAnalyzer;
import jode.decompiler.FieldAnalyzer; import jode.decompiler.FieldAnalyzer;
public class PutFieldOperator extends StoreInstruction { public class PutFieldOperator extends StoreInstruction {
CodeAnalyzer codeAnalyzer; CodeAnalyzer codeAnalyzer;
boolean staticFlag; boolean staticFlag;
String fieldName; Reference ref;
Type fieldType;
Type classType; Type classType;
public PutFieldOperator(CodeAnalyzer codeAnalyzer, boolean staticFlag, public PutFieldOperator(CodeAnalyzer codeAnalyzer, boolean staticFlag,
Type classType, Type type, String fieldName) { Reference ref) {
super(type, ASSIGN_OP); super(Type.tType(ref.getType()), ASSIGN_OP);
this.codeAnalyzer = codeAnalyzer; this.codeAnalyzer = codeAnalyzer;
this.staticFlag = staticFlag; this.staticFlag = staticFlag;
this.fieldName = fieldName; this.ref = ref;
this.fieldType = type; this.classType = Type.tClass(ref.getClazz());
this.classType = classType;
if (staticFlag) if (staticFlag)
classType.useType(); classType.useType();
} }
@ -59,21 +58,20 @@ public class PutFieldOperator extends StoreInstruction {
if (!isThis()) if (!isThis())
return null; return null;
return codeAnalyzer.getClassAnalyzer() return codeAnalyzer.getClassAnalyzer()
.getField(fieldName, fieldType); .getField(ref.getName(), Type.tType(ref.getType()));
} }
public String getFieldName() { public String getFieldName() {
return fieldName; return ref.getName();
} }
public Type getFieldType() { public Type getFieldType() {
return fieldType; return Type.tType(ref.getType());
} }
public boolean matches(Operator loadop) { public boolean matches(Operator loadop) {
return loadop instanceof GetFieldOperator return loadop instanceof GetFieldOperator
&& ((GetFieldOperator)loadop).classType.equals(classType) && ((GetFieldOperator)loadop).ref.equals(ref);
&& ((GetFieldOperator)loadop).fieldName.equals(fieldName);
} }
public int getLValueOperandCount() { public int getLValueOperandCount() {
@ -92,6 +90,7 @@ public class PutFieldOperator extends StoreInstruction {
} }
public String getLValueString(String[] operands) { public String getLValueString(String[] operands) {
String fieldName = getFieldName();
return staticFlag return staticFlag
? (classType.equals(Type.tClass(codeAnalyzer.getClazz().getName())) ? (classType.equals(Type.tClass(codeAnalyzer.getClazz().getName()))
&& codeAnalyzer.findLocal(fieldName) == null && codeAnalyzer.findLocal(fieldName) == null
@ -107,7 +106,6 @@ public class PutFieldOperator extends StoreInstruction {
public boolean equals(Object o) { public boolean equals(Object o) {
return o instanceof PutFieldOperator return o instanceof PutFieldOperator
&& ((PutFieldOperator)o).classType.equals(classType) && ((PutFieldOperator)o).ref.equals(ref);
&& ((PutFieldOperator)o).fieldName.equals(fieldName);
} }
} }

Loading…
Cancel
Save