예제 #1
0
        private static string FormatSet(ushort[] image, int pc)
        {
            int    num  = (int)image[pc++];
            int    num2 = ((int)image[pc++] << 4) - 1;
            string str  = "[";
            bool   flag = false;
            char   c    = '\0';

            for (int i = 0; i <= num2; i++)
            {
                bool flag2 = ((int)image[pc + (i >> 4)] & 1 << (i & 15)) != 0;
                if (flag2 & !flag)
                {
                    c    = (char)(num + i);
                    flag = true;
                }
                else if (flag & (!flag2 || i == num2))
                {
                    char c2 = (char)(num + i - 1);
                    str += Disassembler.FormatChar(c);
                    if (c2 != c)
                    {
                        str = str + "-" + Disassembler.FormatChar(c2);
                    }
                    flag = false;
                }
            }
            return(str + "]");
        }
예제 #2
0
        public static string DisassembleOp(ushort[] image, int pc)
        {
            OpCode  opCode;
            OpFlags opFlags;

            PatternCompiler.DecodeOp(image[pc], out opCode, out opFlags);
            string text = opCode.ToString();

            if (opFlags != OpFlags.None)
            {
                text = text + "[" + opFlags.ToString("f") + "]";
            }
            switch (opCode)
            {
            case OpCode.Position:
                text = text + " /" + (Position)image[pc + 1];
                break;

            case OpCode.String:
                text = text + " '" + Disassembler.ReadString(image, pc + 1) + "'";
                break;

            case OpCode.Reference:
            case OpCode.Open:
            case OpCode.Close:
                text = text + " " + image[pc + 1];
                break;

            case OpCode.Character:
                text = text + " '" + Disassembler.FormatChar((char)image[pc + 1]) + "'";
                break;

            case OpCode.Category:
            case OpCode.NotCategory:
                text = text + " /" + (Category)image[pc + 1];
                break;

            case OpCode.Range:
                text = text + " '" + Disassembler.FormatChar((char)image[pc + 1]) + "', ";
                text = text + " '" + Disassembler.FormatChar((char)image[pc + 2]) + "'";
                break;

            case OpCode.Set:
                text = text + " " + Disassembler.FormatSet(image, pc + 1);
                break;

            case OpCode.In:
            case OpCode.Sub:
            case OpCode.Branch:
            case OpCode.Jump:
                text = text + " :" + Disassembler.FormatAddress(pc + (int)image[pc + 1]);
                break;

            case OpCode.Balance:
            {
                string text2 = text;
                text = string.Concat(new object[]
                    {
                        text2,
                        " ",
                        image[pc + 1],
                        " ",
                        image[pc + 2]
                    });
                break;
            }

            case OpCode.IfDefined:
            case OpCode.Anchor:
                text = text + " :" + Disassembler.FormatAddress(pc + (int)image[pc + 1]);
                text = text + " " + image[pc + 2];
                break;

            case OpCode.Test:
                text = text + " :" + Disassembler.FormatAddress(pc + (int)image[pc + 1]);
                text = text + ", :" + Disassembler.FormatAddress(pc + (int)image[pc + 2]);
                break;

            case OpCode.Repeat:
            case OpCode.FastRepeat:
            {
                text = text + " :" + Disassembler.FormatAddress(pc + (int)image[pc + 1]);
                string text2 = text;
                text = string.Concat(new object[]
                    {
                        text2,
                        " (",
                        image[pc + 2],
                        ", "
                    });
                if (image[pc + 3] == 65535)
                {
                    text += "Inf";
                }
                else
                {
                    text += image[pc + 3];
                }
                text += ")";
                break;
            }

            case OpCode.Info:
            {
                text = text + " " + image[pc + 1];
                string text2 = text;
                text = string.Concat(new object[]
                    {
                        text2,
                        " (",
                        image[pc + 2],
                        ", ",
                        image[pc + 3],
                        ")"
                    });
                break;
            }
            }
            return(text);
        }