*/
return resolveVariable(resolver, (String)_value, ctx);
}
} else if (_type == TokenType.FUNCTION) {
final FunctionMapper mapper = ctx.getFunctionMapper();
final Function fn = mapper.resolveFunction("", (String)_value);
if (fn == null) { //cannot find the specified function
throw new SSErrorXelException(SSError.NAME);
}
Object[] args = new Object[getOperands().size()];
int j = 0;
if ("ISERROR".equals(_value)
|| "ISERR".equals(_value)
|| "ISNA".equals(_value)
|| "ARRAYROW".equals(_value)) { //special function that use error value
for (final Iterator it=getOperands().iterator(); it.hasNext();) {
final Token opn = (Token) it.next();
try {
final Object arg = opn.evaluate(ctx); //recursive
args[j++] = arg;
} catch (SSErrorXelException ex) {
args[j++] = ex.getSSError();
}
}
} else { //general case, whenever error, throw exception to skip following evaluation.
for (final Iterator it=getOperands().iterator(); it.hasNext();) {
final Token opn = (Token) it.next();
final Object arg = opn.evaluate(ctx); //recursive
args[j++] = arg;
}
}
try {
return fn.invoke(null, new Object[] {args, ctx});
} catch (SSErrorXelException ex) {
throw ex; //throw out again
} catch (Exception ex) {
ex.printStackTrace();
throw new SSErrorXelException(SSError.NUM);