if (optimizer == null) { optimizer = new ParseTreeKB(); }
List<? extends ObjProperty> props = envJson.children();
for (ObjProperty prop : props) {
// JSON had better not have getters
ValueProperty vprop = (ValueProperty) prop;
Expression value = vprop.getValueExpr().fold(false); // fold negative nums
if (!(value instanceof Literal)) {
// True for "*useragent*" property inserted by JSKB.
continue;
}
StringLiteral sl = vprop.getPropertyNameNode();
String rawExpr = sl.getValue();
rawExpr = " " + rawExpr.substring(1, rawExpr.length() - 1) + " ";
CharProducer valueCp = CharProducer.Factory.fromJsString(
CharProducer.Factory.fromString(rawExpr, sl.getFilePosition()));
try {
Expression expr = jsExpr(valueCp, DevNullMessageQueue.singleton());
optimizer.addFact(expr, Fact.is((Literal) value));
} catch (ParseException ex) {
continue; // Triggered for browser specific extensions such as for each
}
}