Search in sources :

Example 1 with Variable

use of lucee.transformer.expression.var.Variable in project Lucee by lucee.

the class ArrayToList method execute.

@Override
public void execute(BIF bif, FunctionLibFunction flf) throws TemplateException {
    Argument[] args = bif.getArguments();
    Argument arg = args[0];
    Expression value = arg.getValue();
    if (value instanceof Cast) {
        value = ((Cast) value).getExpr();
    }
    if (value instanceof Variable) {
        ((Variable) value).setAsCollection(Boolean.TRUE);
    }
}
Also used : Cast(lucee.transformer.bytecode.cast.Cast) Variable(lucee.transformer.expression.var.Variable) Argument(lucee.transformer.bytecode.expression.var.Argument) Expression(lucee.transformer.expression.Expression)

Example 2 with Variable

use of lucee.transformer.expression.var.Variable in project Lucee by lucee.

the class IsNull method execute.

@Override
public void execute(BIF bif, FunctionLibFunction flf) throws TemplateException {
    Argument arg = bif.getArguments()[0];
    Expression value = arg.getValue();
    // set all member to safe navigated
    if (value instanceof Variable) {
        Variable var = ((Variable) value);
        /* LDEV-1201 List<Member> members = var.getMembers();
			for(Member m:members) {
				m.setSafeNavigated(true);
			}*/
        var.setDefaultValue(value.getFactory().createNull());
    }
}
Also used : Variable(lucee.transformer.expression.var.Variable) Argument(lucee.transformer.bytecode.expression.var.Argument) Expression(lucee.transformer.expression.Expression)

Example 3 with Variable

use of lucee.transformer.expression.var.Variable in project Lucee by lucee.

the class Output method addEncodeToChildren.

private void addEncodeToChildren(Iterator it, Expression encodeForValue, FunctionLibFunction encodeForBIF) {
    Statement stat;
    while (it.hasNext()) {
        stat = (Statement) it.next();
        if (stat instanceof PrintOut) {
            PrintOut printOut = ((PrintOut) stat);
            Expression e = removeCastString(printOut.getExpr());
            if (!(e instanceof Literal)) {
                if (e instanceof Variable) {
                    Member member = ((Variable) e).getFirstMember();
                    if (member instanceof BIF) {
                        BIF bif = (BIF) member;
                        String cn = bif.getClassDefinition().getClassName();
                        if (cn.startsWith(ENCODE_FOR) || cn.equals(ESAPIEncode.class.getName())) {
                            continue;
                        }
                    }
                }
                printOut.setEncodeFor(encodeForValue);
            }
        } else if (stat instanceof Tag) {
            Body b = ((Tag) stat).getBody();
            if (b != null)
                addEncodeToChildren(b.getStatements().iterator(), encodeForValue, encodeForBIF);
        } else if (stat instanceof Body) {
            addEncodeToChildren(((Body) stat).getStatements().iterator(), encodeForValue, encodeForBIF);
        }
    }
}
Also used : Variable(lucee.transformer.expression.var.Variable) PrintOut(lucee.transformer.bytecode.statement.PrintOut) Expression(lucee.transformer.expression.Expression) Statement(lucee.transformer.bytecode.Statement) Literal(lucee.transformer.expression.literal.Literal) CastString(lucee.transformer.bytecode.cast.CastString) TagLibTag(lucee.transformer.library.tag.TagLibTag) Tag(lucee.transformer.bytecode.statement.tag.Tag) Member(lucee.transformer.expression.var.Member) Body(lucee.transformer.bytecode.Body) BIF(lucee.transformer.bytecode.expression.var.BIF)

Example 4 with Variable

use of lucee.transformer.expression.var.Variable 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)

Example 5 with Variable

use of lucee.transformer.expression.var.Variable in project Lucee by lucee.

the class AbstrCFMLExprTransformer method dynamic.

/**
 * Liest den folgenden idetifier ein und prueft ob dieser ein boolscher Wert ist.
 * Im Gegensatz zu CFMX wird auch "yes" und "no" als bolscher <wert akzeptiert,
 * was bei CFMX nur beim Umwandeln einer Zeichenkette zu einem boolschen Wert der Fall ist.<br />
 * Wenn es sich um keinen bolschen Wert handelt wird der folgende Wert eingelesen mit seiner ganzen Hirarchie.
 * <br />
 * EBNF:<br />
 * <code>"true" | "false" | "yes" | "no" | startElement {("." identifier | "[" structElement "]" )[function] };</code>
 * @return CFXD Element
 * @throws TemplateException
 */
private Expression dynamic(ExprData data) throws TemplateException {
    // Die Implementation weicht ein wenig von der Grammatik ab,
    // aber nicht in der Logik sondern rein wie es umgesetzt wurde.
    // get First Element of the Variable
    Position line = data.srcCode.getPosition();
    Identifier id = identifier(data, false, true);
    if (id == null) {
        if (!data.srcCode.forwardIfCurrent('('))
            return null;
        comments(data);
        Expression expr = assignOp(data);
        if (!data.srcCode.forwardIfCurrent(')'))
            throw new TemplateException(data.srcCode, "Invalid Syntax Closing [)] not found");
        comments(data);
        // subDynamic(expr);
        return expr;
    }
    Variable var;
    comments(data);
    // Boolean constant
    if (id.getString().equalsIgnoreCase("TRUE")) {
        // || name.equals("YES"))	{
        comments(data);
        return id.getFactory().createLitBoolean(true, line, data.srcCode.getPosition());
    } else if (id.getString().equalsIgnoreCase("FALSE")) {
        // || name.equals("NO"))	{
        comments(data);
        return id.getFactory().createLitBoolean(false, line, data.srcCode.getPosition());
    } else if ((data.srcCode.getDialect() != CFMLEngine.DIALECT_CFML || data.config.getFullNullSupport()) && id.getString().equalsIgnoreCase("NULL")) {
        comments(data);
        return id.getFactory().createNull(line, data.srcCode.getPosition());
    }
    // Extract Scope from the Variable
    var = startElement(data, id, line);
    var.setStart(line);
    var.setEnd(data.srcCode.getPosition());
    return var;
}
Also used : Identifier(lucee.transformer.bytecode.literal.Identifier) 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) TemplateException(lucee.runtime.exp.TemplateException)

Aggregations

Variable (lucee.transformer.expression.var.Variable)26 Expression (lucee.transformer.expression.Expression)16 OpVariable (lucee.transformer.bytecode.op.OpVariable)14 FunctionAsExpression (lucee.transformer.bytecode.expression.FunctionAsExpression)12 TemplateException (lucee.runtime.exp.TemplateException)8 Position (lucee.transformer.Position)5 Argument (lucee.transformer.bytecode.expression.var.Argument)5 BIF (lucee.transformer.bytecode.expression.var.BIF)5 ExprString (lucee.transformer.expression.ExprString)5 OPUnary (lucee.transformer.bytecode.op.OPUnary)4 LitString (lucee.transformer.expression.literal.LitString)4 Member (lucee.transformer.expression.var.Member)4 Body (lucee.transformer.bytecode.Body)3 Assign (lucee.transformer.bytecode.expression.var.Assign)3 Literal (lucee.transformer.expression.literal.Literal)3 TransformerException (lucee.transformer.TransformerException)2 Statement (lucee.transformer.bytecode.Statement)2 FunctionMember (lucee.transformer.bytecode.expression.var.FunctionMember)2 NamedArgument (lucee.transformer.bytecode.expression.var.NamedArgument)2 Identifier (lucee.transformer.bytecode.literal.Identifier)2