KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jode > expr > ArrayLoadOperator


1 /* ArrayLoadOperator Copyright (C) 1998-2002 Jochen Hoenicke.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as published by
5  * the Free Software Foundation; either version 2, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * 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: ArrayLoadOperator.java,v 4.10.2.1 2002/05/28 17:34:05 hoenicke Exp $
18  */

19
20 package jode.expr;
21 import jode.type.Type;
22 import jode.type.ArrayType;
23 import jode.decompiler.TabbedPrintWriter;
24
25 public class ArrayLoadOperator extends Operator {
26
27     public ArrayLoadOperator(Type type) {
28         super(type, 0);
29     initOperands(2);
30     }
31
32     public int getPriority() {
33         return 950;
34     }
35
36     public void updateSubTypes() {
37     subExpressions[0].setType(Type.tSubType(Type.tArray(type)));
38     subExpressions[1].setType(Type.tSubType(Type.tInt));
39     }
40
41     public void updateType() {
42     Type subType = Type.tSuperType(subExpressions[0].getType())
43         .intersection(Type.tArray(type));
44     if (!(subType instanceof ArrayType))
45         updateParentType(Type.tError);
46     else
47         updateParentType(((ArrayType)subType).getElementType());
48     }
49
50     public void dumpExpression(TabbedPrintWriter writer)
51     throws java.io.IOException JavaDoc {
52     subExpressions[0].dumpExpression(writer, 950);
53     writer.breakOp();
54     writer.print("[");
55     subExpressions[1].dumpExpression(writer, 0);
56     writer.print("]");
57     }
58 }
59
Popular Tags