Skip to content

Commit 7cc44ce

Browse files
authored
Merge pull request #751 from wado-lang/claude/refactor-wasi-to-cm-attribute-wJyuO
Rename #[wasi("...")] attribute to #[cm("...")] for general CM support
2 parents 0132b7a + aaacabc commit 7cc44ce

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+772
-771
lines changed

docs/compiler.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ The `WasiRegistry` module (`component_model.rs`) collects WASI import informatio
281281

282282
**Purpose:**
283283

284-
- Extract WASI version strings from `#[wasi(...)]` attributes (e.g., `0.3.0-rc-2025-09-16`)
284+
- Extract WASI version strings from `#[cm(...)]` attributes (e.g., `0.3.0-rc-2025-09-16`)
285285
- Map effect methods to function names using a unified naming scheme
286286
- Track which WASI interfaces are used for conditional import generation
287287

@@ -336,7 +336,7 @@ Instead of a hardcoded whitelist, interfaces are included based on type support:
336336
To fully eliminate hardcoded CM structures, the registry would need to:
337337

338338
1. Track WASI types (enums, resources) in addition to effect functions
339-
2. Parse enum variants from `#[wasi(...)]` annotated enums in wasi/\*.wado
339+
2. Parse enum variants from `#[cm(...)]` annotated enums in wasi/\*.wado
340340
3. Generate CM type definitions dynamically from parsed definitions
341341

342342
### Async Export Functions (`export async fn`)

docs/spec.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,11 +2874,11 @@ assert rw as u32 == 3;
28742874
// They produce a compile error; use bitwise operators (|, &, ^) instead
28752875
```
28762876

2877-
Flags are implemented as newtypes over `u32`. Member names can carry `#[wasi("...")]` attributes for WIT/Component Model name mapping:
2877+
Flags are implemented as newtypes over `u32`. Member names can carry `#[cm("...")]` attributes for Component Model name mapping:
28782878

