コード例 #1
0
        private static void AssertRun(GenerationResult result, IEnumerable <Expectation> expectations)
        {
            var machine = new PlottyMachine();

            machine.Load(result.Lines);

            while (machine.CanExecute)
            {
                machine.Execute();
            }

            //foreach (var expectation in expectations)
            //{
            //    var address = result.AddressMap[new Reference(expectation.Reference)];

            //    if (expectation.Operator == Operator.Equal)
            //    {
            //        machine.Memory[address].Should().Be(expectation.Value);
            //    }
            //    else
            //    {
            //        machine.Memory[address].Should().NotBe(expectation.Value);
            //    }
            //}
        }
コード例 #2
0
        private void AssertRun(string source, Expectation[] expectations)
        {
            var result = new PlottyCompiler()
                         .Compile(source)
                         .GenerationResult;

            var machine = new PlottyMachine();

            machine.Load(result.Lines);

            while (machine.CanExecute)
            {
                machine.Execute();
            }

            //foreach (var expectation in expectations)
            //{
            //    var address = result.AddressMap[new Reference(expectation.Reference)];

            //    if (expectation.Operator == Operator.Equal)
            //    {
            //        machine.Memory[address].Should().Be(expectation.Value);
            //    }
            //    else
            //    {
            //        machine.Memory[address].Should().NotBe(expectation.Value);
            //    }
            //}
        }
コード例 #3
0
        private static void Run(CompilationResult result)
        {
            var machine = new PlottyMachine();

            machine.Load(result.GenerationResult.Lines.ToList());
            while (machine.CanExecute)
            {
                machine.Execute();
            }

            System.Console.WriteLine();
            //ShowMachineState(machine, result);
        }
コード例 #4
0
        public async Task Execute(List <ILine> lines, CancellationToken ct)
        {
            History.Clear();
            PlottyMachine.Load(lines);

            while (PlottyMachine.CanExecute)
            {
                CurrentLine = new LineViewModel(PlottyMachine.LineNumber, PlottyMachine.CurrentLine);
                PlottyMachine.Execute();
                RefreshRegisters();
                //RefreshMemory();

                if (CurrentLine?.Line?.Instruction is StoreInstruction)
                {
                    RefreshConsole();
                }

                ct.ThrowIfCancellationRequested();
                await Task.Delay(Delay, ct);
            }
        }
コード例 #5
0
ファイル: MachineContext.cs プロジェクト: attackgithub/Plotty
 public MachineContext(string source)
 {
     machine = new PlottyMachine();
     machine.Load(new PlottyCompiler().Compile(source).GenerationResult.Lines);
 }