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.expression; 020 021import lucee.runtime.exp.TemplateException; 022import lucee.transformer.bytecode.BytecodeContext; 023import lucee.transformer.bytecode.BytecodeException; 024import lucee.transformer.bytecode.Position; 025import lucee.transformer.bytecode.util.ExpressionUtil; 026 027import org.objectweb.asm.Type; 028 029/** 030 * A Expression (Operation, Literal aso.) 031 */ 032public abstract class ExpressionBase implements Expression { 033 034 private Position start; 035 private Position end; 036 037 public ExpressionBase(Position start,Position end) { 038 this.start=start; 039 this.end=end; 040 } 041 042 043 /** 044 * write out the stament to adapter 045 * @param adapter 046 * @param mode 047 * @return return Type of expression 048 * @throws TemplateException 049 */ 050 public final Type writeOut(BytecodeContext bc, int mode) throws BytecodeException { 051 ExpressionUtil.visitLine(bc, start); 052 Type type = _writeOut(bc,mode); 053 ExpressionUtil.visitLine(bc, end); 054 return type; 055 } 056 057 /** 058 * write out the stament to the adater 059 * @param adapter 060 * @param mode 061 * @return return Type of expression 062 * @throws TemplateException 063 */ 064 public abstract Type _writeOut(BytecodeContext bc, int mode) throws BytecodeException; 065 066 067 @Override 068 public Position getStart() { 069 return start; 070 } 071 072 @Override 073 public Position getEnd() { 074 return end; 075 } 076 077 @Override 078 public void setStart(Position start) { 079 this.start= start; 080 } 081 @Override 082 public void setEnd(Position end) { 083 this.end= end; 084 } 085 086 087}