예제 #1
0
            public void Init(List <string> list)
            {
                this.ops = new IOp[list.Count];

                for (int i = 0; i < this.ops.Length; i++)
                {
                    string[] s = list[i].Split(' ');

                    switch (s[0])
                    {
                    case "acc":
                        ACC a = new ACC(Int32.Parse(s[1]), this);
                        this.ops[i] = a;
                        break;

                    case "jmp":
                        JMP j = new JMP(Int32.Parse(s[1]), this);
                        this.ops[i] = j;
                        break;

                    case "nop":
                        NOP n = new NOP(Int32.Parse(s[1]), this);
                        this.ops[i] = n;
                        break;
                    }
                }
            }
예제 #2
0
            private void UndoFix(int idx)
            {
                if (ops[idx].GetType() == typeof(JMP))
                {
                    NOP n = new NOP(ops[idx].Value, this);
                    ops[idx] = n;
                }

                else if (ops[idx].GetType() == typeof(NOP))
                {
                    JMP j = new JMP(ops[idx].Value, this);
                    ops[idx] = j;
                }
            }
예제 #3
0
            private int FindFix(int idx)
            {
                for (int i = idx; i < ops.Length; i++)
                {
                    if (ops[i].GetType() == typeof(JMP))
                    {
                        NOP n = new NOP(ops[i].Value, this);
                        ops[i] = n;
                        return(i);
                    }

                    else if (ops[i].GetType() == typeof(NOP))
                    {
                        JMP j = new JMP(ops[i].Value, this);
                        ops[i] = j;
                        return(i);
                    }
                }

                return(idx);
            }