Пример #1
0
Файл: Host.cs Проект: tupipa/vcc
        internal static int Felt2Cast2Plugin(string fileName, VccOptions commandLineOptions, HostEnvironment hostEnvironment, VccAssembly assem)
        {
            try
            {
                TransHelper.TransEnv helperenv;
                FSharp.Collections.FSharpList <CAST.Top> res;

                try
                {
                    swVisitor.Start();
                    helperenv = new TransEnv(hostEnvironment, commandLineOptions);
                    var visitor = new Microsoft.Research.Vcc.Visitor(assem.Compilation.ContractProvider, helperenv);

                    if (commandLineOptions.VerificationLocation != null)
                    {
                        var memberAtLoc = FindMemberNameByLocation(commandLineOptions.VerificationLocation, assem);
                        if (memberAtLoc != null)
                        {
                            commandLineOptions.Functions.Add(memberAtLoc);
                        }
                    }

                    try
                    {
                        if (commandLineOptions.AggressivePruning && (commandLineOptions.Functions.Count > 0 || commandLineOptions.FunctionsWithExactName.Count > 0))
                        {
                            var pruningRoots = new List <string>();
                            pruningRoots.AddRange(commandLineOptions.Functions.ConvertAll(FunctionOrTypeRoot));
                            pruningRoots.AddRange(commandLineOptions.FunctionsWithExactName.ConvertAll(FunctionOrTypeRoot));
                            visitor.VisitOnly(assem, pruningRoots);
                        }
                        else
                        {
                            ((ICodeVisitor)visitor).Visit(assem);
                        }
                    }
                    catch
                    {
                        if (helperenv.ShouldDumpStack)
                        {
                            throw;
                        }
                        return(0);
                    }

                    res = visitor.GetResult();
                }
                finally
                {
                    swVisitor.Stop();
                }

                if (fileErrorCount > 0)
                {
                    return(fileErrorCount);
                }

                try
                {
                    swPlugin.Start();
                    if (currentPlugin.IsModular())
                    {
                        var fv = currentPlugin.GetFunctionVerifier(fileName, helperenv, res);
                        if (helperenv.ShouldContinue && fileErrorCount == 0)
                        {
                            VerifyFunctions(commandLineOptions, fileName, assem.Name.ToString(), fv);
                        }
                    }
                    else
                    {
                        currentPlugin.Verify(fileName, helperenv, res);
                    }
                }
                finally
                {
                    errorCount    += fileErrorCount;
                    fileErrorCount = 0;
                    swPlugin.Stop();
                }

                return(0);
            }
            catch (ProverDiedException e)
            {
                // we might want to do something else for this one
                Logger.Instance.NewLine();
                Logger.Instance.Error(e.Message);
            }
            catch (UnexpectedProverOutputException e)
            {
                Logger.Instance.NewLine();
                Logger.Instance.Error(e.Message);
            }
            catch (Exception e)
            {
                Logger.Instance.NewLine();
                Logger.Instance.Error(e.Message);
            }

            return(-2);
        }
Пример #2
0
        internal static int Felt2Cast2Plugin(string fileName, VccOptions commandLineOptions, HostEnvironment hostEnvironment, VccAssembly assem)
        {
            try
              {

            TransHelper.TransEnv helperenv;
            FSharp.Collections.FSharpList<CAST.Top> res;

            try
            {
              swVisitor.Start();
              helperenv = new TransEnv(hostEnvironment, commandLineOptions);
              var visitor = new Microsoft.Research.Vcc.Visitor(assem.Compilation.ContractProvider, helperenv);

              if (commandLineOptions.VerificationLocation != null)
              {
            var memberAtLoc = FindMemberNameByLocation(commandLineOptions.VerificationLocation, assem);
            if (memberAtLoc != null)
            {
              commandLineOptions.Functions.Add(memberAtLoc);
            }
              }

              try
              {
            if (commandLineOptions.AggressivePruning && (commandLineOptions.Functions.Count > 0 || commandLineOptions.FunctionsWithExactName.Count > 0))
            {
              var pruningRoots = new List<string>();
              pruningRoots.AddRange(commandLineOptions.Functions.ConvertAll(FunctionOrTypeRoot));
              pruningRoots.AddRange(commandLineOptions.FunctionsWithExactName.ConvertAll(FunctionOrTypeRoot));
              visitor.VisitOnly(assem, pruningRoots);
            }
            else
              ((ICodeVisitor)visitor).Visit(assem);
              }
              catch
              {
            if (helperenv.ShouldDumpStack) throw;
            return 0;
              }

              res = visitor.GetResult();
            }
            finally
            {
              swVisitor.Stop();
            }

            if (fileErrorCount > 0) return fileErrorCount;

            try
            {
              swPlugin.Start();
              if (currentPlugin.IsModular())
              {
            var fv = currentPlugin.GetFunctionVerifier(fileName, helperenv, res);
            if (helperenv.ShouldContinue && fileErrorCount == 0)
              VerifyFunctions(commandLineOptions, fileName, assem.Name.ToString(), fv);
              }
              else
              {
            currentPlugin.Verify(fileName, helperenv, res);
              }
            }
            finally
            {
              errorCount += fileErrorCount;
              fileErrorCount = 0;
              swPlugin.Stop();
            }

            return 0;

              }
              catch (ProverDiedException e)
              {
            // we might want to do something else for this one
            Logger.Instance.NewLine();
            Logger.Instance.Error(e.Message);
              }
              catch (UnexpectedProverOutputException e)
              {
            Logger.Instance.NewLine();
            Logger.Instance.Error(e.Message);
              }
              catch (Exception e)
              {
            Logger.Instance.NewLine();
            Logger.Instance.Error(e.Message);
              }

              return -2;
        }