Ejemplo n.º 1
0
 /// <summary>
 /// Reads the section with the given header.
 /// </summary>
 /// <param name="Header">The section header.</param>
 /// <returns>The parsed section.</returns>
 public Section ReadSectionPayload(SectionHeader Header)
 {
     if (Header.Name.IsCustom)
     {
         return(ReadCustomSectionPayload(Header));
     }
     else
     {
         return(ReadKnownSectionPayload(Header));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Reads the custom section with the given header.
 /// </summary>
 /// <param name="Header">The section header.</param>
 /// <returns>The parsed section.</returns>
 protected virtual Section ReadCustomSectionPayload(SectionHeader Header)
 {
     if (Header.Name.CustomName == NameSection.CustomName)
     {
         return(NameSection.ReadSectionPayload(Header, this));
     }
     else
     {
         return(new CustomSection(
                    Header.Name.CustomName,
                    ReadBytes((int)Header.PayloadLength)));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads the non-custom section with the given header.
        /// </summary>
        /// <param name="Header">The section header.</param>
        /// <returns>The parsed section.</returns>
        protected Section ReadKnownSectionPayload(SectionHeader Header)
        {
            switch (Header.Name.Code)
            {
            case SectionCode.Type:
                return(TypeSection.ReadSectionPayload(Header, this));

            case SectionCode.Import:
                return(ImportSection.ReadSectionPayload(Header, this));

            case SectionCode.Function:
                return(FunctionSection.ReadSectionPayload(Header, this));

            case SectionCode.Table:
                return(TableSection.ReadSectionPayload(Header, this));

            case SectionCode.Memory:
                return(MemorySection.ReadSectionPayload(Header, this));

            case SectionCode.Global:
                return(GlobalSection.ReadSectionPayload(Header, this));

            case SectionCode.Export:
                return(ExportSection.ReadSectionPayload(Header, this));

            case SectionCode.Start:
                return(StartSection.ReadSectionPayload(Header, this));

            case SectionCode.Element:
                return(ElementSection.ReadSectionPayload(Header, this));

            case SectionCode.Code:
                return(CodeSection.ReadSectionPayload(Header, this));

            case SectionCode.Data:
                return(DataSection.ReadSectionPayload(Header, this));

            default:
                return(ReadUnknownSectionPayload(Header));
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Reads the unknown, non-custom section with the given header.
 /// </summary>
 /// <param name="Header">The section header.</param>
 /// <returns>The parsed section.</returns>
 protected virtual Section ReadUnknownSectionPayload(SectionHeader Header)
 {
     return(new UnknownSection(
                Header.Name.Code,
                ReadBytes((int)Header.PayloadLength)));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Reads the remaining payload of the section whose payload starts at the given position.
 /// </summary>
 /// <param name="StartPosition">The start of the section's payload.</param>
 /// <param name="Header">The section's header.</param>
 /// <returns>The remaining payload of the section whose payload starts at the given position.</returns>
 public byte[] ReadRemainingPayload(long StartPosition, SectionHeader Header)
 {
     return(ReadRemainingPayload(StartPosition, Header.PayloadLength));
 }