TPreptimeValue result = super.evaluateConstant(context, inputs);
if (result != null) {
// Already constant
return result;
}
ValueSource pattern = inputs.get(1).value();
if(pattern == null) {
return null; // Dynamic pattern
}
int flags = caseSensitive ? 0 : Pattern.CASE_INSENSITIVE;
if(covering.length == 3) {
ValueSource opts = inputs.get(2).value();
if(opts == null) {
return null; // Dynamic opts
}
flags |= parseOptionFlags(opts.getString());
}
Pattern p = Pattern.compile(pattern.getString(), flags);
context.set(CACHE_INDEX, p);
ValueSource inputValue = inputs.get(0).value();
if(inputValue != null) {
// Constant input
boolean matches = p.matcher(inputValue.getString()).find();
Value value = new Value(context.getOutputType(), matches);
return new TPreptimeValue(value);
}
return null;