示例#1
0
 public SerializeData Parser(byte[] data)
 {
     using (var stream = new MemoryStream(data)) {
         using (var reader = new BinaryReader(stream)) {
             reader.ReadByte();
             ConstDouble = new double[reader.ReadInt32()];
             for (var i = 0; i < ConstDouble.Length; ++i)
             {
                 ConstDouble[i] = reader.ReadDouble();
             }
             ConstLong = new long[reader.ReadInt32()];
             for (var i = 0; i < ConstLong.Length; ++i)
             {
                 ConstLong[i] = reader.ReadInt64();
             }
             ConstString = new string[reader.ReadInt32()];
             for (var i = 0; i < ConstString.Length; ++i)
             {
                 ConstString[i] = ReadString(reader);
             }
             Context   = ReadFunction(reader);
             Functions = new ScriptFunctionData[reader.ReadInt32()];
             for (var i = 0; i < Functions.Length; ++i)
             {
                 Functions[i] = ReadFunction(reader);
             }
             Classes = new ScriptClassData[reader.ReadInt32()];
             for (var i = 0; i < Classes.Length; ++i)
             {
                 Classes[i] = ReadClass(reader);
             }
             return(this);
         }
     }
 }
示例#2
0
 void WriterFunction(BinaryWriter writer, ScriptFunctionData data)
 {
     writer.Write(data.parameterCount);
     writer.Write(data.param ? (byte)1 : (byte)0);
     writer.Write(data.variableCount);
     writer.Write(data.internalCount);
     writer.Write(data.internals.Length);
     Array.ForEach(data.internals, (value) => writer.Write(value));
     writer.Write(data.scriptInstructions.Length);
     Array.ForEach(data.scriptInstructions, (value) => {
         writer.Write((int)value.opcode);
         writer.Write(value.opvalue);
         writer.Write(value.line);
     });
 }
示例#3
0
 public SerializeData(double[] constDouble, long[] constLong, string[] constString, ScriptFunctionData context, ScriptFunctionData[] functions, ScriptClassData[] classes)
 {
     this.ConstDouble = constDouble;
     this.ConstLong   = constLong;
     this.ConstString = constString;
     this.Context     = context;
     this.Functions   = functions;
     this.Classes     = classes;
 }