use of lucee.transformer.bytecode.expression.type.CollectionKey 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.type.CollectionKey in project Lucee by lucee.
the class IsDefined method execute.
@Override
public void execute(BIF bif, FunctionLibFunction flf) throws TemplateException {
Argument arg = bif.getArguments()[0];
Expression value = arg.getValue();
if (value instanceof LitString) {
String str = ((LitString) value).getString();
StringList sl = VariableInterpreter.parse(str, false);
if (sl != null) {
// scope
str = sl.next();
int scope = VariableInterpreter.scopeString2Int(bif.ts.ignoreScopes, str);
if (scope == Scope.SCOPE_UNDEFINED)
sl.reset();
// keys
String[] arr = sl.toArray();
ArrayUtil.trim(arr);
// update first arg
arg.setValue(bif.getFactory().createLitDouble(scope), "number");
if (arr.length == 1) {
// LitString.toExprString(str);
Expression expr = new CollectionKey(bif.getFactory(), arr[0]);
arg = new Argument(expr, Collection.Key.class.getName());
bif.addArgument(arg);
} else {
CollectionKeyArray expr = new CollectionKeyArray(bif.getFactory(), arr);
// LiteralStringArray expr = new LiteralStringArray(arr);
arg = new Argument(expr, Collection.Key[].class.getName());
bif.addArgument(arg);
}
}
}
// print.out("bif:"+arg.getValue().getClass().getName());
}
Aggregations