Exemple #1
0
        /// <summary>
        /// Adds a name entry to the names section, defining a new names section
        /// if one doesn't exist already.
        /// </summary>
        /// <param name="entry">A name entry to add.</param>
        /// <returns>The index in the name section of the newly added name entry.</returns>
        public uint AddNameEntry(NameEntry entry)
        {
            var names = GetFirstSectionOrNull <NameSection>();

            if (names == null)
            {
                InsertSection(names = new NameSection());
            }
            names.Names.Add(entry);
            return((uint)names.Names.Count - 1);
        }
Exemple #2
0
        /// <summary>
        /// Reads the name section with the given header.
        /// </summary>
        /// <param name="Header">The section header.</param>
        /// <param name="Reader">The WebAssembly file reader.</param>
        /// <returns>The parsed section.</returns>
        public static NameSection ReadSectionPayload(SectionHeader Header, BinaryWasmReader Reader)
        {
            var  section  = new NameSection();
            long startPos = Reader.Position;

            while (Reader.Position - startPos < Header.PayloadLength)
            {
                // Read entries until we've read the entire section.
                section.Names.Add(NameEntry.Read(Reader));
            }
            return(section);
        }