private void Put() { switch (_mode) { case InterpreterMode.Normal: long y = _stack.SafePop(), x = _stack.SafePop(), v = _stack.SafePop(); var cell = new InstructionPointer() { X = (int)x, Y = (int)y }; _field[cell] = v; break; case InterpreterMode.String: _stack.Push(InstructionConverter.ToChar[Instruction.Put]); break; default: ThrowHelper.ThrowInvalidEnumValueException( nameof(_mode), nameof(InstructionPointerDirection)); break; } _ip.Move(); }
public CodeRunner(Field field) { _field = field; _ip = new InstructionPointer(); _mode = InterpreterMode.Normal; _stack = new Stack <long>(); _rnd = new Random(); _run = true; // '═' _separatorLine = new string((char)0x2550, Field.Width); _input = ""; _output = ""; }