ContinueNode.java revision 1173:82ae555768c7
11590Srgrimes/*
21590Srgrimes * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
31590Srgrimes * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
41590Srgrimes *
51590Srgrimes * This code is free software; you can redistribute it and/or modify it
61590Srgrimes * under the terms of the GNU General Public License version 2 only, as
71590Srgrimes * published by the Free Software Foundation.  Oracle designates this
81590Srgrimes * particular file as subject to the "Classpath" exception as provided
91590Srgrimes * by Oracle in the LICENSE file that accompanied this code.
101590Srgrimes *
111590Srgrimes * This code is distributed in the hope that it will be useful, but WITHOUT
121590Srgrimes * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
131590Srgrimes * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
141590Srgrimes * version 2 for more details (a copy is included in the LICENSE file that
151590Srgrimes * accompanied this code).
161590Srgrimes *
171590Srgrimes * You should have received a copy of the GNU General Public License version
181590Srgrimes * 2 along with this work; if not, write to the Free Software Foundation,
191590Srgrimes * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
201590Srgrimes *
211590Srgrimes * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
221590Srgrimes * or visit www.oracle.com if you need additional information or have any
231590Srgrimes * questions.
241590Srgrimes */
251590Srgrimes
261590Srgrimespackage jdk.nashorn.internal.ir;
271590Srgrimes
281590Srgrimesimport jdk.nashorn.internal.codegen.Label;
291590Srgrimesimport jdk.nashorn.internal.ir.annotations.Immutable;
301590Srgrimesimport jdk.nashorn.internal.ir.visitor.NodeVisitor;
311590Srgrimes
321590Srgrimes/**
331590Srgrimes * IR representation for CONTINUE statements.
3487628Sdwmalone */
3587628Sdwmalone@Immutable
3687628Sdwmalonepublic class ContinueNode extends JumpStatement {
3787628Sdwmalone    private static final long serialVersionUID = 1L;
3887628Sdwmalone
3987628Sdwmalone    /**
4087249Smarkm     * Constructor
4187249Smarkm     *
4287249Smarkm     * @param lineNumber line number
431590Srgrimes     * @param token      token
441590Srgrimes     * @param finish     finish
451590Srgrimes     * @param labelName  label name for continue or null if none
461590Srgrimes     */
471590Srgrimes    public ContinueNode(final int lineNumber, final long token, final int finish, final String labelName) {
481590Srgrimes        super(lineNumber, token, finish, labelName);
491590Srgrimes    }
501590Srgrimes
511590Srgrimes    private ContinueNode(final ContinueNode continueNode, final LocalVariableConversion conversion) {
521590Srgrimes        super(continueNode, conversion);
531590Srgrimes    }
541590Srgrimes
551590Srgrimes    @Override
561590Srgrimes    public Node accept(final NodeVisitor<? extends LexicalContext> visitor) {
571590Srgrimes        if (visitor.enterContinueNode(this)) {
581590Srgrimes            return visitor.leaveContinueNode(this);
591590Srgrimes        }
601590Srgrimes
611590Srgrimes        return this;
621590Srgrimes    }
631590Srgrimes
641590Srgrimes    @Override
651590Srgrimes    JumpStatement createNewJumpStatement(final LocalVariableConversion conversion) {
661590Srgrimes        return new ContinueNode(this, conversion);
671590Srgrimes    }
681590Srgrimes
691590Srgrimes    @Override
701590Srgrimes    String getStatementName() {
711590Srgrimes        return "continue";
721590Srgrimes    }
731590Srgrimes
741590Srgrimes
751590Srgrimes    @Override
761590Srgrimes    public BreakableNode getTarget(final LexicalContext lc) {
771590Srgrimes        return lc.getContinueTo(getLabelName());
781590Srgrimes    }
791590Srgrimes
801590Srgrimes    @Override
811590Srgrimes    Label getTargetLabel(final BreakableNode target) {
821590Srgrimes        return ((LoopNode)target).getContinueLabel();
831590Srgrimes    }
841590Srgrimes}
851590Srgrimes