Skip to content

Add wat2wasm example compatible with Embedded Swift#273

Draft
MaxDesiatov wants to merge 28 commits into
mainfrom
maxd/embedded-wat2wasm
Draft

Add wat2wasm example compatible with Embedded Swift#273
MaxDesiatov wants to merge 28 commits into
mainfrom
maxd/embedded-wat2wasm

Conversation

@MaxDesiatov
Copy link
Copy Markdown
Member

@MaxDesiatov MaxDesiatov commented Jan 18, 2026

Depends on #277, which adopts typed throws in the WasmParser module, which is a dependency of the WAT module.

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 MaxDesiatov changed the base branch from main to maxd/universal-wasm-parser-error February 25, 2026 12:40
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.
Base automatically changed from maxd/universal-wasm-parser-error to main April 13, 2026 16:57
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant