private TriggerAnnotation AnnotatePotentialCandidate(Expression expr) { bool expr_is_killer = false; HashSet<OldExpr> oldExprSet; if (cache.exprsInOldContext.TryGetValue(expr, out oldExprSet)) { // oldExpr has been set to the value found } else { oldExprSet = null; } var new_exprs = TriggerUtils.MaybeWrapInOld(TriggerUtils.PrepareExprForInclusionInTrigger(expr, out expr_is_killer), oldExprSet); // We expect there to be at least one "new_exprs". // We also expect that the computation of new_term.Variables, collected_terms, and children_contain_killers will be the // same for each of the "new_exprs". // Therefore, we use the values of these variables from the last iteration in the expression that is ultimately returned. TriggerTerm new_term = null; List<TriggerTerm> collected_terms = null; var children_contain_killers = false; foreach (var new_expr in new_exprs) { new_term = new TriggerTerm { Expr = new_expr, OriginalExpr = expr, Variables = CollectVariables(expr) }; collected_terms = CollectExportedCandidates(expr); children_contain_killers = CollectIsKiller(expr); if (!children_contain_killers) { // Add only if the children are not killers; the head has been cleaned up into non-killer form collected_terms.Add(new_term); } } Contract.Assert(new_term != null); // this checks our assumption that "new_exprs" contains at least one value. // This new node is a killer if its children were killers, or if it's non-cleaned-up head is a killer return new TriggerAnnotation(children_contain_killers || expr_is_killer, new_term.Variables, collected_terms); }
private TriggerAnnotation AnnotatePotentialCandidate(Expression expr) { bool expr_is_killer = false; var new_expr = TriggerUtils.MaybeWrapInOld(TriggerUtils.PrepareExprForInclusionInTrigger(expr, out expr_is_killer), cache.exprsInOldContext.Contains(expr)); var new_term = new TriggerTerm { Expr = new_expr, OriginalExpr = expr, Variables = CollectVariables(expr) }; List <TriggerTerm> collected_terms = CollectExportedCandidates(expr); var children_contain_killers = CollectIsKiller(expr); if (!children_contain_killers) { // Add only if the children are not killers; the head has been cleaned up into non-killer form collected_terms.Add(new_term); } // This new node is a killer if its children were killers, or if it's non-cleaned-up head is a killer return(new TriggerAnnotation(children_contain_killers || expr_is_killer, new_term.Variables, collected_terms)); }
internal static IEnumerable <TriggerMatch> SubexpressionsMatchingTrigger(this ComprehensionExpr quantifier, Expression trigger) { return(quantifier.AllSubExpressions(true, true, true) .Select(e => TriggerUtils.PrepareExprForInclusionInTrigger(e).MatchAgainst(trigger, quantifier.BoundVars, e)) .Where(e => e.HasValue).Select(e => e.Value)); }