Beispiel #1
0
        /// <summary>
        /// Processes the file with the settings, definitions and the source manager specified.
        /// </summary>
        /// <param name="files">the file paths to be processed</param>
        /// <param name="settings">the settings that are used</param>
        /// <param name="defs">the definitions that are used</param>
        /// <returns>Returns a list of files that can be compiled in reverse order</returns>
        private ISourceScript[] Process(IFileContent[] files, Settings settings, IDefinitions defs)
        {
            Logger.Log(LogType.Log, "Preprocessing files: " + files.Unpack(", "), 1);
            Timer.GlobalTimer.Restart();
            IDefinitions definitions = defs ?? new Definitions();

            settings = settings ?? new Settings();
            SourceManager sm = new SourceManager(plugins);

            InitializePlugins(settings, definitions, sm);

            foreach (IFileContent file in files)
            {
                sm.SetLock(false);
                sm.TryCreateScript(out ISourceScript sss, sep, file, new ImportResult());
                sm.SetLock(true);
                sm.AddToTodo(sss);
            }

            ISourceScript ss = sm.NextItem;

            do
            {
                Logger.Log(LogType.Log, "Selecting Current File: " + ss.GetFileInterface().GetFilePath(), 2);


                if (!(ss as SourceScript).IsSourceLoaded)
                {
                    RunStages(this, ProcessStage.OnLoadStage, ss, sm, definitions);
                }

                Logger.Log(LogType.Log, $"Selecting File: {Path.GetFileName(ss.GetFileInterface().GetKey())}", 3);
                //RUN MAIN
                sm.SetLock(false);
                RunStages(this, ProcessStage.OnMain, ss, sm, definitions);
                sm.SetLock(true);
                sm.SetState(ss, ProcessStage.OnFinishUp);
                ss = sm.NextItem;
            } while (ss != null);


            ISourceScript[] ret = sm.GetList().ToArray();

            foreach (ISourceScript finishedScript in ret)
            {
                Logger.Log(LogType.Log,
                           $"Selecting File: {Path.GetFileName(finishedScript.GetFileInterface().GetKey())}", 3);
                RunStages(this, ProcessStage.OnFinishUp, finishedScript, sm, definitions);
            }

            Logger.Log(LogType.Log, "Finished Processing Files.", 2);


            return(ret);
        }
Beispiel #2
0
        /// <summary>
        /// Processes the file with the settings, definitions and the source manager specified.
        /// </summary>
        /// <param name="files">the file paths to be processed</param>
        /// <param name="settings">the settings that are used</param>
        /// <param name="defs">the definitions that are used</param>
        /// <returns>Returns a list of files that can be compiled in reverse order</returns>
        private ISourceScript[] Process(IFileContent[] files, Settings settings, IDefinitions defs)
        {
            Timer.GlobalTimer.Restart();
            //string dir = Directory.GetCurrentDirectory();
            IDefinitions definitions = defs ?? new Definitions();

            settings = settings ?? new Settings();
            SourceManager sm = new SourceManager(plugins);

            long old = Timer.MS;

            InitializePlugins(settings, definitions, sm);
            Logger.Log(PPLogType.Progress, Verbosity.Level1, "Finished Initializing {1} Plugins({0}ms)", Timer.MS - old,
                       plugins.Count);

            old = Timer.MS;
            foreach (IFileContent file in files)
            {
                sm.SetLock(false);
                sm.TryCreateScript(out ISourceScript sss, sep, file, new ImportResult());
                sm.SetLock(true);
                sm.AddToTodo(sss);
            }

            Logger.Log(PPLogType.Progress, Verbosity.Level1, "Loaded {1} Files in {0}ms", Timer.MS - old,
                       sm.GetTodoCount());

            Logger.Log(PPLogType.Log, Verbosity.Level1, "Starting Processing of Files: {0}", files.Unpack(", "));

            old = Timer.MS;
            ISourceScript ss = sm.NextItem;

            do
            {
                if (!(ss as SourceScript).IsSourceLoaded)
                {
                    RunStages(this, ProcessStage.OnLoadStage, ss, sm, definitions);
                }

                Logger.Log(PPLogType.Progress, Verbosity.Level1, "Remaining Files: {0}", sm.GetTodoCount());
                Logger.Log(PPLogType.Log, Verbosity.Level2, "Selecting File: {0}",
                           Path.GetFileName(ss.GetFileInterface().GetKey()));
                //RUN MAIN
                sm.SetLock(false);
                RunStages(this, ProcessStage.OnMain, ss, sm, definitions);
                sm.SetLock(true);
                sm.SetState(ss, ProcessStage.OnFinishUp);
                ss = sm.NextItem;
            } while (ss != null);


            //Directory.SetCurrentDirectory(dir);
            ISourceScript[] ret = sm.GetList().ToArray();
            Logger.Log(PPLogType.Log, Verbosity.Level1, "Finishing Up...");
            foreach (ISourceScript finishedScript in ret)
            {
                Logger.Log(PPLogType.Log, Verbosity.Level2, "Selecting File: {0}",
                           Path.GetFileName(finishedScript.GetFileInterface().GetKey()));
                RunStages(this, ProcessStage.OnFinishUp, finishedScript, sm, definitions);
            }
            Logger.Log(PPLogType.Log, Verbosity.Level1, "Finished Processing Files.");

            Logger.Log(PPLogType.Progress, Verbosity.Level1, "Processed {1} Files into {2} scripts in {0}ms",
                       Timer.MS - old, sm.GetList().Count, ret.Length);

            return(ret);
        }