Exemplo n.º 1
0
        public static void SaveProgram(Stream s, SerializableFLProgram program, FLInstructionSet iset, string[] extraSteps,
                                       FLProgramHeader programHeader = null)
        {
            Byt3Serializer main = CreateLoader(iset);

            MemoryStream ms = new MemoryStream();

            if (!main.TryWritePacket(ms, program))
            {
                throw new FLDeserializationException("Can not parse stream");
            }

            if (programHeader == null)
            {
                programHeader = new FLProgramHeader("Program", "NONE", Version.Parse("0.0.0.1"));
            }

            FLHeader header = new FLHeader(FLVersions.HeaderVersion, FLVersions.SerializationVersion,
                                           FLVersions.CommonVersion, extraSteps);

            byte[] p = ms.ToArray();

            ms.Close();

            FLFileFormat file = new FLFileFormat(header, programHeader, p);

            if (!main.TryWritePacket(s, file))
            {
                throw new FLDeserializationException("Can not parse stream");
            }
        }
Exemplo n.º 2
0
        public override FLFileFormat DeserializePacket(PrimitiveValueWrapper s)
        {
            FLHeader header = flHs.DeserializePacket(s);

            if (!header.IsCompatible())
            {
                throw new FLDeserializationException("The Loaded Script is not compatible.");
            }

            FLProgramHeader programHeader = phs.DeserializePacket(s);

            byte[] program = s.ReadBytes();

            List <ExtraStage> extraStages = CreateExtraStages(header.ExtraSerializationSteps);

            for (int i = 0; i < extraStages.Count; i++)
            {
                program = extraStages[i].FromFile.Process(program);
            }

            return(new FLFileFormat(header, programHeader, program));
        }
Exemplo n.º 3
0
 public FLFileFormat(FLHeader compilerHeader, FLProgramHeader programHeader, byte[] program)
 {
     CompilerHeader = compilerHeader;
     Program        = program;
     ProgramHeader  = programHeader;
 }