@shd101wyy/yo 0.1.28 → 0.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/.github/skills/yo-async-effects/SKILL.md +15 -15
  2. package/.github/skills/yo-async-effects/async-effects-recipes.md +118 -121
  3. package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +33 -13
  4. package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +1 -1
  5. package/.github/skills/yo-syntax/SKILL.md +2 -2
  6. package/.github/skills/yo-syntax/syntax-cheatsheet.md +108 -96
  7. package/README.md +6 -3
  8. package/out/cjs/index.cjs +812 -706
  9. package/out/cjs/yo-cli.cjs +1023 -907
  10. package/out/cjs/yo-lsp.cjs +836 -730
  11. package/out/esm/index.mjs +757 -651
  12. package/out/types/src/codegen/exprs/async.d.ts +2 -0
  13. package/out/types/src/codegen/exprs/await.d.ts +1 -0
  14. package/out/types/src/codegen/exprs/closures.d.ts +4 -0
  15. package/out/types/src/codegen/functions/context.d.ts +6 -0
  16. package/out/types/src/codegen/functions/declarations.d.ts +1 -1
  17. package/out/types/src/doc/model.d.ts +0 -1
  18. package/out/types/src/env.d.ts +2 -2
  19. package/out/types/src/evaluator/builtins/pragma.d.ts +9 -0
  20. package/out/types/src/evaluator/builtins/unsafe.d.ts +8 -0
  21. package/out/types/src/evaluator/context.d.ts +3 -1
  22. package/out/types/src/evaluator/exprs/{escape.d.ts → unwind.d.ts} +1 -1
  23. package/out/types/src/evaluator/index.d.ts +1 -1
  24. package/out/types/src/evaluator/memory-safety.d.ts +14 -0
  25. package/out/types/src/evaluator/types/flowability.d.ts +6 -0
  26. package/out/types/src/evaluator/types/function.d.ts +1 -2
  27. package/out/types/src/evaluator/utils.d.ts +0 -1
  28. package/out/types/src/expr-traversal.d.ts +1 -0
  29. package/out/types/src/expr.d.ts +9 -7
  30. package/out/types/src/public-safe-report.d.ts +19 -0
  31. package/out/types/src/tests/comptime-ref-gate.test.d.ts +1 -0
  32. package/out/types/src/tests/pragma-validation.test.d.ts +1 -0
  33. package/out/types/src/tests/public-safe-report.test.d.ts +1 -0
  34. package/out/types/src/tests/type-representation-pointer.test.d.ts +1 -0
  35. package/out/types/src/tests/unsafe-gate.test.d.ts +1 -0
  36. package/out/types/src/tests/unsafe-report-classify.test.d.ts +1 -0
  37. package/out/types/src/types/creators.d.ts +4 -6
  38. package/out/types/src/types/definitions.d.ts +9 -16
  39. package/out/types/src/types/guards.d.ts +1 -2
  40. package/out/types/src/types/tags.d.ts +0 -1
  41. package/out/types/src/types/utils.d.ts +5 -0
  42. package/out/types/src/unsafe-report.d.ts +29 -0
  43. package/out/types/src/value.d.ts +1 -0
  44. package/out/types/tsconfig.tsbuildinfo +1 -1
  45. package/package.json +1 -1
  46. package/scripts/add-pragma-for-pointer-decls.ts +134 -0
  47. package/scripts/add-pragma.ts +58 -0
  48. package/scripts/migrate-amp-method-calls.ts +186 -0
  49. package/scripts/migrate-clone-calls.ts +93 -0
  50. package/scripts/migrate-get-unwrap.ts +166 -0
  51. package/scripts/migrate-index-patterns.ts +210 -0
  52. package/scripts/migrate-index-trait.ts +142 -0
  53. package/scripts/migrate-iterator.ts +150 -0
  54. package/scripts/migrate-self-ptr.ts +220 -0
  55. package/scripts/migrate-skip-pragmas.ts +109 -0
  56. package/scripts/migrate-tostring.ts +134 -0
  57. package/scripts/trim-pragma.ts +130 -0
  58. package/scripts/wrap-extern-calls.ts +161 -0
  59. package/std/alg/hash.yo +3 -2
  60. package/std/allocator.yo +6 -5
  61. package/std/async.yo +2 -2
  62. package/std/collections/array_list.yo +59 -40
  63. package/std/collections/btree_map.yo +19 -18
  64. package/std/collections/deque.yo +9 -8
  65. package/std/collections/hash_map.yo +101 -13
  66. package/std/collections/hash_set.yo +5 -4
  67. package/std/collections/linked_list.yo +39 -4
  68. package/std/collections/ordered_map.yo +3 -3
  69. package/std/collections/priority_queue.yo +14 -13
  70. package/std/crypto/md5.yo +2 -1
  71. package/std/crypto/random.yo +21 -20
  72. package/std/crypto/sha256.yo +2 -1
  73. package/std/encoding/base64.yo +18 -18
  74. package/std/encoding/hex.yo +5 -5
  75. package/std/encoding/json.yo +62 -13
  76. package/std/encoding/punycode.yo +24 -23
  77. package/std/encoding/toml.yo +4 -3
  78. package/std/encoding/utf16.yo +3 -3
  79. package/std/env.yo +43 -28
  80. package/std/error.yo +15 -3
  81. package/std/fmt/display.yo +2 -2
  82. package/std/fmt/index.yo +6 -5
  83. package/std/fmt/to_string.yo +39 -38
  84. package/std/fmt/writer.yo +9 -8
  85. package/std/fs/dir.yo +61 -66
  86. package/std/fs/file.yo +121 -126
  87. package/std/fs/metadata.yo +13 -18
  88. package/std/fs/temp.yo +35 -30
  89. package/std/fs/walker.yo +14 -19
  90. package/std/gc.yo +1 -0
  91. package/std/glob.yo +7 -7
  92. package/std/http/client.yo +33 -36
  93. package/std/http/http.yo +6 -6
  94. package/std/http/index.yo +4 -4
  95. package/std/imm/list.yo +33 -0
  96. package/std/imm/map.yo +2 -1
  97. package/std/imm/set.yo +1 -0
  98. package/std/imm/sorted_map.yo +1 -0
  99. package/std/imm/sorted_set.yo +1 -0
  100. package/std/imm/string.yo +27 -23
  101. package/std/imm/vec.yo +18 -2
  102. package/std/io/reader.yo +2 -1
  103. package/std/io/writer.yo +3 -2
  104. package/std/libc/assert.yo +1 -0
  105. package/std/libc/ctype.yo +1 -0
  106. package/std/libc/dirent.yo +1 -0
  107. package/std/libc/errno.yo +1 -0
  108. package/std/libc/fcntl.yo +1 -0
  109. package/std/libc/float.yo +1 -0
  110. package/std/libc/limits.yo +1 -0
  111. package/std/libc/math.yo +1 -0
  112. package/std/libc/signal.yo +1 -0
  113. package/std/libc/stdatomic.yo +1 -0
  114. package/std/libc/stdint.yo +1 -0
  115. package/std/libc/stdio.yo +1 -0
  116. package/std/libc/stdlib.yo +1 -0
  117. package/std/libc/string.yo +1 -0
  118. package/std/libc/sys/stat.yo +1 -0
  119. package/std/libc/time.yo +1 -0
  120. package/std/libc/unistd.yo +1 -0
  121. package/std/libc/wctype.yo +1 -0
  122. package/std/libc/windows.yo +2 -0
  123. package/std/log.yo +7 -6
  124. package/std/net/addr.yo +6 -5
  125. package/std/net/dns.yo +13 -16
  126. package/std/net/errors.yo +9 -9
  127. package/std/net/tcp.yo +71 -74
  128. package/std/net/udp.yo +40 -43
  129. package/std/os/signal.yo +5 -5
  130. package/std/path.yo +1 -0
  131. package/std/prelude.yo +377 -200
  132. package/std/process/command.yo +57 -46
  133. package/std/process/index.yo +2 -1
  134. package/std/regex/compiler.yo +10 -9
  135. package/std/regex/index.yo +41 -41
  136. package/std/regex/match.yo +2 -2
  137. package/std/regex/parser.yo +31 -31
  138. package/std/regex/vm.yo +42 -41
  139. package/std/string/string.yo +95 -40
  140. package/std/string/string_builder.yo +9 -9
  141. package/std/string/unicode.yo +50 -49
  142. package/std/sync/channel.yo +2 -1
  143. package/std/sync/cond.yo +5 -4
  144. package/std/sync/mutex.yo +4 -3
  145. package/std/sys/advise.yo +1 -0
  146. package/std/sys/bufio/buf_reader.yo +27 -26
  147. package/std/sys/bufio/buf_writer.yo +22 -21
  148. package/std/sys/clock.yo +1 -0
  149. package/std/sys/copy.yo +1 -0
  150. package/std/sys/dir.yo +10 -9
  151. package/std/sys/dns.yo +6 -5
  152. package/std/sys/errors.yo +12 -12
  153. package/std/sys/events.yo +1 -0
  154. package/std/sys/externs.yo +38 -37
  155. package/std/sys/file.yo +17 -16
  156. package/std/sys/future.yo +4 -3
  157. package/std/sys/iov.yo +1 -0
  158. package/std/sys/mmap.yo +1 -0
  159. package/std/sys/path.yo +1 -0
  160. package/std/sys/perm.yo +2 -1
  161. package/std/sys/pipe.yo +1 -0
  162. package/std/sys/process.yo +5 -4
  163. package/std/sys/signal.yo +1 -0
  164. package/std/sys/socketpair.yo +1 -0
  165. package/std/sys/sockinfo.yo +1 -0
  166. package/std/sys/statfs.yo +2 -1
  167. package/std/sys/statx.yo +1 -0
  168. package/std/sys/sysinfo.yo +1 -0
  169. package/std/sys/tcp.yo +15 -14
  170. package/std/sys/temp.yo +1 -0
  171. package/std/sys/time.yo +2 -1
  172. package/std/sys/timer.yo +6 -6
  173. package/std/sys/tty.yo +2 -1
  174. package/std/sys/udp.yo +13 -12
  175. package/std/sys/unix.yo +12 -11
  176. package/std/testing/bench.yo +4 -3
  177. package/std/thread.yo +7 -6
  178. package/std/time/datetime.yo +18 -15
  179. package/std/time/duration.yo +11 -10
  180. package/std/time/instant.yo +4 -4
  181. package/std/time/sleep.yo +1 -0
  182. package/std/url/index.yo +5 -5
  183. package/std/worker.yo +4 -3
