LabeledStatementTreeImpl.java revision 1204:9597425b6b38
1104862Sru/*
2104862Sru * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
3104862Sru * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4104862Sru *
5104862Sru * This code is free software; you can redistribute it and/or modify it
6151497Sru * under the terms of the GNU General Public License version 2 only, as
7104862Sru * published by the Free Software Foundation.  Oracle designates this
8104862Sru * particular file as subject to the "Classpath" exception as provided
9104862Sru * by Oracle in the LICENSE file that accompanied this code.
10104862Sru *
11151497Sru * This code is distributed in the hope that it will be useful, but WITHOUT
12104862Sru * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13104862Sru * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14104862Sru * version 2 for more details (a copy is included in the LICENSE file that
15104862Sru * accompanied this code).
16104862Sru *
17104862Sru * You should have received a copy of the GNU General Public License version
18104862Sru * 2 along with this work; if not, write to the Free Software Foundation,
19104862Sru * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20104862Sru *
21104862Sru * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22104862Sru * or visit www.oracle.com if you need additional information or have any
23104862Sru * questions.
24104862Sru */
25104862Sru
26104862Srupackage jdk.nashorn.api.tree;
27104862Sru
28104862Sruimport jdk.nashorn.internal.ir.LabelNode;
29104862Sru
30104862Srufinal class LabeledStatementTreeImpl extends StatementTreeImpl
31151497Sru    implements LabeledStatementTree {
32151497Sru    private final String name;
33151497Sru    private final StatementTree stat;
34104862Sru
35104862Sru    LabeledStatementTreeImpl(final LabelNode node, final StatementTree stat) {
36104862Sru        super(node);
37104862Sru        this.name = node.getLabelName();
38104862Sru        this.stat = stat;
39104862Sru    }
40104862Sru
41104862Sru    @Override
42104862Sru    public Kind getKind() {
43104862Sru        return Kind.LABELED_STATEMENT;
44104862Sru    }
45104862Sru
46104862Sru    @Override
47104862Sru    public String getLabel() {
48104862Sru        return name;
49104862Sru    }
50104862Sru
51104862Sru    @Override
52104862Sru    public StatementTree getStatement() {
53104862Sru        return stat;
54104862Sru    }
55104862Sru
56104862Sru    @Override
57104862Sru    public <R,D> R accept(TreeVisitor<R,D> visitor, D data) {
58104862Sru        return visitor.visitLabeledStatement(this, data);
59104862Sru    }
60104862Sru}
61104862Sru