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.util.ExpressionUtil;
009    
010    /**
011     * A Expression (Operation, Literal aso.)
012     */
013    public abstract class ExpressionBase implements Expression {
014    
015        private int line;
016    
017        /**
018             * @see railo.transformer.bytecode.expression.Expression#setLine(int)
019             */
020            public void setLine(int line) {
021                    this.line=line;
022            }
023    
024    
025            /**
026         * constructor of the class
027         * @param line
028         */
029        public ExpressionBase(int line) {
030            this.line=line;
031        }
032    
033    
034        /**
035         * write out the stament to adapter
036         * @param adapter
037         * @param mode 
038         * @return return Type of expression
039         * @throws TemplateException
040         */
041        public final Type writeOut(BytecodeContext bc, int mode) throws BytecodeException {
042            ExpressionUtil.visitLine(bc, line);
043            return _writeOut(bc,mode);
044        }
045    
046        /**
047         * write out the stament to the adater
048         * @param adapter
049         * @param mode 
050         * @return return Type of expression
051         * @throws TemplateException
052         */
053        public abstract Type _writeOut(BytecodeContext bc, int mode) throws BytecodeException;
054    
055    
056        /**
057         * Returns the value of line.
058         * @return value line
059         */
060        public int getLine() {
061            return line;
062        }
063        
064    }