1 | // uses ctxContext() |
2 | // returns true when rule "matched" |
3 | static bool ctxProcessRule(S ruleName) { |
4 | if (ruleName == null) false; |
5 | ctxContext().rulesFired.add(ruleName); |
6 | ++ctxContext().safetyCounter; |
7 | WoodyRule rule = woodyBot().getRule(ruleName); |
8 | if (rule == null) { print("Rule not found: " + ruleName); false; } |
9 | printObjectWithFields(rule, "fullName", "condition", "body", "properties"); |
10 | |
11 | print("Processing rule " + rule.fullName); |
12 | |
13 | S a = rule.properties.get("ANALYZER"); |
14 | if (a != null) |
15 | ctxContext().activeAnalyzer = a; |
16 | |
17 | // evaluate condition again to set MATCH1 |
18 | rule.parsedCondition.get(); |
19 | |
20 | // fake |
21 | if (eqic(ruleName, "Agent#EVENT.NEWUSER")) { |
22 | S theGoto = ctxFindFirstGoto(rule.body); |
23 | print("NEWUSER -> Goto: " + theGoto); |
24 | ctxContext().nextRule = theGoto; |
25 | true; |
26 | } |
27 | |
28 | if (neq(rule.properties.get("ACTIONSELECTOR"), "SWITCH")) |
29 | // multi-action rules (RANDOMLOOP/TILLEND) |
30 | if (ctxDoNextActionInRule(rule)) { |
31 | if (!ctxPostRule()) |
32 | // continue with this rule |
33 | ctxContext().setActiveRule(rule.fullName); |
34 | |
35 | true; |
36 | } |
37 | |
38 | // SWITCH |
39 | L<CtxCase> cases = ctxCases(rule.body); |
40 | if (nempty(cases)) { |
41 | for (CtxCase c : cases) { |
42 | Bool b = c.condition == null /* default */ |
43 | || ctxEvalCondition(c.condition); |
44 | print("case " + c.condition + " -> " + b + (b ? " (input: " + quote(ctxContext().input) + ")" : "")); |
45 | if (isTrue(b)) { |
46 | ctxContext().nextRule = mapGet(c.properties, "GOTO"); |
47 | a = mapGet(c.properties, "ANALYZER"); |
48 | if (a != null) { |
49 | print("Setting analyzer to " + a + " by case in rule " + rule.fullName); |
50 | ctxContext().activeAnalyzer = a; |
51 | } |
52 | ctxProcessAction(c.action); |
53 | ctxPostRule(); |
54 | true; |
55 | } |
56 | } |
57 | false; |
58 | } |
59 | |
60 | print("Unknown rule type: " + ruleName); |
61 | false; |
62 | } |
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: | 575 / 611 |
Version history: | 29 change(s) |
Referenced in: | [show references] |