001 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
002 // for details. All rights reserved. Use of this source code is governed by a
003 // BSD-style license that can be found in the LICENSE file.
004
005 package com.google.dart.compiler.backend.js.ast;
006
007 import com.google.dart.compiler.util.AstUtil;
008 import org.jetbrains.annotations.NotNull;
009
010 /**
011 * Represents a JavaScript do..while statement.
012 */
013 public class JsDoWhile extends JsWhile {
014 public JsDoWhile() {
015 }
016
017 public JsDoWhile(JsExpression condition, JsStatement body) {
018 super(condition, body);
019 }
020
021 @Override
022 public void accept(JsVisitor v) {
023 v.visitDoWhile(this);
024 }
025
026 @Override
027 public void traverse(JsVisitorWithContext v, JsContext ctx) {
028 if (v.visit(this, ctx)) {
029 body = v.acceptStatement(body);
030 condition = v.accept(condition);
031 }
032 v.endVisit(this, ctx);
033 }
034
035 @NotNull
036 @Override
037 public JsDoWhile deepCopy() {
038 JsExpression conditionCopy = AstUtil.deepCopy(condition);
039 JsStatement bodyCopy = AstUtil.deepCopy(body);
040
041 return new JsDoWhile(conditionCopy, bodyCopy).withMetadataFrom(this);
042 }
043 }