Beispiel #1
0
        internal void Write(PexWriteMeta write)
        {
            write.WriteString(ReturnTypeName);
            write.WriteString(DocString);
            write.Writer.Write(RawUserFlags);
            write.Writer.Write((byte)Flags);

            write.Writer.Write((ushort)Parameters.Count);
            foreach (var parameter in Parameters)
            {
                parameter.Write(write);
            }

            write.Writer.Write((ushort)Locals.Count);
            foreach (var local in Locals)
            {
                local.Write(write);
            }

            write.Writer.Write((ushort)Instructions.Count);
            foreach (var instruction in Instructions)
            {
                instruction.Write(write);
            }
        }
Beispiel #2
0
        internal void Write(PexWriteMeta write)
        {
            write.WriteString(Name);
            write.WriteString(TypeName);
            write.WriteString(DocString);
            write.Writer.Write(RawUserFlags);

            var flags = (byte)Flags;

            write.Writer.Write(flags);

            if ((flags & 4) != 0)
            {
                write.WriteString(AutoVarName);
            }

            if ((flags & 5) == 1)
            {
                ReadHandler?.Write(write);
            }

            if ((flags & 6) == 2)
            {
                WriteHandler?.Write(write);
            }
        }
Beispiel #3
0
        private void WriteContent(PexWriteMeta write)
        {
            if (DebugInfo == null)
            {
                write.Writer.Write((byte)0);
            }
            else
            {
                write.Writer.Write((byte)1);
                DebugInfo.Write(write);
            }

            write.Writer.Write((ushort)UserFlags.NotNull().Count());
            for (byte i = 0; i < 32; i++)
            {
                var str = UserFlags[i];
                if (str == null)
                {
                    continue;
                }
                write.WriteString(str);
                write.Writer.Write(i);
            }

            write.Writer.Write((ushort)Objects.Count);
            foreach (var pexObject in Objects)
            {
                pexObject.Write(write);
            }
        }
