Search in sources :

Example 1 with DynAssign

use of lucee.transformer.bytecode.expression.var.DynAssign in project Lucee by lucee.

the class AbstrCFMLExprTransformer method assignOp.

/**
 * Transfomiert Zuweisungs Operation.
 * <br />
 * EBNF:<br />
 * <code>eqvOp ["=" spaces assignOp];</code>
 * @return CFXD Element
 * @throws TemplateException
 */
protected Expression assignOp(ExprData data) throws TemplateException {
    Expression expr = conditionalOp(data);
    if (data.srcCode.forwardIfCurrent('=')) {
        comments(data);
        if (data.mode == STATIC)
            expr = new DynAssign(expr, assignOp(data));
        else {
            if (expr instanceof Variable) {
                Expression value = assignOp(data);
                expr = new Assign((Variable) expr, value, data.srcCode.getPosition());
            } else if (expr instanceof Null) {
                Variable var = ((Null) expr).toVariable();
                Expression value = assignOp(data);
                expr = new Assign(var, value, data.srcCode.getPosition());
            } else
                throw new TemplateException(data.srcCode, "invalid assignment left-hand side (" + expr.getClass().getName() + ")");
        }
    }
    // patch for test()();  only works at the end of an expression!
    comments(data);
    while (data.srcCode.isCurrent('(')) {
        comments(data);
        Call call = new Call(expr);
        getFunctionMemberAttrs(data, null, false, call, null);
        call.setEnd(data.srcCode.getPosition());
        comments(data);
        expr = call;
    }
    return expr;
}
Also used : Call(lucee.transformer.bytecode.expression.var.Call) Null(lucee.transformer.bytecode.literal.Null) OpVariable(lucee.transformer.bytecode.op.OpVariable) Variable(lucee.transformer.expression.var.Variable) FunctionAsExpression(lucee.transformer.bytecode.expression.FunctionAsExpression) Expression(lucee.transformer.expression.Expression) TemplateException(lucee.runtime.exp.TemplateException) DynAssign(lucee.transformer.bytecode.expression.var.DynAssign) Assign(lucee.transformer.bytecode.expression.var.Assign) DynAssign(lucee.transformer.bytecode.expression.var.DynAssign)

Aggregations

TemplateException (lucee.runtime.exp.TemplateException)1 FunctionAsExpression (lucee.transformer.bytecode.expression.FunctionAsExpression)1 Assign (lucee.transformer.bytecode.expression.var.Assign)1 Call (lucee.transformer.bytecode.expression.var.Call)1 DynAssign (lucee.transformer.bytecode.expression.var.DynAssign)1 Null (lucee.transformer.bytecode.literal.Null)1 OpVariable (lucee.transformer.bytecode.op.OpVariable)1 Expression (lucee.transformer.expression.Expression)1 Variable (lucee.transformer.expression.var.Variable)1