01: /* GetFieldOperator Copyright (C) 1998-2002 Jochen Hoenicke.
02: *
03: * This program is free software; you can redistribute it and/or modify
04: * it under the terms of the GNU Lesser General Public License as published by
05: * the Free Software Foundation; either version 2, or (at your option)
06: * any later version.
07: *
08: * This program is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11: * GNU General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public License
14: * along with this program; see the file COPYING.LESSER. If not, write to
15: * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
16: *
17: * $Id: GetFieldOperator.java,v 4.23.2.1 2002/05/28 17:34:06 hoenicke Exp $
18: */
19:
20: package jode.expr;
21:
22: import jode.type.Type;
23: import jode.type.NullType;
24: import jode.type.ClassInterfacesType;
25: import jode.bytecode.FieldInfo;
26: import jode.bytecode.ClassInfo;
27: import jode.bytecode.Reference;
28: import jode.decompiler.MethodAnalyzer;
29: import jode.decompiler.ClassAnalyzer;
30: import jode.decompiler.MethodAnalyzer;
31: import jode.decompiler.FieldAnalyzer;
32: import jode.decompiler.TabbedPrintWriter;
33: import jode.decompiler.Scope;
34:
35: public class GetFieldOperator extends FieldOperator {
36: public GetFieldOperator(MethodAnalyzer methodAnalyzer,
37: boolean staticFlag, Reference ref) {
38: super (methodAnalyzer, staticFlag, ref);
39: }
40:
41: public Expression simplify() {
42: if (!staticFlag) {
43: subExpressions[0] = subExpressions[0].simplify();
44: subExpressions[0].parent = this ;
45: if (subExpressions[0] instanceof ThisOperator) {
46: FieldAnalyzer field = getField();
47: /* This should check for isFinal(), but sadly,
48: * sometimes jikes doesn't make a val$ field final. I
49: * don't know when, or why, so I currently ignore
50: * isFinal.
51: */
52: if (field != null && field.isSynthetic()) {
53: Expression constant = field.getConstant();
54: if (constant instanceof ThisOperator
55: || constant instanceof OuterLocalOperator)
56: return constant;
57: }
58: }
59: }
60: return this ;
61: }
62:
63: public boolean opEquals(Operator o) {
64: return o instanceof GetFieldOperator
65: && ((GetFieldOperator) o).ref.equals(ref);
66: }
67: }
|