001 package railo.transformer.bytecode.expression; 002 003 import org.objectweb.asm.Type; 004 005 import railo.runtime.exp.TemplateException; 006 import railo.transformer.bytecode.BytecodeContext; 007 import railo.transformer.bytecode.BytecodeException; 008 import railo.transformer.bytecode.Position; 009 import railo.transformer.bytecode.util.ExpressionUtil; 010 011 /** 012 * A Expression (Operation, Literal aso.) 013 */ 014 public abstract class ExpressionBase implements Expression { 015 016 private Position start; 017 private Position end; 018 019 public ExpressionBase(Position start,Position end) { 020 this.start=start; 021 this.end=end; 022 } 023 024 025 /** 026 * write out the stament to adapter 027 * @param adapter 028 * @param mode 029 * @return return Type of expression 030 * @throws TemplateException 031 */ 032 public final Type writeOut(BytecodeContext bc, int mode) throws BytecodeException { 033 ExpressionUtil.visitLine(bc, start); 034 Type type = _writeOut(bc,mode); 035 ExpressionUtil.visitLine(bc, end); 036 return type; 037 } 038 039 /** 040 * write out the stament to the adater 041 * @param adapter 042 * @param mode 043 * @return return Type of expression 044 * @throws TemplateException 045 */ 046 public abstract Type _writeOut(BytecodeContext bc, int mode) throws BytecodeException; 047 048 049 @Override 050 public Position getStart() { 051 return start; 052 } 053 054 @Override 055 public Position getEnd() { 056 return end; 057 } 058 059 @Override 060 public void setStart(Position start) { 061 this.start= start; 062 } 063 @Override 064 public void setEnd(Position end) { 065 this.end= end; 066 } 067 068 069 }