Skip to content

Commit 9e1b633

Browse files
committed
merge origin/main (conflicts unresolved)
2 parents 001897d + bccc8bb commit 9e1b633

Some content is hidden

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

63 files changed

+9688
-629
lines changed

AGENTS.md

Lines changed: 20 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -14,122 +14,11 @@ If you need detailed specification, read the `docs/spec.md`.
1414

1515
The compiler is implemented in `wado-compiler/`.
1616

17-
Standard libraries (stdlib) are implemented in `wado-compiler/lib`, with `wasi/` for WASI interface and `core/` for the core library.
18-
19-
For other important files:
20-
21-
- `wado-compiler/lib/core/builtin.wado` for compiler intrinsics.
22-
- `wado-compiler/lib/core/internal.wado` for utilities to implement language features
23-
2417
See also:
2518

2619
- `docs/compiler.md` for the compiler internals.
2720
- `docs/optimizer.md` for the optimization passes.
2821

29-
### Wasm Compatibility
30-
31-
`wado-compiler` must compile for `wasm32-unknown-unknown`. Do not use OS-dependent `std` modules in production code. CI enforces this with a wasm32 build check.
32-
33-
### E2E Test Specification (Compiler Tests)
34-
35-
E2E tests verify language features and compiler behaviors (codegen, error messages, optimization). They are `.wado` files in `wado-compiler/tests/fixtures/` with a `__DATA__` section containing JSON test specification.
36-
37-
Each test fixture group has the same prefix in their filenames.
38-
39-
By default, only O0 and O2 run locally; O1/O3/Os require `WADO_FULL_TEST=1`.
40-
41-
#### Data Section Schema
42-
43-
The target world is indicated by the top-level key in the JSON object:
44-
45-
- No world key → `wasi:cli/command` (default)
46-
- `"test": {}` → test world (runs test block exports)
47-
- `"wasi:http/service": {...}` → HTTP service world
48-
49-
| Field | Type | Description |
50-
| --------------------- | -------------------- | ----------------------------------------------------------- |
51-
| `"test"` | `{}` | Run as test world (`wasi:test`), executing test exports |
52-
| `"wasi:http/service"` | `object` | Run as HTTP service (see HTTP sub-fields below) |
53-
| `stdout` | `string` | Expected stdout (exact match) |
54-
| `stderr` | `string` | Expected stderr (exact match) |
55-
| `stdout_contains` | `string[]` | Strings that must appear in stdout |
56-
| `stderr_contains` | `string[]` | Strings that must appear in stderr |
57-
| `trapped` | `bool` | Whether the program should trap |
58-
| `compile_error` | `string` | Expected compile error (substring match) |
59-
| `TODO` | `bool` | Mark as TODO test - must fail until feature is implemented |
60-
| `skip_os` | `bool` | Skip this test under `-Os` (e.g. tests relying on names) |
61-
| `preopened_dirs` | `[string, string][]` | Preopened directories `[host_path, guest_path]` |
62-
| `allocator` | `string` | Override allocator: `"bump"` (default) or `"debug"` |
63-
| `wir_expect:Ox` | `string[]` | Patterns that must appear in WIR at `-Ox` (substring match) |
64-
| `wir_not_expect:Ox` | `string[]` | Patterns that must NOT appear in WIR at `-Ox` |
65-
| `outgoing_mocks` | `object` | Mock responses for outgoing HTTP requests (see below) |
66-
67-
HTTP sub-fields (inside `"wasi:http/service": {...}`):
68-
69-
| Field | Type | Description |
70-
| ----------------- | -------------------- | --------------------------------------------- |
71-
| `request` | `object` | Injected HTTP request (defaults to `GET /`) |
72-
| `request.method` | `string` | HTTP method (default: `"GET"`) |
73-
| `request.path` | `string` | Request path (default: `"/"`) |
74-
| `request.headers` | `[string, string][]` | Request headers |
75-
| `request.body` | `string` | Request body as UTF-8 |
76-
| `status` | `number` | Expected HTTP status code |
77-
| `body` | `string` | Expected response body (exact UTF-8 match) |
78-
| `body_contains` | `string[]` | Strings that must appear in the response body |
79-
| `headers_contain` | `[string, string][]` | Response headers that must be present |
80-
81-
Outgoing mock sub-fields (inside each entry of `"outgoing_mocks": {...}`):
82-
83-
Keys are URL patterns matched against the request URI (exact match on full URI or path).
84-
85-
| Field | Type | Description |
86-
| --------- | -------------------- | --------------------------------------- |
87-
| `status` | `number` | HTTP status code (default: 200) |
88-
| `body` | `string` | Response body as UTF-8 (default: empty) |
89-
| `headers` | `[string, string][]` | Response headers |
90-
91-
#### Examples
92-
93-
```wado
94-
test "Hello, world!" {
95-
let x = 1;
96-
assert x == 1;
97-
}
98-
99-
__DATA__
100-
{"test": {}}
101-
```
102-
103-
```wado
104-
// WIR pattern test - verify optimization effects at a specific -Ox level
105-
// Use `wado dump [-O0|-O2] file.wado` to discover WIR patterns
106-
export fn run() {
107-
let a: Array<i32> = [10, 20, 30];
108-
assert a.len() == 3;
109-
}
110-
111-
__DATA__
112-
{
113-
"stdout": "",
114-
"wir_expect:O1": ["SequenceLiteralBuilder::push_literal("]
115-
"wir_expect:O2": ["array.new_fixed<i32>(10, 20, 30)"],
116-
}
117-
```
118-
119-
### Adding Test Fixtures
120-
121-
After adding new `.wado` files to `wado-compiler/tests/fixtures/`, you must touch `wado-compiler/tests/e2e.rs` to trigger `datatest_mini` to rediscover test files:
122-
123-
```sh
124-
touch wado-compiler/tests/e2e.rs
125-
```
126-
127-
Without this, `cargo test` will not detect the new fixture because `datatest_mini` discovers files at compile time.
128-
129-
### Standard Library Tests (Library Logic)
130-
131-
Tests for standard library logic live alongside implementations in `wado-compiler/lib/`. These are `.wado` files with `test` blocks (e.g., `zlib_test.wado`, `string_test.wado`) , run with `wado test`.
132-
13322
### The `wasi:*` Modules
13423

