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 the JavaScript case statement. 012 */ 013 public final class JsCase extends JsSwitchMember { 014 private JsExpression caseExpression; 015 016 public JsCase() { 017 super(); 018 } 019 020 public JsExpression getCaseExpression() { 021 return caseExpression; 022 } 023 024 public void setCaseExpression(JsExpression caseExpression) { 025 this.caseExpression = caseExpression; 026 } 027 028 @Override 029 public void accept(JsVisitor v) { 030 v.visitCase(this); 031 } 032 033 @Override 034 public void acceptChildren(JsVisitor visitor) { 035 visitor.accept(caseExpression); 036 super.acceptChildren(visitor); 037 } 038 039 @Override 040 public void traverse(JsVisitorWithContext v, JsContext ctx) { 041 if (v.visit(this, ctx)) { 042 caseExpression = v.accept(caseExpression); 043 v.acceptStatementList(statements); 044 } 045 v.endVisit(this, ctx); 046 } 047 048 @NotNull 049 @Override 050 public JsCase deepCopy() { 051 JsCase caseCopy = new JsCase(); 052 caseCopy.caseExpression = AstUtil.deepCopy(caseExpression); 053 caseCopy.statements.addAll(AstUtil.deepCopy(statements)); 054 055 return caseCopy.withMetadataFrom(this); 056 } 057 }