Ejemplo n.º 1
0
        public virtual void dump(PrettyPrinter printer)
        {
            switch (type)
            {
            case ObjectType.False:
                printer.addLine("false");
                break;

            case ObjectType.None:
                printer.addLine("None");
                break;

            case ObjectType.True:
                printer.addLine("true");
                break;

            default:
                printer.addLine("Error!");
                break;
            }
        }
Ejemplo n.º 2
0
 public override void dump(PrettyPrinter printer)
 {
     printer.addLine("[PyBuffer " + Data.Length + " bytes]" + PrettyPrinter.PrintRawData(this));
     if (Data != null && (Data[0] == Unmarshal.HeaderByte || Data[0] == Unmarshal.ZlibMarker || Data[0] == 0x63))
     {
         byte[] d = Data;
         if (d[0] == Unmarshal.ZlibMarker)
         {
             d = Zlib.Decompress(d);
         }
         if (d != null && (d[0] == Unmarshal.PythonMarker || d[0] == 0x63) && printer.decompilePython && d.Length > 60)
         {
             // We have a python file.
             Bytecode code = new Bytecode();
             if (code.load(d, d[0] == 0x63))
             {
                 Python.PrettyPrinter pp = new Python.PrettyPrinter();
                 pp.indentLevel = printer.indentLevel + 1;
                 pp.indent      = printer.indent;
                 code.dump(pp);
                 printer.addLine(pp.dump);
             }
         }
         else if (d != null && d[0] == Unmarshal.HeaderByte)
         {
             Unmarshal un  = new Unmarshal();
             PyRep     rep = un.Process(d);
             if (rep != null)
             {
                 if (Data[0] == Unmarshal.ZlibMarker)
                 {
                     printer.addLine("<compressed-data>");
                 }
                 printer.addItem(rep);
             }
         }
     }
 }
Ejemplo n.º 3
0
 public void dump(PrettyPrinter printer)
 {
     printer.addLine("Length: " + length.ToString() + " bytes.");
     items.dump(printer);
 }
Ejemplo n.º 4
0
        public override void dump(PrettyPrinter printer)
        {
            string name = "Unknown";

            if (opCode == MarshalOpcode.StringEmpty)
            {
                name = "PyStringEmpty";
            }
            else if (opCode == MarshalOpcode.StringChar)
            {
                name = "PyStringChar";
            }
            else if (opCode == MarshalOpcode.WStringUTF8)
            {
                name = "PyWStringUTF8";
            }
            else if (opCode == MarshalOpcode.WStringUCS2Char)
            {
                name = "PyWStringUCS2Char";
            }
            else if (opCode == MarshalOpcode.WStringEmpty)
            {
                name = "PyWStringEmpty";
            }
            else if (opCode == MarshalOpcode.WStringUCS2)
            {
                name = "PyWStringUCS2";
            }
            else if (opCode == MarshalOpcode.StringShort)
            {
                name = "PyString";
            }
            else if (opCode == MarshalOpcode.StringLong)
            {
                name = "PyString";
            }
            else if (opCode == MarshalOpcode.StringTable)
            {
                name = "PyStringTable[" + tableIndex.ToString() + "]";
            }

            bool printed = false;

            if (Raw.Length > 0 && (Raw[0] == (byte)Unmarshal.ZlibMarker || Raw[0] == (byte)Unmarshal.HeaderByte || Raw[0] == Unmarshal.PythonMarker || Raw[0] == 0x63))
            {
                // We have serialized python data, decode and display it.
                byte[] d = Raw;
                if (d[0] == Unmarshal.ZlibMarker)
                {
                    d = Zlib.Decompress(d);
                }
                if (d != null && (d[0] == Unmarshal.PythonMarker || d[0] == 0x63) && printer.decompilePython && d.Length > 60)
                {
                    // We have a python file.
                    Bytecode code = new Bytecode();
                    if (code.load(d, d[0] == 0x63))
                    {
                        printer.addLine("[" + name);
                        Python.PrettyPrinter pp = new Python.PrettyPrinter();
                        pp.indent      = printer.indent;
                        pp.indentLevel = printer.indentLevel + 1;
                        code.dump(pp);
                        printer.addLine(pp.dump);
                        printer.addLine("]");
                        printed = true;
                    }
                }
                else if (d != null && d[0] == Unmarshal.HeaderByte)
                {
                    Unmarshal un = new Unmarshal();
                    un.analizeInput = decodedAnalized;
                    PyRep obj = un.Process(d);
                    if (obj != null)
                    {
                        string sType = "<serialized>";
                        if (Raw[0] == Unmarshal.ZlibMarker)
                        {
                            sType = "<serialized-compressed>";
                        }
                        printer.addLine("[" + name + " " + sType);
                        printer.addItem(obj);
                        printer.addLine("]");
                        printed = true;
                    }
                }
            }
            if (!printed)
            {
                if (!PrettyPrinter.containsBinary(Raw))
                {
                    printer.addLine("[" + name + " \"" + Value + "\"]");
                }
                else
                {
                    printer.addLine("[" + name + " \"" + Value + "\"");
                    printer.indentLevel += 2;
                    printer.addLine("<binary len=" + Value.Length + "> hex=\"" + PrettyPrinter.ByteArrayToString(Raw) + "\"]");
                    printer.indentLevel -= 2;
                }
            }
        }
Ejemplo n.º 5
0
 public override void dump(PrettyPrinter printer)
 {
     printer.addLine("<Module '" + name + " from ' (" + source + ")>");
 }
Ejemplo n.º 6
0
 public override void dump(PrettyPrinter printer)
 {
     printer.addLine("{String: " + str + "}");
 }
Ejemplo n.º 7
0
 public override void dump(PrettyPrinter printer)
 {
     printer.addLine("#{Ref: " + index.ToString() + ":dec}");
 }
Ejemplo n.º 8
0
 public override void dump(PrettyPrinter printer)
 {
     printer.addLine("{" + value.ToString() + "}");
 }