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