Пример #1
0
 internal VccFunctionVerifier(VccPlugin parent, Microsoft.FSharp.Collections.FSharpList <CAST.Top> currentDecls, TransHelper.TransEnv env)
     : base(env, currentDecls)
 {
     this.currentDecls = currentDecls;
     this.parent       = parent;
     this.env          = env;
     if (!this.InitBoogie())
     {
         this.env.Error(Token.NoToken, 1000, "Boogie initialization failed.");
     }
 }
Пример #2
0
Файл: Host.cs Проект: tupipa/vcc
        private static Plugin InitializePlugin(VccOptions commandLineOptions)
        {
            try
            {
                string      pluginName     = null;
                Plugin      selectedPlugin = null;
                VCGenPlugin vcgenPlugin    = null;

                if (commandLineOptions.PluginOptions.Count != 0 || commandLineOptions.DisplayCommandLineHelp)
                {
                    pluginManager = new PluginManager(commandLineOptions);
                    string pluginDir = PathHelper.PluginDir;
                    if (pluginDir != null)
                    {
                        pluginManager.AddPluginDirectory(pluginDir);
                    }
                    pluginManager.Discover();
                    foreach (var opt in commandLineOptions.PluginOptions.Keys)
                    {
                        if (opt == "dir")
                        {
                            continue;
                        }
                        if (pluginName == null)
                        {
                            pluginName = opt;
                        }
                        else
                        {
                            Logger.Instance.Error("More than one plugin requested ('{0}' and '{1}').", pluginName, opt);
                            return(null);
                        }
                    }

                    if (pluginName != null)
                    {
                        foreach (var plugin in pluginManager.Plugins)
                        {
                            if (string.Compare(pluginName, plugin.Name(), true) == 0)
                            {
                                if (selectedPlugin != null)
                                {
                                    Logger.Instance.Error("More than one plugin matches '{0}'.", pluginName);
                                    return(null);
                                }
                                selectedPlugin = plugin;
                            }
                        }
                        if (selectedPlugin == null)
                        {
                            foreach (var plugin in pluginManager.VCGenPlugins)
                            {
                                if (string.Compare(pluginName, plugin.Name, true) == 0)
                                {
                                    if (vcgenPlugin != null)
                                    {
                                        Logger.Instance.Error("More than one VCGEN plugin matches '{0}'.", pluginName);
                                        return(null);
                                    }
                                    vcgenPlugin = plugin;
                                }
                            }

                            if (vcgenPlugin == null)
                            {
                                Logger.Instance.Error("Plugin '{0}' not found.", pluginName);
                                return(null);
                            }
                        }
                    }
                }

                if (selectedPlugin == null)
                {
                    selectedPlugin = new VccPlugin(vcgenPlugin);                 // the default
                }
                selectedPlugin.RegisterStopwatch(swTotal);
                selectedPlugin.RegisterStopwatch(swVisitor);
                selectedPlugin.RegisterStopwatch(swPlugin);
                selectedPlugin.RegisterStopwatch(swPrelude);
                selectedPlugin.MessageHandler.AddHandler(PrintPluginMessage);

                try
                {
                    swPlugin.Start();
                    selectedPlugin.UseOptions(new VccOptionWrapper(commandLineOptions));
                    if (pluginName != null)
                    {
                        selectedPlugin.UseCommandLineOptions(commandLineOptions.PluginOptions[pluginName]);
                    }
                }
                finally
                {
                    swPlugin.Stop();
                }

                return(selectedPlugin);
            }
            catch (System.Reflection.ReflectionTypeLoadException e)
            {
                foreach (Exception ex in e.LoaderExceptions)
                {
                    Logger.Instance.Error(ex.Message);
                    Logger.Instance.Error(ex.StackTrace);
                }
            }
            return(null);
        }
Пример #3
0
 internal VccFunctionVerifier(VccPlugin parent, Microsoft.FSharp.Collections.FSharpList<CAST.Top> currentDecls, TransHelper.TransEnv env)
     : base(env, currentDecls)
 {
     this.currentDecls = currentDecls;
       this.parent = parent;
       this.env = env;
       if (!this.InitBoogie()) this.env.Error(Token.NoToken, 1000, "Boogie initialization failed.");
 }
Пример #4
0
        private static Plugin InitializePlugin(VccOptions commandLineOptions)
        {
            try
              {
            string pluginName = null;
            Plugin selectedPlugin = null;
            VCGenPlugin vcgenPlugin = null;

            if (commandLineOptions.PluginOptions.Count != 0 || commandLineOptions.DisplayCommandLineHelp)
            {
              pluginManager = new PluginManager(commandLineOptions);
              string pluginDir = PathHelper.PluginDir;
              if (pluginDir != null) pluginManager.AddPluginDirectory(pluginDir);
              pluginManager.Discover();
              foreach (var opt in commandLineOptions.PluginOptions.Keys)
              {
            if (opt == "dir") continue;
            if (pluginName == null)
            {
              pluginName = opt;
            }
            else
            {
              Logger.Instance.Error("More than one plugin requested ('{0}' and '{1}').", pluginName, opt);
              return null;
            }
              }

              if (pluginName != null)
              {
            foreach (var plugin in pluginManager.Plugins)
            {
              if (string.Compare(pluginName, plugin.Name(), true) == 0)
              {
                if (selectedPlugin != null)
                {
                  Logger.Instance.Error("More than one plugin matches '{0}'.", pluginName);
                  return null;
                }
                selectedPlugin = plugin;
              }
            }
            if (selectedPlugin == null)
            {
              foreach (var plugin in pluginManager.VCGenPlugins)
              {
                if (string.Compare(pluginName, plugin.Name, true) == 0)
                {
                  if (vcgenPlugin != null)
                  {
                    Logger.Instance.Error("More than one VCGEN plugin matches '{0}'.", pluginName);
                    return null;
                  }
                  vcgenPlugin = plugin;
                }
              }

              if (vcgenPlugin == null)
              {
                Logger.Instance.Error("Plugin '{0}' not found.", pluginName);
                return null;
              }
            }
              }
            }

            if (selectedPlugin == null) selectedPlugin = new VccPlugin(vcgenPlugin); // the default

            selectedPlugin.RegisterStopwatch(swTotal);
            selectedPlugin.RegisterStopwatch(swVisitor);
            selectedPlugin.RegisterStopwatch(swPlugin);
            selectedPlugin.RegisterStopwatch(swPrelude);
            selectedPlugin.MessageHandler.AddHandler(PrintPluginMessage);

            try
            {
              swPlugin.Start();
              selectedPlugin.UseOptions(new VccOptionWrapper(commandLineOptions));
              if (pluginName != null)
            selectedPlugin.UseCommandLineOptions(commandLineOptions.PluginOptions[pluginName]);
            }
            finally
            {
              swPlugin.Stop();
            }

            return selectedPlugin;

              }
              catch (System.Reflection.ReflectionTypeLoadException e)
              {
            foreach (Exception ex in e.LoaderExceptions)
            {
              Logger.Instance.Error(ex.Message);
              Logger.Instance.Error(ex.StackTrace);
            }
              }
              return null;
        }