01: /* ThisOperator 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: ThisOperator.java,v 1.2.4.1 2002/05/28 17:34:06 hoenicke Exp $
18: */
19:
20: package jode.expr;
21:
22: import jode.type.Type;
23: import jode.bytecode.ClassInfo;
24: import jode.decompiler.Scope;
25: import jode.decompiler.TabbedPrintWriter;
26:
27: public class ThisOperator extends NoArgOperator {
28: boolean isInnerMost;
29: ClassInfo classInfo;
30:
31: public ThisOperator(ClassInfo classInfo, boolean isInnerMost) {
32: super (Type.tClass(classInfo));
33: this .classInfo = classInfo;
34: this .isInnerMost = isInnerMost;
35: }
36:
37: public ThisOperator(ClassInfo classInfo) {
38: this (classInfo, false);
39: }
40:
41: public ClassInfo getClassInfo() {
42: return classInfo;
43: }
44:
45: public int getPriority() {
46: return 1000;
47: }
48:
49: public String toString() {
50: return classInfo + ".this";
51: }
52:
53: public boolean opEquals(Operator o) {
54: return (o instanceof ThisOperator && ((ThisOperator) o).classInfo
55: .equals(classInfo));
56: }
57:
58: public void dumpExpression(TabbedPrintWriter writer)
59: throws java.io.IOException {
60: if (!isInnerMost) {
61: writer.print(writer.getClassString(classInfo,
62: Scope.AMBIGUOUSNAME));
63: writer.print(".");
64: }
65: writer.print("this");
66: }
67: }
|