nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/tree/SimpleTreeVisitorES6.java
author sundar
Tue, 12 Jul 2016 21:18:13 +0530
changeset 39662 e2b36a3779b9
child 41422 97eda72f53b6
permissions -rw-r--r--
8149929: Nashorn Parser API needs to be updated for ES6 Reviewed-by: mhaupt, hannesw
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39662
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
     1
/*
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
     4
 *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    10
 *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    15
 * accompanied this code).
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    16
 *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    20
 *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    23
 * questions.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    24
 */
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    25
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    26
package jdk.nashorn.api.tree;
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    27
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    28
import java.util.List;
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    29
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    30
/**
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    31
 * A simple implementation of the TreeVisitor for ECMAScript edition 6.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    32
 *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    33
 * <p>The visit methods corresponding to ES 6 language constructs walk the
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    34
 * "components" of the given tree by calling accept method passing the
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    35
 * current visitor and the additional parameter.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    36
 *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    37
 * <p>For constructs introduced in later versions, {@code visitUnknown}
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    38
 * is called instead which throws {@link UnknownTreeException}.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    39
 *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    40
 * <p> Methods in this class may be overridden subject to their
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    41
 * general contract.  Note that annotating methods in concrete
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    42
 * subclasses with {@link java.lang.Override @Override} will help
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    43
 * ensure that methods are overridden as intended.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    44
 *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    45
 * @param <R> the return type of this visitor's methods.  Use {@link
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    46
 *            Void} for visitors that do not need to return results.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    47
 * @param <P> the type of the additional parameter to this visitor's
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    48
 *            methods.  Use {@code Void} for visitors that do not need an
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    49
 *            additional parameter.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    50
 */
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    51
public class SimpleTreeVisitorES6<R, P> extends SimpleTreeVisitorES5_1<R, P> {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    52
    @Override
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    53
    public R visitCompilationUnit(final CompilationUnitTree node, final P r) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    54
        final ModuleTree mod = node.getModule();
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    55
        if (mod != null) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    56
            mod.accept(this, r);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    57
        }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    58
        return super.visitCompilationUnit(node, r);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    59
    }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    60
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    61
    /**
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    62
     * Visit Module tree.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    63
     *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    64
     * @param node node being visited
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    65
     * @param p extra parameter passed to the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    66
     * @return value from the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    67
     */
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    68
    @Override
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    69
    public R visitModule(ModuleTree node, P p) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    70
        node.getImportEntries().forEach(e -> visitImportEntry(e, p));
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    71
        node.getLocalExportEntries().forEach(e -> visitExportEntry(e, p));
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    72
        node.getIndirectExportEntries().forEach(e -> visitExportEntry(e, p));
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    73
        node.getStarExportEntries().forEach(e -> visitExportEntry(e, p));
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    74
        return null;
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    75
    }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    76
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    77
    /**
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    78
     * Visit Module ExportEntry tree.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    79
     *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    80
     * @param node node being visited
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    81
     * @param p extra parameter passed to the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    82
     * @return value from the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    83
     */
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    84
    @Override
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    85
    public R visitExportEntry(ExportEntryTree node, P p) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    86
        return null;
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    87
    }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    88
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    89
    /**
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    90
     * Visit Module ImportEntry tree.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    91
     *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    92
     * @param node node being visited
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    93
     * @param p extra parameter passed to the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    94
     * @return value from the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    95
     */
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    96
    @Override
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    97
    public R visitImportEntry(ImportEntryTree node, P p) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    98
        return null;
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
    99
    }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   100
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   101
   /**
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   102
    * Visit class statement tree.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   103
    *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   104
    * @param node node being visited
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   105
    * @param p extra parameter passed to the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   106
    * @return value from the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   107
    */
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   108
    @Override
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   109
    public R visitClassDeclaration(ClassDeclarationTree node, P p) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   110
        node.getName().accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   111
        final ExpressionTree heritage = node.getClassHeritage();
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   112
        if (heritage != null) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   113
            heritage.accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   114
        }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   115
        final PropertyTree constructor = node.getConstructor();
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   116
        if (constructor != null) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   117
            constructor.accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   118
        }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   119
        final List<? extends PropertyTree> elements = node.getClassElements();
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   120
        if (elements != null) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   121
            for (PropertyTree prop : elements) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   122
                prop.accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   123
            }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   124
        }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   125
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   126
        return null;
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   127
    }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   128
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   129
    /**
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   130
     * Visit class expression tree.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   131
     *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   132
     * @param node node being visited
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   133
     * @param p extra parameter passed to the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   134
     * @return value from the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   135
     */
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   136
    @Override
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   137
    public R visitClassExpression(ClassExpressionTree node, P p) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   138
        node.getName().accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   139
        final ExpressionTree heritage = node.getClassHeritage();
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   140
        if (heritage != null) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   141
            heritage.accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   142
        }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   143
        final PropertyTree constructor = node.getConstructor();
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   144
        if (constructor != null) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   145
            constructor.accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   146
        }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   147
        final List<? extends PropertyTree> elements = node.getClassElements();
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   148
        if (elements != null) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   149
            for (PropertyTree prop : elements) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   150
                prop.accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   151
            }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   152
        }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   153
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   154
        return null;
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   155
    }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   156
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   157
    /**
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   158
     * Visit for..of statement tree.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   159
     *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   160
     * @param node node being visited
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   161
     * @param p extra parameter passed to the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   162
     * @return value from the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   163
     */
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   164
    @Override
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   165
    public R visitForOfLoop(final ForOfLoopTree node, final P p) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   166
        node.getVariable().accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   167
        node.getExpression().accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   168
        final StatementTree stat = node.getStatement();
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   169
        if (stat != null) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   170
            stat.accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   171
        }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   172
        return null;
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   173
    }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   174
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   175
    /**
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   176
     * Visit 'yield' expression tree.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   177
     *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   178
     * @param node node being visited
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   179
     * @param p extra parameter passed to the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   180
     * @return value from the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   181
     */
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   182
    @Override
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   183
    public R visitYield(YieldTree node, P p) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   184
        node.getExpression().accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   185
        return null;
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   186
    }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   187
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   188
    /**
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   189
     * Visit 'spread' expression tree.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   190
     *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   191
     * @param node node being visited
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   192
     * @param p extra parameter passed to the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   193
     * @return value from the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   194
     */
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   195
    @Override
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   196
    public R visitSpread(SpreadTree node, P p) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   197
        node.getExpression().accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   198
        return null;
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   199
    }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   200
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   201
   /**
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   202
    * Visit template literal tree.
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   203
    *
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   204
    * @param node node being visited
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   205
    * @param p extra parameter passed to the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   206
    * @return value from the visitor
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   207
    */
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   208
    @Override
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   209
    public R visitTemplateLiteral(TemplateLiteralTree node, P p) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   210
        final List<? extends ExpressionTree> expressions = node.getExpressions();
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   211
        for (ExpressionTree expr : expressions) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   212
            expr.accept(this, p);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   213
        }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   214
        return null;
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   215
    }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   216
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   217
    @Override
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   218
    public R visitVariable(final VariableTree node, final P r) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   219
        final ExpressionTree expr = node.getBinding();
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   220
        if (expr != null) {
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   221
            expr.accept(this, r);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   222
        }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   223
        super.visitVariable(node, r);
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   224
        return null;
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   225
    }
e2b36a3779b9 8149929: Nashorn Parser API needs to be updated for ES6
sundar
parents:
diff changeset
   226
}