001/** 002 * 003 * Copyright (c) 2014, the Railo Company Ltd. All rights reserved. 004 * 005 * This library is free software; you can redistribute it and/or 006 * modify it under the terms of the GNU Lesser General Public 007 * License as published by the Free Software Foundation; either 008 * version 2.1 of the License, or (at your option) any later version. 009 * 010 * This library is distributed in the hope that it will be useful, 011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 013 * Lesser General Public License for more details. 014 * 015 * You should have received a copy of the GNU Lesser General Public 016 * License along with this library. If not, see <http://www.gnu.org/licenses/>. 017 * 018 **/ 019package lucee.transformer.bytecode.statement.tag; 020 021import lucee.transformer.bytecode.BytecodeContext; 022import lucee.transformer.bytecode.BytecodeException; 023import lucee.transformer.bytecode.Position; 024import lucee.transformer.bytecode.expression.Expression; 025import lucee.transformer.bytecode.statement.FlowControlBreak; 026import lucee.transformer.bytecode.statement.FlowControlContinue; 027import lucee.transformer.bytecode.visitor.WhileVisitor; 028 029import org.objectweb.asm.Label; 030 031public final class TagWhile extends TagBaseNoFinal implements FlowControlBreak,FlowControlContinue { 032 033 private WhileVisitor wv; 034 private String label; 035 036 public TagWhile(Position start,Position end) { 037 super(start,end); 038 } 039 040 041 /** 042 * @see lucee.transformer.bytecode.statement.StatementBase#_writeOut(org.objectweb.asm.commons.GeneratorAdapter) 043 */ 044 public void _writeOut(BytecodeContext bc) throws BytecodeException { 045 wv = new WhileVisitor(); 046 wv.visitBeforeExpression(bc); 047 getAttribute("condition").getValue().writeOut(bc, Expression.MODE_VALUE); 048 wv.visitAfterExpressionBeforeBody(bc); 049 getBody().writeOut(bc); 050 wv.visitAfterBody(bc,getEnd()); 051 } 052 053 054 /** 055 * @see lucee.transformer.bytecode.statement.FlowControl#getBreakLabel() 056 */ 057 public Label getBreakLabel() { 058 return wv.getBreakLabel(); 059 } 060 061 062 /** 063 * @see lucee.transformer.bytecode.statement.FlowControl#getContinueLabel() 064 */ 065 public Label getContinueLabel() { 066 return wv.getContinueLabel(); 067 } 068 069 070 @Override 071 public String getLabel() { 072 return label; 073 } 074 075 public void setLabel(String label) { 076 this.label=label; 077 } 078 079}