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 org.jetbrains.annotations.NotNull;
008    
009    public final class JsExpressionStatement extends AbstractNode implements JsStatement {
010        @NotNull
011        private JsExpression expression;
012    
013        public JsExpressionStatement(@NotNull JsExpression expression) {
014            this.expression = expression;
015        }
016    
017        @NotNull
018        public JsExpression getExpression() {
019            return expression;
020        }
021    
022        @Override
023        public void accept(JsVisitor v) {
024            v.visitExpressionStatement(this);
025        }
026    
027        @Override
028        public void acceptChildren(JsVisitor visitor) {
029            visitor.accept(expression);
030        }
031    
032        @Override
033        public Object getSource() {
034            return null;
035        }
036    
037        @Override
038        public void setSource(Object info) {
039            throw new IllegalStateException("You must not set source info for JsExpressionStatement, set for expression");
040        }
041    
042        @Override
043        public JsNode source(Object info) {
044            throw new IllegalStateException("You must not set source info for JsExpressionStatement, set for expression");
045        }
046    
047        @Override
048        public void traverse(JsVisitorWithContext v, JsContext ctx) {
049            if (v.visit(this, ctx)) {
050                expression = v.accept(expression);
051            }
052            v.endVisit(this, ctx);
053        }
054    
055        @NotNull
056        @Override
057        public JsExpressionStatement deepCopy() {
058            return new JsExpressionStatement(expression.deepCopy()).withMetadataFrom(this);
059        }
060    }