// uses ctxContext() // returns true when rule "matched" static bool ctxProcessRule(S ruleName) { if (ruleName == null) false; ctxContext().rulesFired.add(ruleName); ++ctxContext().safetyCounter; WoodyRule rule = woodyBot().getRule(ruleName); if (rule == null) { print("Rule not found: " + ruleName); false; } printObjectWithFields(rule, "fullName", "condition", "body", "properties"); print("Processing rule " + rule.fullName); S a = rule.properties.get("ANALYZER"); if (a != null) ctxContext().activeAnalyzer = a; // evaluate condition again to set MATCH1 rule.parsedCondition.get(); // fake if (eqic(ruleName, "Agent#EVENT.NEWUSER")) { S theGoto = ctxFindFirstGoto(rule.body); print("NEWUSER -> Goto: " + theGoto); ctxContext().nextRule = theGoto; true; } if (neq(rule.properties.get("ACTIONSELECTOR"), "SWITCH")) // multi-action rules (RANDOMLOOP/TILLEND) if (ctxDoNextActionInRule(rule)) { if (!ctxPostRule()) // continue with this rule ctxContext().setActiveRule(rule.fullName); true; } // SWITCH L<CtxCase> cases = ctxCases(rule.body); if (nempty(cases)) { for (CtxCase c : cases) { Bool b = c.condition == null /* default */ || ctxEvalCondition(c.condition); print("case " + c.condition + " -> " + b + (b ? " (input: " + quote(ctxContext().input) + ")" : "")); if (isTrue(b)) { ctxContext().nextRule = mapGet(c.properties, "GOTO"); a = mapGet(c.properties, "ANALYZER"); if (a != null) { print("Setting analyzer to " + a + " by case in rule " + rule.fullName); ctxContext().activeAnalyzer = a; } ctxProcessAction(c.action); ctxPostRule(); true; } } false; } print("Unknown rule type: " + ruleName); false; }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1008930 |
Snippet name: | ctxProcessRule |
Eternal ID of this version: | #1008930/30 |
Text MD5: | b8cf47b127203b1e73b3330c3f700017 |
Author: | stefan |
Category: | javax / a.i. |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-07-19 00:00:20 |
Source code size: | 1929 bytes / 62 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 573 / 608 |
Version history: | 29 change(s) |
Referenced in: | [show references] |