Beispiel #4
0
        internal void Write(PexWriteMeta write)
        {
            write.Writer.Write((byte)VariableType);
            switch (VariableType)
            {
            case VariableType.Null:
                break;

            case VariableType.Identifier:
            case VariableType.String:
                write.WriteString(StringValue);
                break;

            case VariableType.Integer:
                write.Writer.Write(IntValue ?? int.MaxValue);
                break;

            case VariableType.Float:
                write.Writer.Write(FloatValue ?? float.MaxValue);
                break;

            case VariableType.Bool:
                write.Writer.Write(BoolValue ?? false);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Beispiel #5
0
        internal void Write(PexWriteMeta bw)
        {
            bw.Writer.Write(ModificationTime.ToUInt64());

            bw.Writer.Write((ushort)Functions.Count);
            foreach (var debugFunction in Functions)
            {
                debugFunction.Write(bw);
            }

            //F04 only
            if (_gameCategory != GameCategory.Fallout4)
            {
                return;
            }

            bw.Writer.Write((ushort)PropertyGroups.Count);
            foreach (var propertyGroup in PropertyGroups)
            {
                propertyGroup.Write(bw);
            }

            bw.Writer.Write((ushort)StructOrders.Count);
            foreach (var structOrder in StructOrders)
            {
                structOrder.Write(bw);
            }
        }
Beispiel #6
0
        internal void Write(BinaryWriter bw)
        {
            bw.Write(PexMagic);
            bw.Write(MajorVersion);
            bw.Write(MinorVersion);
            bw.Write(GameId);
            bw.Write(CompilationTime.ToUInt64());
            bw.Write(SourceFileName);
            bw.Write(Username);
            bw.Write(MachineName);

            var memoryTrib = new MemoryTributary();
            var bw2        = new PexWriter(memoryTrib, Encoding.UTF8, this._gameCategory.IsBigEndian());
            var writeMeta  = new PexWriteMeta(_gameCategory, bw2);

            WriteContent(writeMeta);

            bw.Write((ushort)writeMeta.Strings.Count);
            foreach (var pair in writeMeta.Strings
                     .OrderBy(x => x.Value))
            {
                bw.Write(pair.Key);
            }

            memoryTrib.Position = 0;
            memoryTrib.CopyTo(bw.BaseStream);
        }
Beispiel #7
0
        internal void Write(PexWriteMeta write)
        {
            write.WriteString(Name);
            write.WriteString(TypeName);
            write.Writer.Write(RawUserFlags);

            VariableData?.Write(write);
        }
Beispiel #8
0
        internal void Write(PexWriteMeta write)
        {
            write.WriteString(Name);

            //needed for later changing
            var currentPos = write.Writer.BaseStream.Position;

            write.Writer.Write(sizeof(uint));

            write.WriteString(ParentClassName);
            write.WriteString(DocString);

            if (write.Category == GameCategory.Fallout4)
            {
                write.Writer.Write(IsConst ? (byte)1 : (byte)0);
            }

            write.Writer.Write(RawUserFlags);
            write.WriteString(AutoStateName);

            if (write.Category == GameCategory.Fallout4)
            {
                write.Writer.Write((ushort)StructInfos.Count);
                foreach (var structInfo in StructInfos)
                {
                    structInfo.Write(write);
                }
            }

            write.Writer.Write((ushort)Variables.Count);
            foreach (var objectVariable in Variables)
            {
                objectVariable.Write(write);
            }

            write.Writer.Write((ushort)Properties.Count);
            foreach (var objectProperty in Properties)
            {
                objectProperty.Write(write);
            }

            write.Writer.Write((ushort)States.Count);
            foreach (var objectState in States)
            {
                objectState.Write(write);
            }

            //calculate object size, go back, change it and return to the current position
            var newPos = write.Writer.BaseStream.Position;

            write.Writer.BaseStream.Position = currentPos;

            var objectSize = newPos - currentPos;

            write.Writer.Write((uint)objectSize);

            write.Writer.BaseStream.Position = newPos;
        }
Beispiel #9
0
        internal void Write(PexWriteMeta write)
        {
            write.Writer.Write((byte)OpCode);

            foreach (var argument in Arguments)
            {
                argument.Write(write);
            }
        }
Beispiel #10
0
 internal void Write(PexWriteMeta write)
 {
     write.WriteString(Name);
     write.WriteString(TypeName);
     write.Writer.Write(RawUserFlags);
     Value?.Write(write);
     write.Writer.Write(IsConst);
     write.WriteString(DocString);
 }
Beispiel #11
0
 internal void Write(PexWriteMeta writer)
 {
     writer.WriteString(Name);
     writer.Writer.Write((ushort)Functions.Count);
     foreach (var namedFunction in Functions)
     {
         namedFunction.Write(writer);
     }
 }
Beispiel #12
0
 internal void Write(PexWriteMeta write)
 {
     write.WriteString(Name);
     write.Writer.Write((ushort)Members.Count);
     foreach (var infoMember in Members)
     {
         infoMember.Write(write);
     }
 }
Beispiel #13
0
        internal void Write(PexWriteMeta meta)
        {
            meta.WriteString(ObjectName);
            meta.WriteString(OrderName);
            meta.Writer.Write((ushort)Names.Count);

            foreach (var name in Names)
            {
                meta.WriteString(name);
            }
        }
Beispiel #14
0
        internal void Write(PexWriteMeta meta)
        {
            meta.WriteString(ObjectName);
            meta.WriteString(GroupName);
            meta.Writer.Write((ushort)PropertyNames.Count);

            foreach (var name in PropertyNames)
            {
                meta.WriteString(name);
            }
        }
Beispiel #15
0
        internal void Write(PexWriteMeta meta)
        {
            meta.WriteString(ObjectName);
            meta.WriteString(StateName);
            meta.WriteString(FunctionName);
            meta.Writer.Write((byte)FunctionType);

            meta.Writer.Write((ushort)Instructions.Count);
            foreach (var lineNumber in Instructions)
            {
                meta.Writer.Write(lineNumber);
            }
        }
Beispiel #16
0
 internal void Write(PexWriteMeta write)
 {
     write.WriteString(Name);
     write.WriteString(TypeName);
 }
Beispiel #17
0
 internal void Write(PexWriteMeta write)
 {
     write.WriteString(FunctionName);
     Function?.Write(write);
 }