コード例 #1
0
        //////////////////////////////////////////////
        // Private guys -- need not bother about these
        //////////////////////////////////////////////

        protected override Program getInput(ProgTransformation.PersistentProgram inp)
        {
            PersistentCBAProgram ap = inp as PersistentCBAProgram;

            Debug.Assert(ap != null);

            return(ap.getCBAProgram());
        }
コード例 #2
0
        // Remove all procs in "procsToRemove" from the program, and replace calls to these procedures by
        // assume false
        public static PersistentCBAProgram prune(PersistentCBAProgram pprogram, HashSet <string> procsToRemove)
        {
            if (procsToRemove.Count == 0)
            {
                return(pprogram);
            }

            // Go through all Commands and remove calls
            CBAProgram program = pprogram.getCBAProgram();

            foreach (var decl in program.TopLevelDeclarations)
            {
                if (!(decl is Implementation))
                {
                    continue;
                }
                var impl = decl as Implementation;
                foreach (Block blk in impl.Blocks)
                {
                    for (int i = 0; i < blk.Cmds.Count; i++)
                    {
                        if (isCall(blk.Cmds[i], procsToRemove))
                        {
                            blk.Cmds[i] = new AssumeCmd(Token.NoToken, Expr.False);
                        }
                    }
                }
            }

            // Remove declarations and implementations
            var newDecls = new List <Declaration>();

            foreach (var decl in program.TopLevelDeclarations)
            {
                if (decl is Implementation)
                {
                    if (procsToRemove.Contains((decl as Implementation).Name))
                    {
                        continue;
                    }
                }
                else if (decl is Procedure)
                {
                    if (procsToRemove.Contains((decl as Procedure).Name))
                    {
                        continue;
                    }
                }
                newDecls.Add(decl);
            }

            program.TopLevelDeclarations = newDecls;
            return(new PersistentCBAProgram(program, program.mainProcName, program.contextBound));
        }
コード例 #3
0
        public static PersistentCBAProgram AddLoopBounds(PersistentCBAProgram program, Dictionary <string, int> extraRecBounds)
        {
            if (extraRecBounds.Count == 0 || extraRecBounds.All(tup => tup.Value == 0))
            {
                return(program);
            }

            var prog = program.getCBAProgram();

            AddLoopBounds(prog, extraRecBounds);
            return(new PersistentCBAProgram(prog, prog.mainProcName, prog.contextBound));
        }