public new Trigger Clone() { Trigger c = new Trigger(op, type, literal.Copy()); c.predicateIndicatorCache = predicateIndicatorCache; c.isTerm = isTerm; return(c); }
//public bool HasNext() //{ // if (needsUpdate) // Get(); // return current != null; //} //public Unifier Next() //{ // if (needsUpdate) // Get(); // if (current != null) // needsUpdate = true; // return current; //} private void Get() { needsUpdate = false; current = default; if (arch != null && !arch.IsRunning()) { return; } if (annotsOptions != null) { while (annotsOptions.MoveNext()) { Literal belToTry = belInBB.Copy().SetAnnots(null).AddAnnots(annotsOptions.Current); Unifier u = un.Clone(); if (u.UnifiesNoUndo(lit, belToTry)) { current = u; return; } } annotsOptions = null; } if (ruleIt != null) { while (ruleIt.MoveNext()) { Unifier ruleUn = ruleIt.Current; Literal rHead = rule.HeadCApply(ruleUn); UseDerefVars(rHead, ruleUn); rHead.MakeVarsAnnon(); Unifier unC = un.Clone(); if (unC.UnifiesNoUndo(lit, rHead)) { current = unC; return; } } ruleIt = null; } while (il.MoveNext()) { belInBB = il.Current; if (belInBB.IsRule()) { rule = (Rule)belInBB; if (cloneAnnon == null) { cloneAnnon = (Literal)lit.CApply(un); cloneAnnon.MakeVarsAnnon(); } Unifier ruleUn = new Unifier(); if (ruleUn.UnifiesNoUndo(cloneAnnon, rule)) { ruleIt = rule.GetBody().LogicalConsequence(ag, ruleUn); Get(); if (current != null) { return; } } else { if (nbAnnots > 0) { if (belInBB.HasAnnot()) { int nbAnnotsB = belInBB.GetAnnots().Count; if (nbAnnotsB >= nbAnnots) { annotsOptions = belInBB.GetAnnots().SubSets(nbAnnots); Get(); if (current != null) { return; } } } } else { Unifier u = un.Clone(); if (u.UnifiesNoUndo(lit, belInBB)) { current = u; return; } } } } } }