use of lucee.transformer.expression.ExprDouble in project Lucee by lucee.
the class CastBoolean method _writeOut.
/**
* @see lucee.transformer.expression.Expression#writeOut(org.objectweb.asm.commons.GeneratorAdapter, int)
*/
@Override
public Type _writeOut(BytecodeContext bc, int mode) throws TransformerException {
GeneratorAdapter adapter = bc.getAdapter();
if (expr instanceof ExprDouble) {
expr.writeOut(bc, MODE_VALUE);
if (mode == MODE_VALUE)
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_BOOLEAN_VALUE_FROM_DOUBLE);
else
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_BOOLEAN_FROM_DOUBLE);
} else if (expr instanceof ExprString) {
expr.writeOut(bc, MODE_REF);
if (mode == MODE_VALUE)
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_BOOLEAN_VALUE_FROM_STRING);
else
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_BOOLEAN_FROM_STRING);
} else {
Type rtn = expr.writeOut(bc, mode);
if (mode == MODE_VALUE) {
if (!Types.isPrimitiveType(rtn)) {
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_BOOLEAN_VALUE);
} else if (Types.BOOLEAN_VALUE.equals(rtn)) {
} else if (Types.DOUBLE_VALUE.equals(rtn)) {
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_BOOLEAN_VALUE_FROM_DOUBLE);
} else {
adapter.invokeStatic(Types.CASTER, new Method("toRef", Types.toRefType(rtn), new Type[] { rtn }));
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_BOOLEAN_VALUE);
}
// return Types.BOOLEAN_VALUE;
} else {
if (Types.BOOLEAN.equals(rtn)) {
} else
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_BOOLEAN);
}
}
if (mode == MODE_VALUE)
return Types.BOOLEAN_VALUE;
return Types.BOOLEAN;
}
use of lucee.transformer.expression.ExprDouble in project Lucee by lucee.
the class CastDouble method _writeOut.
/**
* @see lucee.transformer.expression.Expression#_writeOut(org.objectweb.asm.commons.GeneratorAdapter, int)
*/
@Override
public Type _writeOut(BytecodeContext bc, int mode) throws TransformerException {
GeneratorAdapter adapter = bc.getAdapter();
if (expr instanceof ExprBoolean) {
expr.writeOut(bc, MODE_VALUE);
if (mode == MODE_VALUE)
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_DOUBLE_VALUE_FROM_BOOLEAN);
else
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_DOUBLE_FROM_BOOLEAN);
} else if (expr instanceof ExprDouble) {
expr.writeOut(bc, mode);
// if(mode==MODE_VALUE)adapter.invokeStatic(Types.CASTER,Methods.METHOD_TO_DOUBLE_VALUE_FROM_DOUBLE);
// if(mode==MODE_REF) adapter.invokeStatic(Types.CASTER,Methods.METHOD_TO_DOUBLE_FROM_DOUBLE);
} else if (expr instanceof ExprString) {
expr.writeOut(bc, MODE_REF);
if (mode == MODE_VALUE)
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_DOUBLE_VALUE_FROM_STRING);
else
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_DOUBLE_FROM_STRING);
} else {
Type rtn = expr.writeOut(bc, mode);
if (mode == MODE_VALUE) {
if (!Types.isPrimitiveType(rtn)) {
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_DOUBLE_VALUE);
} else if (Types.DOUBLE_VALUE.equals(rtn)) {
} else if (Types.BOOLEAN_VALUE.equals(rtn)) {
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_DOUBLE_VALUE_FROM_BOOLEAN);
} else {
adapter.invokeStatic(Types.CASTER, new Method("toRef", Types.toRefType(rtn), new Type[] { rtn }));
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_DOUBLE_VALUE);
}
return Types.DOUBLE_VALUE;
} else if (Types.isPrimitiveType(rtn)) {
if (Types.DOUBLE_VALUE.equals(rtn)) {
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_DOUBLE_FROM_DOUBLE);
} else if (Types.BOOLEAN_VALUE.equals(rtn)) {
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_DOUBLE_FROM_BOOLEAN);
} else {
adapter.invokeStatic(Types.CASTER, new Method("toRef", Types.toRefType(rtn), new Type[] { rtn }));
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_DOUBLE);
}
return Types.DOUBLE;
}
// else {
if (!Types.DOUBLE.equals(rtn))
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_DOUBLE);
return Types.DOUBLE;
// }
}
if (mode == MODE_VALUE)
return Types.DOUBLE_VALUE;
return Types.DOUBLE;
}
use of lucee.transformer.expression.ExprDouble in project Lucee by lucee.
the class CastFloat method _writeOut.
/**
* @see lucee.transformer.expression.Expression#_writeOut(org.objectweb.asm.commons.GeneratorAdapter, int)
*/
@Override
public Type _writeOut(BytecodeContext bc, int mode) throws TransformerException {
GeneratorAdapter adapter = bc.getAdapter();
if (expr instanceof OpDouble) {
((OpDouble) expr).writeOutDouble(bc, MODE_VALUE);
if (mode == MODE_VALUE)
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_VALUE_FROM_DOUBLE);
else
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_FROM_DOUBLE);
} else if (expr instanceof ExprBoolean) {
expr.writeOut(bc, MODE_VALUE);
if (mode == MODE_VALUE)
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_VALUE_FROM_BOOLEAN);
else
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_FROM_BOOLEAN);
} else if (expr instanceof ExprFloat) {
expr.writeOut(bc, mode);
} else if (expr instanceof ExprDouble) {
expr.writeOut(bc, MODE_VALUE);
if (mode == MODE_VALUE)
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_VALUE_FROM_DOUBLE);
else
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_FROM_DOUBLE);
} else if (expr instanceof ExprString) {
expr.writeOut(bc, MODE_REF);
if (mode == MODE_VALUE)
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_VALUE_FROM_STRING);
else
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_FROM_STRING);
} else {
Type rtn = expr.writeOut(bc, mode);
if (mode == MODE_VALUE) {
if (!Types.isPrimitiveType(rtn)) {
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_VALUE);
} else if (Types.DOUBLE_VALUE.equals(rtn)) {
adapter.cast(Types.DOUBLE_VALUE, Types.FLOAT_VALUE);
} else if (Types.FLOAT_VALUE.equals(rtn)) {
} else if (Types.BOOLEAN_VALUE.equals(rtn)) {
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_VALUE_FROM_BOOLEAN);
} else {
adapter.invokeStatic(Types.CASTER, new Method("toRef", Types.toRefType(rtn), new Type[] { rtn }));
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_VALUE);
}
return Types.FLOAT_VALUE;
} else if (Types.isPrimitiveType(rtn)) {
if (Types.DOUBLE_VALUE.equals(rtn)) {
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_FROM_DOUBLE);
} else if (Types.FLOAT_VALUE.equals(rtn)) {
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_FROM_FLOAT);
} else if (Types.BOOLEAN_VALUE.equals(rtn)) {
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT_FROM_BOOLEAN);
} else {
adapter.invokeStatic(Types.CASTER, new Method("toRef", Types.toRefType(rtn), new Type[] { rtn }));
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT);
}
return Types.FLOAT;
}
// else {
if (!Types.FLOAT.equals(rtn))
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_FLOAT);
return Types.FLOAT;
// }
}
if (mode == MODE_VALUE)
return Types.FLOAT_VALUE;
return Types.FLOAT;
}
use of lucee.transformer.expression.ExprDouble in project Lucee by lucee.
the class CastString method _writeOut.
/**
* @see lucee.transformer.expression.Expression#_writeOut(org.objectweb.asm.commons.GeneratorAdapter, int)
*/
@Override
public Type _writeOut(BytecodeContext bc, int mode) throws TransformerException {
GeneratorAdapter adapter = bc.getAdapter();
if (expr instanceof ExprBoolean) {
expr.writeOut(bc, MODE_VALUE);
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_STRING_FROM_BOOLEAN);
} else if (expr instanceof ExprDouble) {
expr.writeOut(bc, MODE_VALUE);
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_STRING_FROM_DOUBLE);
} else {
Type rtn = expr.writeOut(bc, MODE_REF);
if (rtn.equals(Types.STRING))
return Types.STRING;
adapter.invokeStatic(Types.CASTER, Methods.METHOD_TO_STRING);
}
return Types.STRING;
}
use of lucee.transformer.expression.ExprDouble in project Lucee by lucee.
the class AbstrCFMLExprTransformer method _modOp.
private Expression _modOp(ExprData data, Expression expr) throws TemplateException {
if (data.srcCode.isCurrent('=') && expr instanceof Variable) {
data.srcCode.next();
comments(data);
Expression right = assignOp(data);
ExprDouble res = OpDouble.toExprDouble(expr, right, OpDouble.MODULUS);
return new OpVariable((Variable) expr, res, data.srcCode.getPosition());
}
comments(data);
return OpDouble.toExprDouble(expr, expoOp(data), OpDouble.MODULUS);
}
Aggregations