Add wat2wasm example compatible with Embedded Swift#273
Draft
MaxDesiatov wants to merge 28 commits into
Draft
Conversation
MaxDesiatov
added a commit
that referenced
this pull request
Jan 18, 2026
Both `Stream` and `StreamError` are over-generalization of generic streams, while only `ByteStream` is actually used in `WasmParser`, and `StreamError` is always used with `UInt8` type parameter. Let's clean these up as unused, `WasmParser` is not in the business of providing general stream APIs. `StreamError` is now merged with `WasmParserError`, which simplifies future adoption of typed throws to unblock #273. While we're at it, `ByteStream` now conforms to `~Copyable`, but ideally we'd want it to return `Span<UInt8>` and not `ArraySlice` from its methods. Bumping required Swift version to 6.2 is required for that, which we're not ready to do just yet, so `~Escapable` constraint is not added in this PR.
…al-wasm-parser-error # Conflicts: # Sources/WAT/Parser.swift # Sources/WAT/Parser/WastParser.swift # Sources/WAT/Parser/WatParser.swift # Sources/WAT/WAT.swift # Sources/WasmKit/Execution/Instances.swift # Sources/WasmKit/Translator.swift # Sources/WasmKit/Validator.swift # Sources/WasmParser/BinaryInstructionDecoder.swift # Sources/WasmParser/InstructionVisitor.swift # Sources/WasmParser/Stream/ByteStream.swift # Sources/WasmParser/Stream/FileHandleStream.swift # Sources/WasmParser/WasmParser.swift # Utilities/Sources/WasmGen.swift
…sm/WasmKit into maxd/embedded-wat2wasm # Conflicts: # Package.swift # Sources/WasmParser/CMakeLists.txt # Sources/WasmParser/WasmParser.swift # Sources/WasmParserCore/Stream/Stream.swift
MaxDesiatov
added a commit
that referenced
this pull request
Apr 13, 2026
The main reason for using single array type is that combining error types from different visitor types is impractical in certain functions that combine those visitors, and probably also detrimental for code size and performance. Fortunately, existing error types fit well within the unified type, so mostly it's a text replacement to use `WasmKitError` everywhere. Unblocks #295 and #273.
…d-wat2wasm # Conflicts: # Sources/WAT/BinaryEncoding/ComponentEncoder.swift # Sources/WAT/BinaryEncoding/Encoder.swift # Sources/WAT/ParseTextInstruction.swift # Sources/WAT/Parser/ComponentWatParser.swift # Sources/WAT/Parser/ExpressionParser.swift # Sources/WAT/Parser/WastParser.swift # Sources/WAT/Parser/WatParser.swift # Sources/WAT/WAT.swift # Sources/WasmKit/ModuleParser.swift # Sources/WasmKit/Translator.swift # Sources/WasmKit/Validator.swift # Sources/WasmParser/CMakeLists.txt # Sources/WasmParser/FileHandleStream.swift # Sources/WasmParser/WasmParser.swift # Sources/WasmParserCore/BinaryInstructionDecoder.swift # Sources/WasmParserCore/ComponentParser.swift # Sources/WasmParserCore/InstructionVisitor.swift # Sources/WasmParserCore/LEB.swift # Sources/WasmParserCore/Stream/ByteStream.swift # Tests/WasmKitTests/Spectest/TestCase.swift # Utilities/Sources/WasmGen.swift
This should improve WASI performance and make adoption easier for Embedded Swift.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #277, which adopts typed throws in the
WasmParsermodule, which is a dependency of theWATmodule.