Exemplo n.º 1
0
        public static IEnumerable <ProofState> EvalTopLevelTactic(ProofState state, Dictionary <IVariable, Type> variables,
                                                                  Statement tacticApplication, ApplySuffix aps, ErrorReporterDelegate errorDelegate, bool ifPartial)
        {
            Contract.Requires <ArgumentNullException>(Tcce.NonNull(variables));
            Contract.Requires <ArgumentNullException>(Tcce.NonNull(tacticApplication));
            Contract.Requires <ArgumentNullException>(state != null, "state");
            Contract.Requires(tacticApplication == null ||
                              tacticApplication is UpdateStmt || tacticApplication is InlineTacticBlockStmt);

            IEnumerable <ProofState> branches;

            if (state.InitState(tacticApplication, aps, variables, ifPartial) == false)
            {
                return(null);
            }

#if !TACNY_DEBUG
            try {
#endif
            if (state.GetErrHandler().Reporter.Count(ErrorLevel.Error) != 0)
            {
                var errs = CompoundErrorInformation.GenerateErrorInfoList(state);
                if (errorDelegate != null)
                {
                    foreach (var err in errs)
                    {
                        errorDelegate(err);
                    }
                }

                return(null);
            }
            branches = GenerateSolution(state, errorDelegate);

      #if !TACNY_DEBUG
        }

        catch (Exception e) {
            String msg;
            List <CompoundErrorInformation> errs;
            try {
                msg  = "Tactic unknown exception: " + e.Message;
                errs = CompoundErrorInformation.GenerateErrorInfoList(state, msg);
            } catch (Exception) {
                msg  = "Tactic exception";
                errs = new List <CompoundErrorInformation>();
            }

            if (errorDelegate != null)
            {
                foreach (var err in errs)
                {
                    errorDelegate(err);
                }
            }
            return(null);
        }
#endif

            return(branches);
        }