28792879
```wado
28802880
pub flags PathFlags {
2881-
#[wasi("symlink-follow")]
2881+
#[cm("symlink-follow")]
28822882
SymlinkFollow,
28832883
}
28842884
```
@@ -4346,23 +4346,23 @@ export async fn handle(request: Request) -> Result<Response, ErrorCode> {
43464346
- The `task return` expression is type-checked against the declared return type of the enclosing `export async fn`.
43474347
- The `async` keyword on a function declaration has no effect on callers; Wado is fully colorless. `async` only appears in `export async fn` declarations to signal CM async calling convention at the component boundary.
43484348

4349-
### Attribute Syntax for WASI Linking
4349+
### Attribute Syntax for Component Model Linking
43504350

4351-
Use `#[wasi(...)]` attributes to link Wado definitions to WASI interfaces:
4351+
Use `#[cm(...)]` attributes to link Wado definitions to Component Model interfaces:
43524352

43534353
```wado
4354-
// Link an effect interface to a WASI interface
4355-
#[wasi("wasi:cli/stdout@0.3.0-rc-2025-09-16")]
4354+
// Link an effect interface to a CM interface
4355+
#[cm("wasi:cli/stdout@0.3.0-rc-2025-09-16")]
43564356
pub effect Stdout {
4357-
#[wasi("wasi:cli/stdout@0.3.0-rc-2025-09-16#write-via-stream")]
4357+
#[cm("wasi:cli/stdout@0.3.0-rc-2025-09-16#write-via-stream")]
43584358
fn write_via_stream(data: Stream<u8>) -> Result<(), ErrorCode>;
43594359
}
43604360
4361-
// Link a resource to a WASI resource
4362-
#[wasi("wasi:cli/terminal-output@0.3.0-rc-2025-09-16")]
4361+
// Link a resource to a CM resource
4362+
#[cm("wasi:cli/terminal-output@0.3.0-rc-2025-09-16")]
43634363
resource TerminalOutput;
43644364
4365-
// Link an enum to a WASI enum
4365+
// Link an enum to a CM enum
43664366
pub enum ErrorCode { // Maps to WIT: enum error-code
43674367
Io, // Maps to WIT: io
43684368
IllegalByteSequence, // Maps to WIT: illegal-byte-sequence
@@ -4542,9 +4542,9 @@ fn realloc(oldptr: i32, oldsize: i32, align: i32, newsize: i32) -> i32;
45424542

45434543
Marks a function as providing a compiler feature. The compiler uses these flags to enable optimizations and synthesis passes (e.g., `array_append`, `string_append`, `option`, `result`, `default`). Used in `core:prelude` method implementations.
45444544

4545-
#### `#[wasi("interface@version")]` / `#[wasi_params(...)]`
4545+
#### `#[cm("namespace:pkg/interface@version")]` / `#[cm_params(...)]`
45464546

4547-
Links Wado definitions (effects, resources, enums) to WASI interfaces. See [Attribute Syntax for WASI Linking](#attribute-syntax-for-wasi-linking).
4547+
Links Wado definitions (effects, resources, enums) to Component Model interfaces. See [Attribute Syntax for Component Model Linking](#attribute-syntax-for-component-model-linking).
45484548

45494549
### The "mem" Core Module
45504550

docs/wep-2026-04-01-tide.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Pipeline:
8787

8888
### Unified Attribute: `#[cm("...")]`
8989

90-
The current `#[wasi("...")]` attribute is WASI-specific. Tide introduces a generalized `#[cm("...")]` attribute for all Component Model ABI mappings, with the namespace encoded in the value:
90+
The `#[cm("...")]` attribute provides Component Model ABI mappings for all namespaces, with the namespace encoded in the value:
9191

9292
```wado
9393
// Web API binding
@@ -97,7 +97,7 @@ pub resource Element extends Node { ... }
9797
#[cm("web:dom#Element.getAttribute")]
9898
fn get_attribute(&self, name: String) -> Option<String>;
9999
100-
// WASI binding (replaces #[wasi("...")])
100+
// WASI binding
101101
#[cm("wasi:http/types@0.3.0#request")]
102102
pub resource Request { ... }
103103
```
@@ -111,7 +111,7 @@ Sub-attributes for method kinds:
111111
#[cm("web:url#[static]URL.createObjectURL")] // static method
112112
```
113113

114-
Parameter name mapping (replaces `#[wasi_params(...)]`):
114+
Parameter name mapping:
115115

116116
```wado
117117
#[cm_params("self", "qualified-name")]
@@ -931,7 +931,7 @@ Organized by W3C/WHATWG specification, mirroring how `wasi/` is organized by WAS
931931
### Language Changes Required
932932

933933
- `resource extends` syntax — new compiler feature for resource inheritance.
934-
- `#[cm("...")]` attribute — replaces `#[wasi("...")]` for all CM bindings.
934+
- `#[cm("...")]` attribute — Component Model bindings with namespace in the value string.
935935
- `downcast::<T>()` built-in on resources with `extends`.
936936
- Implicit upcast coercion for resource reference types.
937937

wado-cli/src/dump.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -508,17 +508,17 @@ async fn run_single(opts: &DumpOptions, input: &str) {
508508
.map(|t| format!(" -> {t}"))
509509
.unwrap_or_default();
510510
let wasi = f
511-
.wasi_import
511+
.cm_import
512512
.as_ref()
513-
.map(|w| format!(" [wasi: {}]", w.interface_path()))
513+
.map(|w| format!(" [cm: {}]", w.interface_path()))
514514
.unwrap_or_default();
515515
format!("fn({}){ret}{effects}{wasi}", f.params.join(", "))
516516
}
517517
wado_compiler::symbol::SymbolKind::Effect(e) => {
518518
let wasi = e
519-
.wasi_import
519+
.cm_import
520520
.as_ref()
521-
.map(|w| format!(" [wasi: {}]", w.interface_path()))
521+
.map(|w| format!(" [cm: {}]", w.interface_path()))
522522
.unwrap_or_default();
523523
format!("effect{{ {} }}{wasi}", e.methods.join(", "))
524524
}
@@ -553,9 +553,9 @@ async fn run_single(opts: &DumpOptions, input: &str) {
553553
}
554554
wado_compiler::symbol::SymbolKind::Resource(r) => {
555555
let wasi = r
556-
.wasi_import
556+
.cm_import
557557
.as_ref()
558-
.map(|w| format!(" [wasi: {}]", w.interface_path()))
558+
.map(|w| format!(" [cm: {}]", w.interface_path()))
559559
.unwrap_or_default();
560560
format!("resource{{ {} }}{wasi}", r.methods.join(", "))
561561
}

wado-compiler/lib/wasi/cli/environment.wado

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// Source files:
44
// - vendor/wasmtime/crates/wasi/src/p3/wit/deps/cli.wit
55

6-
#[wasi("wasi:cli/environment@0.3.0-rc-2026-03-15")]
6+
#[cm("wasi:cli/environment@0.3.0-rc-2026-03-15")]
77
pub effect Environment {
88
/// Get the POSIX-style environment variables.
99
///
@@ -13,14 +13,14 @@ pub effect Environment {
1313
/// Morally, these are a value import, but until value imports are available
1414
/// in the component model, this import function should return the same
1515
/// values each time it is called.
16-
#[wasi("wasi:cli/environment@0.3.0-rc-2026-03-15#get-environment")]
16+
#[cm("wasi:cli/environment@0.3.0-rc-2026-03-15#get-environment")]
1717
fn get_environment() -> Array<[String, String]>;
1818
/// Get the POSIX-style arguments to the program.
19-
#[wasi("wasi:cli/environment@0.3.0-rc-2026-03-15#get-arguments")]
19+
#[cm("wasi:cli/environment@0.3.0-rc-2026-03-15#get-arguments")]
2020
fn get_arguments() -> Array<String>;
2121
/// Return a path that programs should use as their initial current working
2222
/// directory, interpreting `.` as shorthand for this.
23-
#[wasi("wasi:cli/environment@0.3.0-rc-2026-03-15#get-initial-cwd")]
23+
#[cm("wasi:cli/environment@0.3.0-rc-2026-03-15#get-initial-cwd")]
2424
fn get_initial_cwd() -> Option<String>;
2525
}
2626

wado-compiler/lib/wasi/cli/exit.wado

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// Source files:
44
// - vendor/wasmtime/crates/wasi/src/p3/wit/deps/cli.wit
55

6-
#[wasi("wasi:cli/exit@0.3.0-rc-2026-03-15")]
6+
#[cm("wasi:cli/exit@0.3.0-rc-2026-03-15")]
77
pub effect Exit {
88
/// Exit the current instance and any linked instances.
9-
#[wasi("wasi:cli/exit@0.3.0-rc-2026-03-15#exit")]
10-
#[wasi_params("status")]
9+
#[cm("wasi:cli/exit@0.3.0-rc-2026-03-15#exit")]
10+
#[cm_params("status")]
1111
fn exit(status: Result<(), ()>);
1212
/// Exit the current instance and any linked instances, reporting the
1313
/// specified status code to the host.
@@ -17,8 +17,8 @@ pub effect Exit {
1717
///
1818
/// This function does not return; the effect is analogous to a trap, but
1919
/// without the connotation that something bad has happened.
20-
#[wasi("wasi:cli/exit@0.3.0-rc-2026-03-15#exit-with-code")]
21-
#[wasi_params("status-code")]
20+
#[cm("wasi:cli/exit@0.3.0-rc-2026-03-15#exit-with-code")]
21+
#[cm_params("status-code")]
2222
fn exit_with_code(status_code: u8);
2323
}
2424

wado-compiler/lib/wasi/cli/run.wado

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
// Source files:
44
// - vendor/wasmtime/crates/wasi/src/p3/wit/deps/cli.wit
55

6-
#[wasi("wasi:cli/run@0.3.0-rc-2026-03-15")]
6+
#[cm("wasi:cli/run@0.3.0-rc-2026-03-15")]
77
pub effect Run {
88
/// Run the program.
9-
#[wasi("wasi:cli/run@0.3.0-rc-2026-03-15#run")]
9+
#[cm("wasi:cli/run@0.3.0-rc-2026-03-15#run")]
1010
async fn run() -> Result<(), ()>;
1111
}
1212

wado-compiler/lib/wasi/cli/stderr.wado

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use { ErrorCode } from "wasi:cli/types.wado";
77

88

9-
#[wasi("wasi:cli/stderr@0.3.0-rc-2026-03-15")]
9+
#[cm("wasi:cli/stderr@0.3.0-rc-2026-03-15")]
1010
pub effect Stderr {
1111
/// Write the given stream to stderr.
1212
///
@@ -16,8 +16,8 @@ pub effect Stderr {
1616
///
1717
/// Otherwise if there is an error the readable end of the stream will be
1818
/// dropped and this function will return an error-code.
19-
#[wasi("wasi:cli/stderr@0.3.0-rc-2026-03-15#write-via-stream")]
20-
#[wasi_params("data")]
19+
#[cm("wasi:cli/stderr@0.3.0-rc-2026-03-15#write-via-stream")]
20+
#[cm_params("data")]
2121
fn write_via_stream(data: Stream<u8>) -> Future<Result<(), ErrorCode>>;
2222
}
2323

wado-compiler/lib/wasi/cli/stdin.wado

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use { ErrorCode } from "wasi:cli/types.wado";
77

88

9-
#[wasi("wasi:cli/stdin@0.3.0-rc-2026-03-15")]
9+
#[cm("wasi:cli/stdin@0.3.0-rc-2026-03-15")]
1010
pub effect Stdin {
1111
/// Return a stream for reading from stdin.
1212
///
@@ -21,7 +21,7 @@ pub effect Stdin {
2121
///
2222
/// Multiple streams may be active at the same time. The behavior of concurrent
2323
/// reads is implementation-specific.
24-
#[wasi("wasi:cli/stdin@0.3.0-rc-2026-03-15#read-via-stream")]
24+
#[cm("wasi:cli/stdin@0.3.0-rc-2026-03-15#read-via-stream")]
2525
fn read_via_stream() -> [Stream<u8>, Future<Result<(), ErrorCode>>];
2626
}
2727

wado-compiler/lib/wasi/cli/stdout.wado

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use { ErrorCode } from "wasi:cli/types.wado";
77

88

9-
#[wasi("wasi:cli/stdout@0.3.0-rc-2026-03-15")]
9+
#[cm("wasi:cli/stdout@0.3.0-rc-2026-03-15")]
1010
pub effect Stdout {
1111
/// Write the given stream to stdout.
1212
///
@@ -16,8 +16,8 @@ pub effect Stdout {
1616
///
1717
/// Otherwise if there is an error the readable end of the stream will be
1818
/// dropped and this function will return an error-code.
19-
#[wasi("wasi:cli/stdout@0.3.0-rc-2026-03-15#write-via-stream")]
20-
#[wasi_params("data")]
19+
#[cm("wasi:cli/stdout@0.3.0-rc-2026-03-15#write-via-stream")]
20+
#[cm_params("data")]
2121
fn write_via_stream(data: Stream<u8>) -> Future<Result<(), ErrorCode>>;
2222
}
2323

0 commit comments

Comments
 (0)