Exemple #1
0
 public void Clear()
 {
     Sessioninfos.Clear();
     Groups.Clear();
     Packages.Clear();
     Counters.Clear();
 }
Exemple #2
0
        internal override void OnSceneChanging()
        {
            _activeCoroutines.Clear();

            Flags.Clear();
            Counters.Clear();
            Timers.Clear();
        }
Exemple #3
0
        public void Build()
        {
            Counters.Clear();
            IsSucccessful = false;

            CompileStartTime = DateTime.Now;

            try
            {
                if (!Directory.Exists(LauncherSettings.TemporaryFolder))
                {
                    Directory.CreateDirectory(LauncherSettings.ImageFolder);
                }

                if (!Directory.Exists(LauncherSettings.ImageFolder))
                {
                    Directory.CreateDirectory(LauncherSettings.ImageFolder);
                }

                if (string.IsNullOrEmpty(LauncherSettings.SourceFiles[0]))
                {
                    Output("ERROR: Missing source file");
                    return;
                }
                else if (!File.Exists(LauncherSettings.SourceFiles[0]))
                {
                    Output($"File {LauncherSettings.SourceFiles[0]} does not exists");
                    return;
                }

                Compile();

                BuildImage();

                if (!string.IsNullOrWhiteSpace(LauncherSettings.NasmFile))
                {
                    LaunchNDISASM();
                }

                if (!string.IsNullOrWhiteSpace(LauncherSettings.AsmFile))
                {
                    GenerateASMFile();
                }

                IsSucccessful = true;
            }
            catch (Exception e)
            {
                IsSucccessful = false;
                Output($"Exception: {e}");
            }
            finally
            {
                //compiler = null;
            }
        }
Exemple #4
0
 public void Reset()
 {
     Controller = 7;
     Location   = 0;
     Sequence   = 0;
     Data.Reset();
     Position = (int)CardPosition.FaceDownAttack;
     Counters.Clear();
     Transform.position = Vector3.zero;
     MainGame.Instance.FrameActions.Add(Update);
 }
Exemple #5
0
        public async Task LoadCounters()
        {
            Counters.Clear();
            var counters = await service.GetAllCounters();

            foreach (var counter in counters)
            {
                var viewModel = new CounterViewModel(service, navigationService);
                viewModel.Prepare(counter);
                Counters.Add(viewModel);
            }
        }
    // usually used for when a creature is removed from the board
    // both clients know how to do this so no need for syncing
    public void ResetToBaseStatsWithoutSyncing()
    {
        if (GameManager.gameMode != GameManager.GameMode.online)
        {
            Debug.LogError("Do not call this unless gameMode is online");
            ResetToBaseStats(); // go ahead and call normal reset to base just to stop things from breaking
        }

        Health     = BaseHealth;
        AttackStat = BaseAttack;
        Range      = BaseRange;
        Movement   = BaseMovement;
        if (Counters != null) // counter controller will be null before awake is called (when card is created)
        {
            Counters.Clear();
        }
    }
Exemple #7
0
 public void ApplyGas()
 {
     Counters.Clear();
     Counters = new ObservableCollection <Counter>(CountersForGas);
     OnPropertyChanged(nameof(Counters));
 }
