use of lucee.transformer.library.function.FunctionLibFunction 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.library.function.FunctionLibFunction in project Lucee by lucee.
the class CFMLExpressionInterpreter method startElement.
/**
* Extrahiert den Start Element einer Variale,
* dies ist entweder eine Funktion, eine Scope Definition oder eine undefinierte Variable.
* <br />
* EBNF:<br />
* <code>identifier "(" functionArg ")" | scope | identifier;</code>
* @param name Einstiegsname
* @return CFXD Element
* @throws PageException
*/
private Ref startElement(String name) throws PageException {
// check function
if (!limited && cfml.isCurrent('(')) {
FunctionLibFunction function = fld.getFunction(name);
Ref[] arguments = functionArg(name, true, function, ')');
if (function != null)
return new BIFCall(function, arguments);
Ref ref = new lucee.runtime.interpreter.ref.var.Scope(Scope.SCOPE_UNDEFINED);
return new UDFCall(ref, name, arguments);
}
// check scope
return scope(name);
}
use of lucee.transformer.library.function.FunctionLibFunction in project Lucee by lucee.
the class CFMLExpressionInterpreter method newOp.
private Ref newOp() throws PageException {
int start = cfml.getPos();
String name = null;
cfml.removeSpace();
// first identifier
name = identifier(true);
Ref refName = null;
if (name != null) {
StringBuilder fullName = new StringBuilder();
fullName.append(name);
// Loop over addional identifier
while (cfml.isValidIndex()) {
if (cfml.forwardIfCurrent('.')) {
cfml.removeSpace();
name = identifier(true);
if (name == null)
throw new InterpreterException("invalid Component declaration");
cfml.removeSpace();
fullName.append('.');
fullName.append(name);
} else
break;
}
refName = new LString(fullName.toString());
} else {
if (cfml.isCurrentQuoter())
refName = string();
if (refName == null) {
cfml.setPos(start);
return null;
}
}
cfml.removeSpace();
if (cfml.isCurrent('(')) {
FunctionLibFunction function = fld.getFunction("_createComponent");
Ref[] arguments = functionArg("_createComponent", true, function, ')');
Ref[] args = new Ref[arguments.length + 1];
for (int i = 0; i < arguments.length; i++) {
args[i] = arguments[i];
}
args[args.length - 1] = refName;
BIFCall bif = new BIFCall(function, args);
cfml.removeSpace();
return bif;
}
throw new InterpreterException("invalid Component declaration ");
}
use of lucee.transformer.library.function.FunctionLibFunction in project Lucee by lucee.
the class GetFunctionData method _call.
private static Struct _call(PageContext pc, String strFunctionName, int dialect) throws PageException {
FunctionLib[] flds;
flds = ((ConfigImpl) pc.getConfig()).getFLDs(dialect);
FunctionLibFunction function = null;
for (int i = 0; i < flds.length; i++) {
function = flds[i].getFunction(strFunctionName.toLowerCase());
if (function != null)
break;
}
if (function == null)
throw new ExpressionException("function [" + strFunctionName + "] is not a built in function");
// CFML Based Function
Class clazz = null;
try {
clazz = function.getFunctionClassDefinition().getClazz();
} catch (Throwable t) {
ExceptionUtil.rethrowIfNecessary(t);
}
if (clazz == lucee.runtime.functions.system.CFFunction.class) {
return cfmlBasedFunction(pc, function);
}
return javaBasedFunction(function);
}
use of lucee.transformer.library.function.FunctionLibFunction in project Lucee by lucee.
the class GetFunctionList method _call.
private static lucee.runtime.type.Struct _call(PageContext pc, int dialect) throws PageException {
Struct sct = new StructImpl();
// synchronized(sct) {
// hasSet=true;
FunctionLib[] flds;
flds = ((ConfigImpl) pc.getConfig()).getFLDs(dialect);
FunctionLibFunction func;
Map<String, FunctionLibFunction> _functions;
Iterator<Entry<String, FunctionLibFunction>> it;
Entry<String, FunctionLibFunction> e;
for (int i = 0; i < flds.length; i++) {
_functions = flds[i].getFunctions();
it = _functions.entrySet().iterator();
while (it.hasNext()) {
e = it.next();
func = e.getValue();
if (func.getStatus() != TagLib.STATUS_HIDDEN && func.getStatus() != TagLib.STATUS_UNIMPLEMENTED)
sct.set(e.getKey(), "");
}
}
return sct;
}
Aggregations