sbool nlLogic_evalExp_verbose = true; static O nlLogic_evalExp(final NLLogicChecker_v2 c, Exp e, NLLogicChecker_v2.Matching m) { ret nlLogic_evalExp(c, e.text(), m); } static O nlLogic_evalExp(final NLLogicChecker_v2 c, S code, NLLogicChecker_v2.Matching m) { // prepare context final SS vars = m.matches; temp tempSetTL(ai_context_tl(), new O { LS getList(S var) { int i = 1; S s; new LS l; while ((s = vars.get(var + i++)) != null) l.add(s); ret l; } IfThen getRule(S id) { ret findByField(c.rules, globalID := id); } }); if (nlLogic_evalExp_verbose) print("Eval'ing: " + code); temp tempAdd(hotwire_copyOver_after, voidfunc(Class c) { copyFields(mc(), c, ai_staticVars()) }); O result = null; pcall { temp tempSetTL(evalJava_prep2_useCacheInThread, true); temp tempSetTL(evalJava_prep_voidMagic, false); Pair p = prepareEvalWithDollarVars_assertAllVarsSet(code, m.matches); // Accomodate ai_isTrue if (hasField(p.b, 'ai_isTrue_f)) set(p.b, 'ai_isTrue_f := func(S s) -> bool { nlLogic_matchAnyFact(c, s, new NLLogicChecker_v2.Matching()) }); // Accomodate ai_input if (c.input != null) { ThreadLocal tl_vars = cast getOpt(p.b, 'ai_getVar_map); if (tl_vars != null) tl_vars.set(litmap("#input" := c.input)); } result = evalWithDollarVars_step2(p, m.matches); } if (nlLogic_evalExp_verbose) print(" eval => " + shorten(str(result), 100)); ret result; }