Beispiel #1
0
        public TacticReplaceStatus ExpandTacticByMember(out string expandedTactic)
        {
            expandedTactic = "";
            var l = Microsoft.Dafny.Tacny.TacnyDriver.GetTacticResultList();
            var x = _member as Method;

            if (x == null)
            {
                return(TacticReplaceStatus.NoTactic);
            }
            var sr        = new StringWriter();
            var printer   = new Printer(sr);
            var hasTactic = false;

            foreach (var stmt in x.Body.SubStatements)
            {
                var result = l.FirstOrDefault(pair => RefactoringUtil.TokenEquals(pair.Key, stmt.Tok));
                if (result.Key == null)
                {
                    printer.PrintStatement(stmt, 0);
                }
                else
                {
                    hasTactic = true;
                    result.Value.ForEach(foundStmt => printer.PrintStatement(foundStmt, 0));
                }
                sr.Write("\n");
            }
            expandedTactic = hasTactic ? sr.ToString() : "";
            return(TacticReplaceStatus.Success);
        }
Beispiel #2
0
        private TacticReplaceStatus ExpandSingleTacticCall(UpdateStmt us, out string expanded)
        {
            expanded = "";
            var l      = Interpreter.GetTacnyResultList();
            var result = l.FirstOrDefault(pair => RefactoringUtil.TokenEquals(pair.Key, us.Tok));

            if (result.Value == null)
            {
                return(TacticReplaceStatus.NoTactic);
            }
            var sr      = new StringWriter();
            var printer = new Printer(sr);

            result.Value.ForEach(stmt => printer.PrintStatement(stmt, 4));
            expanded = sr.ToString();
            return(!string.IsNullOrEmpty(expanded) ? TacticReplaceStatus.Success : TacticReplaceStatus.NoTactic);
        }
Beispiel #3
0
        private TacticReplaceStatus ExpandSingleTacticCall(Statement us, out string expanded)
        {
            expanded = "";
            var l      = Microsoft.Dafny.Tacny.TacnyDriver.GetTacticResultList();
            var result = l.FirstOrDefault(pair => RefactoringUtil.TokenEquals(pair.Key, us.Tok));

            if (result.Value == null)
            {
                return(TacticReplaceStatus.NoTactic);
            }
            var sr      = new StringWriter();
            var printer = new Printer(sr);

            foreach (var stmt in result.Value)
            {
                printer.PrintStatement(stmt, 4);
                sr.Write("\n");
            }
            expanded = sr.ToString();
            return(!string.IsNullOrEmpty(expanded) ? TacticReplaceStatus.Success : TacticReplaceStatus.NoTactic);
        }