01: /* ArrayStoreOperator 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: ArrayStoreOperator.java,v 4.10.2.2 2002/05/28 17:34:05 hoenicke Exp $
18: */
19:
20: package jode.expr;
21:
22: import jode.type.Type;
23: import jode.type.ArrayType;
24: import jode.decompiler.TabbedPrintWriter;
25:
26: public class ArrayStoreOperator extends ArrayLoadOperator implements
27: LValueExpression {
28:
29: public ArrayStoreOperator(Type type) {
30: super (type);
31: }
32:
33: public boolean matches(Operator loadop) {
34: return loadop instanceof ArrayLoadOperator;
35: }
36:
37: public void dumpExpression(TabbedPrintWriter writer)
38: throws java.io.IOException {
39: Type arrType = subExpressions[0].getType().getHint();
40: if (arrType instanceof ArrayType) {
41: Type elemType = ((ArrayType) arrType).getElementType();
42: if (!elemType.isOfType(getType())) {
43: /* We need an explicit widening cast */
44: writer.print("(");
45: writer.startOp(writer.EXPL_PAREN, 1);
46: writer.print("(");
47: writer.printType(Type.tArray(getType().getHint()));
48: writer.print(") ");
49: writer.breakOp();
50: subExpressions[0].dumpExpression(writer, 700);
51: writer.print(")");
52: writer.breakOp();
53: writer.print("[");
54: subExpressions[1].dumpExpression(writer, 0);
55: writer.print("]");
56: return;
57: }
58: }
59: super.dumpExpression(writer);
60: }
61: }
|