01: /* StringAddOperator 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: StringAddOperator.java,v 2.14.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.decompiler.TabbedPrintWriter;
24:
25: public class StringAddOperator extends Operator {
26: protected Type operandType;
27:
28: public StringAddOperator() {
29: super (Type.tString, ADD_OP);
30: initOperands(2);
31: }
32:
33: public int getPriority() {
34: return 610;
35: }
36:
37: public boolean opEquals(Operator o) {
38: return (o instanceof StringAddOperator);
39: }
40:
41: public void updateSubTypes() {
42: /* A string add allows everything */
43: }
44:
45: public void updateType() {
46: }
47:
48: public void dumpExpression(TabbedPrintWriter writer)
49: throws java.io.IOException {
50:
51: if (!subExpressions[0].getType().isOfType(Type.tString)
52: && !subExpressions[1].getType().isOfType(Type.tString)) {
53: writer.print("\"\"");
54: writer.breakOp();
55: writer.print(getOperatorString());
56: }
57:
58: subExpressions[0].dumpExpression(writer, 610);
59: writer.breakOp();
60: writer.print(getOperatorString());
61: subExpressions[1].dumpExpression(writer, 611);
62: }
63: }
|