You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* feat: add map support across backends
Implement map type rendering plus lowering/lifting/deallocation support across the C, C++, C#, Go, MoonBit, and Markdown backends, and add map codegen/runtime tests.
This aligns non-Rust generators with core map ABI support and fixes the Go test harness module replacement path needed for map codegen verification.
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
* revert: remove map support from non-Rust backends
Defer map codegen for MoonBit, Go, C#, C++, and C to future PRs
that include runtime tests and review from language-specific
maintainers. Only todo!() stubs for the new MapLower/MapLift/
IterMapKey/IterMapValue/GuestDeallocateMap instruction variants
are kept so exhaustive matches compile.
* revert: drop unrelated go.mod replace path fix
This change was a fix for a latent bug from the vanity imports migration
but is unrelated to map support. Removing to keep the PR focused on Rust.
* refactor: clean up map type support across backends
- Make `InterfaceGenerator::type_map` a required trait method instead of
providing a default `todo!()` impl, so missing implementations are
caught at compile time rather than runtime.
- Remove `RuntimeItem::MapType` indirection in the Rust backend; reference
`{rt}::Map` directly instead of emitting a `pub use` re-export.
- Fix borrowed map rendering to use `&Map<K, V>` instead of the
incorrect `&[(K, V)]` slice syntax that was copy-pasted from lists.
- Add explanatory comments on map ABI methods that reuse list
read/write helpers (maps share the list<tuple<K, V>> memory layout).
- Add explicit `type_map` todo stubs to C, C++, C#, Go, and MoonBit
backends.
* Address PR review: make anonymous_type_map required and fix runner test
- Make `anonymous_type_map` a required method on `AnonymousTypeGenerator`
trait (no default impl), consistent with all other methods in the trait.
- Add explicit `anonymous_type_map` todo!() implementation to C backend.
- Fix map runner test to construct proper Map types instead of passing
slice literals, matching the generated `&Map<K, V>` parameter signatures.
* Mark map.wit codegen test as expected failure for unsupported backends
The map.wit codegen test hits todo!() panics in backends that don't yet
implement map support (C, C++, C#, Go, MoonBit). Add map.wit to each
backend's should_fail_verify so CI treats these as expected failures.
* Fix rustfmt and use starts_with for C map.wit codegen variants
- Run cargo fmt to fix formatting in c/lib.rs, test/c.rs, test/moonbit.rs.
- Use starts_with("map.wit") for the C backend's should_fail_verify to
catch all codegen test variants (no-sig-flattening, autodrop, async).
* Add comment back
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
* Expand map test coverage with additional runtime and codegen tests
Add runtime tests for empty maps, option values, maps inside records,
inline anonymous map types, and a 100-entry stress test. Expand codegen
tests with option values, nested maps, record values, bool keys, and
char keys.
* Add map tests for nested maps, multi-param, variant, and result types
Exercise additional ABI code paths: nested map<K, map<K2, V>> with
recursive lower/lift blocks, multiple map parameters with independent
ptr/len pairs, map as a variant arm payload, map inside result<ok, err>,
and tuple-with-map in codegen.
* Add tuple-with-map and single-entry map runtime tests
Exercise map inside an anonymous tuple (filter_mode_preserve_top path)
and the single-entry boundary case.
* Add WitMap trait and configurable map_type for Rust bindings
Instead of hardcoding HashMap/BTreeMap, introduce a WitMap trait that
generated code delegates to for map construction, insertion, and length.
This lets users swap in their own map type via the new `map_type`
bindgen option. The default is BTreeMap (always, regardless of std).
* Format code
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
* Add tests for WitMap trait and map_type codegen option
- Unit tests for WitMap trait impls (BTreeMap, HashMap, reference blanket)
- Proc-macro integration tests exercising map_type with HashMap and default
- Codegen test variant running all .wit files with --map-type=HashMap
* Fix &&BTreeMap WitMap trait resolution for borrowed map variants
Remove `type Iter` and `wit_map_into_iter` from the `WitMap` trait and
drop the `IntoIterator` bound from the blanket `&T` impl. This allows
the blanket impl to apply at any reference depth (e.g. `&&BTreeMap`)
which is needed when codegen emits `WitMap::wit_map_len(&map)` on an
already-borrowed map.
Generated lowering code now uses `IntoIterator::into_iter(map)` for
iteration, which the standard library already provides for both owned
and borrowed map types.
* Fix map codegen for borrowed ownership mode
Use method syntax (.wit_map_len() and .into_iter()) in generated
MapLower code instead of UFCS. This lets Rust's auto-deref handle
&&BTreeMap operands that arise when the borrow-mode param wrapper
adds an extra & prefix to already-borrowed map arguments.
A scoped `use WitMap;` import is emitted so method resolution finds
the trait's wit_map_len method.
* Use .len() and .into_iter() in MapLower codegen
Revert MapLower to use method syntax for length and iteration, matching
the original pre-WitMap code. Method syntax auto-derefs through &&Map
operands that arise in borrowed ownership modes.
Simplify WitMap trait to just new/push (used only in MapLift). The map
type must also provide .len() and implement IntoIterator, which all
standard map types already do.
* Route MapLower .len() through WitMap trait via module-level import
Instead of calling .len() directly (which bypasses the WitMap trait and
would break custom map types), generated code now calls .wit_map_len()
using method syntax. The WitMap trait is brought into scope via a
module-level `use _rt::WitMap;` import, avoiding the scoping issues
that arose from emitting `use` inside nested blocks.
* Format code
---------
Signed-off-by: Yordis Prieto <yordis.prieto@gmail.com>
0 commit comments