Пример #1
0
Файл: Host.cs Проект: tupipa/vcc
        private static void RunPlugin(string fileName, StreamReader instream, VccOptions commandLineOptions)
        {
            HostEnvironment hostEnvironment = new HostEnvironment(commandLineOptions.PointerSize);

            hostEnvironment.Errors += new CciErrorHandler(commandLineOptions).HandleErrors;
            IName assemName = hostEnvironment.NameTable.GetNameFor(Path.GetFileNameWithoutExtension(fileName));
            IName docName   = hostEnvironment.NameTable.GetNameFor(Path.GetFileName(fileName));
            List <IAssemblyReference> assemblyReferences = new List <IAssemblyReference>();
            List <IModuleReference>   moduleReferences   = new List <IModuleReference>();

            assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.CoreAssemblySymbolicIdentity));
            assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.VccRuntimeAssemblyIdentity));
            List <VccSourceDocument> programSources = new List <VccSourceDocument>(1);
            VccAssembly          assem  = new VccAssembly(assemName, Path.GetFullPath(fileName), hostEnvironment, commandLineOptions, assemblyReferences, moduleReferences, programSources);
            VccCompilationHelper helper = new VccCompilationHelper(assem.Compilation);

            programSources.Add(new VccSourceDocument(helper, docName, Path.GetFullPath(fileName), instream));
            if (0 != Felt2Cast2Plugin(fileName, commandLineOptions, hostEnvironment, assem))
            {
                fileErrorCount++;
            }
        }
Пример #2
0
        private static int RunTest(CciErrorHandler errorHandler, string suiteName, string fileNameWithoutExt,
                               string test, VccOptions commandLineOptions, List<string> compilerParameters)
        {
            VccCommandLineHost.ResetErrorCount();
              string fileNameC = fileNameWithoutExt + ".c";
              string fileNameI = fileNameWithoutExt + ".i";

              StreamWriter tempStreamWriter = new StreamWriter(fileNameC);
              tempStreamWriter.Write(test);
              tempStreamWriter.Close();

              VccOptions options = new VccOptions();
              options.CopyFrom(commandLineOptions);

              if (compilerParameters != null)
            options = OptionParser.ParseCommandLineArguments(VccCommandLineHost.dummyHostEnvironment, compilerParameters, options);

              options.NoPreprocessor = false;
              options.CheckedArithmetic = true;
              options.RunTestSuite = true;
              options.FileNames = new List<string> { fileNameC };

              HostEnvironment hostEnvironment = new HostEnvironment(options.PointerSize);
              hostEnvironment.Errors += errorHandler.HandleErrors;

              bool errorsInPreprocessor;
              var f = CCompilerHelper.Preprocess(options, out errorsInPreprocessor);
              if (errorsInPreprocessor) return -1;
              var st = f.First();
              test = st.ReadToEnd();
              st.Close();
              File.Delete(fileNameC);
              // if (!options.KeepPreprocessorFiles) File.Delete(fileNameI);

              IName name = hostEnvironment.NameTable.GetNameFor(suiteName);
              List<IAssemblyReference> assemblyReferences = new List<IAssemblyReference>();
              List<IModuleReference> moduleReferences = new List<IModuleReference>();
              assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.CoreAssemblySymbolicIdentity));
              assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.VccRuntimeAssemblyIdentity));
              VccAssembly/*?*/ assem = null;
              if (hostEnvironment.previousDocument == null || compilerParameters == null ||
              !compilerParameters.Contains("/incremental"))
              {
            List<VccSourceDocument> programSources = new List<VccSourceDocument>(1);
            assem = new VccAssembly(name, "", hostEnvironment, options, assemblyReferences, moduleReferences, programSources);
            var helper = new VccCompilationHelper(assem.Compilation);
            programSources.Add(hostEnvironment.previousDocument = new VccSourceDocument(helper, name, name.ToString(), test));
              }
              VccCommandLineHost.ResetStartTime();
              return VccCommandLineHost.Felt2Cast2Plugin("testcase", options, hostEnvironment, assem);
        }
