Search in sources :

Example 1 with Argument

use of lucee.transformer.bytecode.expression.var.Argument 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 Argument

use of lucee.transformer.bytecode.expression.var.Argument 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 Argument

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

the class StructKeyExists method execute.

@Override
public void execute(BIF bif, FunctionLibFunction flf) throws TemplateException {
    Argument arg = bif.getArguments()[1];
    Expression value = arg.getValue();
    if (value instanceof LitString) {
        String str = ((LitString) value).getString();
        // update first arg
        arg.setValue(new CollectionKey(bif.getFactory(), str), Collection.Key.class.getName());
    }
}
Also used : LitString(lucee.transformer.expression.literal.LitString) Argument(lucee.transformer.bytecode.expression.var.Argument) Expression(lucee.transformer.expression.Expression) CollectionKey(lucee.transformer.bytecode.expression.type.CollectionKey) LitString(lucee.transformer.expression.literal.LitString) CollectionKey(lucee.transformer.bytecode.expression.type.CollectionKey)

Example 4 with Argument

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

the class AbstrCFMLExprTransformer method newOp.

private Expression newOp(ExprData data, Expression expr) throws TemplateException {
    if (!(expr instanceof Variable))
        return expr;
    Variable var = (Variable) expr;
    Member m = var.getFirstMember();
    if (!(m instanceof DataMember))
        return expr;
    ExprString n = ((DataMember) m).getName();
    if (!(n instanceof LitString))
        return expr;
    LitString ls = (LitString) n;
    if (!"new".equalsIgnoreCase(ls.getString()))
        return expr;
    int start = data.srcCode.getPos();
    ExprString exprName = readComponentPath(data);
    if (exprName == null) {
        data.srcCode.setPos(start);
        return expr;
    }
    comments(data);
    if (data.srcCode.isCurrent('(')) {
        FunctionMember func = getFunctionMember(data, Identifier.toIdentifier(data.factory, "_createComponent", Identifier.CASE_ORIGNAL, null, null), true);
        func.addArgument(new Argument(exprName, "string"));
        Variable v = expr.getFactory().createVariable(expr.getStart(), expr.getEnd());
        v.addMember(func);
        comments(data);
        return v;
    }
    data.srcCode.setPos(start);
    return expr;
}
Also used : LitString(lucee.transformer.expression.literal.LitString) OpVariable(lucee.transformer.bytecode.op.OpVariable) Variable(lucee.transformer.expression.var.Variable) NamedArgument(lucee.transformer.bytecode.expression.var.NamedArgument) Argument(lucee.transformer.bytecode.expression.var.Argument) ExprString(lucee.transformer.expression.ExprString) DataMember(lucee.transformer.expression.var.DataMember) FunctionMember(lucee.transformer.bytecode.expression.var.FunctionMember) DataMember(lucee.transformer.expression.var.DataMember) Member(lucee.transformer.expression.var.Member) FunctionMember(lucee.transformer.bytecode.expression.var.FunctionMember)

Example 5 with Argument

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

the class AbstrCFMLExprTransformer method staticScope.

private Expression staticScope(ExprData data, Expression expr) throws TemplateException {
    if (data.srcCode.forwardIfCurrent("::")) {
        if (!(expr instanceof Variable))
            throw new TemplateException(data.srcCode, "invalid syntax before [::]");
        Variable old = (Variable) expr;
        // set back to read again as a component path
        data.srcCode.setPos(old.getStart().pos);
        // now we read the component path
        ExprString componentPath = readComponentPath(data);
        if (!data.srcCode.forwardIfCurrent("::"))
            throw new TemplateException(data.srcCode, "invalid syntax before [::]" + data.srcCode.getCurrent());
        comments(data);
        BIF bif = null;
        if (componentPath instanceof LitString) {
            LitString ls = (LitString) componentPath;
            if ("super".equalsIgnoreCase(ls.getString())) {
                bif = ASMUtil.createBif(data, GET_SUPER_STATIC_SCOPE);
            }
        }
        // now we generate a _getStaticScope function call with that path
        if (bif == null) {
            bif = ASMUtil.createBif(data, GET_STATIC_SCOPE);
            bif.addArgument(new Argument(componentPath, "string"));
        }
        Variable var = data.factory.createVariable(old.getStart(), data.srcCode.getPosition());
        var.addMember(bif);
        // now we are reading what is coming after ":::"
        Expression sd = subDynamic(data, var, false, true);
        return sd;
    }
    return null;
}
Also used : LitString(lucee.transformer.expression.literal.LitString) OpVariable(lucee.transformer.bytecode.op.OpVariable) Variable(lucee.transformer.expression.var.Variable) NamedArgument(lucee.transformer.bytecode.expression.var.NamedArgument) Argument(lucee.transformer.bytecode.expression.var.Argument) TemplateException(lucee.runtime.exp.TemplateException) ExprString(lucee.transformer.expression.ExprString) FunctionAsExpression(lucee.transformer.bytecode.expression.FunctionAsExpression) Expression(lucee.transformer.expression.Expression) BIF(lucee.transformer.bytecode.expression.var.BIF)

Aggregations

Argument (lucee.transformer.bytecode.expression.var.Argument)8 Expression (lucee.transformer.expression.Expression)7 LitString (lucee.transformer.expression.literal.LitString)5 Variable (lucee.transformer.expression.var.Variable)5 CollectionKey (lucee.transformer.bytecode.expression.type.CollectionKey)2 BIF (lucee.transformer.bytecode.expression.var.BIF)2 NamedArgument (lucee.transformer.bytecode.expression.var.NamedArgument)2 OpVariable (lucee.transformer.bytecode.op.OpVariable)2 ExprString (lucee.transformer.expression.ExprString)2 Member (lucee.transformer.expression.var.Member)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 StringList (lucee.commons.lang.StringList)1 TemplateException (lucee.runtime.exp.TemplateException)1 PreserveSingleQuotes (lucee.runtime.functions.other.PreserveSingleQuotes)1 QuotedValueList (lucee.runtime.functions.other.QuotedValueList)1 ValueList (lucee.runtime.functions.query.ValueList)1 Collection (lucee.runtime.type.Collection)1 Body (lucee.transformer.bytecode.Body)1 Statement (lucee.transformer.bytecode.Statement)1