src/jdk/nashorn/internal/ir/BreakNode.java

Tue, 07 May 2013 14:36:57 +0200

author
lagergren
date
Tue, 07 May 2013 14:36:57 +0200
changeset 252
544e17632e96
parent 211
3a209cbd1d8f
child 253
fb1d7ea3e1b6
permissions
-rw-r--r--

8013913: Removed Source field from all nodes except FunctionNode in order to save footprint
Reviewed-by: jlaskey, attila

jlaskey@3 1 /*
jlaskey@7 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
jlaskey@3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jlaskey@3 4 *
jlaskey@3 5 * This code is free software; you can redistribute it and/or modify it
jlaskey@3 6 * under the terms of the GNU General Public License version 2 only, as
jlaskey@3 7 * published by the Free Software Foundation. Oracle designates this
jlaskey@3 8 * particular file as subject to the "Classpath" exception as provided
jlaskey@3 9 * by Oracle in the LICENSE file that accompanied this code.
jlaskey@3 10 *
jlaskey@3 11 * This code is distributed in the hope that it will be useful, but WITHOUT
jlaskey@3 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jlaskey@3 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jlaskey@3 14 * version 2 for more details (a copy is included in the LICENSE file that
jlaskey@3 15 * accompanied this code).
jlaskey@3 16 *
jlaskey@3 17 * You should have received a copy of the GNU General Public License version
jlaskey@3 18 * 2 along with this work; if not, write to the Free Software Foundation,
jlaskey@3 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jlaskey@3 20 *
jlaskey@3 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
jlaskey@3 22 * or visit www.oracle.com if you need additional information or have any
jlaskey@3 23 * questions.
jlaskey@3 24 */
jlaskey@3 25
jlaskey@3 26 package jdk.nashorn.internal.ir;
jlaskey@3 27
lagergren@211 28 import jdk.nashorn.internal.ir.annotations.Immutable;
jlaskey@3 29 import jdk.nashorn.internal.ir.visitor.NodeVisitor;
jlaskey@3 30
jlaskey@3 31 /**
jlaskey@3 32 * IR representation for {@code break} statements.
jlaskey@3 33 */
lagergren@211 34 @Immutable
lagergren@211 35 public final class BreakNode extends Node {
jlaskey@3 36
lagergren@211 37 private final IdentNode label;
lagergren@211 38
lagergren@211 39 /**
jlaskey@3 40 * Constructor
jlaskey@3 41 *
lagergren@211 42 * @param token token
lagergren@211 43 * @param finish finish
lagergren@211 44 * @param label label for break or null if none
jlaskey@3 45 */
lagergren@252 46 public BreakNode(final long token, final int finish, final IdentNode label) {
lagergren@252 47 super(token, finish);
lagergren@211 48 this.label = label;
jlaskey@3 49 }
jlaskey@3 50
jlaskey@3 51 @Override
lagergren@211 52 public boolean hasGoto() {
lagergren@211 53 return true;
jlaskey@3 54 }
jlaskey@3 55
jlaskey@3 56 /**
jlaskey@3 57 * Assist in IR navigation.
jlaskey@3 58 * @param visitor IR navigating visitor.
jlaskey@3 59 */
jlaskey@3 60 @Override
jlaskey@3 61 public Node accept(final NodeVisitor visitor) {
lagergren@211 62 if (visitor.enterBreakNode(this)) {
attila@144 63 return visitor.leaveBreakNode(this);
jlaskey@3 64 }
jlaskey@3 65
jlaskey@3 66 return this;
jlaskey@3 67 }
jlaskey@3 68
jlaskey@3 69 /**
lagergren@211 70 * Get the label for this break node
lagergren@211 71 * @return label, or null if none
jlaskey@3 72 */
lagergren@211 73 public IdentNode getLabel() {
lagergren@211 74 return label;
jlaskey@3 75 }
jlaskey@3 76
jlaskey@3 77 @Override
jlaskey@3 78 public void toString(final StringBuilder sb) {
jlaskey@3 79 sb.append("break");
jlaskey@3 80
lagergren@211 81 if (label != null) {
jlaskey@3 82 sb.append(' ');
lagergren@211 83 label.toString(sb);
jlaskey@3 84 }
jlaskey@3 85 }
jlaskey@3 86 }

mercurial