01: /* Copyright (C) 2004 - 2007 db4objects Inc. http://www.db4o.com
02:
03: This file is part of the db4o open source object database.
04:
05: db4o is free software; you can redistribute it and/or modify it under
06: the terms of version 2 of the GNU General Public License as published
07: by the Free Software Foundation and as clarified by db4objects' GPL
08: interpretation policy, available at
09: http://www.db4o.com/about/company/legalpolicies/gplinterpretation/
10: Alternatively you can write to db4objects, Inc., 1900 S Norfolk Street,
11: Suite 350, San Mateo, CA 94403, USA.
12:
13: db4o is distributed in the hope that it will be useful, but WITHOUT ANY
14: WARRANTY; without even the implied warranty of MERCHANTABILITY or
15: FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16: for more details.
17:
18: You should have received a copy of the GNU General Public License along
19: with this program; if not, write to the Free Software Foundation, Inc.,
20: 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21: package EDU.purdue.cs.bloat.tree;
22:
23: /**
24: * <tt>InitStmt</tt> groups together the initialization of local variables (<tt>LocalExpr</tt>).
25: *
26: * @see LocalExpr
27: * @see Tree#initLocals
28: */
29: public class InitStmt extends Stmt implements Assign {
30: LocalExpr[] targets;
31:
32: /**
33: * Constructor.
34: *
35: * @param targets
36: * The instances of LocalExpr that are to be initialized.
37: */
38: public InitStmt(final LocalExpr[] targets) {
39: this .targets = new LocalExpr[targets.length];
40:
41: for (int i = 0; i < targets.length; i++) {
42: this .targets[i] = targets[i];
43: this .targets[i].setParent(this );
44: }
45: }
46:
47: /**
48: * Returns the local variables (<tt>LocalExpr</tt>s) initialized by this
49: * <tt>InitStmt</tt>.
50: */
51: public LocalExpr[] targets() {
52: return targets;
53: }
54:
55: /**
56: * Returns the local variables (<tt>LocalExpr</tt>s) defined by this
57: * <tt>InitStmt</tt>. These are the same local variables that are the
58: * targets of the <tt>InitStmt</tt>.
59: */
60: public DefExpr[] defs() {
61: return targets;
62: }
63:
64: public void visitForceChildren(final TreeVisitor visitor) {
65: for (int i = 0; i < targets.length; i++) {
66: targets[i].visit(visitor);
67: }
68: }
69:
70: public void visit(final TreeVisitor visitor) {
71: visitor.visitInitStmt(this );
72: }
73:
74: public Object clone() {
75: final LocalExpr[] t = new LocalExpr[targets.length];
76:
77: for (int i = 0; i < targets.length; i++) {
78: t[i] = (LocalExpr) targets[i].clone();
79: }
80:
81: return copyInto(new InitStmt(t));
82: }
83: }
|