package/std/sys/file.yo CHANGED
@@ -2,64 +2,65 @@
2
2
  //!
3
3
  //! Provides low-level file I/O wrappers around the C runtime externs.
4
4
  //!
5
- //! Async operations return `IOFuture` which resolves to:
5
+ //! Async operations return `IoFuture` which resolves to:
6
6
  //! - Positive value: success (fd for open, bytes for read/write, 0 for others)
7
7
  //! - Negative value: -errno on failure
8
- // Use IOError.from_result() to convert results to Result(i32, IOError).
8
+ // Use IoError.from_result() to convert results to Result(i32, IoError).
9
9
  //
10
10
  // Example:
11
- // IO :: import "std/io";
11
+ // Io :: import "std/io";
12
12
  //
13
13
  // task := async {
14
14
  // (path : *(u8)) = "test.txt";
15
- // fd_result := await IO.openat(IO.AT_FDCWD, path, IO.O_RDONLY, i32(0));
16
- // fd := IOError.from_result(fd_result).unwrap();
17
- // close_result := await IO.close(fd);
15
+ // fd_result := await Io.openat(Io.AT_FDCWD, path, Io.O_RDONLY, i32(0));
16
+ // fd := IoError.from_result(fd_result).unwrap();
17
+ // close_result := await Io.close(fd);
18
18
  // };