Пример #3
0
 private static void RunPlugin(string fileName, StreamReader instream, VccOptions commandLineOptions)
 {
     HostEnvironment hostEnvironment = new HostEnvironment(commandLineOptions.PointerSize);
       hostEnvironment.Errors += new CciErrorHandler(commandLineOptions).HandleErrors;
       IName assemName = hostEnvironment.NameTable.GetNameFor(Path.GetFileNameWithoutExtension(fileName));
       IName docName = hostEnvironment.NameTable.GetNameFor(Path.GetFileName(fileName));
       List<IAssemblyReference> assemblyReferences = new List<IAssemblyReference>();
       List<IModuleReference> moduleReferences = new List<IModuleReference>();
       assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.CoreAssemblySymbolicIdentity));
       assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.VccRuntimeAssemblyIdentity));
       List<VccSourceDocument> programSources = new List<VccSourceDocument>(1);
       VccAssembly assem = new VccAssembly(assemName, Path.GetFullPath(fileName), hostEnvironment, commandLineOptions, assemblyReferences, moduleReferences, programSources);
       VccCompilationHelper helper = new VccCompilationHelper(assem.Compilation);
       programSources.Add(new VccSourceDocument(helper, docName, Path.GetFullPath(fileName), instream));
       if (0 != Felt2Cast2Plugin(fileName, commandLineOptions, hostEnvironment, assem))
       {
       fileErrorCount++;
       }
 }
Пример #4
0
        private static int RunTest(CciErrorHandler errorHandler, string suiteName, string fileNameWithoutExt,
                                   string test, VccOptions commandLineOptions, List <string> compilerParameters)
        {
            VccCommandLineHost.ResetErrorCount();
            string fileNameC = fileNameWithoutExt + ".c";
            string fileNameI = fileNameWithoutExt + ".i";

            StreamWriter tempStreamWriter = new StreamWriter(fileNameC);

            tempStreamWriter.Write(test);
            tempStreamWriter.Close();

            VccOptions options = new VccOptions();

            options.CopyFrom(commandLineOptions);

            if (compilerParameters != null)
            {
                options = OptionParser.ParseCommandLineArguments(VccCommandLineHost.dummyHostEnvironment, compilerParameters, options);
            }

            options.NoPreprocessor    = false;
            options.CheckedArithmetic = true;
            options.RunTestSuite      = true;
            options.FileNames         = new List <string> {
                fileNameC
            };

            HostEnvironment hostEnvironment = new HostEnvironment(options.PointerSize);

            hostEnvironment.Errors += errorHandler.HandleErrors;

            bool errorsInPreprocessor;
            var  f = CCompilerHelper.Preprocess(options, out errorsInPreprocessor);

            if (errorsInPreprocessor)
            {
                return(-1);
            }
            var st = f.First();

            test = st.ReadToEnd();
            st.Close();
            File.Delete(fileNameC);
            // if (!options.KeepPreprocessorFiles) File.Delete(fileNameI);

            IName name = hostEnvironment.NameTable.GetNameFor(suiteName);
            List <IAssemblyReference> assemblyReferences = new List <IAssemblyReference>();
            List <IModuleReference>   moduleReferences   = new List <IModuleReference>();

            assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.CoreAssemblySymbolicIdentity));
            assemblyReferences.Add(hostEnvironment.LoadAssembly(hostEnvironment.VccRuntimeAssemblyIdentity));
            VccAssembly /*?*/ assem = null;

            if (hostEnvironment.previousDocument == null || compilerParameters == null ||
                !compilerParameters.Contains("/incremental"))
            {
                List <VccSourceDocument> programSources = new List <VccSourceDocument>(1);
                assem = new VccAssembly(name, "", hostEnvironment, options, assemblyReferences, moduleReferences, programSources);
                var helper = new VccCompilationHelper(assem.Compilation);
                programSources.Add(hostEnvironment.previousDocument = new VccSourceDocument(helper, name, name.ToString(), test));
            }
            VccCommandLineHost.ResetStartTime();
            return(VccCommandLineHost.Felt2Cast2Plugin("testcase", options, hostEnvironment, assem));
        }