Exemplo n.º 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);
            //    }
            //}
        }
Exemplo n.º 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);
            //    }
            //}
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 5
0
 public void Execute()
 {
     machine.Execute();
     state = new MachineState(machine.Registers, machine.Memory, machine.CurrentLine);
 }