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.editor.*;
24:
25: /**
26: * NegExpr represents the arithmetic negation of an expression.
27: */
28: public class NegExpr extends Expr {
29: Expr expr;
30:
31: /**
32: * Constructor.
33: *
34: * @param expr
35: * The expression to be negated.
36: * @param type
37: * The type of this expression.
38: */
39: public NegExpr(final Expr expr, final Type type) {
40: super (type);
41: this .expr = expr;
42: expr.setParent(this );
43: }
44:
45: public Expr expr() {
46: return expr;
47: }
48:
49: public void visitForceChildren(final TreeVisitor visitor) {
50: if (visitor.reverse()) {
51: expr.visit(visitor);
52: } else {
53: expr.visit(visitor);
54: }
55: }
56:
57: public void visit(final TreeVisitor visitor) {
58: visitor.visitNegExpr(this );
59: }
60:
61: public int exprHashCode() {
62: return 14 + expr.exprHashCode();
63: }
64:
65: public boolean equalsExpr(final Expr other) {
66: return (other != null) && (other instanceof NegExpr)
67: && ((NegExpr) other).expr.equalsExpr(expr);
68: }
69:
70: public Object clone() {
71: return copyInto(new NegExpr((Expr) expr.clone(), type));
72: }
73: }
|