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 initializers 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 LoopInit extends JavaNonTerminalProgramElement implements
19: StatementContainer, ILoopInit {
20:
21: ArrayOfLoopInitializer inits;
22:
23: public LoopInit(ArrayOfLoopInitializer exprarr) {
24: inits = exprarr;
25: }
26:
27: public LoopInit(LoopInitializer[] exprarr) {
28: inits = new ArrayOfLoopInitializer(exprarr);
29: }
30:
31: public LoopInit(ExtList ups, PositionInfo pos) {
32: super (pos);
33: final LoopInitializer[] exps = new LoopInitializer[ups.size()];
34: for (int i = 0; i < exps.length; i++) {
35: exps[i] = (LoopInitializer) ups.get(i);
36: }
37: inits = new ArrayOfLoopInitializer(exps);
38: }
39:
40: /**
41: * Get the number of statements in this container.
42: * @return the number of statements.
43: */
44: public int getStatementCount() {
45: return inits.size();
46: }
47:
48: /*
49: Return the statement at the specified index in this node's
50: "virtual" statement array.
51: @param index an index for an statement.
52: @return the statement with the given index.
53: @exception ArrayIndexOutOfBoundsException if <tt>index</tt> is out
54: of bounds.
55: */
56: public Statement getStatementAt(int index) {
57: return inits.getLoopInitializer(index);
58: }
59:
60: public int size() {
61: return getStatementCount();
62: }
63:
64: public ArrayOfLoopInitializer getInits() {
65: return inits;
66: }
67:
68: public void visit(Visitor v) {
69: v.performActionOnLoopInit(this );
70: }
71:
72: public int getChildCount() {
73: return getStatementCount();
74: }
75:
76: public ProgramElement getChildAt(int index) {
77: return getStatementAt(index);
78: }
79:
80: }
|