Пример #1
0
        internal override void Serialize(IDefinitionWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            writer.WriteValueU8((byte)this.Visibility);
            writer.WriteValueU32((uint)this.Flags);

            if ((this.Flags & FunctionFlags.IsNative) == 0)
            {
                writer.WriteReference(this.SourceFile);
                writer.WriteValueU32(this.SourceLine);
            }

            if ((this.Flags & FunctionFlags.HasReturnValue) != 0)
            {
                writer.WriteReference(this.ReturnType);
                writer.WriteValueB8(this.Unknown50);
            }

            if ((this.Flags & FunctionFlags.Unknown8) != 0)
            {
                writer.WriteReference(this.Unknown58);
            }

            if ((this.Flags & FunctionFlags.HasParameters) != 0)
            {
                writer.WriteReferences(this.Parameters);
            }
            if ((this.Flags & FunctionFlags.HasLocals) != 0)
            {
                writer.WriteReferences(this.Locals);
            }
            if ((this.Flags & FunctionFlags.Unknown6) != 0)
            {
                writer.WriteValueU32(this.Unknown98);
            }
            if ((this.Flags & FunctionFlags.Unknown12) != 0)
            {
                writer.WriteValueU8(this.UnknownA0);
            }
            if ((this.Flags & FunctionFlags.HasBody) != 0)
            {
                var bodySizePosition = writer.Position;
                writer.WriteValueU32(uint.MaxValue);
                var bodySize    = Instructions.Write(writer, this.Body);
                var endPosition = writer.Position;
                writer.Position = bodySizePosition;
                writer.WriteValueU32(bodySize);
                writer.Position = endPosition;
            }
        }
Пример #2
0
        internal override void Serialize(IDefinitionWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            writer.WriteValueU8(this.Unknown2A);
            writer.WriteValueU8(this.Size);
            writer.WriteReferences(this.Enumerals);
            writer.WriteValueB8(this.Unknown29);
        }
Пример #3
0
 internal static uint Write(object argument, IDefinitionWriter writer)
 {
     var (type, unknown) = (DynamicCast)argument;
     writer.WriteReference(type);
     writer.WriteValueU8(unknown);
     return 9;
 }
Пример #4
0
 internal static uint Write(object argument, IDefinitionWriter writer)
 {
     var(type, size) = (EnumCast)argument;
     writer.WriteReference(type);
     writer.WriteValueU8(size);
     return(9);
 }
Пример #5
0
 public static uint Write(object argument, IDefinitionWriter writer)
 {
     var(bytes, unknown) = ((byte[], byte))argument;
     writer.WriteBytes(bytes);
     writer.WriteValueU8(unknown);
     return((uint)bytes.Length + 5);
 }
Пример #6
0
 internal static uint Write(object argument, IDefinitionWriter writer)
 {
     var(parameterCount, type) = (Constructor)argument;
     writer.WriteValueU8(parameterCount);
     writer.WriteReference(type);
     return(9);
 }
Пример #7
0
        internal override void Serialize(IDefinitionWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            writer.WriteReference(this.Type);
            writer.WriteValueU8(this.Unknown28);
        }
Пример #8
0
 public static uint Write(object argument, IDefinitionWriter writer)
 {
     var(unknown0, unknown1, unknown2, unknown3, unknown4, unknown5) = ((ushort, uint, ushort, ushort, byte, ulong))argument;
     writer.WriteValueU16(unknown0);
     writer.WriteValueU32(unknown1);
     writer.WriteValueU16(unknown2);
     writer.WriteValueU16(unknown3);
     writer.WriteValueU8(unknown4);
     writer.WriteValueU64(unknown5);
     return(19);
 }
Пример #9
0
        internal override void Serialize(IDefinitionWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            writer.WriteValueU8((byte)this.NativeType);

            if (HasBaseType(this.NativeType) == true)
            {
                writer.WriteReference(this.BaseType);
            }

            if (this.NativeType == NativeType.StaticArray)
            {
                writer.WriteValueU32(this.ArraySize);
            }
        }
        internal static uint Write(Instruction instruction, IDefinitionWriter writer)
        {
            var op = instruction.Op;

            uint size = 0;

            writer.WriteValueU8((byte)op);
            size++;

            if (_Lookup.TryGetValue(op, out var handler) == false)
            {
                throw new FormatException($"no handler for {op}");
            }

            if (handler.write != null)
            {
                size += handler.write(instruction.Argument, writer);
            }

            return(size);
        }
Пример #11
0
        internal override void Serialize(IDefinitionWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            writer.WriteValueU8((byte)this.Visibility);
            writer.WriteValueU16((ushort)this.Flags);
            writer.WriteReference(this.BaseClass);
            if ((this.Flags & ClassFlags.HasFunctions) != 0)
            {
                writer.WriteReferences(this.Functions);
            }
            if ((this.Flags & ClassFlags.Unknown5) != 0)
            {
                writer.WriteReferences(this.Unknown20s);
            }
            if ((this.Flags & ClassFlags.Unknown8) != 0)
            {
                writer.WriteReferences(this.Unknown30s);
            }
        }
Пример #12
0
 public static uint Write(object argument, IDefinitionWriter writer)
 {
     writer.WriteValueU8((byte)argument);
     return(1);
 }