13524
`wasi:*` modules are part of the Wado standard library.
@@ -176,7 +65,7 @@ wado compile --allocator debug file.wado
17665
wado run --allocator debug file.wado # not yet wired, use compile + wasmtime
17766
```
17867

179-
The debug allocator is **automatically selected** when compiling for tests.
68+
The debug allocator is selected when compiling for the test world, and enabled in E2E tests as well.
18069

18170
### Serve Command
18271

@@ -238,7 +127,7 @@ The compiler bundles Wasm modules for the language futures:
238127

239128
- `wado-bundled-libm/` - deterministic Math functions with `libm` crate
240129

241-
### Wasm and WASI
130+
## Wasm and WASI
242131

243132
Wado is designed on the following Wasm features:
244133

@@ -253,17 +142,22 @@ Wado is designed on the following Wasm features:
253142
- P3 is supported by wasmtime v42
254143
- See wasmtime P3 support: `find vendor/wasmtime/crates/wasi/src/p3/wit -name '*.wit'`
255144

145+
## Vendor submodules
146+
147+
There are reference repositories in `vendor/` for the specification of Wasm & Component Model, and also runtimes such as wasmtime.
148+
149+
To initialize: `git submodule update --init`
150+
256151
## General Rules
257152

258-
- Don't be anchored by existing implementations or conventions. Always design from first principles toward the optimal solution.
259153
- All the documents and comments must be written in English.
260-
- When referring to WAT, use folded style syntax.
261-
- If you find a compiler bug or a limitation, fix it. Such a problem must be treated as the highest priority.
154+
- If you find a compiler bug, fix it with the highest priority by TDD - a standalone minimum reproducible e2e fixture is required before fixing the bug.
262155
- Use sub-agents only for research tasks (searching, reading, exploring). Never use sub-agents for editing files.
263-
- `CLAUDE.md` is a symlink to `AGENTS.md`. Editing either one is sufficient.
156+
- `CLAUDE.md` is a symlink to `AGENTS.md`.
264157

265158
## Rules for Rust
266159

160+
- Write correct code with correct design.
267161
- Manage dependencies in the workspace `Cargo.toml`.
268162
- Do not use `#![allow(deprecated)]`; use newer alternatives instead.
269163
- Use `panic!` for things that are not yet implemented or not supported.
@@ -272,17 +166,11 @@ Wado is designed on the following Wasm features:
272166
- Do not use any comment sections to separate or organize code.
273167
- Follow TDD: write a failing test case first, then implement the concern.
274168

