示例#1
0
 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();
示例#2
0
 public void Store(InsnValue register, BigInteger value)
 {
     Debug.Assert(register.RegisterName != null);
     Registers[register.RegisterName] = value;
 }
示例#3
0
 public BigInteger Read(InsnValue insnValue)
 => insnValue.RegisterName == null
                             ? insnValue.Value
                             : Registers.TryGetValue(insnValue.RegisterName, out var val)
                                     ? val
                                     : 0;