public static List <Instruction> ParseInput(string input) => input.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries) .Select(line => line.Split(' ')) .Select(args => new Instruction() { Type = (InstructionType)Enum.Parse(typeof(InstructionType), args[0], ignoreCase: true), Value1 = InsnValue.Parse(args[1]), Value2 = args.Length < 3 ? null : InsnValue.Parse(args[2]), }) .ToList();
public void Store(InsnValue register, BigInteger value) { Debug.Assert(register.RegisterName != null); Registers[register.RegisterName] = value; }
public BigInteger Read(InsnValue insnValue) => insnValue.RegisterName == null ? insnValue.Value : Registers.TryGetValue(insnValue.RegisterName, out var val) ? val : 0;