Search in sources :

Example 1 with OpVariable

use of lucee.transformer.bytecode.op.OpVariable in project Lucee by lucee.

the class AbstrCFMLExprTransformer method concatOp.

/**
 * Transfomiert eine  Konkatinations-Operator (&) Operation. Im Gegensatz zu CFMX ,
 * wird das "!" Zeichen auch als Not Operator anerkannt.
 * <br />
 * EBNF:<br />
 * <code>plusMinusOp {"&" spaces concatOp};</code>
 * @return CFXD Element
 * @throws TemplateException
 */
private Expression concatOp(ExprData data) throws TemplateException {
    Expression expr = plusMinusOp(data);
    while (data.srcCode.isCurrent('&') && !data.srcCode.isCurrent("&&")) {
        data.srcCode.next();
        // &=
        if (data.srcCode.isCurrent('=') && expr instanceof Variable) {
            data.srcCode.next();
            comments(data);
            Expression value = assignOp(data);
            expr = new OPUnary((Variable) expr, value, OPUnary.PRE, OPUnary.CONCAT, expr.getStart(), data.srcCode.getPosition());
        // ExprString res = OpString.toExprString(expr, right);
        // expr=new OpVariable((Variable)expr,res,data.cfml.getPosition());
        } else {
            comments(data);
            expr = data.factory.opString(expr, plusMinusOp(data));
        }
    }
    return expr;
}
Also used : OpVariable(lucee.transformer.bytecode.op.OpVariable) Variable(lucee.transformer.expression.var.Variable) FunctionAsExpression(lucee.transformer.bytecode.expression.FunctionAsExpression) Expression(lucee.transformer.expression.Expression) OPUnary(lucee.transformer.bytecode.op.OPUnary)

Example 2 with OpVariable

use of lucee.transformer.bytecode.op.OpVariable in project Lucee by lucee.

the class AbstrCFMLExprTransformer method _plusMinusOp.

private Expression _plusMinusOp(ExprData data, Expression expr, int opr) throws TemplateException {
    // plus|Minus Assignment
    if (data.srcCode.isCurrent('=') && expr instanceof Variable) {
        data.srcCode.next();
        comments(data);
        Expression value = assignOp(data);
        // if(opr==OpDouble.MINUS) value=OpNegateNumber.toExprDouble(value, null, null);
        expr = new OPUnary((Variable) expr, value, OPUnary.PRE, opr, expr.getStart(), data.srcCode.getPosition());
    // ExprDouble res = OpDouble.toExprDouble(expr, right,opr);
    // expr=new OpVariable((Variable)expr,res,data.cfml.getPosition());
    } else {
        comments(data);
        expr = OpDouble.toExprDouble(expr, modOp(data), opr);
    }
    return expr;
}
Also used : OpVariable(lucee.transformer.bytecode.op.OpVariable) Variable(lucee.transformer.expression.var.Variable) FunctionAsExpression(lucee.transformer.bytecode.expression.FunctionAsExpression) Expression(lucee.transformer.expression.Expression) OPUnary(lucee.transformer.bytecode.op.OPUnary)

Example 3 with OpVariable

use of lucee.transformer.bytecode.op.OpVariable in project Lucee by lucee.

the class AbstrCFMLExprTransformer method _divMultiOp.

private Expression _divMultiOp(ExprData data, Expression expr, int iOp) throws TemplateException {
    if (data.srcCode.isCurrent('=') && expr instanceof Variable) {
        data.srcCode.next();
        comments(data);
        Expression value = assignOp(data);
        return new OPUnary((Variable) expr, value, OPUnary.PRE, iOp, expr.getStart(), data.srcCode.getPosition());
    // ExprDouble res = OpDouble.toExprDouble(expr, right,iOp);
    // return new OpVariable((Variable)expr,res,data.cfml.getPosition());
    }
    comments(data);
    return OpDouble.toExprDouble(expr, expoOp(data), iOp);
}
Also used : OpVariable(lucee.transformer.bytecode.op.OpVariable) Variable(lucee.transformer.expression.var.Variable) FunctionAsExpression(lucee.transformer.bytecode.expression.FunctionAsExpression) Expression(lucee.transformer.expression.Expression) OPUnary(lucee.transformer.bytecode.op.OPUnary)

Example 4 with OpVariable

use of lucee.transformer.bytecode.op.OpVariable in project Lucee by lucee.

the class AbstrCFMLExprTransformer method negatePlusMinusOp.

/**
 * Negate Numbers
 * @return CFXD Element
 * @throws TemplateException
 */
private Expression negatePlusMinusOp(ExprData data) throws TemplateException {
    // And Operation
    Position line = data.srcCode.getPosition();
    if (data.srcCode.forwardIfCurrent('-')) {
        // pre increment
        if (data.srcCode.forwardIfCurrent('-')) {
            comments(data);
            Expression expr = clip(data);
            return new OPUnary((Variable) expr, data.factory.DOUBLE_ONE(), OPUnary.PRE, OpDouble.MINUS, line, data.srcCode.getPosition());
        // ExprDouble res = OpDouble.toExprDouble(expr, LitDouble.toExprDouble(1D),OpDouble.MINUS);
        // return new OpVariable((Variable)expr,res,data.cfml.getPosition());
        }
        comments(data);
        return OpNegateNumber.toExprDouble(clip(data), OpNegateNumber.MINUS, line, data.srcCode.getPosition());
    } else if (data.srcCode.forwardIfCurrent('+')) {
        if (data.srcCode.forwardIfCurrent('+')) {
            comments(data);
            Expression expr = clip(data);
            return new OPUnary((Variable) expr, data.factory.DOUBLE_ONE(), OPUnary.PRE, OpDouble.PLUS, line, data.srcCode.getPosition());
        }
        comments(data);
        // OpNegateNumber.toExprDouble(clip(),OpNegateNumber.PLUS,line);
        return data.factory.toExprDouble(clip(data));
    }
    return clip(data);
}
Also used : OpVariable(lucee.transformer.bytecode.op.OpVariable) Variable(lucee.transformer.expression.var.Variable) Position(lucee.transformer.Position) FunctionAsExpression(lucee.transformer.bytecode.expression.FunctionAsExpression) Expression(lucee.transformer.expression.Expression) OPUnary(lucee.transformer.bytecode.op.OPUnary)

Example 5 with OpVariable

use of lucee.transformer.bytecode.op.OpVariable 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);
}
Also used : OpVariable(lucee.transformer.bytecode.op.OpVariable) Variable(lucee.transformer.expression.var.Variable) ExprDouble(lucee.transformer.expression.ExprDouble) OpVariable(lucee.transformer.bytecode.op.OpVariable) FunctionAsExpression(lucee.transformer.bytecode.expression.FunctionAsExpression) Expression(lucee.transformer.expression.Expression)

Aggregations

FunctionAsExpression (lucee.transformer.bytecode.expression.FunctionAsExpression)5 OpVariable (lucee.transformer.bytecode.op.OpVariable)5 Expression (lucee.transformer.expression.Expression)5 Variable (lucee.transformer.expression.var.Variable)5 OPUnary (lucee.transformer.bytecode.op.OPUnary)4 Position (lucee.transformer.Position)1 ExprDouble (lucee.transformer.expression.ExprDouble)1