01: // This file is part of KeY - Integrated Deductive Software Design
02: // Copyright (C) 2001-2007 Universitaet Karlsruhe, Germany
03: // Universitaet Koblenz-Landau, Germany
04: // Chalmers University of Technology, Sweden
05: //
06: // The KeY system is protected by the GNU General Public License.
07: // See LICENSE.TXT for details.
08: //
09: //
10: /**
11: * This class encapsulates updates of a for loop
12: */package de.uka.ilkd.key.java.statement;
13:
14: import de.uka.ilkd.key.java.*;
15: import de.uka.ilkd.key.java.visitor.Visitor;
16: import de.uka.ilkd.key.util.ExtList;
17:
18: public class ForUpdates extends JavaNonTerminalProgramElement implements
19: ExpressionContainer, IForUpdates {
20:
21: ArrayOfExpression updates;
22:
23: public ForUpdates(ArrayOfExpression exprarr) {
24: updates = exprarr;
25: }
26:
27: public ForUpdates(ExtList ups, PositionInfo pos) {
28: super (pos);
29: Expression[] exps = new Expression[ups.size()];
30: for (int i = 0; i < exps.length; i++) {
31: exps[i] = (Expression) ups.get(i);
32: }
33: updates = new ArrayOfExpression(exps);
34: }
35:
36: /**
37: * Get the number of expressions in this container.
38: * @return the number of expressions.
39: */
40: public int getExpressionCount() {
41: return updates.size();
42: }
43:
44: /*
45: Return the expression at the specified index in this node's
46: "virtual" expression array.
47: @param index an index for an expression.
48: @return the expression with the given index.
49: @exception ArrayIndexOutOfBoundsException if <tt>index</tt> is out
50: of bounds.
51: */
52: public Expression getExpressionAt(int index) {
53: return updates.getExpression(index);
54: }
55:
56: public int size() {
57: return getExpressionCount();
58: }
59:
60: public ArrayOfExpression getUpdates() {
61: return updates;
62: }
63:
64: public void visit(Visitor v) {
65: v.performActionOnForUpdates(this );
66: }
67:
68: public int getChildCount() {
69: return getExpressionCount();
70: }
71:
72: public ProgramElement getChildAt(int index) {
73: return getExpressionAt(index);
74: }
75:
76: }
|