Ejemplo n.º 1
0
        /// <summary>
        /// Writes a textual representation of this WebAssembly file to the given text writer.
        /// Note that this representation is intended as a human-readable debugging format that may
        /// change at any time, not as a first-class textual WebAssembly module encoding.
        /// </summary>
        /// <param name="writer">The text writer use.</param>
        public void Dump(TextWriter writer)
        {
            writer.Write(
                "WebAssembly module; magic number: {0}, version number: {1}",
                DumpHelpers.FormatHex(Header.Magic),
                Header.Version);

            foreach (var section in Sections)
            {
                writer.WriteLine();
                section.Dump(writer);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Verifies that this version header is a WebAssembly version header for a known
        /// version.
        /// </summary>
        public void Verify()
        {
            if (Magic != WasmMagic)
            {
                throw new BadHeaderException(
                          this,
                          string.Format(
                              "Invalid magic number. Got '{0}', expected '{1}'.",
                              DumpHelpers.FormatHex(Magic),
                              DumpHelpers.FormatHex(WasmMagic)));
            }

            if (Version != PreMvpVersion && Version != MvpVersion)
            {
                throw new BadHeaderException(this, "Invalid version number '" + Version + "'.");
            }
        }