01: /* NewArrayOperator 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: NewArrayOperator.java,v 4.10.2.2 2002/05/28 17:34:06 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 NewArrayOperator extends Operator {
27: String baseTypeString;
28:
29: public NewArrayOperator(Type arrayType, int dimensions) {
30: super (arrayType, 0);
31: initOperands(dimensions);
32: }
33:
34: public int getDimensions() {
35: return subExpressions.length;
36: }
37:
38: public int getPriority() {
39: return 900;
40: }
41:
42: public void updateSubTypes() {
43: for (int i = 0; i < subExpressions.length; i++)
44: subExpressions[i].setType(Type.tUInt);
45: }
46:
47: public void updateType() {
48: }
49:
50: public void dumpExpression(TabbedPrintWriter writer)
51: throws java.io.IOException {
52: Type flat = type.getCanonic();
53: int depth = 0;
54: while (flat instanceof ArrayType) {
55: flat = ((ArrayType) flat).getElementType();
56: depth++;
57: }
58: writer.print("new ");
59: writer.printType(flat.getHint());
60: for (int i = 0; i < depth; i++) {
61: writer.breakOp();
62: writer.print("[");
63: if (i < subExpressions.length)
64: subExpressions[i].dumpExpression(writer, 0);
65: writer.print("]");
66: }
67: }
68: }
|