private TriggerAnnotation Annotate(Expression expr) { TriggerAnnotation cached; if (cache.annotations.TryGetValue(expr, out cached)) { return(cached); } expr.SubExpressions.Iter(e => Annotate(e)); TriggerAnnotation annotation; // TODO: Using ApplySuffix fixes the unresolved members problem in GenericSort if (IsPotentialTriggerCandidate(expr)) { annotation = AnnotatePotentialCandidate(expr); } else if (expr is QuantifierExpr) { annotation = AnnotateQuantifier((QuantifierExpr)expr); } else if (expr is LetExpr) { annotation = AnnotateLetExpr((LetExpr)expr); } else if (expr is IdentifierExpr) { annotation = AnnotateIdentifier((IdentifierExpr)expr); } else if (expr is ApplySuffix) { annotation = AnnotateApplySuffix((ApplySuffix)expr); } else if (expr is MatchExpr) { annotation = AnnotateMatchExpr((MatchExpr)expr); } else if (expr is ComprehensionExpr) { annotation = AnnotateComprehensionExpr((ComprehensionExpr)expr); } else if (expr is ConcreteSyntaxExpression || expr is LiteralExpr || expr is OldExpr || expr is ThisExpr || expr is BoxingCastExpr || expr is DatatypeValue || expr is MultiSetFormingExpr) { annotation = AnnotateOther(expr, false); } else { annotation = AnnotateOther(expr, true); } TriggerUtils.DebugTriggers("{0} ({1})\n{2}", Printer.ExprToString(expr), expr.GetType(), annotation); cache.annotations[expr] = annotation; return(annotation); }
private TriggerAnnotation Annotate(Expression expr) { TriggerAnnotation cached; if (cache.annotations.TryGetValue(expr, out cached)) { return cached; } TriggerAnnotation annotation = null; // TODO: Using ApplySuffix fixes the unresolved members problem in GenericSort if (expr is LetExpr) { var le = (LetExpr)expr; if (le.LHSs.All(p => p.Var != null) && le.Exact) { // Inline the let expression before doing trigger selection. annotation = Annotate(Translator.InlineLet(le)); } } if (annotation == null) { expr.SubExpressions.Iter(e => Annotate(e)); if (IsPotentialTriggerCandidate(expr)) { annotation = AnnotatePotentialCandidate(expr); } else if (expr is QuantifierExpr) { annotation = AnnotateQuantifier((QuantifierExpr)expr); } else if (expr is LetExpr) { annotation = AnnotateLetExpr((LetExpr)expr); } else if (expr is IdentifierExpr) { annotation = AnnotateIdentifier((IdentifierExpr)expr); } else if (expr is ApplySuffix) { annotation = AnnotateApplySuffix((ApplySuffix)expr); } else if (expr is MatchExpr) { annotation = AnnotateMatchExpr((MatchExpr)expr); } else if (expr is ComprehensionExpr) { annotation = AnnotateComprehensionExpr((ComprehensionExpr)expr); } else if (expr is ConcreteSyntaxExpression || expr is LiteralExpr || expr is ThisExpr || expr is BoxingCastExpr || expr is MultiSetFormingExpr) { annotation = AnnotateOther(expr, false); } else { annotation = AnnotateOther(expr, true); } } TriggerUtils.DebugTriggers("{0} ({1})\n{2}", Printer.ExprToString(expr), expr.GetType(), annotation); cache.annotations[expr] = annotation; return annotation; }
private TriggerAnnotation Annotate(Expression expr) { TriggerAnnotation cached; if (cache.annotations.TryGetValue(expr, out cached)) { return(cached); } expr.SubExpressions.Iter(e => Annotate(e)); TriggerAnnotation annotation; // TODO: Using ApplySuffix fixes the unresolved members problem in GenericSort if (expr is FunctionCallExpr || expr is SeqSelectExpr || expr is MultiSelectExpr || expr is MemberSelectExpr || expr is OldExpr || expr is ApplyExpr || expr is DisplayExpression || TranslateToFunctionCall(expr) || (expr is UnaryOpExpr && (((UnaryOpExpr)expr).Op == UnaryOpExpr.Opcode.Cardinality)) || // FIXME || ((UnaryOpExpr)expr).Op == UnaryOpExpr.Opcode.Fresh doesn't work, as fresh is a pretty tricky predicate when it's not about datatypes. See translator.cs:10944 (expr is BinaryExpr && (((BinaryExpr)expr).Op == BinaryExpr.Opcode.NotIn || ((BinaryExpr)expr).Op == BinaryExpr.Opcode.In) && !(((BinaryExpr)expr).E1 is DisplayExpression))) { annotation = AnnotatePotentialCandidate(expr); } else if (expr is QuantifierExpr) { annotation = AnnotateQuantifier((QuantifierExpr)expr); } else if (expr is LetExpr) { annotation = AnnotateLetExpr((LetExpr)expr); } else if (expr is IdentifierExpr) { annotation = AnnotateIdentifier((IdentifierExpr)expr); } else if (expr is ApplySuffix) { annotation = AnnotateApplySuffix((ApplySuffix)expr); } else if (expr is ComprehensionExpr) { annotation = AnnotateComprehensionExpr((ComprehensionExpr)expr); } else if (expr is ConcreteSyntaxExpression || expr is LiteralExpr || expr is OldExpr || expr is ThisExpr || expr is BoxingCastExpr || expr is DatatypeValue || expr is MultiSetFormingExpr) { annotation = AnnotateOther(expr, false); } else { annotation = AnnotateOther(expr, true); } TriggerUtils.DebugTriggers("{0} ({1})\n{2}", Printer.ExprToString(expr), expr.GetType(), annotation); cache.annotations[expr] = annotation; return(annotation); }