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 org.jetbrains.kotlin.js.backend.ast;
006    
007    import org.jetbrains.annotations.NotNull;
008    
009    import java.util.List;
010    
011    public abstract class JsExpression extends SourceInfoAwareJsNode {
012        /**
013         * Determines whether or not this expression is a leaf, such as a
014         * {@link JsNameRef}, {@link JsLiteral.JsBooleanLiteral}, and so on. Leaf expressions
015         * never need to be parenthesized.
016         */
017        public boolean isLeaf() {
018            // Conservatively say that it isn't a leaf.
019            // Individual subclasses can speak for themselves if they are a leaf.
020            return false;
021        }
022    
023        @NotNull
024        public JsStatement makeStmt() {
025            return new JsExpressionStatement(this);
026        }
027    
028        public abstract static class JsExpressionHasArguments extends JsExpression implements HasArguments {
029            protected final List<JsExpression> arguments;
030    
031            protected JsExpressionHasArguments(List<JsExpression> arguments) {
032                this.arguments = arguments;
033            }
034    
035            @Override
036            public List<JsExpression> getArguments() {
037                return arguments;
038            }
039        }
040    
041        @Override
042        public JsExpression source(Object info) {
043            setSource(info);
044            return this;
045        }
046    
047        @NotNull
048        @Override
049        public abstract JsExpression deepCopy();
050    }