예제 #1
0
        public List <string> Decompile(long[] data)
        {
            List <string>  decompiled = new List <string>();
            IntcodeContext context    = new IntcodeContext(data, IntcodeMode.None, "decompiled");

            while (context.InstructionPointer < data.Length)
            {
                if (Opcodes.ContainsKey(context.CurrentOpcode))
                {
                    Opcode opcode = Opcodes[context.CurrentOpcode];
                    decompiled.Add(opcode.Describe(context));
                    context.InstructionPointer += opcode.Params + 1;
                }
                else
                {
                    decompiled.Add($"{{ {context.Id} }} {context.InstructionPointer:0000}: Raw data [{context.Data[context.InstructionPointer]}]");
                    context.InstructionPointer++;
                }
            }
            return(decompiled);
        }