/// <summary> /// Writes this exported value to the given WebAssembly file writer. /// </summary> /// <param name="Writer">The WebAssembly file writer.</param> public void WriteTo(BinaryWasmWriter Writer) { Writer.WriteVarUInt32(MemoryIndex); Offset.WriteTo(Writer); Writer.WriteVarUInt32((uint)Data.Length); Writer.Writer.Write(Data); }
/// <summary> /// Writes this exported value to the given WebAssembly file writer. /// </summary> /// <param name="Writer">The WebAssembly file writer.</param> public void WriteTo(BinaryWasmWriter Writer) { Writer.WriteString(ModuleName); Writer.WriteString(FieldName); Writer.Writer.Write((byte)Kind); WriteContentsTo(Writer); }
/// <summary> /// Writes this WebAssembly file to the given stream using the binary WebAssembly file encoding. /// </summary> /// <param name="target">The stream to write to.</param> public void WriteBinaryTo(Stream target) { var writer = new BinaryWriter(target); var wasmWriter = new BinaryWasmWriter(writer); wasmWriter.WriteFile(this); }
/// <inheritdoc/> public override void WritePayloadTo(BinaryWasmWriter Writer) { foreach (var entry in Names) { entry.WriteTo(Writer); } }
/// <summary> /// Writes this WebAssembly section's optional custom name and payload to the given /// WebAssembly writer. /// </summary> /// <param name="Writer">The writer to which the custom name and payload are written.</param> internal void WriteCustomNameAndPayloadTo(BinaryWasmWriter Writer) { if (Name.IsCustom) { Writer.WriteString(Name.CustomName); } WritePayloadTo(Writer); }
/// <summary> /// Writes this instruction's child instructions to the given WebAssembly file writer, /// followed by an 'end' opcode. /// </summary> /// <param name="writer">The writer to write this instruction's child instructions to.</param> public void WriteContentsTo(BinaryWasmWriter writer) { foreach (var instr in Contents) { instr.WriteTo(writer); } writer.Writer.Write(Operators.EndOpCode); }
/// <inheritdoc/> public override void WritePayloadTo(BinaryWasmWriter writer) { writer.WriteVarUInt32((uint)Segments.Count); foreach (var segment in Segments) { segment.WriteTo(writer); } writer.Writer.Write(ExtraPayload); }
/// <inheritdoc/> public override void WritePayloadTo(BinaryWasmWriter writer) { writer.WriteVarUInt32((uint)Exports.Count); foreach (var export in Exports) { export.WriteTo(writer); } writer.Writer.Write(ExtraPayload); }
/// <summary> /// Writes this WebAssembly section's payload to the given binary WebAssembly writer. /// </summary> /// <param name="writer">The writer to which the payload is written.</param> public override void WritePayloadTo(BinaryWasmWriter writer) { writer.WriteVarUInt32((uint)GlobalVariables.Count); foreach (var index in GlobalVariables) { index.WriteTo(writer); } writer.Writer.Write(ExtraPayload); }
/// <summary> /// Writes this instruction's immediates (but not its opcode) /// to the given WebAssembly file writer. /// </summary> /// <param name="writer">The writer to write this instruction's immediates to.</param> public override void WriteImmediatesTo(BinaryWasmWriter writer) { writer.WriteVarUInt32((uint)TargetTable.Count); foreach (var entry in TargetTable) { writer.WriteVarUInt32(entry); } writer.WriteVarUInt32(DefaultTarget); }
/// <inheritdoc/> public override void WritePayloadTo(BinaryWasmWriter Writer) { Writer.WriteVarUInt32((uint)Bodies.Count); foreach (var body in Bodies) { body.WriteTo(Writer); } Writer.Writer.Write(ExtraPayload); }
/// <inheritdoc/> public override void WritePayloadTo(BinaryWasmWriter Writer) { Writer.WriteVarUInt32((uint)Segments.Count); foreach (var export in Segments) { export.WriteTo(Writer); } Writer.Writer.Write(ExtraPayload); }
/// <summary> /// Writes this WebAssembly section's payload to the given binary WebAssembly writer. /// </summary> /// <param name="writer">The writer to which the payload is written.</param> public override void WritePayloadTo(BinaryWasmWriter writer) { writer.WriteVarUInt32((uint)FunctionTypes.Count); foreach (var index in FunctionTypes) { writer.WriteVarUInt32(index); } writer.Writer.Write(ExtraPayload); }
/// <summary> /// Writes these resizable limits to the given WebAssembly file writer. /// </summary> /// <param name="writer">The WebAssembly file writer.</param> public void WriteTo(BinaryWasmWriter writer) { writer.WriteVarUInt1(HasMaximum); writer.WriteVarUInt32(Initial); if (HasMaximum) { writer.WriteVarUInt32(Maximum.Value); } }
/// <inheritdoc/> public override void WritePayloadTo(BinaryWasmWriter Writer) { Writer.WriteVarUInt32((uint)Memories.Count); foreach (var limits in Memories) { limits.WriteTo(Writer); } Writer.Writer.Write(ExtraPayload); }
/// <inheritdoc/> public override void WritePayloadTo(BinaryWasmWriter writer) { writer.WriteVarUInt32((uint)Tables.Count); foreach (var type in Tables) { type.WriteTo(writer); } writer.Writer.Write(ExtraPayload); }
/// <inheritdoc/> public override void WritePayloadTo(BinaryWasmWriter Writer) { Writer.WriteVarUInt32((uint)FunctionTypes.Count); foreach (var type in FunctionTypes) { type.WriteTo(Writer); } Writer.Writer.Write(ExtraPayload); }
/// <summary> /// Writes this element segment to the given WebAssembly file writer. /// </summary> /// <param name="Writer">The WebAssembly file writer.</param> public void WriteTo(BinaryWasmWriter Writer) { Writer.WriteVarUInt32(TableIndex); Offset.WriteTo(Writer); Writer.WriteVarUInt32((uint)Elements.Count); foreach (var item in Elements) { Writer.WriteVarUInt32(item); } }
/// <summary> /// Writes this function type to the given binary WebAssembly file. /// </summary> /// <param name="writer">The writer for a binary WebAssembly file.</param> public void WriteTo(BinaryWasmWriter writer) { writer.WriteWasmType(Form); writer.WriteVarUInt32((uint)ParameterTypes.Count); foreach (var item in ParameterTypes) { writer.WriteWasmValueType(item); } writer.WriteVarUInt32((uint)ReturnTypes.Count); foreach (var item in ReturnTypes) { writer.WriteWasmValueType(item); } }
/// <summary> /// Writes this instruction's child instructions to the given WebAssembly file writer, /// followed by an 'end' opcode. /// </summary> /// <param name="writer">The writer to write this instruction's child instructions to.</param> public void WriteContentsTo(BinaryWasmWriter writer) { foreach (var instr in IfBranch) { instr.WriteTo(writer); } if (HasElseBranch) { writer.Writer.Write(Operators.ElseOpCode); foreach (var instr in ElseBranch) { instr.WriteTo(writer); } } writer.Writer.Write(Operators.EndOpCode); }
private void WriteContentsTo(BinaryWasmWriter Writer) { // Write the number of local entries to the file. Writer.WriteVarUInt32((uint)Locals.Count); // Write the local variables to the file. foreach (var local in Locals) { local.WriteTo(Writer); } // Write the body to the file. Operators.Block.Create(WasmType.Empty, BodyInstructions).WriteContentsTo(Writer); if (HasExtraPayload) { // If we have at least one byte of additional payload, // then we should write it to the stream now. Writer.Writer.Write(ExtraPayload); } }
/// <summary> /// Writes the initializer expression to the given WebAssembly writer. /// </summary> /// <param name="Writer">The WebAssembly writer.</param> public void WriteTo(BinaryWasmWriter Writer) { Operators.Block.Create(WasmType.Empty, BodyInstructions).WriteContentsTo(Writer); }
/// <summary> /// Writes this instruction's immediates (but not its opcode) /// to the given WebAssembly file writer. /// </summary> /// <param name="Writer">The writer to write this instruction's immediates to.</param> public override void WriteImmediatesTo(BinaryWasmWriter Writer) { Writer.WriteVarInt64(Immediate); }
/// <inheritdoc/> public override void WritePayloadTo(BinaryWasmWriter writer) { writer.WriteVarUInt32(StartFunctionIndex); writer.Writer.Write(ExtraPayload); }
/// <summary> /// Writes this WebAssembly section's payload to the given binary WebAssembly writer. /// </summary> /// <param name="Writer">The writer to which the payload is written.</param> public abstract void WritePayloadTo(BinaryWasmWriter Writer);
/// <summary> /// Writes this instruction's immediates (but not its opcode) /// to the given WebAssembly file writer. /// </summary> /// <param name="writer">The writer to write this instruction's immediates to.</param> public override void WriteImmediatesTo(BinaryWasmWriter writer) { writer.WriteWasmType(Type); WriteContentsTo(writer); }
/// <summary> /// Writes this instruction's immediates (but not its opcode) /// to the given WebAssembly file writer. /// </summary> /// <param name="writer">The writer to write this instruction's immediates to.</param> public override void WriteImmediatesTo(BinaryWasmWriter writer) { writer.WriteVarUInt32(Immediate); }
/// <summary> /// Writes this local entry to the given WebAssembly file writer. /// </summary> /// <param name="Writer">The WebAssembly file writer.</param> public void WriteTo(BinaryWasmWriter Writer) { Writer.WriteVarUInt32(LocalCount); Writer.WriteWasmValueType(LocalType); }
/// <summary> /// Writes this memory description to the given binary WebAssembly file. /// </summary> /// <param name="Writer">The writer for a binary WebAssembly file.</param> public void WriteTo(BinaryWasmWriter Writer) { Limits.WriteTo(Writer); }
/// <summary> /// Writes this function body to the given WebAssembly file writer. /// </summary> /// <param name="Writer">The WebAssembly file writer.</param> public void WriteTo(BinaryWasmWriter Writer) { Writer.WriteLengthPrefixed(WriteContentsTo); }