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: import EDU.purdue.cs.bloat.cfg.*;
24:
25: /**
26: * IfCmpStmt consists of a comparison expression (a left-hand expression, a
27: * comparison operator, and a right-hand expression) that is to be evaluated.
28: */
29: public class IfCmpStmt extends IfStmt {
30: Expr left;
31:
32: Expr right;
33:
34: /**
35: * Constructor.
36: *
37: * @param comparison
38: * Comparison operator for this if statement.
39: * @param left
40: * Expression on the left side of the comparison.
41: * @param right
42: * Expression on the right side of the comparison.
43: * @param trueTarget
44: * Block executed if comparison evaluates to true.
45: * @param falseTarget
46: * Block executed if comparison evaluates to false.
47: */
48: public IfCmpStmt(final int comparison, final Expr left,
49: final Expr right, final Block trueTarget,
50: final Block falseTarget) {
51: super (comparison, trueTarget, falseTarget);
52: this .left = left;
53: this .right = right;
54: left.setParent(this );
55: right.setParent(this );
56: }
57:
58: public Expr left() {
59: return left;
60: }
61:
62: public Expr right() {
63: return right;
64: }
65:
66: public void visitForceChildren(final TreeVisitor visitor) {
67: if (visitor.reverse()) {
68: right.visit(visitor);
69: left.visit(visitor);
70: } else {
71: left.visit(visitor);
72: right.visit(visitor);
73: }
74: }
75:
76: public void visit(final TreeVisitor visitor) {
77: visitor.visitIfCmpStmt(this );
78: }
79:
80: public Object clone() {
81: return copyInto(new IfCmpStmt(comparison, (Expr) left.clone(),
82: (Expr) right.clone(), trueTarget, falseTarget));
83: }
84: }
|