use of lucee.transformer.bytecode.expression.var.BIF in project Lucee by lucee.
the class AbstrCFMLExprTransformer method json.
protected Expression json(ExprData data, FunctionLibFunction flf, char start, char end) throws TemplateException {
if (!data.srcCode.forwardIfCurrent(start))
return null;
Position line = data.srcCode.getPosition();
data.srcCode.removeSpace();
// [:|=]
if (data.srcCode.forwardIfCurrent(':', ']') || data.srcCode.forwardIfCurrent('=', ']')) {
flf = flf.getFunctionLib().getFunction("_literalOrderedStruct");
BIF bif = new BIF(data.factory, data.settings, flf);
bif.setArgType(flf.getArgType());
try {
bif.setClassDefinition(flf.getFunctionClassDefinition());
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
throw new PageRuntimeException(t);
}
bif.setReturnType(flf.getReturnTypeAsString());
data.ep.add(flf, bif, data.srcCode);
Variable var = data.factory.createVariable(line, data.srcCode.getPosition());
var.addMember(bif);
return var;
}
BIF bif = new BIF(data.factory, data.settings, flf);
bif.setArgType(flf.getArgType());
try {
bif.setClassDefinition(flf.getFunctionClassDefinition());
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
throw new PageRuntimeException(t);
}
bif.setReturnType(flf.getReturnTypeAsString());
do {
comments(data);
if (data.srcCode.isCurrent(end))
break;
bif.addArgument(functionArgument(data, data.settings.dotNotationUpper));
comments(data);
} while (data.srcCode.forwardIfCurrent(','));
comments(data);
if (!data.srcCode.forwardIfCurrent(end))
throw new TemplateException(data.srcCode, "Invalid Syntax Closing [" + end + "] not found");
comments(data);
if (flf.hasTteClass()) {
FunctionLibFunction tmp = flf.getEvaluator().pre(bif, flf);
if (tmp != null && tmp != flf) {
bif.setFlf(flf = tmp);
bif.setArgType(flf.getArgType());
try {
bif.setClassDefinition(flf.getFunctionClassDefinition());
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
throw new PageRuntimeException(t);
}
bif.setReturnType(flf.getReturnTypeAsString());
}
}
data.ep.add(flf, bif, data.srcCode);
Variable var = data.factory.createVariable(line, data.srcCode.getPosition());
var.addMember(bif);
return var;
}
use of lucee.transformer.bytecode.expression.var.BIF in project Lucee by lucee.
the class Query method translateChildren.
private void translateChildren(Iterator it) {
Statement stat;
while (it.hasNext()) {
stat = (Statement) it.next();
if (stat instanceof PrintOut) {
PrintOut printOut = ((PrintOut) stat);
Expression e = printOut.getExpr();
if (!(e instanceof Literal)) {
Expression expr = removeCastString(e);
if (expr instanceof Variable) {
// do not preserve BIF PreserveSingleQuotes return value
Member member = ((Variable) expr).getFirstMember();
if (member instanceof BIF) {
BIF bif = (BIF) member;
if (bif.getClassDefinition().getClassName().equals(PreserveSingleQuotes.class.getName())) {
printOut.setExpr(bif.getArguments()[0].getValue());
continue;
} else if (bif.getClassDefinition().getClassName().equals(ListQualify.class.getName())) {
Argument[] args = bif.getArguments();
List<Argument> arr = new ArrayList<Argument>();
// first get existing arguments
arr.add(args[0]);
arr.add(args[1]);
if (args.length >= 3)
arr.add(args[2]);
else
arr.add(new Argument(expr.getFactory().createLitString(","), "string"));
if (args.length >= 4)
arr.add(args[3]);
else
arr.add(new Argument(expr.getFactory().createLitString("all"), "string"));
if (args.length >= 5)
arr.add(args[4]);
else
arr.add(new Argument(expr.getFactory().createLitBoolean(false), "boolean"));
// PSQ-BIF DO NOT REMOVE THIS COMMENT
arr.add(new Argument(expr.getFactory().createLitBoolean(true), "boolean"));
bif.setArguments(arr.toArray(new Argument[arr.size()]));
continue;
} else if (bif.getClassDefinition().getClassName().equals(QuotedValueList.class.getName()) || bif.getClassDefinition().getClassName().equals(ValueList.class.getName())) {
// printOut.setPreserveSingleQuote(false);
continue;
}
}
// do not preserve UDF return value
member = ((Variable) expr).getLastMember();
if (member instanceof UDF)
continue;
}
printOut.setCheckPSQ(true);
if (e != expr)
printOut.setExpr(expr);
}
} else if (stat instanceof Tag) {
Body b = ((Tag) stat).getBody();
if (b != null)
translateChildren(b.getStatements().iterator());
} else if (stat instanceof Body) {
translateChildren(((Body) stat).getStatements().iterator());
}
}
}
Aggregations