275-
### Rules for the Compiler Code Base
276-
277-
- The principle: `codegen.rs` emits the `Project` as is, which does not have the knowledge of the previous phases.
278-
- Use utilities in `name.rs` to handle name mangling and monomorphization. Other components must not know the details of name formats.
279-
- Minimize hard-coded logic for compiler builtins or WASI. Define builtin and internal functions in Wado source files in `lib/core/*.wado` or `lib/wasi/*.wado`.
280-
281169
## Wado Evolution Proposals (WEP)
282170

283171
Wado has a set of document for significant language features and architecture decisions.
284172

285-
See [docs/WEP.md] for details and existing WEPs.
173+
See `docs/` for existing WEPs.
286174

287175
## Project Development
288176

@@ -304,8 +192,8 @@ Then run `mise run on-task-started` to install the development tools.
304192
### Development Tasks
305193

306194
```sh
307-
mise run test # test Rust crates (included in on-task-done)
308-
mise run test-wado # test Wado modules (included in on-task-done)
195+
mise run test # test Rust crates
196+
mise run test-wado # test Wado modules
309197
mise run format # format Rust files and Markdown files
310198

311199
mise run benchmark-all # count-prime, mandelbrot, sieve, fts, and zlib
@@ -317,7 +205,7 @@ mise run report-wasm-size # hello_world, pi_approx, and zlib
317205
The compiler emits timestamped diagnostics to stderr. Use `--log-level` to control verbosity.
318206

319207
```sh
320-
wado compile --log-level debug file.wado # all messages including phase spans
208+
wado compile --log-level debug file.wado
321209
```
322210

323211
## Development Workflow
@@ -335,13 +223,13 @@ mise run on-task-started # install project tools
335223

336224
When you have completed a task, make sure everything is up-to-date and tested:
337225

338-
- Update the docs if necessary:
226+
- Update docs if necessary:
339227
- docs/spec.md
340228
- docs/cheatsheet.md
341229
- docs/compiler.md
342230
- docs/optimizer.md
343231
- Run `time mise run on-task-done`
344-
- It performs format, clippy-fix, update golden fixtures, regenerate stdlib docs, and tests.
345-
- It will take 15+ minutes
346-
- Run in foreground and commit the results with without `| tail` in order not to lost the results.
347-
- CI's integrity check fails if generated files are uncommitted.
232+
- It performs format, clippy-fix, update golden fixtures, generation of stdlib docs, and tests.
233+
- It will take 20+ minutes.
234+
- Run it in foreground without `| tail` in order not to lost the results.
235+
- Commit the entire results of `on-task-done`.

docs/AGENTS.md

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,95 @@
1-
# Docs
1+
# Overview of Docs
2+
3+
This is the documentation directory of Wado.
24

35
## Rules for Markdown
46

5-
- Keep documentation mutually exclusive and collectively exhaustive (MECE).
7+
- Keep documentation mutually exclusive and collectively exhaustive.
68
- Do not use `**...**` (bold) for sub-sections. Use markdown sections instead.
79
- Use markdown checklist for TODOs (`- [ ] ...`) and what's done (`- [x] ...`), instead of `~~...~~` (strike-through) and emojis.
810
- After updating any docs, always run `mise run format`.
11+
- Do not make a sub-directory for docs.
12+
13+
## WEP: Wado Evolution Proposals
14+
15+
WEPs combine language specification and implementation strategy in a single document, covering both user-visible features and compiler architecture decisions.
16+
17+
Filename: `docs/wep-YYYY-MM-DD-{feature-name}.md`
18+
19+
- Title: Short description of the proposal
20+
- Context: Background and problem statement
21+
- Decision: What was decided and why
22+
- Consequences: Impact and trade-offs
23+
24+
It may include TODOs on WIP.
25+
26+
### Index of WEPs
27+
28+
- [Target WASI P3 Only](./wep-2026-01-11-wasi-p3-only.md)
29+
- [Deterministic Math Library (libm) Integration](./wep-2026-01-10-deterministic-libm.md)
30+
- [Tagged Template Literals for Compile-Time Execution](./wep-2026-01-10-tagged-template-literals.md)
31+
- [WebAssembly Module Import Support](./wep-2026-01-10-wasm-import.md)
32+
- [Operator Precedence and Associativity](./wep-2026-01-11-operator-precedence.md)
33+
- [Ambient Logging Functions](./wep-2026-01-12-ambient-logging.md)
34+
- [Data Section (`__DATA__`)](./wep-2026-01-12-data-section.md)
35+
- [Literal Type Conversion Rules](./wep-2026-01-12-literal-type-conversion.md)
36+
- [Resource Lifecycle Management (RAII)](./wep-2026-01-12-resource-lifecycle.md)
37+
- [Value Semantics and Reference Stores](./wep-2026-01-12-value-semantics-and-stores.md)
38+
- [Struct and Trait System](./wep-2026-01-13-struct-and-trait.md)
39+
- [Compiler Pipeline Refactoring](./wep-2026-01-14-compiler-pipeline-refactoring.md)
40+
- [String Type Design](./wep-2026-01-15-string-type-design.md)
41+
- [Tuple and Array Literal Syntax](./wep-2026-01-15-tuple-and-array-literals.md)
42+
- [World Conformance and Export Syntax](./wep-2026-01-16-world-conformance-and-export.md)
43+
- [Closure Implementation](./wep-2026-01-16-closure-implementation.md)
44+
- [Function Return Type Syntax](./wep-2026-01-16-function-return-type-syntax.md)
45+
- [CompilerHost Abstraction for Compiler I/O](./wep-2026-01-16-source-provider-abstraction.md)
46+
- [Type Stringification](./wep-2026-01-16-type-stringification.md)
47+
- [Template Format Specifiers](./wep-2026-01-17-template-format-specifiers.md)
48+
- [JSON Literal Compatibility](./wep-2026-01-18-json-literal-compatibility.md)
49+
- [JSON Module Import](./wep-2026-01-18-json-module-import.md)
50+
- [Operator Overloading](./wep-2026-01-18-operator-overloading.md)
51+
- [Iterator-Based Literal Coercion](./wep-2026-01-18-iterator-based-literal-coercion.md)
52+
- [Effect System and Randomness in Collections](./wep-2026-01-20-effect-system-randomness.md)
53+
- [Associated Types in Traits](./wep-2026-01-20-associated-types.md)
54+
- [Indexing Traits Design](./wep-2026-01-20-indexing-traits.md)
55+
- [String Template Desugaring](./wep-2026-01-20-string-template-desugaring.md)
56+
- [Compile-Time Location Literals](./wep-2026-01-23-compile-time-location-literals.md)
57+
- [Iterator Traits Design](./wep-2026-01-24-iterator-traits.md)
58+
- [Module Loader Design](./wep-2026-01-24-module-loader.md)
59+
- [Closure Parameter Monomorphization](./wep-2026-01-25-closure-parameter-monomorphization.md)
60+
- [128-bit Integer Types (i128/u128)](./wep-2026-01-24-i128-u128-types.md)
61+
- [Re-export Syntax (`pub use`)](./wep-2026-01-25-pub-use-reexport.md)
62+
- [Variant Payload Design](./wep-2026-01-25-variant-payload-design.md)
63+
- [Effect System Design](./wep-2026-01-27-effect-system-design.md)
64+
- [Match Expression Design](./wep-2026-01-28-match-expression-design.md)
65+
- [Global Variables](./wep-2026-01-27-global-variables.md)
66+
- [WIT and Wado Mapping](./wep-2026-01-29-wit-wado-mapping.md)
67+
- [Newtype Semantics](./wep-2026-01-29-newtype-semantics.md)
68+
- [SIMD v128 Types](./wep-2026-01-31-simd-v128.md)
69+
- [Format Traits](./wep-2026-02-01-format-traits.md)
70+
- [Wasm Plan Phase](./wep-2026-02-03-wasm-plan-phase.md)
71+
- [Trait Bounds Enforcement](./wep-2026-02-07-trait-bounds.md)
72+
- [Variant Wasm GC Representation](./wep-2026-02-08-variant-representation.md)
73+
- [Variant-Independent Types](./wep-2026-02-09-variant-independent-types.md)
74+
- [Compile-Time Tuple Enumeration](./wep-2026-02-10-compile-time-tuple-enumeration.md)
75+
- [Package Manifest (`wado.toml`)](./wep-2026-02-14-package-manifest.md)
76+
- [Wasm IR (WIR) Layer](./wep-2026-02-14-wir-layer.md)
77+
- [TIR-Level CM Binding Synthesis](./wep-2026-02-15-cm-binding-synthesis.md)
78+
- [WASI HTTP Integration](./wep-2026-02-21-wasi-http.md)
79+
- [Inspect (Debug Output)](./wep-2026-02-21-inspect-debug-output.md)
80+
- [CLI Subcommands for Package Management](./wep-2026-02-22-cli-subcommands.md)
81+
- [Struct Destructuring](./wep-2026-02-22-struct-destructuring.md)
82+
- [Tuple Destructuring](./wep-2026-02-22-tuple-destructuring.md)
83+
- [Base64 Encoding API](./wep-2026-02-27-base64-api.md)
84+
- [Serialization and Deserialization (Serde)](./wep-2026-02-28-serde.md)
85+
- [Documentation Generation (`wado doc`)](./wep-2026-02-28-doc-command.md)
86+
- [Redesign Wasm CM Builtins as Resource Canonical Attributes](./wep-2026-03-01-cm-resource-canonical-attrs.md)
87+
- [Compile-Time File Inclusion (`#include_str`)](./wep-2026-03-02-include-str.md)
88+
- [Gale — Grammar Adaptive LL Engine](./wep-2026-03-02-gale.md)
89+
- [Range Object](./wep-2026-03-03-range-object.md)
90+
- [Default Trait](./wep-2026-03-04-default-trait.md)
91+
- [Variadic Type Parameters](./wep-2026-03-14-variadic-type-parameters.md)
92+
- [Conversion Traits (From, TryFrom, ? operator)](./wep-2026-03-16-conversion-traits.md)
93+
- [WIT Bundling in Component Binaries](./wep-2026-03-21-wit-bundling.md)
94+
- [Same-Scope Shadowing with Self-Reference](./wep-2026-03-25-same-scope-shadowing.md)
95+
- [Migration to GC in Components](./wep-2026-03-28-gc-in-components.md)

docs/CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

docs/cheatsheet-stdlib-core.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,9 @@ impl Array {
10351035
pub fn internal_raw_data(&self) -> builtin::array<T>;
10361036
pub fn internal_from_raw(repr: builtin::array<T>, used: i32) -> Array<T>;
10371037
pub fn append(&mut self, value: T);
1038+
pub fn pop(&mut self) -> Option<T>;
1039+
pub fn truncate(&mut self, len: i32);
1040+
pub fn last(&self) -> Option<T>;
10381041
pub fn get(&self, index: i32) -> Option<T>;
10391042
pub fn copy_within_append(&mut self, src_start: i32, count: i32);
10401043
pub fn slice(&self, start: i32, end: i32) -> ArraySlice<T>;

0 commit comments

Comments
 (0)