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);
}
}
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());
}
}
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());
}
}
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;
}
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;
}
Aggregations