19
- { IOFuture } :: import("./future.yo");
19
+ pragma(Pragma.AllowUnsafe);
20
+ { IoFuture } :: import("./future.yo");
20
21
  { __yo_async_read_start, __yo_async_write_start, __yo_async_openat_start, __yo_async_close_start, __yo_async_statx_start, __yo_async_fsync_start, __yo_async_fdatasync_start, __yo_async_ftruncate_start, __yo_file_open, __yo_file_close, __yo_file_size } :: import("./externs.yo");
21
22
  // ============================================================================
22
- // Async File Operations (return IOFuture, use with await)
23
+ // Async File Operations (return IoFuture, use with await)
23
24
  // ============================================================================
24
25
  // Open a file relative to dirfd. Use AT_FDCWD for current directory.
25
26
  // Returns fd on success, -errno on failure.
26
- openat :: (fn(dirfd : i32, path : *(u8), flags : i32, mode : i32) -> IOFuture)(
27
+ openat :: (fn(dirfd : i32, path : *(u8), flags : i32, mode : i32) -> IoFuture)(
27
28
  __yo_async_openat_start(dirfd, path, flags, mode)
28
29
  );
29
30
  // Close a file descriptor.
30
31
  // Returns 0 on success, -errno on failure.
31
- close :: (fn(fd : i32) -> IOFuture)(
32
+ close :: (fn(fd : i32) -> IoFuture)(
32
33
  __yo_async_close_start(fd)
33
34
  );
34
35
  // Read from fd into buffer at the given offset.
35
36
  // Returns number of bytes read on success, -errno on failure.
36
- read :: (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IOFuture)(
37
+ read :: (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IoFuture)(
37
38
  __yo_async_read_start(fd, buffer, size, offset)
38
39
  );
39
40
  // Write buffer to fd at the given offset.
40
41
  // Returns number of bytes written on success, -errno on failure.
41
- write :: (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IOFuture)(
42
+ write :: (fn(fd : i32, buffer : *(u8), size : u32, offset : u64) -> IoFuture)(
42
43
  __yo_async_write_start(fd, buffer, size, offset)
43
44
  );
44
45
  // Get file metadata via statx. Results are written to statxbuf.
45
46
  // Use Statx object to wrap and read the buffer.
46
47
  // Returns 0 on success, -errno on failure.
47
- statx :: (fn(dirfd : i32, path : *(u8), flags : i32, mask : u32, statxbuf : *(u8)) -> IOFuture)(
48
+ statx :: (fn(dirfd : i32, path : *(u8), flags : i32, mask : u32, statxbuf : *(u8)) -> IoFuture)(
48
49
  __yo_async_statx_start(dirfd, path, flags, mask, statxbuf)
49
50
  );
50
51
  // Sync file data and metadata to disk.
51
52
  // Returns 0 on success, -errno on failure.
52
- fsync :: (fn(fd : i32) -> IOFuture)(
53
+ fsync :: (fn(fd : i32) -> IoFuture)(
53
54
  __yo_async_fsync_start(fd)
54
55
  );
55
56
  // Sync file data (but not metadata) to disk.
56
57
  // Returns 0 on success, -errno on failure.
57
- fdatasync :: (fn(fd : i32) -> IOFuture)(
58
+ fdatasync :: (fn(fd : i32) -> IoFuture)(
58
59
  __yo_async_fdatasync_start(fd)
59
60
  );
60
61
  // Truncate file to the given length.
61
62
  // Returns 0 on success, -errno on failure.
62
- ftruncate :: (fn(fd : i32, length : i64) -> IOFuture)(
63
+ ftruncate :: (fn(fd : i32, length : i64) -> IoFuture)(
63
64
  __yo_async_ftruncate_start(fd, length)
64
65
  );
65
66
  // ============================================================================
package/std/sys/future.yo CHANGED
@@ -1,13 +1,14 @@
1
- //! `IOFuture` type — opaque handle to a C async I/O future struct.
1
+ //! `IoFuture` type — opaque handle to a C async I/O future struct.
2
2
  // ============================================================================
3
3
  // Extern type for I/O Future
4
4
  // ============================================================================
5
+ pragma(Pragma.AllowUnsafe);
5
6
  extern(
6
7
  "Yo",
7
8
  __yo_io_future_t : Type
8
9
  );
9
- IOFuture :: Impl(Concrete(__yo_io_future_t), Future(i32));
10
+ IoFuture :: Impl(Concrete(__yo_io_future_t), Future(i32));
10
11
  export(
11
12
  __yo_io_future_t,
12
- IOFuture
13
+ IoFuture
13
14
  );
package/std/sys/iov.yo CHANGED
@@ -2,6 +2,7 @@
2
2
  //!
3
3
  //! Synchronous wrappers for vectored file descriptor I/O.
4
4
  //! Returns byte count on success, -errno / negative platform error on failure.
5
+ pragma(Pragma.AllowUnsafe);
5
6
  { __yo_sync_readv, __yo_sync_writev, __yo_sync_preadv, __yo_sync_pwritev, __yo_iovec_size, __yo_iovec_set } :: import("./externs.yo");
6
7
  iovec_size :: (fn() -> usize)(
7
8
  __yo_iovec_size()
package/std/sys/mmap.yo CHANGED
@@ -6,6 +6,7 @@
6
6
  //! - Mapped pointer on success
7
7
  //! - Encoded error pointer on failure (negative errno cast to pointer)
8
8
  // Use is_error(ptr) and error_code(ptr) to detect/decode mmap failures.
9
+ pragma(Pragma.AllowUnsafe);
9
10
  { platform, Platform } :: import("../process");
10
11
  { __yo_sync_mmap, __yo_sync_mmap_is_error, __yo_sync_mmap_errno, __yo_sync_munmap, __yo_sync_mprotect, __yo_sync_msync } :: import("./externs.yo");
11
12
  // Protection constants
package/std/sys/path.yo CHANGED
@@ -2,6 +2,7 @@
2
2
  //!
3
3
  //! Synchronous wrapper for `realpath`.
4
4
  //! Returns 0 on success, -errno on failure.
5
+ pragma(Pragma.AllowUnsafe);
5
6
  { __yo_sync_realpath } :: import("./externs.yo");
6
7
  // Resolve a path to its canonical absolute form (resolves symlinks, . and ..).
7
8
  // Writes result to `resolved` buffer (must be at least PATH_MAX bytes).
package/std/sys/perm.yo CHANGED
@@ -1,7 +1,7 @@
1
1
  //! File permission and access operations.
2
2
  //!
3
3
  //! Provides synchronous wrappers for `chmod`, `chown`, and `access` operations.
4
- //! All operations return `i32` directly (no `IOFuture` overhead).
4
+ //! All operations return `i32` directly (no `IoFuture` overhead).
5
5
  //!
6
6
  //! Returns:
7
7
  //! - 0: success
@@ -18,6 +18,7 @@
18
18
  // // Change file permissions to 0644
19
19
  // ret2 := perm.chmodat(AT_FDCWD, *(u8)("/tmp/test.txt"), u32(0o644), i32(0));
20
20
  // assert(ret2 == i32(0));
21
+ pragma(Pragma.AllowUnsafe);
21
22
  { __yo_sync_access, __yo_sync_fchmod, __yo_sync_fchmodat, __yo_sync_fchown, __yo_sync_fchownat } :: import("./externs.yo");
22
23
  // ============================================================================
23
24
  // chmod — Change file permissions
package/std/sys/pipe.yo CHANGED
@@ -7,6 +7,7 @@
7
7
  //!
8
8
  //! - `pipe`: 0 on success, -errno on failure
9
9
  //! - `dup`/`dup2`: new fd on success, -errno on failure
10
+ pragma(Pragma.AllowUnsafe);
10
11
  { __yo_sync_pipe, __yo_sync_dup, __yo_sync_dup2 } :: import("./externs.yo");
11
12
  // Create a pipe pair (pipefd[0] = read, pipefd[1] = write).
12
13
  // Returns 0 on success, -errno on failure.
@@ -1,13 +1,14 @@
1
1
  //! Child process management.
2
2
  //!
3
3
  //! Provides cross-platform child process spawning, waiting, and signal delivery.
4
- //! All async operations return `IOFuture` which resolves to:
4
+ //! All async operations return `IoFuture` which resolves to:
5
5
  //! - Positive value: success (pid for spawn, status for waitpid)
6
6
  //! - Negative value: -errno on failure
7
7
  //!
8
8
  //! `argv`/`envp` are NULL-terminated arrays of C strings.
9
9
  // Use `?*(u8)` for entries so .None can be used as the terminator.
10
- { IOFuture } :: import("./future.yo");
10
+ pragma(Pragma.AllowUnsafe);
11
+ { IoFuture } :: import("./future.yo");
11
12
  { __yo_async_spawn_start, __yo_async_waitpid_start, __yo_process_exit_status, __yo_process_term_signal, __yo_kill } :: import("./externs.yo");
12
13
  // Spawn a child process.
13
14
  // Returns the child pid on success, -errno on failure.
@@ -22,13 +23,13 @@ spawn :: (
22
23
  stdin_fd : i32,
23
24
  stdout_fd : i32,
24
25
  stderr_fd : i32
25
- ) -> IOFuture
26
+ ) -> IoFuture
26
27
  )(
27
28
  __yo_async_spawn_start(file, argv, envp, stdin_fd, stdout_fd, stderr_fd)
28
29
  );
29
30
  // Wait for a child process to exit.
30
31
  // Returns the exit status (encoded; use exit_status/term_signal helpers).
31
- waitpid :: (fn(pid : i32, options : i32) -> IOFuture)(
32
+ waitpid :: (fn(pid : i32, options : i32) -> IoFuture)(
32
33
  __yo_async_waitpid_start(pid, options)
33
34
  );
34
35
  // Send a signal to a process.
package/std/sys/signal.yo CHANGED
@@ -1,6 +1,7 @@
1
1
  //! Signal handling functions.
2
2
  //!
3
3
  //! Provides low-level wrappers for signal registration and delivery.
4
+ pragma(Pragma.AllowUnsafe);
4
5
  { __yo_signal_start, __yo_signal_stop, __yo_kill } :: import("./externs.yo");
5
6
  SignalHandler :: (fn(data : *(u8)) -> unit);
6
7
  // Register a signal handler.
@@ -2,6 +2,7 @@
2
2
  //!
3
3
  //! Synchronous wrapper for `socketpair`-like behavior.
4
4
  //! Returns 0 on success, negative error on failure.
5
+ pragma(Pragma.AllowUnsafe);
5
6
  { __yo_sync_socketpair } :: import("./externs.yo");
6
7
  // Create a pair of connected sockets.
7
8
  // Writes two socket fds into `sv` (sv[0], sv[1]).
@@ -2,6 +2,7 @@
2
2
  //!
3
3
  //! Synchronous wrappers for socket metadata operations.
4
4
  //! Returns 0 on success, -errno (or negative platform socket error) on failure.
5
+ pragma(Pragma.AllowUnsafe);
5
6
  { __yo_sync_getsockname, __yo_sync_getpeername, __yo_sync_getsockopt, __yo_sync_setsockopt } :: import("./externs.yo");
6
7
  // Get local address of a socket.
7
8
  // Writes the address into `addr` buffer and updates `addrlen` with actual size.
package/std/sys/statfs.yo CHANGED
@@ -3,7 +3,7 @@
3
3
  //! Provides a synchronous wrapper around `statfs` and typed accessors
4
4
  //! for the statfs buffer returned by the C runtime.
5
5
  //!
6
- //! All operations return `i32` directly (no `IOFuture` overhead):
6
+ //! All operations return `i32` directly (no `IoFuture` overhead):
7
7
  //! - 0 on success
8
8
  //! - Negative value: -errno on failure
9
9
  //
@@ -16,6 +16,7 @@
16
16
  // assert(ret == i32(0));
17
17
  // block_size := statfs.statfs_bsize(buf);
18
18
  // free(.Some(*(void)(buf)));
19
+ pragma(Pragma.AllowUnsafe);
19
20
  { __yo_sync_statfs, __yo_statfs_buf_size, __yo_statfs_type, __yo_statfs_bsize, __yo_statfs_blocks, __yo_statfs_bfree, __yo_statfs_bavail, __yo_statfs_files, __yo_statfs_ffree } :: import("./externs.yo");
20
21
  // ============================================================================
21
22
  // statfs — Filesystem statistics (sync)
package/std/sys/statx.yo CHANGED
@@ -2,6 +2,7 @@
2
2
  //!
3
3
  //! Object wrapper around the C statx buffer, providing
4
4
  //! accessor methods for file metadata.
5
+ pragma(Pragma.AllowUnsafe);
5
6
  { S_IFMT, S_IFREG, S_IFDIR, S_IFLNK } :: import("./constants.yo");
6
7
  { __yo_statx_mode, __yo_statx_size, __yo_statx_uid, __yo_statx_gid, __yo_statx_ino, __yo_statx_nlink, __yo_statx_mtime_sec, __yo_statx_mtime_nsec, __yo_statx_atime_sec, __yo_statx_atime_nsec, __yo_statx_ctime_sec, __yo_statx_ctime_nsec } :: import("./externs.yo");
7
8
  // ============================================================================
@@ -2,6 +2,7 @@
2
2
  //!
3
3
  //! Synchronous wrappers for `uname`/`gethostname`.
4
4
  //! Returns 0 on success, -errno / negative platform error on failure.
5
+ pragma(Pragma.AllowUnsafe);
5
6
  { platform, Platform } :: import("../process");
6
7
  { __yo_sync_uname, __yo_sync_gethostname } :: import("./externs.yo");
7
8
  // uname() layout constants.
package/std/sys/tcp.yo CHANGED
@@ -3,7 +3,7 @@
3
3
  //! Provides TCP socket wrappers around the low-level C runtime externs.
4
4
  //! Uses the socket address helpers to construct `sockaddr_in`/`sockaddr_in6` buffers.
5
5
  //!
6
- //! All async operations return `IOFuture` which resolves to:
6
+ //! All async operations return `IoFuture` which resolves to:
7
7
  //! - Positive value: success (fd for socket/accept, bytes for send/recv, 0 for others)
8
8
  //! - Negative value: -errno on failure
9
9
  //
@@ -33,9 +33,10 @@
33
33
  // client_fd := await tcp.accept(sockfd);
34
34
  // // ...
35
35
  // };
36
+ pragma(Pragma.AllowUnsafe);
36
37
  { GlobalAllocator } :: import("../allocator.yo");
37
38
  { malloc, free } :: GlobalAllocator;
38
- { IOFuture } :: import("./future.yo");
39
+ { IoFuture } :: import("./future.yo");
39
40
  { __yo_async_socket_start, __yo_async_bind_start, __yo_async_listen_start, __yo_async_accept_start, __yo_async_connect_start, __yo_async_send_start, __yo_async_recv_start, __yo_async_shutdown_start, __yo_async_setsockopt_start, __yo_async_getsockopt_start, __yo_async_close_start, __yo_sockaddr_set_family, __yo_sockaddr_get_family, __yo_sockaddr_in_set_port, __yo_sockaddr_in_get_port, __yo_sockaddr_in_set_addr, __yo_sockaddr_in_get_addr, __yo_sockaddr_in6_set_port, __yo_sockaddr_in6_get_port, __yo_sockaddr_in6_set_addr, __yo_sockaddr_in6_get_addr, __yo_inet_pton, __yo_inet_ntop, __yo_htons, __yo_ntohs, __yo_htonl, __yo_ntohl } :: import("./externs.yo");
40
41
  { AF_INET, AF_INET6, SOCK_STREAM, sockaddr_in_size, sockaddr_in6_size } :: import("./socket.yo");
41
42
  // ============================================================================
@@ -47,55 +48,55 @@ SockAddr :: struct(
47
48
  );
48
49
  export(SockAddr);
49
50
  // ============================================================================
50
- // Core TCP Operations (return IOFuture, use with await)
51
+ // Core TCP Operations (return IoFuture, use with await)
51
52
  // ============================================================================
52
53
  // Create a TCP socket.
53
54
  // domain: AF_INET or AF_INET6
54
55
  // Returns fd on success, -errno on failure.
55
- socket :: (fn(domain : i32, sock_type : i32, protocol : i32) -> IOFuture)(
56
+ socket :: (fn(domain : i32, sock_type : i32, protocol : i32) -> IoFuture)(
56
57
  __yo_async_socket_start(domain, sock_type, protocol)
57
58
  );
58
59
  // Bind a socket to a local address.
59
60
  // Returns 0 on success, -errno on failure.
60
- bind :: (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IOFuture)(
61
+ bind :: (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IoFuture)(
61
62
  __yo_async_bind_start(sockfd, addr, addrlen)
62
63
  );
63
64
  // Listen for incoming connections on a socket.
64
65
  // backlog: maximum length of the pending connections queue.
65
66
  // Returns 0 on success, -errno on failure.
66
- listen :: (fn(sockfd : i32, backlog : i32) -> IOFuture)(
67
+ listen :: (fn(sockfd : i32, backlog : i32) -> IoFuture)(
67
68
  __yo_async_listen_start(sockfd, backlog)
68
69
  );
69
70
  // Accept an incoming connection on a listening socket.
70
71
  // Returns the new connection fd on success, -errno on failure.
71
72
  // addr/addrlen can be used to retrieve the peer address.
72
- accept :: (fn(sockfd : i32, addr : *(u8), addrlen : *(u32)) -> IOFuture)(
73
+ accept :: (fn(sockfd : i32, addr : *(u8), addrlen : *(u32)) -> IoFuture)(
73
74
  __yo_async_accept_start(sockfd, addr, addrlen)
74
75
  );
75
76
  // Connect to a remote address.
76
77
  // Returns 0 on success, -errno on failure.
77
- connect :: (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IOFuture)(
78
+ connect :: (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IoFuture)(
78
79
  __yo_async_connect_start(sockfd, addr, addrlen)
79
80
  );
80
81
  // Send data on a connected socket.
81
82
  // Returns number of bytes sent on success, -errno on failure.
82
- send :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture)(
83
+ send :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IoFuture)(
83
84
  __yo_async_send_start(sockfd, buf, len, flags)
84
85
  );
85
86
  // Receive data from a connected socket.
86
87
  // Returns number of bytes received on success (0 = peer closed), -errno on failure.
87
- recv :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture)(
88
+ recv :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IoFuture)(
88
89
  __yo_async_recv_start(sockfd, buf, len, flags)
89
90
  );
90
91
  // Shut down part of a full-duplex connection.
91
92
  // how: SHUT_RD (0), SHUT_WR (1), or SHUT_RDWR (2).
92
93
  // Returns 0 on success, -errno on failure.
93
- shutdown :: (fn(sockfd : i32, how : i32) -> IOFuture)(
94
+ shutdown :: (fn(sockfd : i32, how : i32) -> IoFuture)(
94
95
  __yo_async_shutdown_start(sockfd, how)
95
96
  );
96
97
  // Close a socket file descriptor.
97
98
  // Returns 0 on success, -errno on failure.
98
- close :: (fn(fd : i32) -> IOFuture)(
99
+ close :: (fn(fd : i32) -> IoFuture)(
99
100
  __yo_async_close_start(fd)
100
101
  );
101
102
  // ============================================================================
@@ -103,12 +104,12 @@ close :: (fn(fd : i32) -> IOFuture)(
103
104
  // ============================================================================
104
105
  // Set a socket option (raw).
105
106
  // Returns 0 on success, -errno on failure.
106
- setsockopt :: (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : u32) -> IOFuture)(
107
+ setsockopt :: (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : u32) -> IoFuture)(
107
108
  __yo_async_setsockopt_start(sockfd, level, optname, optval, optlen)
108
109
  );
109
110
  // Get a socket option (raw).
110
111
  // Returns 0 on success, -errno on failure.
111
- getsockopt :: (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : *(u32)) -> IOFuture)(
112
+ getsockopt :: (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : *(u32)) -> IoFuture)(
112
113
  __yo_async_getsockopt_start(sockfd, level, optname, optval, optlen)
113
114
  );
114
115
  // ============================================================================
package/std/sys/temp.yo CHANGED
@@ -7,6 +7,7 @@
7
7
  //!
8
8
  //! - `mkdtemp`: 0 on success, -errno on failure
9
9
  //! - `mkstemp`: fd on success, -errno on failure
10
+ pragma(Pragma.AllowUnsafe);
10
11
  { __yo_sync_mkdtemp, __yo_sync_mkstemp } :: import("./externs.yo");
11
12
  // Create a temporary directory from template (e.g., "/tmp/myapp-XXXXXX").
12
13
  // The template is modified in-place with the actual path.
package/std/sys/time.yo CHANGED
@@ -1,7 +1,7 @@
1
1
  //! File timestamp operations.
2
2
  //!
3
3
  //! Provides synchronous wrappers for `utime`/`futime`/`lutime` to change file timestamps.
4
- //! All operations return `i32` directly (no `IOFuture` overhead).
4
+ //! All operations return `i32` directly (no `IoFuture` overhead).
5
5
  //!
6
6
  //! Returns:
7
7
  //! - 0: success
@@ -21,6 +21,7 @@
21
21
  // // Set timestamps on an open fd
22
22
  // ret2 := time.futime(fd, i64(1000000), i64(0), i64(2000000), i64(0));
23
23
  // assert(ret2 == i32(0));
24
+ pragma(Pragma.AllowUnsafe);
24
25
  { __yo_sync_utime, __yo_sync_futime, __yo_sync_lutime } :: import("./externs.yo");
25
26
  // ============================================================================
26
27
  // utime — Change file timestamps by path
package/std/sys/timer.yo CHANGED
@@ -3,21 +3,21 @@
3
3
  //! Provides high-level async timer functions:
4
4
  //! - `sleep(ms)` — async sleep for the given number of milliseconds
5
5
  //!
6
- //! Returns an `IOFuture` that resolves to a positive value on success
6
+ //! Returns an `IoFuture` that resolves to a positive value on success
7
7
  //! or a negative errno. Use with `await` in async contexts.
8
8
  //
9
9
  // Example:
10
- // IO :: import "std/io";
10
+ // Io :: import "std/io";
11
11
  //
12
12
  // task := async {
13
13
  // // Sleep for 100 milliseconds
14
- // result := await IO.sleep(u64(100));
14
+ // result := await Io.sleep(u64(100));
15
15
  // printf("Woke up! result=%d\n", result);
16
16
  // };
17
- { IOFuture } :: import("./future.yo");
18
- { IOError } :: import("./errors.yo");
17
+ { IoFuture } :: import("./future.yo");
18
+ { IoError } :: import("./errors.yo");
19
19
  { __yo_async_sleep_start } :: import("./externs.yo");
20
- sleep :: (fn(milliseconds : u64) -> IOFuture)(
20
+ sleep :: (fn(milliseconds : u64) -> IoFuture)(
21
21
  __yo_async_sleep_start(milliseconds)
22
22
  );
23
23
  export(sleep);
package/std/sys/tty.yo CHANGED
@@ -1,4 +1,5 @@
1
1
  //! TTY operations.
2
+ pragma(Pragma.AllowUnsafe);
2
3
  { __yo_tty_init, __yo_tty_set_mode, __yo_tty_reset_mode, __yo_tty_get_winsize, __yo_isatty } :: import("./externs.yo");
3
4
  { TTY_MODE_NORMAL, TTY_MODE_RAW, TTY_MODE_IO } :: import("./events.yo");
4
5
  /// Terminal window size.
@@ -13,7 +14,7 @@ WinSize :: struct(
13
14
  tty_init :: (fn(fd : i32) -> i32)(
14
15
  __yo_tty_init(fd)
15
16
  );
16
- /// Set TTY mode (normal, raw, IO).
17
+ /// Set TTY mode (normal, raw, Io).
17
18
  /// Returns 0 on success, -errno on failure.
18
19
  tty_set_mode :: (fn(fd : i32, mode : i32) -> i32)(
19
20
  __yo_tty_set_mode(fd, mode)
package/std/sys/udp.yo CHANGED
@@ -3,7 +3,7 @@
3
3
  //! Provides UDP socket wrappers around the low-level C runtime externs.
4
4
  //! Reuses `SockAddr` and address helpers from `tcp.yo`.
5
5
  //!
6
- //! All async operations return `IOFuture` which resolves to:
6
+ //! All async operations return `IoFuture` which resolves to:
7
7
  //! - Positive value: success (fd for socket, bytes for sendto/recvfrom, 0 for others)
8
8
  //! - Negative value: -errno on failure
9
9
  //
@@ -26,48 +26,49 @@
26
26
  // await udp.close(sockfd);
27
27
  // tcp.free_sockaddr(addr);
28
28
  // };
29
- { IOFuture } :: import("./future.yo");
29
+ pragma(Pragma.AllowUnsafe);
30
+ { IoFuture } :: import("./future.yo");
30
31
  { __yo_async_socket_start, __yo_async_bind_start, __yo_async_send_start, __yo_async_recv_start, __yo_async_sendto_start, __yo_async_recvfrom_start, __yo_async_close_start, __yo_async_setsockopt_start, __yo_async_getsockopt_start } :: import("./externs.yo");
31
32
  { SOCK_DGRAM } :: import("./socket.yo");
32
33
  // ============================================================================
33
- // Core UDP Operations (return IOFuture, use with await)
34
+ // Core UDP Operations (return IoFuture, use with await)
34
35
  // ============================================================================
35
36
  // Create a UDP socket.
36
37
  // domain: AF_INET or AF_INET6
37
38
  // protocol: typically 0
38
39
  // Returns fd on success, -errno on failure.
39
- socket :: (fn(domain : i32, protocol : i32) -> IOFuture)(
40
+ socket :: (fn(domain : i32, protocol : i32) -> IoFuture)(
40
41
  __yo_async_socket_start(domain, SOCK_DGRAM, protocol)
41
42
  );
42
43
  // Bind a UDP socket to a local address.
43
44
  // Returns 0 on success, -errno on failure.
44
- bind :: (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IOFuture)(
45
+ bind :: (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IoFuture)(
45
46
  __yo_async_bind_start(sockfd, addr, addrlen)
46
47
  );
47
48
  // Send a datagram to a specific destination address.
48
49
  // Returns number of bytes sent on success, -errno on failure.
49
- sendto :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32, dest_addr : *(u8), addrlen : u32) -> IOFuture)(
50
+ sendto :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32, dest_addr : *(u8), addrlen : u32) -> IoFuture)(
50
51
  __yo_async_sendto_start(sockfd, buf, len, flags, dest_addr, addrlen)
51
52
  );
52
53
  // Receive a datagram and get the source address.
53
54
  // src_addr/addrlen are filled with the sender's address.
54
55
  // Returns number of bytes received on success, -errno on failure.
55
- recvfrom :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32, src_addr : *(u8), addrlen : *(u32)) -> IOFuture)(
56
+ recvfrom :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32, src_addr : *(u8), addrlen : *(u32)) -> IoFuture)(
56
57
  __yo_async_recvfrom_start(sockfd, buf, len, flags, src_addr, addrlen)
57
58
  );
58
59
  // Send data on a connected UDP socket (after connect()).
59
60
  // Returns number of bytes sent on success, -errno on failure.
60
- send :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture)(
61
+ send :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IoFuture)(
61
62
  __yo_async_send_start(sockfd, buf, len, flags)
62
63
  );
63
64
  // Receive data on a connected UDP socket (after connect()).
64
65
  // Returns number of bytes received on success, -errno on failure.
65
- recv :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture)(
66
+ recv :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IoFuture)(
66
67
  __yo_async_recv_start(sockfd, buf, len, flags)
67
68
  );
68
69
  // Close a UDP socket file descriptor.
69
70
  // Returns 0 on success, -errno on failure.
70
- close :: (fn(fd : i32) -> IOFuture)(
71
+ close :: (fn(fd : i32) -> IoFuture)(
71
72
  __yo_async_close_start(fd)
72
73
  );
73
74
  // ============================================================================
@@ -75,12 +76,12 @@ close :: (fn(fd : i32) -> IOFuture)(
75
76
  // ============================================================================
76
77
  // Set a socket option (raw).
77
78
  // Returns 0 on success, -errno on failure.
78
- setsockopt :: (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : u32) -> IOFuture)(
79
+ setsockopt :: (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : u32) -> IoFuture)(
79
80
  __yo_async_setsockopt_start(sockfd, level, optname, optval, optlen)
80
81
  );
81
82
  // Get a socket option (raw).
82
83
  // Returns 0 on success, -errno on failure.
83
- getsockopt :: (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : *(u32)) -> IOFuture)(
84
+ getsockopt :: (fn(sockfd : i32, level : i32, optname : i32, optval : *(u8), optlen : *(u32)) -> IoFuture)(
84
85
  __yo_async_getsockopt_start(sockfd, level, optname, optval, optlen)
85
86
  );
86
87
  export(
package/std/sys/unix.yo CHANGED
@@ -3,9 +3,10 @@
3
3
  //! Provides Unix domain socket wrappers around the low-level C runtime externs.
4
4
  //! Reuses the socket ops (bind/listen/accept/connect/send/recv/close) from the
5
5
  //! generic socket externs. Uses `sockaddr_un` helpers to build address buffers.
6
+ pragma(Pragma.AllowUnsafe);
6
7
  { GlobalAllocator } :: import("../allocator.yo");
7
8
  { malloc, free } :: GlobalAllocator;
8
- { IOFuture } :: import("./future.yo");
9
+ { IoFuture } :: import("./future.yo");
9
10
  { __yo_async_socket_start, __yo_async_bind_start, __yo_async_listen_start, __yo_async_accept_start, __yo_async_connect_start, __yo_async_send_start, __yo_async_recv_start, __yo_async_close_start, __yo_sockaddr_un_set_path, __yo_sockaddr_un_get_path, __yo_sockaddr_set_family } :: import("./externs.yo");
10
11
  { AF_UNIX, SOCK_STREAM, SOCK_DGRAM, sockaddr_un_size } :: import("./socket.yo");
11
12
  // ============================================================================
@@ -17,51 +18,51 @@ UnixAddr :: struct(
17
18
  );
18
19
  export(UnixAddr);
19
20
  // ============================================================================
20
- // Core Unix Socket Operations (return IOFuture, use with await)
21
+ // Core Unix Socket Operations (return IoFuture, use with await)
21
22
  // ============================================================================
22
23
  // Create a Unix domain socket (SOCK_STREAM).
23
24
  // Returns fd on success, -errno on failure.
24
- socket_stream :: (fn() -> IOFuture)(
25
+ socket_stream :: (fn() -> IoFuture)(
25
26
  __yo_async_socket_start(AF_UNIX, SOCK_STREAM, i32(0))
26
27
  );
27
28
  // Create a Unix domain socket (SOCK_DGRAM).
28
29
  // Returns fd on success, -errno on failure.
29
- socket_dgram :: (fn() -> IOFuture)(
30
+ socket_dgram :: (fn() -> IoFuture)(
30
31
  __yo_async_socket_start(AF_UNIX, SOCK_DGRAM, i32(0))
31
32
  );
32
33
  // Bind a socket to a local Unix address.
33
34
  // Returns 0 on success, -errno on failure.
34
- bind :: (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IOFuture)(
35
+ bind :: (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IoFuture)(
35
36
  __yo_async_bind_start(sockfd, addr, addrlen)
36
37
  );
37
38
  // Listen for incoming connections on a Unix socket.
38
39
  // Returns 0 on success, -errno on failure.
39
- listen :: (fn(sockfd : i32, backlog : i32) -> IOFuture)(
40
+ listen :: (fn(sockfd : i32, backlog : i32) -> IoFuture)(
40
41
  __yo_async_listen_start(sockfd, backlog)
41
42
  );
42
43
  // Accept an incoming connection.
43
44
  // Returns fd on success, -errno on failure.
44
- accept :: (fn(sockfd : i32, addr : *(u8), addrlen : *(u32)) -> IOFuture)(
45
+ accept :: (fn(sockfd : i32, addr : *(u8), addrlen : *(u32)) -> IoFuture)(
45
46
  __yo_async_accept_start(sockfd, addr, addrlen)
46
47
  );
47
48
  // Connect to a Unix socket address.
48
49
  // Returns 0 on success, -errno on failure.
49
- connect :: (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IOFuture)(
50
+ connect :: (fn(sockfd : i32, addr : *(u8), addrlen : u32) -> IoFuture)(
50
51
  __yo_async_connect_start(sockfd, addr, addrlen)
51
52
  );
52
53
  // Send data on a connected Unix socket.
53
54
  // Returns number of bytes sent on success, -errno on failure.
54
- send :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture)(
55
+ send :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IoFuture)(
55
56
  __yo_async_send_start(sockfd, buf, len, flags)
56
57
  );
57
58
  // Receive data from a connected Unix socket.
58
59
  // Returns number of bytes received on success, -errno on failure.
59
- recv :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IOFuture)(
60
+ recv :: (fn(sockfd : i32, buf : *(u8), len : usize, flags : i32) -> IoFuture)(
60
61
  __yo_async_recv_start(sockfd, buf, len, flags)
61
62
  );
62
63
  // Close a Unix socket file descriptor.
63
64
  // Returns 0 on success, -errno on failure.
64
- close :: (fn(fd : i32) -> IOFuture)(
65
+ close :: (fn(fd : i32) -> IoFuture)(
65
66
  __yo_async_close_start(fd)
66
67
  );
67
68
  // ============================================================================
@@ -11,6 +11,7 @@
11
11
  //! result := bench(`sort`, u64(1000), () => { /* work */ });
12
12
  //! println(result.to_string());
13
13
  //! ```
14
+ pragma(Pragma.AllowUnsafe);
14
15
  open(import("../string"));
15
16
  { ToString } :: import("../fmt");
16
17
  { snprintf } :: import("../libc/stdio");
@@ -36,19 +37,19 @@ BenchResult :: struct(
36
37
  _i64_to_string :: (fn(v : i64) -> String)({
37
38
  buf := Array(u8, usize(32)).fill(u8(0));
38
39
  buf_ptr := &(buf(usize(0)));
39
- snprintf(*(char)(buf_ptr), usize(32), "%lld", v);
40
+ unsafe(snprintf(*(char)(buf_ptr), usize(32), "%lld", v));
40
41
  String.from_cstr(buf_ptr).unwrap()
41
42
  });
42
43
  _u64_to_string :: (fn(v : u64) -> String)({
43
44
  buf := Array(u8, usize(32)).fill(u8(0));
44
45
  buf_ptr := &(buf(usize(0)));
45
- snprintf(*(char)(buf_ptr), usize(32), "%llu", v);
46
+ unsafe(snprintf(*(char)(buf_ptr), usize(32), "%llu", v));
46
47
  String.from_cstr(buf_ptr).unwrap()
47
48
  });
48
49
  impl(
49
50
  BenchResult,
50
51
  ToString(
51
- to_string : (fn(self : *(Self)) -> String)({
52
+ to_string : (fn(ref(self) : Self) -> String)({
52
53
  prefix := String.from("bench '");
53
54
  part1 := prefix.concat(self.name);
54
55
  part2 := part1.concat(String.from("': iters="));