示例#1
0
        public static void PrintStatement(ref Text fInput, ref Win32FileWriter fOutput, int iRecords, string strDefaultIndentation)
        {
            int indentations = 0;
            for (int r = 0; r < iRecords; r++)
            {
                long iOpCode = fInput.GetInt64();

                string strPrefixNeg = "";
                if ((iOpCode & 0x80000000) != 0)
                {
                    strPrefixNeg = "neg|";
                    iOpCode ^= 0x80000000;
                }
                string strPrefixThisOrNext = "";
                if ((iOpCode & 0x40000000) != 0)
                {
                    strPrefixThisOrNext = "this_or_next|";
                    iOpCode ^= 0x40000000;
                }

                var op = FindOperator((int)(iOpCode & 0xFFFF));

                if (iOpCode == 4 || iOpCode == 6 || iOpCode == 7 || iOpCode == 11 || iOpCode == 12 || iOpCode == 15 || iOpCode == 16 || iOpCode == 17 ||
                    iOpCode == 18)
                    indentations++;
                if (iOpCode == 3)
                    indentations--;

                var strIdentations = iOpCode == 4 || iOpCode == 5 || iOpCode == 6 || iOpCode == 7 || iOpCode == 11 || iOpCode == 12 || iOpCode == 15 || iOpCode == 16 || iOpCode == 17 ||
                                      iOpCode == 18 ? GetIndentations(indentations - 1) : GetIndentations(indentations);

                string strOpCode = null;
                if (strPrefixNeg != "" && iOpCode >= 30 && iOpCode <= 32)
                {
                    switch (iOpCode)
                    {
                        case 30:
                            strOpCode = "lt";
                            break;
                        case 31:
                            strOpCode = "neq";
                            break;
                        case 32:
                            strOpCode = "le";
                            break;
                    }
                    fOutput.Write("{0}{1}({2}{3}", strIdentations, strDefaultIndentation, strPrefixThisOrNext, strOpCode);
                }
                else
                {
                    /*try
                    {
                        strOpCode = Operations[iOpCode];
                    }
                    catch (Exception)
                    {
                        strOpCode = Convert.ToString(iOpCode);
                    }*/

                    //strOpCode = Operations.ContainsKey(iOpCode) ? Operations[iOpCode] :
                    //    CustomOperations.HaveCommand((int)(iOpCode & 0x1FFF)) ? CustomOperations.GetCommandName((int)(iOpCode & 0x1FFF)) : Convert.ToString(iOpCode);
                    strOpCode = op.Value;
                    fOutput.Write("{0}{1}({2}{3}{4}", strIdentations, strDefaultIndentation, strPrefixNeg, strPrefixThisOrNext, strOpCode);
                }
                
                int iParams = fInput.GetInt();
                for (int p = 0; p < iParams; p++)
                {
                    string strParam = fInput.GetWord();
                    fOutput.Write(", {0}", op.GetParameter(p, strParam));
                }
                fOutput.WriteLine("),");

            }
        }