예제 #1
0
 private Solution ResolveTactic(List <IVariable> variables, List <IVariable> resolved, UpdateStmt us, MemberDecl md, WhileStmt ws = null)
 {
     try
     {
         var prog   = Util.ObjectExtensions.Copy(_tacnyProgram);
         var result = Atomic.ResolveTactic(us, md, prog, variables, resolved, ws);
         prog.PrintDebugData(prog.CurrentDebug);
         return(result);
     } catch (Exception e) {
         Printer.Error(e.Message);
         return(null);
     }
 }
예제 #2
0
        private string ScanMemberBody(MemberDecl md)
        {
            Contract.Requires(md != null);
            solution_list.plist.Clear();
            Method m = md as Method;

            if (m == null)
            {
                return(null);
            }
            if (m.Body == null)
            {
                return(null);
            }

            List <IVariable> variables = new List <IVariable>();

            variables.AddRange(m.Ins);
            variables.AddRange(m.Outs);
            SolutionList sol_list = new SolutionList();

            sol_list.AddRange(solution_list.plist);
            if (TacnyOptions.O.ParallelExecution)
            {
                Parallel.ForEach(m.Body.Body, st =>
                {
                    // register local variables
                    VarDeclStmt vds = st as VarDeclStmt;
                    if (vds != null)
                    {
                        variables.AddRange(vds.Locals);
                    }

                    UpdateStmt us = st as UpdateStmt;
                    if (us != null)
                    {
                        if (tacnyProgram.IsTacticCall(us))
                        {
                            try
                            {
                                tacnyProgram.SetCurrent(tacnyProgram.GetTactic(us), md);
                                // get the resolved variables
                                List <IVariable> resolved = tacnyProgram.GetResolvedVariables(md);
                                resolved.AddRange(m.Ins);     // add input arguments as resolved variables
                                Atomic.ResolveTactic(tacnyProgram.GetTactic(us), us, md, tacnyProgram, variables, resolved, ref sol_list);
                                tacnyProgram.CurrentDebug.Fin();
                            }
                            catch (AggregateException e)
                            {
                                foreach (var err in e.Data)
                                {
                                    Printer.Error(err.ToString());
                                }
                            }
                        }
                    }
                });
            }
            else
            {
                foreach (var st in m.Body.Body)
                {
                    // register local variables
                    VarDeclStmt vds = st as VarDeclStmt;
                    if (vds != null)
                    {
                        variables.AddRange(vds.Locals);
                    }

                    UpdateStmt us = st as UpdateStmt;
                    if (us != null)
                    {
                        if (tacnyProgram.IsTacticCall(us))
                        {
                            try
                            {
                                tacnyProgram.SetCurrent(tacnyProgram.GetTactic(us), md);
                                // get the resolved variables
                                List <IVariable> resolved = tacnyProgram.GetResolvedVariables(md);
                                resolved.AddRange(m.Ins); // add input arguments as resolved variables
                                Atomic.ResolveTactic(tacnyProgram.GetTactic(us), us, md, tacnyProgram, variables, resolved, ref sol_list);
                                tacnyProgram.CurrentDebug.Fin();
                            }
                            catch (Exception e)
                            {
                                return(e.Message);
                            }
                        }
                    }
                }
            }
            solution_list.AddRange(sol_list.plist);
            return(null);
        }