01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.dev.js.ast;
17:
18: /**
19: * Represents a JavaScript conditional expression.
20: */
21: public final class JsConditional extends JsExpression {
22:
23: private JsExpression testExpr;
24:
25: private JsExpression thenExpr;
26:
27: private JsExpression elseExpr;
28:
29: public JsConditional() {
30: }
31:
32: public JsConditional(JsExpression testExpr, JsExpression thenExpr,
33: JsExpression elseExpr) {
34: this .testExpr = testExpr;
35: this .thenExpr = thenExpr;
36: this .elseExpr = elseExpr;
37: }
38:
39: public JsExpression getElseExpression() {
40: return elseExpr;
41: }
42:
43: public JsExpression getTestExpression() {
44: return testExpr;
45: }
46:
47: public JsExpression getThenExpression() {
48: return thenExpr;
49: }
50:
51: public void setElseExpression(JsExpression elseExpr) {
52: this .elseExpr = elseExpr;
53: }
54:
55: public void setTestExpression(JsExpression testExpr) {
56: this .testExpr = testExpr;
57: }
58:
59: public void setThenExpression(JsExpression thenExpr) {
60: this .thenExpr = thenExpr;
61: }
62:
63: public void traverse(JsVisitor v, JsContext<JsExpression> ctx) {
64: if (v.visit(this, ctx)) {
65: testExpr = v.accept(testExpr);
66: thenExpr = v.accept(thenExpr);
67: elseExpr = v.accept(elseExpr);
68: }
69: v.endVisit(this, ctx);
70: }
71: }
|