BreakNode.java revision 953:221a84ef44c0
1226031Sstas/*
2226031Sstas * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
3226031Sstas * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4226031Sstas *
5226031Sstas * This code is free software; you can redistribute it and/or modify it
6226031Sstas * under the terms of the GNU General Public License version 2 only, as
7226031Sstas * published by the Free Software Foundation.  Oracle designates this
8226031Sstas * particular file as subject to the "Classpath" exception as provided
9226031Sstas * by Oracle in the LICENSE file that accompanied this code.
10226031Sstas *
11226031Sstas * This code is distributed in the hope that it will be useful, but WITHOUT
12226031Sstas * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13226031Sstas * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14226031Sstas * version 2 for more details (a copy is included in the LICENSE file that
15226031Sstas * accompanied this code).
16226031Sstas *
17226031Sstas * You should have received a copy of the GNU General Public License version
18226031Sstas * 2 along with this work; if not, write to the Free Software Foundation,
19226031Sstas * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20226031Sstas *
21226031Sstas * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22226031Sstas * or visit www.oracle.com if you need additional information or have any
23226031Sstas * questions.
24226031Sstas */
25226031Sstas
26226031Sstaspackage jdk.nashorn.internal.ir;
27226031Sstas
28226031Sstasimport jdk.nashorn.internal.ir.annotations.Immutable;
29226031Sstasimport jdk.nashorn.internal.ir.visitor.NodeVisitor;
30226031Sstas
31226031Sstas/**
32226031Sstas * IR representation for {@code break} statements.
33226031Sstas */
34226031Sstas@Immutable
35226031Sstaspublic final class BreakNode extends JumpStatement {
36226031Sstas
37226031Sstas    /**
38226031Sstas     * Constructor
39226031Sstas     *
40226031Sstas     * @param lineNumber line number
41226031Sstas     * @param token      token
42226031Sstas     * @param finish     finish
43226031Sstas     * @param labelName  label name for break or null if none
44226031Sstas     */
45226031Sstas    public BreakNode(final int lineNumber, final long token, final int finish, final String labelName) {
46226031Sstas        super(lineNumber, token, finish, labelName);
47226031Sstas    }
48226031Sstas
49226031Sstas    private BreakNode(final BreakNode breakNode, final LocalVariableConversion conversion) {
50226031Sstas        super(breakNode, conversion);
51226031Sstas    }
52226031Sstas
53226031Sstas    @Override
54226031Sstas    public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
55226031Sstas        if (visitor.enterBreakNode(this)) {
56226031Sstas            return visitor.leaveBreakNode(this);
57226031Sstas        }
58226031Sstas
59226031Sstas        return this;
60226031Sstas    }
61226031Sstas
62226031Sstas    @Override
63226031Sstas    JumpStatement createNewJumpStatement(final LocalVariableConversion conversion) {
64226031Sstas        return new BreakNode(this, conversion);
65226031Sstas    }
66226031Sstas
67226031Sstas    @Override
68226031Sstas    String getStatementName() {
69226031Sstas        return "break";
70226031Sstas    }
71226031Sstas}
72226031Sstas