001    package railo.transformer.bytecode.literal;
002    
003    import org.objectweb.asm.Type;
004    import org.objectweb.asm.commons.GeneratorAdapter;
005    
006    import railo.runtime.op.Caster;
007    import railo.transformer.bytecode.BytecodeContext;
008    import railo.transformer.bytecode.Literal;
009    import railo.transformer.bytecode.Position;
010    import railo.transformer.bytecode.expression.Expression;
011    import railo.transformer.bytecode.expression.ExpressionBase;
012    import railo.transformer.bytecode.util.Methods;
013    import railo.transformer.bytecode.util.Types;
014    
015    /**
016     * Literal Double Value
017     */
018    public final class LitLong extends ExpressionBase implements Literal {
019        
020        private long l;
021    
022            public static Expression toExpr(long l, Position start,Position end) {
023                    return new LitLong(l,start,end);
024            }
025        
026        /**
027         * constructor of the class
028         * @param d
029         * @param line 
030         */
031            public LitLong(long l, Position start,Position end) {
032            super(start,end);        
033            this.l=l;
034        }
035    
036            /**
037         * @return return value as int
038         */ 
039        public long getLongValue() {
040            return l;
041        }
042        
043        /**
044         * @return return value as Double Object
045         */
046        public Long getLong() {
047            return new Long(l);
048        }
049        
050        /**
051         * @see railo.transformer.bytecode.Literal#getString()
052         */
053        public String getString() {
054            return Caster.toString(l);
055        }
056        
057        /**
058         * @return return value as a Boolean Object
059         */
060        public Boolean getBoolean() {
061            return Caster.toBoolean(l);
062        }
063        
064        /**
065         * @return return value as a boolean value
066         */
067        public boolean getBooleanValue() {
068            return Caster.toBooleanValue(l);
069        }
070    
071        /**
072         * @see railo.transformer.bytecode.expression.Expression#_writeOut(org.objectweb.asm.commons.GeneratorAdapter, int)
073         */
074        public Type _writeOut(BytecodeContext bc, int mode) {
075            GeneratorAdapter adapter = bc.getAdapter();
076            adapter.push(l);
077            if(mode==MODE_REF) {
078                adapter.invokeStatic(Types.CASTER,Methods.METHOD_TO_LONG_FROM_LONG_VALUE);
079                return Types.LONG;
080            }
081            return Types.LONG_VALUE;
082        }
083    
084        /**
085         * @see railo.transformer.bytecode.Literal#getDouble(java.lang.Double)
086         */
087        public Double getDouble(Double defaultValue) {
088            return getDouble();
089        }
090    
091        private Double getDouble() {
092                    return new Double(l);
093            }
094    
095            /**
096         * @see railo.transformer.bytecode.Literal#getBoolean(java.lang.Boolean)
097         */
098        public Boolean getBoolean(Boolean defaultValue) {
099            return getBoolean();
100        }
101    }