/// <summary> method compiles ObjectConditions, which include NOTCE /// </summary> public override BaseJoin compileJoin(ICondition condition, int position, Rule.IRule rule) { Binding[] binds = getBindings(condition, rule, position); ObjectCondition oc = (ObjectCondition)condition; BaseJoin joinNode = null; //deal with the CE which is not NOT CE. if (!oc.Negated) { if (binds.Length > 0 && oc.HasPredicateJoin) { joinNode = new PredicateBNode(ruleCompiler.Engine.nextNodeId()); } else if (binds.Length > 0 && oc.HasNotEqual) { joinNode = new HashedNotEqBNode(ruleCompiler.Engine.nextNodeId()); } else if (binds.Length > 0) { joinNode = new HashedEqBNode(ruleCompiler.Engine.nextNodeId()); } else if (binds.Length == 0) { joinNode = new ZJBetaNode(ruleCompiler.Engine.nextNodeId()); } } //deal with the CE which is NOT CE. if (oc.Negated) { if (binds.Length > 0 && oc.HasPredicateJoin) { joinNode = new NotJoin(ruleCompiler.Engine.nextNodeId()); } else if (oc.HasNotEqual) { joinNode = new HashedNotEqNJoin(ruleCompiler.Engine.nextNodeId()); } else { joinNode = new HashedEqNJoin(ruleCompiler.Engine.nextNodeId()); } } if (joinNode != null) { joinNode.Bindings = binds; } return(joinNode); }
/// <summary> method compiles ExistCE to an exist node. It does not include rules that /// start with Exist for the first CE. /// </summary> public override BaseJoin compileJoin(ICondition condition, int position, Rule.IRule rule) { ExistCondition exc = (ExistCondition)condition; Binding[] binds = getBindings(exc, rule, position); BaseJoin joinNode = null; if (exc.HasPredicateJoin) { joinNode = new ExistPredJoin(ruleCompiler.Engine.nextNodeId()); } else if (exc.HasNotEqual) { joinNode = new ExistNeqJoin(ruleCompiler.Engine.nextNodeId()); } else { joinNode = new ExistJoin(ruleCompiler.Engine.nextNodeId()); } joinNode.Bindings = binds; return(joinNode); }
/// <summary> the method is responsible for compiling a TestCE pattern to a testjoin node. /// It uses the globally declared prevCE and prevJoinNode /// </summary> public virtual BaseJoin compileJoin(ICondition condition, int position, Rule.IRule rule) { TestCondition tc = (TestCondition)condition; ShellFunction fn = (ShellFunction)tc.Function; fn.lookUpFunction(ruleCompiler.Engine); IParameter[] oldpm = fn.Parameters; IParameter[] pms = new IParameter[oldpm.Length]; for (int ipm = 0; ipm < pms.Length; ipm++) { if (oldpm[ipm] is ValueParam) { pms[ipm] = ((ValueParam)oldpm[ipm]).cloneParameter(); } else if (oldpm[ipm] is BoundParam) { BoundParam bpm = (BoundParam)oldpm[ipm]; // now we need to resolve and setup the BoundParam Binding b = rule.getBinding(bpm.VariableName); BoundParam newpm = new BoundParam(b.LeftRow, b.LeftIndex, 9, bpm.ObjectBinding); newpm.VariableName = bpm.VariableName; pms[ipm] = newpm; } } BaseJoin joinNode = null; if (tc.Negated) { joinNode = new NTestNode(ruleCompiler.Engine.nextNodeId(), fn.Function, pms); } else { joinNode = new TestNode(ruleCompiler.Engine.nextNodeId(), fn.Function, pms); } ((TestNode)joinNode).lookUpFunction(ruleCompiler.Engine); return(joinNode); }
/// <summary> The first step is to connect the exist join to the parent on the left side. /// The second step is to connect it to the parent on the right. For the right /// side, if the objectCondition doesn't have any nodes, we attach it to the /// objectType node. /// </summary> public void connectJoinNode(ICondition previousCondition, ICondition condition, BaseJoin previousJoinNode, BaseJoin joinNode) { if (previousJoinNode != null) { ruleCompiler.attachJoinNode(previousJoinNode, (BaseJoin) joinNode); } else { ruleCompiler.attachJoinNode(previousCondition.LastNode, (BaseJoin) joinNode); } // Current we have to Add the ExistJoin for the right side, which should be either // an alphaNode or the objectTypeNode ObjectCondition oc = getObjectCondition(condition); ObjectTypeNode otn = ruleCompiler.findObjectTypeNode(oc.TemplateName); if (oc.Nodes.Count > 0) { ruleCompiler.attachJoinNode(oc.LastNode, (BaseJoin) joinNode); } else { otn.addSuccessorNode(joinNode, ruleCompiler.Engine, ruleCompiler.Engine.WorkingMemory); } }
/// <summary> Add join nodes to the rule /// </summary> public virtual void addJoinNode(BaseJoin node) { joins.Add(node); }
public virtual void clear() { reteNode = null; }
/// <summary> The first step is to connect the exist join to the parent on the left side. /// The second step is to connect it to the parent on the right. For the right /// side, if the objectCondition doesn't have any nodes, we attach it to the /// objectType node. /// </summary> public void connectJoinNode(ICondition previousCondition, ICondition condition, BaseJoin previousJoinNode, BaseJoin joinNode) { if (previousJoinNode != null) { ruleCompiler.attachJoinNode(previousJoinNode, (BaseJoin)joinNode); } else { ruleCompiler.attachJoinNode(previousCondition.LastNode, (BaseJoin)joinNode); } // Current we have to Add the ExistJoin for the right side, which should be either // an alphaNode or the objectTypeNode ObjectCondition oc = getObjectCondition(condition); ObjectTypeNode otn = ruleCompiler.findObjectTypeNode(oc.TemplateName); if (oc.Nodes.Count > 0) { ruleCompiler.attachJoinNode(oc.LastNode, (BaseJoin)joinNode); } else { otn.addSuccessorNode(joinNode, ruleCompiler.Engine, ruleCompiler.Engine.WorkingMemory); } }
public virtual void connectJoinNode(ICondition previousCondition, ICondition condition, BaseJoin previousJoinNode, BaseJoin joinNode) { if (previousJoinNode != null) { ruleCompiler.attachJoinNode(previousJoinNode, (BaseJoin)joinNode); } else { ruleCompiler.attachJoinNode(previousCondition.LastNode, (BaseJoin)joinNode); } }
public virtual void connectJoinNode(ICondition previousCondition, ICondition condition, BaseJoin previousJoinNode, BaseJoin joinNode) { if (previousJoinNode != null) { ruleCompiler.attachJoinNode(previousJoinNode, (BaseJoin) joinNode); } else { ruleCompiler.attachJoinNode(previousCondition.LastNode, (BaseJoin) joinNode); } }