/// <summary> /// Run controller /// </summary> public void RunController() { var stack = new UserStack <Vehicle>(16); _outputService.ShowVehicleEnumerable(stack); var counter = 1; foreach (var vehicle in _context.UserCollection.Vehicles) { _outputService.ShowStringWithLineBreak($"{counter++}. {vehicle.ModelName} заехало в гараж"); stack.Push(vehicle); } counter--; while (stack.Count != 0) { _outputService.ShowStringWithLineBreak($"{counter--}. {stack.Pop().ModelName} выехало из гаража"); } }
public void Clear() { UserStack.Clear(); BootStack.Clear(); }
public void Interpret(string code, bool printStack) { #if DEBUG var sw = Stopwatch.StartNew(); #endif SetupInterpreter(code); #if DEBUG Utils.PrintLabels(labels); #endif try { while (true) { // Break on EOF if (!Enumerator.MoveNext()) { break; } switch (Enumerator.Current) { case '&': ReadGlobal(); continue; case '"': ReadString(); continue; case '@': ReadLabel(); continue; case '/': SkipComment(); continue; case '.': case char c when char.IsDigit(c): ReadNumber(); continue; case char c when char.IsWhiteSpace(c): continue; default: ReadOperation()?.Operate(this); continue; } } } catch (Exception ex) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(ex); Console.ResetColor(); UserStack.Clear(); } #if DEBUG sw.Stop(); Utils.PrintGlobals(globals); Console.ForegroundColor = ConsoleColor.DarkGray; Console.WriteLine("Execution time: {0}ms", sw.ElapsedMilliseconds); Console.ResetColor(); #endif if (printStack) { Utils.PrintStack(UserStack); labels.Clear(); CallStack.Clear(); } }
public void Push(Collection <KeyMapping> usermaps, Collection <KeyMapping> bootmaps) { UserStack.Push(usermaps); BootStack.Push(bootmaps); }