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);
}