Exemple #8
0
        public void Compile()
        {
            Log.Clear();
            Counters.Clear();
            HasCompileError = true;

            var compiler = new MosaCompiler(GetCompilerExtensions());

            try
            {
                CompileStartTime = DateTime.Now;

                CompiledFile = Path.Combine(LauncherOptions.DestinationDirectory, $"{Path.GetFileNameWithoutExtension(LauncherOptions.SourceFile)}.bin");

                compiler.CompilerOptions.EnableSSA             = LauncherOptions.EnableSSA;
                compiler.CompilerOptions.EnableIROptimizations = LauncherOptions.EnableIROptimizations;
                compiler.CompilerOptions.EnableSparseConditionalConstantPropagation = LauncherOptions.EnableSparseConditionalConstantPropagation;
                compiler.CompilerOptions.EnableInlinedMethods   = LauncherOptions.EnableInlinedMethods;
                compiler.CompilerOptions.InlinedIRMaximum       = LauncherOptions.InlinedIRMaximum;
                compiler.CompilerOptions.EnableLongExpansion    = LauncherOptions.EnableLongExpansion;
                compiler.CompilerOptions.TwoPassOptimizations   = LauncherOptions.TwoPassOptimizations;
                compiler.CompilerOptions.EnableValueNumbering   = LauncherOptions.EnableValueNumbering;
                compiler.CompilerOptions.OutputFile             = CompiledFile;
                compiler.CompilerOptions.Architecture           = SelectArchitecture(LauncherOptions.PlatformType);
                compiler.CompilerOptions.LinkerFormatType       = LauncherOptions.LinkerFormatType;
                compiler.CompilerOptions.MultibootSpecification = LauncherOptions.MultibootSpecification;
                compiler.CompilerOptions.SetCustomOption("multiboot.video", LauncherOptions.VBEVideo ? "true" : "false");
                compiler.CompilerOptions.SetCustomOption("multiboot.width", LauncherOptions.Width.ToString());
                compiler.CompilerOptions.SetCustomOption("multiboot.height", LauncherOptions.Height.ToString());
                compiler.CompilerOptions.SetCustomOption("multiboot.depth", LauncherOptions.Depth.ToString());
                compiler.CompilerOptions.BaseAddress           = LauncherOptions.BaseAddress;
                compiler.CompilerOptions.EmitAllSymbols        = LauncherOptions.EmitAllSymbols;
                compiler.CompilerOptions.EmitStaticRelocations = LauncherOptions.EmitStaticRelocations;
                compiler.CompilerOptions.EnableMethodScanner   = LauncherOptions.EnableMethodScanner;
                compiler.CompilerOptions.EnableBitTracker      = LauncherOptions.EnableBitTracker;

                compiler.CompilerOptions.CreateExtraSections       = LauncherOptions.CreateExtraSections;
                compiler.CompilerOptions.CreateExtraProgramHeaders = LauncherOptions.CreateExtraProgramHeaders;

                if (LauncherOptions.GenerateMapFile)
                {
                    compiler.CompilerOptions.MapFile = Path.Combine(LauncherOptions.DestinationDirectory, $"{Path.GetFileNameWithoutExtension(LauncherOptions.SourceFile)}.map");
                }

                if (LauncherOptions.GenerateCompileTimeFile)
                {
                    compiler.CompilerOptions.CompileTimeFile = Path.Combine(LauncherOptions.DestinationDirectory, $"{Path.GetFileNameWithoutExtension(LauncherOptions.SourceFile)}-time.txt");
                }

                if (LauncherOptions.GenerateDebugFile)
                {
                    var debugFile = LauncherOptions.DebugFile ?? Path.GetFileNameWithoutExtension(LauncherOptions.SourceFile) + ".debug";

                    compiler.CompilerOptions.DebugFile = Path.Combine(LauncherOptions.DestinationDirectory, debugFile);
                }

                if (!Directory.Exists(LauncherOptions.DestinationDirectory))
                {
                    Directory.CreateDirectory(LauncherOptions.DestinationDirectory);
                }

                compiler.CompilerTrace.SetTraceListener(traceListener);

                if (string.IsNullOrEmpty(LauncherOptions.SourceFile))
                {
                    AddOutput("Please select a source file");
                    return;
                }
                else if (!File.Exists(LauncherOptions.SourceFile))
                {
                    AddOutput($"File {LauncherOptions.SourceFile} does not exists");
                    return;
                }

                compiler.CompilerOptions.AddSourceFile(LauncherOptions.SourceFile);
                compiler.CompilerOptions.AddSearchPaths(LauncherOptions.Paths);

                var inputFiles = new List <FileInfo>
                {
                    (LauncherOptions.HuntForCorLib) ? HuntFor("mscorlib.dll") : null,
                    (LauncherOptions.PlugKorlib) ? HuntFor("Mosa.Plug.Korlib.dll") : null,
                    (LauncherOptions.PlugKorlib) ? HuntFor("Mosa.Plug.Korlib." + LauncherOptions.PlatformType.ToString() + ".dll"): null,
                };

                compiler.CompilerOptions.AddSourceFiles(inputFiles);
                compiler.CompilerOptions.AddSearchPaths(inputFiles);

                compiler.Load();
                compiler.Initialize();
                compiler.Setup();

                // TODO Include Unit Tests

                if (LauncherOptions.EnableMultiThreading)
                {
                    compiler.ThreadedCompile();
                }
                else
                {
                    compiler.Compile();
                }

                Linker     = compiler.Linker;
                TypeSystem = compiler.TypeSystem;

                if (LauncherOptions.ImageFormat == ImageFormat.ISO)
                {
                    if (LauncherOptions.BootLoader == BootLoader.Grub_0_97 || LauncherOptions.BootLoader == BootLoader.Grub_2_00)
                    {
                        CreateISOImageWithGrub(CompiledFile);
                    }
                    else                     // assuming syslinux
                    {
                        CreateISOImageWithSyslinux(CompiledFile);
                    }
                }
                else
                {
                    CreateDiskImage(CompiledFile);

                    if (LauncherOptions.ImageFormat == ImageFormat.VMDK)
                    {
                        CreateVMDK();
                    }
                }

                if (LauncherOptions.GenerateNASMFile)
                {
                    LaunchNDISASM();
                }

                if (LauncherOptions.GenerateASMFile)
                {
                    GenerateASMFile();
                }

                HasCompileError = false;
            }
            catch (Exception e)
            {
                HasCompileError = true;
                AddOutput(e.ToString());
            }
            finally
            {
                compiler = null;
            }
        }
