Fri, 15 Feb 2013 09:44:15 +0100
8008239: Unpublicized parts of the code generator package that were only package internal.
Reviewed-by: hannesw, 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@96 | 28 | import jdk.nashorn.internal.codegen.Label; |
jlaskey@3 | 29 | import jdk.nashorn.internal.ir.visitor.NodeVisitor; |
jlaskey@3 | 30 | import jdk.nashorn.internal.runtime.Source; |
jlaskey@3 | 31 | |
jlaskey@3 | 32 | /** |
jlaskey@3 | 33 | * IR representation for CONTINUE statements. |
jlaskey@3 | 34 | * |
jlaskey@3 | 35 | */ |
jlaskey@3 | 36 | public class ContinueNode extends LabeledNode { |
jlaskey@3 | 37 | |
jlaskey@3 | 38 | /** |
jlaskey@3 | 39 | * Constructor |
jlaskey@3 | 40 | * |
jlaskey@3 | 41 | * @param source the source |
jlaskey@3 | 42 | * @param token token |
jlaskey@3 | 43 | * @param finish finish |
jlaskey@3 | 44 | * @param labelNode the continue label |
jlaskey@3 | 45 | * @param targetNode node to continue to |
jlaskey@3 | 46 | * @param tryChain surrounding try chain |
jlaskey@3 | 47 | */ |
jlaskey@3 | 48 | public ContinueNode(final Source source, final long token, final int finish, final LabelNode labelNode, final Node targetNode, final TryNode tryChain) { |
jlaskey@3 | 49 | super(source, token, finish, labelNode, targetNode, tryChain); |
jlaskey@3 | 50 | setHasGoto(); |
jlaskey@3 | 51 | } |
jlaskey@3 | 52 | |
jlaskey@3 | 53 | private ContinueNode(final ContinueNode continueNode, final CopyState cs) { |
jlaskey@3 | 54 | super(continueNode, cs); |
jlaskey@3 | 55 | } |
jlaskey@3 | 56 | |
jlaskey@3 | 57 | @Override |
jlaskey@3 | 58 | protected Node copy(final CopyState cs) { |
jlaskey@3 | 59 | return new ContinueNode(this, cs); |
jlaskey@3 | 60 | } |
jlaskey@3 | 61 | |
jlaskey@3 | 62 | @Override |
jlaskey@3 | 63 | public Node accept(final NodeVisitor visitor) { |
jlaskey@3 | 64 | if (visitor.enter(this) != null) { |
jlaskey@3 | 65 | return visitor.leave(this); |
jlaskey@3 | 66 | } |
jlaskey@3 | 67 | |
jlaskey@3 | 68 | return this; |
jlaskey@3 | 69 | } |
jlaskey@3 | 70 | |
jlaskey@3 | 71 | /** |
jlaskey@3 | 72 | * Return the target label of this continue node. |
jlaskey@3 | 73 | * @return the target label. |
jlaskey@3 | 74 | */ |
lagergren@96 | 75 | public Label getTargetLabel() { |
jlaskey@3 | 76 | assert targetNode instanceof WhileNode : "continue target must be a while node"; |
jlaskey@3 | 77 | return ((WhileNode)targetNode).getContinueLabel(); |
jlaskey@3 | 78 | } |
jlaskey@3 | 79 | |
jlaskey@3 | 80 | @Override |
jlaskey@3 | 81 | public void toString(final StringBuilder sb) { |
jlaskey@3 | 82 | sb.append("continue"); |
jlaskey@3 | 83 | |
jlaskey@3 | 84 | if (labelNode != null) { |
jlaskey@3 | 85 | sb.append(' '); |
jlaskey@3 | 86 | labelNode.getLabel().toString(sb); |
jlaskey@3 | 87 | } |
jlaskey@3 | 88 | } |
jlaskey@3 | 89 | } |
jlaskey@3 | 90 |