Exemple #9
0
        public void Compile()
        {
            HasCompileError = true;
            Log.Clear();
            Counters.Clear();

            var compiler = new MosaCompiler();

            try
            {
                CompileStartTime = DateTime.Now;

                CompiledFile = Path.Combine(Options.DestinationDirectory, $"{Path.GetFileNameWithoutExtension(Options.SourceFile)}.bin");

                compiler.CompilerFactory = delegate { return(new AotCompiler()); };

                compiler.CompilerOptions.EnableSSA             = Options.EnableSSA;
                compiler.CompilerOptions.EnableIROptimizations = Options.EnableIROptimizations;
                compiler.CompilerOptions.EnableSparseConditionalConstantPropagation = Options.EnableSparseConditionalConstantPropagation;
                compiler.CompilerOptions.EnableInlinedMethods = Options.EnableInlinedMethods;
                compiler.CompilerOptions.InlinedIRMaximum     = Options.InlinedIRMaximum;
                compiler.CompilerOptions.OutputFile           = CompiledFile;

                compiler.CompilerOptions.Architecture     = SelectArchitecture(Options.PlatformType);
                compiler.CompilerOptions.LinkerFormatType = Options.LinkerFormatType;
                compiler.CompilerOptions.BootStageFactory = GetBootStageFactory(Options.BootFormat);

                compiler.CompilerOptions.SetCustomOption("multiboot.video", Options.VBEVideo ? "true" : "false");
                compiler.CompilerOptions.SetCustomOption("multiboot.width", Options.Width.ToString());
                compiler.CompilerOptions.SetCustomOption("multiboot.height", Options.Height.ToString());
                compiler.CompilerOptions.SetCustomOption("multiboot.depth", Options.Depth.ToString());

                compiler.CompilerOptions.BaseAddress     = Options.BaseAddress;
                compiler.CompilerOptions.EmitSymbols     = Options.EmitSymbols;
                compiler.CompilerOptions.EmitRelocations = Options.EmitRelocations;

                compiler.CompilerOptions.SetCustomOption("x86.irq-methods", Options.Emitx86IRQMethods ? "true" : "false");

                if (Options.GenerateMapFile)
                {
                    compiler.CompilerOptions.MapFile = Path.Combine(Options.DestinationDirectory, $"{Path.GetFileNameWithoutExtension(Options.SourceFile)}.map");
                }

                if (!Directory.Exists(Options.DestinationDirectory))
                {
                    Directory.CreateDirectory(Options.DestinationDirectory);
                }

                compiler.CompilerTrace.TraceListener = traceListener;

                if (string.IsNullOrEmpty(Options.SourceFile))
                {
                    AddOutput("Please select a source file");
                    return;
                }
                else if (!File.Exists(Options.SourceFile))
                {
                    AddOutput($"File {Options.SourceFile} does not exists");
                    return;
                }

                var inputFiles = new List <FileInfo>();
                inputFiles.Add(new FileInfo(Options.SourceFile));

                compiler.Load(inputFiles);

                var threads = Options.UseMultipleThreadCompiler ? Environment.ProcessorCount : 1;
                compiler.Execute(threads);

                Linker     = compiler.Linker;
                TypeSystem = compiler.TypeSystem;

                if (Options.ImageFormat == ImageFormat.ISO)
                {
                    if (Options.BootLoader == BootLoader.Grub_0_97 || Options.BootLoader == BootLoader.Grub_2_00)
                    {
                        CreateISOImageWithGrub(CompiledFile);
                    }
                    else                     // assuming syslinux
                    {
                        CreateISOImageWithSyslinux(CompiledFile);
                    }
                }
                else
                {
                    CreateDiskImage(CompiledFile);

                    if (Options.ImageFormat == ImageFormat.VMDK)
                    {
                        CreateVMDK(ImageFile);
                    }
                }

                HasCompileError = false;

                if (Options.GenerateNASMFile)
                {
                    LaunchNDISASM();
                }

                if (Options.GenerateASMFile)
                {
                    GenerateASMFile();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
            finally
            {
                compiler.Dispose();
                compiler = null;
            }
        }
Exemple #10
0
 public void Dispose()
 {
     HttpClient.Dispose();
     Counters.Clear();
 }
Exemple #11
0
 internal override void OnSceneChanging()
 {
     Flags.Clear();
     Counters.Clear();
     Timers.Clear();
 }
Exemple #12
0
        public async Task Parse(string[] files, bool recursive, int?max, CancellationToken token)
        {
            _logger.LogInformation($"Parsing files, Recursive={recursive}, Max={max}, {(files.Select(x => $"File: {x}").ToStringVector(Environment.NewLine))}");

            using var monitorToken = CancellationTokenSource.CreateLinkedTokenSource(token);
            Stopwatch sw = Stopwatch.StartNew();

            Console.CancelKeyPress += (sender, e) =>
            {
                e.Cancel = false;
                monitorToken.Cancel();
            };

            var parseOption = new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = 20, BoundedCapacity = 1000
            };
            var batchOption = new GroupingDataflowBlockOptions {
                BoundedCapacity = 1000
            };
            var writeOption = new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = 1, BoundedCapacity = 1000
            };
            var linkOption = new DataflowLinkOptions {
                PropagateCompletion = true
            };

            TransformBlock <string, NmeaRecord?> toParse     = new TransformBlock <string, NmeaRecord?>(x => _parseNmea.Parse(x), parseOption);
            BatchBlock <NmeaRecord?>             toSaveBatch = new BatchBlock <NmeaRecord?>(100, batchOption);
            ActionBlock <NmeaRecord?[]>          toSave      = new ActionBlock <NmeaRecord?[]>(x => _store.Write(x), writeOption);

            toParse.LinkTo(toSaveBatch, linkOption);
            _ = toParse.Completion.ContinueWith(delegate { toSaveBatch.Complete(); });

            toSaveBatch.LinkTo(toSave, linkOption);
            _ = toSaveBatch.Completion.ContinueWith(delegate { toSave.Complete(); });

            _counters.Clear();
            _tracking.Load();

            _counters.Sampler = x =>
            {
                x.Set(Counter.ToParseIn, toParse.InputCount);
                x.Set(Counter.ToParseOut, toParse.OutputCount);
                x.Set(Counter.ToSaveIn, toParse.InputCount);
                x.Set(Counter.ToSaveOut, toParse.OutputCount);
            };

            // Start the process
            IReadOnlyList <string> readFiles = files
                                               .SelectMany(x => _fileReader.GetFiles(x !, true))
                                               .Select(x => _tracking.Check(x))
                                               .Where(x => x != null)
                                               .TakeWhile((x, i) => max == null || i < (int)max)
                                               .ToList() !;

            _counters.Monitor(monitorToken.Token);
            _counters.Set(Counter.FileQueued, readFiles.Count);

            foreach (var file in readFiles)
            {
                if (monitorToken.IsCancellationRequested)
                {
                    break;
                }

                _tracking.Add(file);
                await _fileReader.ReadFile(file, toParse);
            }

            toParse.Complete();
            await toSave.Completion;

            await _counters.Completion(monitorToken.Token);

            _logger.LogInformation("Shutting down");
            monitorToken.Cancel();

            _store.Close();
            _tracking.Save();

            // Report on performance
            sw.Stop();
            _logger.LogInformation($"Final: {_counters.FinalScore(sw.Elapsed)}");
        }