@shd101wyy/yo 0.1.29 → 0.1.31

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 (186) hide show
  1. package/.github/skills/yo-async-effects/SKILL.md +3 -3
  2. package/.github/skills/yo-async-effects/async-effects-recipes.md +19 -11
  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/syntax-cheatsheet.md +59 -21
  6. package/README.md +4 -3
  7. package/out/cjs/index.cjs +964 -710
  8. package/out/cjs/yo-cli.cjs +1119 -855
  9. package/out/cjs/yo-lsp.cjs +1003 -749
  10. package/out/esm/index.mjs +964 -710
  11. package/out/types/src/codegen/exprs/async.d.ts +2 -0
  12. package/out/types/src/codegen/exprs/await.d.ts +1 -0
  13. package/out/types/src/codegen/exprs/closures.d.ts +4 -0
  14. package/out/types/src/codegen/functions/context.d.ts +6 -0
  15. package/out/types/src/codegen/index.d.ts +1 -1
  16. package/out/types/src/compiler-utils.d.ts +1 -1
  17. package/out/types/src/env.d.ts +2 -0
  18. package/out/types/src/evaluator/builtins/pragma.d.ts +9 -0
  19. package/out/types/src/evaluator/builtins/unsafe.d.ts +8 -0
  20. package/out/types/src/evaluator/context.d.ts +2 -0
  21. package/out/types/src/evaluator/index.d.ts +1 -1
  22. package/out/types/src/evaluator/memory-safety.d.ts +14 -0
  23. package/out/types/src/evaluator/types/flowability.d.ts +6 -0
  24. package/out/types/src/evaluator/utils/closure.d.ts +2 -1
  25. package/out/types/src/evaluator/utils.d.ts +3 -0
  26. package/out/types/src/evaluator/values/impl.d.ts +14 -0
  27. package/out/types/src/expr-traversal.d.ts +1 -0
  28. package/out/types/src/expr.d.ts +4 -1
  29. package/out/types/src/public-safe-report.d.ts +19 -0
  30. package/out/types/src/tests/comptime-ref-gate.test.d.ts +1 -0
  31. package/out/types/src/tests/pragma-validation.test.d.ts +1 -0
  32. package/out/types/src/tests/public-safe-report.test.d.ts +1 -0
  33. package/out/types/src/tests/thread-safety-codegen.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/definitions.d.ts +2 -0
  38. package/out/types/src/types/utils.d.ts +4 -0
  39. package/out/types/src/unsafe-report.d.ts +29 -0
  40. package/out/types/src/value.d.ts +1 -0
  41. package/out/types/tsconfig.tsbuildinfo +1 -1
  42. package/package.json +1 -1
  43. package/scripts/add-pragma-for-pointer-decls.ts +134 -0
  44. package/scripts/add-pragma.ts +58 -0
  45. package/scripts/migrate-amp-method-calls.ts +186 -0
  46. package/scripts/migrate-clone-calls.ts +93 -0
  47. package/scripts/migrate-get-unwrap.ts +166 -0
  48. package/scripts/migrate-index-patterns.ts +210 -0
  49. package/scripts/migrate-index-trait.ts +142 -0
  50. package/scripts/migrate-iterator.ts +150 -0
  51. package/scripts/migrate-self-ptr.ts +220 -0
  52. package/scripts/migrate-skip-pragmas.ts +109 -0
  53. package/scripts/migrate-tostring.ts +134 -0
  54. package/scripts/trim-pragma.ts +130 -0
  55. package/scripts/wrap-extern-calls.ts +161 -0
  56. package/std/alg/hash.yo +3 -2
  57. package/std/allocator.yo +6 -5
  58. package/std/async.yo +2 -2
  59. package/std/build.yo +5 -2
  60. package/std/collections/array_list.yo +59 -40
  61. package/std/collections/btree_map.yo +19 -18
  62. package/std/collections/deque.yo +9 -8
  63. package/std/collections/hash_map.yo +101 -13
  64. package/std/collections/hash_set.yo +5 -4
  65. package/std/collections/linked_list.yo +39 -4
  66. package/std/collections/ordered_map.yo +3 -3
  67. package/std/collections/priority_queue.yo +14 -13
  68. package/std/crypto/md5.yo +2 -1
  69. package/std/crypto/random.yo +16 -15
  70. package/std/crypto/sha256.yo +2 -1
  71. package/std/encoding/base64.yo +14 -14
  72. package/std/encoding/hex.yo +3 -3
  73. package/std/encoding/json.yo +59 -10
  74. package/std/encoding/punycode.yo +24 -23
  75. package/std/encoding/toml.yo +4 -3
  76. package/std/encoding/utf16.yo +2 -2
  77. package/std/env.yo +43 -28
  78. package/std/error.yo +6 -6
  79. package/std/fmt/display.yo +2 -2
  80. package/std/fmt/index.yo +6 -5
  81. package/std/fmt/to_string.yo +39 -38
  82. package/std/fmt/writer.yo +9 -8
  83. package/std/fs/dir.yo +34 -33
  84. package/std/fs/file.yo +52 -51
  85. package/std/fs/metadata.yo +10 -9
  86. package/std/fs/temp.yo +24 -13
  87. package/std/fs/walker.yo +10 -9
  88. package/std/gc.yo +1 -0
  89. package/std/glob.yo +7 -7
  90. package/std/http/client.yo +15 -14
  91. package/std/http/http.yo +6 -6
  92. package/std/http/index.yo +1 -1
  93. package/std/imm/list.yo +34 -1
  94. package/std/imm/map.yo +2 -1
  95. package/std/imm/set.yo +1 -0
  96. package/std/imm/sorted_map.yo +2 -1
  97. package/std/imm/sorted_set.yo +1 -0
  98. package/std/imm/string.yo +27 -23
  99. package/std/imm/vec.yo +18 -2
  100. package/std/io/reader.yo +2 -1
  101. package/std/io/writer.yo +3 -2
  102. package/std/libc/assert.yo +1 -0
  103. package/std/libc/ctype.yo +1 -0
  104. package/std/libc/dirent.yo +1 -0
  105. package/std/libc/errno.yo +1 -0
  106. package/std/libc/fcntl.yo +1 -0
  107. package/std/libc/float.yo +1 -0
  108. package/std/libc/limits.yo +1 -0
  109. package/std/libc/math.yo +1 -0
  110. package/std/libc/signal.yo +1 -0
  111. package/std/libc/stdatomic.yo +251 -1
  112. package/std/libc/stdint.yo +1 -0
  113. package/std/libc/stdio.yo +1 -0
  114. package/std/libc/stdlib.yo +1 -0
  115. package/std/libc/string.yo +1 -0
  116. package/std/libc/sys/stat.yo +1 -0
  117. package/std/libc/time.yo +1 -0
  118. package/std/libc/unistd.yo +1 -0
  119. package/std/libc/wctype.yo +1 -0
  120. package/std/libc/windows.yo +2 -0
  121. package/std/log.yo +7 -6
  122. package/std/net/addr.yo +5 -4
  123. package/std/net/dns.yo +7 -6
  124. package/std/net/errors.yo +8 -8
  125. package/std/net/tcp.yo +19 -18
  126. package/std/net/udp.yo +13 -12
  127. package/std/os/signal.yo +3 -3
  128. package/std/path.yo +1 -0
  129. package/std/prelude.yo +398 -184
  130. package/std/process/command.yo +40 -23
  131. package/std/process/index.yo +2 -1
  132. package/std/regex/compiler.yo +10 -9
  133. package/std/regex/index.yo +41 -41
  134. package/std/regex/match.yo +2 -2
  135. package/std/regex/parser.yo +21 -21
  136. package/std/regex/vm.yo +42 -41
  137. package/std/string/rune.yo +4 -0
  138. package/std/string/string.yo +95 -40
  139. package/std/string/string_builder.yo +9 -9
  140. package/std/string/unicode.yo +50 -49
  141. package/std/sync/atomic.yo +557 -0
  142. package/std/sync/channel.yo +59 -43
  143. package/std/sync/cond.yo +12 -7
  144. package/std/sync/mutex.yo +79 -18
  145. package/std/sync/once.yo +25 -19
  146. package/std/sync/rwlock.yo +18 -15
  147. package/std/sync/waitgroup.yo +25 -16
  148. package/std/sys/advise.yo +1 -0
  149. package/std/sys/bufio/buf_reader.yo +17 -16
  150. package/std/sys/bufio/buf_writer.yo +10 -9
  151. package/std/sys/clock.yo +1 -0
  152. package/std/sys/copy.yo +1 -0
  153. package/std/sys/dir.yo +10 -9
  154. package/std/sys/dns.yo +6 -5
  155. package/std/sys/errors.yo +11 -11
  156. package/std/sys/events.yo +1 -0
  157. package/std/sys/externs.yo +38 -37
  158. package/std/sys/file.yo +17 -16
  159. package/std/sys/future.yo +4 -3
  160. package/std/sys/iov.yo +1 -0
  161. package/std/sys/mmap.yo +1 -0
  162. package/std/sys/path.yo +1 -0
  163. package/std/sys/perm.yo +2 -1
  164. package/std/sys/pipe.yo +1 -0
  165. package/std/sys/process.yo +5 -4
  166. package/std/sys/signal.yo +1 -0
  167. package/std/sys/socketpair.yo +1 -0
  168. package/std/sys/sockinfo.yo +1 -0
  169. package/std/sys/statfs.yo +2 -1
  170. package/std/sys/statx.yo +1 -0
  171. package/std/sys/sysinfo.yo +1 -0
  172. package/std/sys/tcp.yo +15 -14
  173. package/std/sys/temp.yo +1 -0
  174. package/std/sys/time.yo +2 -1
  175. package/std/sys/timer.yo +6 -6
  176. package/std/sys/tty.yo +2 -1
  177. package/std/sys/udp.yo +13 -12
  178. package/std/sys/unix.yo +12 -11
  179. package/std/testing/bench.yo +4 -3
  180. package/std/thread.yo +7 -6
  181. package/std/time/datetime.yo +18 -15
  182. package/std/time/duration.yo +11 -10
  183. package/std/time/instant.yo +4 -4
  184. package/std/time/sleep.yo +1 -0
  185. package/std/url/index.yo +3 -3
  186. package/std/worker.yo +4 -3
@@ -1,4 +1,5 @@
1
1
  //! C11 `<stdatomic.h>` — atomic operations and types.
2
+ pragma(Pragma.AllowUnsafe);
2
3
  c_include(
3
4
  "<stdatomic.h>",
4
5
  // Atomic types
@@ -137,6 +138,209 @@ c_include(
137
138
  ATOMIC_LLONG_LOCK_FREE : i32,
138
139
  ATOMIC_POINTER_LOCK_FREE : i32
139
140
  );
141
+ // SAFETY: C11 atomic typedefs (atomic_bool, atomic_int, etc.) are opaque C
142
+ // types backed by _Atomic-qualified primitives. They contain no heap
143
+ // allocations or thread-local state — they are trivially safe to send
144
+ // across threads. They are Acyclic because they don't participate in Yo's
145
+ // ARC reference-counting cycle analysis.
146
+ impl(atomic_bool, Send());
147
+ impl(atomic_bool, Acyclic());
148
+ impl(atomic_char, Send());
149
+ impl(atomic_char, Acyclic());
150
+ impl(atomic_schar, Send());
151
+ impl(atomic_schar, Acyclic());
152
+ impl(atomic_uchar, Send());
153
+ impl(atomic_uchar, Acyclic());
154
+ impl(atomic_short, Send());
155
+ impl(atomic_short, Acyclic());
156
+ impl(atomic_ushort, Send());
157
+ impl(atomic_ushort, Acyclic());
158
+ impl(atomic_int, Send());
159
+ impl(atomic_int, Acyclic());
160
+ impl(atomic_uint, Send());
161
+ impl(atomic_uint, Acyclic());
162
+ impl(atomic_long, Send());
163
+ impl(atomic_long, Acyclic());
164
+ impl(atomic_ulong, Send());
165
+ impl(atomic_ulong, Acyclic());
166
+ impl(atomic_llong, Send());
167
+ impl(atomic_llong, Acyclic());
168
+ impl(atomic_ullong, Send());
169
+ impl(atomic_ullong, Acyclic());
170
+ impl(atomic_char16_t, Send());
171
+ impl(atomic_char16_t, Acyclic());
172
+ impl(atomic_char32_t, Send());
173
+ impl(atomic_char32_t, Acyclic());
174
+ impl(atomic_wchar_t, Send());
175
+ impl(atomic_wchar_t, Acyclic());
176
+ impl(atomic_int_least8_t, Send());
177
+ impl(atomic_int_least8_t, Acyclic());
178
+ impl(atomic_uint_least8_t, Send());
179
+ impl(atomic_uint_least8_t, Acyclic());
180
+ impl(atomic_int_least16_t, Send());
181
+ impl(atomic_int_least16_t, Acyclic());
182
+ impl(atomic_uint_least16_t, Send());
183
+ impl(atomic_uint_least16_t, Acyclic());
184
+ impl(atomic_int_least32_t, Send());
185
+ impl(atomic_int_least32_t, Acyclic());
186
+ impl(atomic_uint_least32_t, Send());
187
+ impl(atomic_uint_least32_t, Acyclic());
188
+ impl(atomic_int_least64_t, Send());
189
+ impl(atomic_int_least64_t, Acyclic());
190
+ impl(atomic_uint_least64_t, Send());
191
+ impl(atomic_uint_least64_t, Acyclic());
192
+ impl(atomic_int_fast8_t, Send());
193
+ impl(atomic_int_fast8_t, Acyclic());
194
+ impl(atomic_uint_fast8_t, Send());
195
+ impl(atomic_uint_fast8_t, Acyclic());
196
+ impl(atomic_int_fast16_t, Send());
197
+ impl(atomic_int_fast16_t, Acyclic());
198
+ impl(atomic_uint_fast16_t, Send());
199
+ impl(atomic_uint_fast16_t, Acyclic());
200
+ impl(atomic_int_fast32_t, Send());
201
+ impl(atomic_int_fast32_t, Acyclic());
202
+ impl(atomic_uint_fast32_t, Send());
203
+ impl(atomic_uint_fast32_t, Acyclic());
204
+ impl(atomic_int_fast64_t, Send());
205
+ impl(atomic_int_fast64_t, Acyclic());
206
+ impl(atomic_uint_fast64_t, Send());
207
+ impl(atomic_uint_fast64_t, Acyclic());
208
+ impl(atomic_intptr_t, Send());
209
+ impl(atomic_intptr_t, Acyclic());
210
+ impl(atomic_uintptr_t, Send());
211
+ impl(atomic_uintptr_t, Acyclic());
212
+ impl(atomic_size_t, Send());
213
+ impl(atomic_size_t, Acyclic());
214
+ impl(atomic_ptrdiff_t, Send());
215
+ impl(atomic_ptrdiff_t, Acyclic());
216
+ impl(atomic_intmax_t, Send());
217
+ impl(atomic_intmax_t, Acyclic());
218
+ impl(atomic_uintmax_t, Send());
219
+ impl(atomic_uintmax_t, Acyclic());
220
+ // Phase C (THREAD_SAFETY): int-specific atomic operations. The c_include
221
+ // block only declares load/store/exchange for atomic_bool. These Yo-runtime
222
+ // wrappers forward to the C11 _Generic macros in <stdatomic.h> so AtomicI32
223
+ // can use the full atomic API.
224
+ extern(
225
+ "Yo",
226
+ __yo_atomic_load_int :
227
+ fn(obj : *(atomic_int), order : memory_order) -> i32,
228
+ __yo_atomic_store_int :
229
+ fn(obj : *(atomic_int), desired : i32, order : memory_order) -> unit,
230
+ __yo_atomic_exchange_int :
231
+ fn(obj : *(atomic_int), desired : i32, order : memory_order) -> i32,
232
+ __yo_atomic_compare_exchange_int :
233
+ fn(
234
+ obj : *(atomic_int),
235
+ expected : *(i32),
236
+ desired : i32,
237
+ success : memory_order,
238
+ failure : memory_order
239
+ ) -> bool
240
+ );
241
+ // Phase C: size_t-specific atomic operations (for AtomicUsize)
242
+ extern(
243
+ "Yo",
244
+ __yo_atomic_load_size_t :
245
+ fn(obj : *(atomic_size_t), order : memory_order) -> usize,
246
+ __yo_atomic_store_size_t :
247
+ fn(obj : *(atomic_size_t), desired : usize, order : memory_order) -> unit,
248
+ __yo_atomic_exchange_size_t :
249
+ fn(obj : *(atomic_size_t), desired : usize, order : memory_order) -> usize,
250
+ __yo_atomic_compare_exchange_size_t :
251
+ fn(
252
+ obj : *(atomic_size_t),
253
+ expected : *(usize),
254
+ desired : usize,
255
+ success : memory_order,
256
+ failure : memory_order
257
+ ) -> bool
258
+ );
259
+ // Phase C: long-long-specific atomic operations (for AtomicI64)
260
+ extern(
261
+ "Yo",
262
+ __yo_atomic_load_llong :
263
+ fn(obj : *(atomic_llong), order : memory_order) -> i64,
264
+ __yo_atomic_store_llong :
265
+ fn(obj : *(atomic_llong), desired : i64, order : memory_order) -> unit,
266
+ __yo_atomic_exchange_llong :
267
+ fn(obj : *(atomic_llong), desired : i64, order : memory_order) -> i64,
268
+ __yo_atomic_compare_exchange_llong :
269
+ fn(
270
+ obj : *(atomic_llong),
271
+ expected : *(i64),
272
+ desired : i64,
273
+ success : memory_order,
274
+ failure : memory_order
275
+ ) -> bool
276
+ );
277
+ // Phase C: remaining atomic type wrappers
278
+ extern(
279
+ "Yo",
280
+ __yo_atomic_load_schar :
281
+ fn(obj : *(atomic_schar), order : memory_order) -> i8,
282
+ __yo_atomic_store_schar :
283
+ fn(obj : *(atomic_schar), desired : i8, order : memory_order) -> unit,
284
+ __yo_atomic_exchange_schar :
285
+ fn(obj : *(atomic_schar), desired : i8, order : memory_order) -> i8,
286
+ __yo_atomic_compare_exchange_schar :
287
+ fn(obj : *(atomic_schar), expected : *(i8), desired : i8,
288
+ success : memory_order, failure : memory_order) -> bool,
289
+ __yo_atomic_load_short :
290
+ fn(obj : *(atomic_short), order : memory_order) -> i16,
291
+ __yo_atomic_store_short :
292
+ fn(obj : *(atomic_short), desired : i16, order : memory_order) -> unit,
293
+ __yo_atomic_exchange_short :
294
+ fn(obj : *(atomic_short), desired : i16, order : memory_order) -> i16,
295
+ __yo_atomic_compare_exchange_short :
296
+ fn(obj : *(atomic_short), expected : *(i16), desired : i16,
297
+ success : memory_order, failure : memory_order) -> bool,
298
+ __yo_atomic_load_uchar :
299
+ fn(obj : *(atomic_uchar), order : memory_order) -> u8,
300
+ __yo_atomic_store_uchar :
301
+ fn(obj : *(atomic_uchar), desired : u8, order : memory_order) -> unit,
302
+ __yo_atomic_exchange_uchar :
303
+ fn(obj : *(atomic_uchar), desired : u8, order : memory_order) -> u8,
304
+ __yo_atomic_compare_exchange_uchar :
305
+ fn(obj : *(atomic_uchar), expected : *(u8), desired : u8,
306
+ success : memory_order, failure : memory_order) -> bool,
307
+ __yo_atomic_load_ushort :
308
+ fn(obj : *(atomic_ushort), order : memory_order) -> u16,
309
+ __yo_atomic_store_ushort :
310
+ fn(obj : *(atomic_ushort), desired : u16, order : memory_order) -> unit,
311
+ __yo_atomic_exchange_ushort :
312
+ fn(obj : *(atomic_ushort), desired : u16, order : memory_order) -> u16,
313
+ __yo_atomic_compare_exchange_ushort :
314
+ fn(obj : *(atomic_ushort), expected : *(u16), desired : u16,
315
+ success : memory_order, failure : memory_order) -> bool,
316
+ __yo_atomic_load_uint :
317
+ fn(obj : *(atomic_uint), order : memory_order) -> u32,
318
+ __yo_atomic_store_uint :
319
+ fn(obj : *(atomic_uint), desired : u32, order : memory_order) -> unit,
320
+ __yo_atomic_exchange_uint :
321
+ fn(obj : *(atomic_uint), desired : u32, order : memory_order) -> u32,
322
+ __yo_atomic_compare_exchange_uint :
323
+ fn(obj : *(atomic_uint), expected : *(u32), desired : u32,
324
+ success : memory_order, failure : memory_order) -> bool,
325
+ __yo_atomic_load_ullong :
326
+ fn(obj : *(atomic_ullong), order : memory_order) -> u64,
327
+ __yo_atomic_store_ullong :
328
+ fn(obj : *(atomic_ullong), desired : u64, order : memory_order) -> unit,
329
+ __yo_atomic_exchange_ullong :
330
+ fn(obj : *(atomic_ullong), desired : u64, order : memory_order) -> u64,
331
+ __yo_atomic_compare_exchange_ullong :
332
+ fn(obj : *(atomic_ullong), expected : *(u64), desired : u64,
333
+ success : memory_order, failure : memory_order) -> bool,
334
+ __yo_atomic_load_ptrdiff :
335
+ fn(obj : *(atomic_ptrdiff_t), order : memory_order) -> isize,
336
+ __yo_atomic_store_ptrdiff :
337
+ fn(obj : *(atomic_ptrdiff_t), desired : isize, order : memory_order) -> unit,
338
+ __yo_atomic_exchange_ptrdiff :
339
+ fn(obj : *(atomic_ptrdiff_t), desired : isize, order : memory_order) -> isize,
340
+ __yo_atomic_compare_exchange_ptrdiff :
341
+ fn(obj : *(atomic_ptrdiff_t), expected : *(isize), desired : isize,
342
+ success : memory_order, failure : memory_order) -> bool
343
+ );
140
344
  export(
141
345
  // Atomic types
142
346
  atomic_bool,
@@ -237,5 +441,51 @@ export(
237
441
  ATOMIC_LLONG_LOCK_FREE,
238
442
  ATOMIC_POINTER_LOCK_FREE,
239
443
  // Kill dependency
240
- kill_dependency
444
+ kill_dependency,
445
+ // Phase C (THREAD_SAFETY): int-specific atomic wrappers
446
+ __yo_atomic_load_int,
447
+ __yo_atomic_store_int,
448
+ __yo_atomic_exchange_int,
449
+ __yo_atomic_compare_exchange_int,
450
+ // Phase C: size_t atomic wrappers
451
+ __yo_atomic_load_size_t,
452
+ __yo_atomic_store_size_t,
453
+ __yo_atomic_exchange_size_t,
454
+ __yo_atomic_compare_exchange_size_t,
455
+ // Phase C: llong atomic wrappers
456
+ __yo_atomic_load_llong,
457
+ __yo_atomic_store_llong,
458
+ __yo_atomic_exchange_llong,
459
+ __yo_atomic_compare_exchange_llong,
460
+ // Phase C: signed narrow atomics
461
+ __yo_atomic_load_schar,
462
+ __yo_atomic_store_schar,
463
+ __yo_atomic_exchange_schar,
464
+ __yo_atomic_compare_exchange_schar,
465
+ __yo_atomic_load_short,
466
+ __yo_atomic_store_short,
467
+ __yo_atomic_exchange_short,
468
+ __yo_atomic_compare_exchange_short,
469
+ // Phase C: unsigned atomics
470
+ __yo_atomic_load_uchar,
471
+ __yo_atomic_store_uchar,
472
+ __yo_atomic_exchange_uchar,
473
+ __yo_atomic_compare_exchange_uchar,
474
+ __yo_atomic_load_ushort,
475
+ __yo_atomic_store_ushort,
476
+ __yo_atomic_exchange_ushort,
477
+ __yo_atomic_compare_exchange_ushort,
478
+ __yo_atomic_load_uint,
479
+ __yo_atomic_store_uint,
480
+ __yo_atomic_exchange_uint,
481
+ __yo_atomic_compare_exchange_uint,
482
+ __yo_atomic_load_ullong,
483
+ __yo_atomic_store_ullong,
484
+ __yo_atomic_exchange_ullong,
485
+ __yo_atomic_compare_exchange_ullong,
486
+ // Phase C: isize
487
+ __yo_atomic_load_ptrdiff,
488
+ __yo_atomic_store_ptrdiff,
489
+ __yo_atomic_exchange_ptrdiff,
490
+ __yo_atomic_compare_exchange_ptrdiff
241
491
  );
@@ -3,6 +3,7 @@
3
3
  //! Note: Yo already has `i8`, `i16`, `i32`, `i64`, `u8`, `u16`, `u32`, `u64`.
4
4
  //! This file provides C-compatible aliases and additional types/constants.
5
5
  // Type aliases for C compatibility (mapping Yo types to C stdint names)
6
+ pragma(Pragma.AllowUnsafe);
6
7
  int8_t :: i8;
7
8
  int16_t :: i16;
8
9
  int32_t :: i32;
package/std/libc/stdio.yo CHANGED
@@ -1,4 +1,5 @@
1
1
  //! C11 `<stdio.h>` — standard I/O functions.
2
+ pragma(Pragma.AllowUnsafe);
2
3
  c_include(
3
4
  "<stdio.h>",
4
5
  // Types
@@ -1,4 +1,5 @@
1
1
  //! C11 `<stdlib.h>` — general utility functions.
2
+ pragma(Pragma.AllowUnsafe);
2
3
  c_include(
3
4
  "<stdlib.h>",
4
5
  // Types for div functions
@@ -1,4 +1,5 @@
1
1
  //! C11 `<string.h>` — string and memory functions.
2
+ pragma(Pragma.AllowUnsafe);
2
3
  c_include(
3
4
  "<string.h>",
4
5
  // Memory functions
@@ -1,4 +1,5 @@
1
1
  //! POSIX `<sys/stat.h>` — file status and mode operations.
2
+ pragma(Pragma.AllowUnsafe);
2
3
  c_include(
3
4
  "<sys/stat.h>",
4
5
  // Types
package/std/libc/time.yo CHANGED
@@ -1,4 +1,5 @@
1
1
  //! C11 `<time.h>` — date and time functions.
2
+ pragma(Pragma.AllowUnsafe);
2
3
  c_include(
3
4
  "<time.h>",
4
5
  // Types
@@ -1,4 +1,5 @@
1
1
  //! POSIX `<unistd.h>` — standard symbolic constants and types.
2
+ pragma(Pragma.AllowUnsafe);
2
3
  c_include(
3
4
  "<unistd.h>",
4
5
  // Types
@@ -1,4 +1,5 @@
1
1
  //! C11 `<wctype.h>` — wide character classification and conversion functions.
2
+ pragma(Pragma.AllowUnsafe);
2
3
  { wint_t } :: import("./stdint");
3
4
  c_include(
4
5
  "<wctype.h>",
@@ -1,6 +1,8 @@
1
1
  //! Windows-specific C API bindings.
2
2
  //! Only available when compiling for Windows.
3
3
  // Windows type aliases (using Yo types that match the C types)
4
+ pragma(Pragma.AllowUnsafe);
5
+ pragma(Pragma.AllowUnsafe);
4
6
  DWORD :: ulong; // unsigned long on Windows
5
7
  WCHAR :: ushort; // unsigned short (UTF-16 code unit)
6
8
  BOOL :: int; // int
package/std/log.yo CHANGED
@@ -1,4 +1,5 @@
1
1
  //! Structured logging with configurable level and output destination.
2
+ pragma(Pragma.AllowUnsafe);
2
3
  open(import("./string"));
3
4
  { ToString } :: import("./fmt");
4
5
  { fwrite, stdout, stderr, FILE } :: import("./libc/stdio");
@@ -7,9 +8,9 @@ Level :: enum(Trace, Debug, Info, Warn, Error);
7
8
  impl(
8
9
  Level,
9
10
  ToString(
10
- to_string : (fn(self : *(Self)) -> String)(
11
+ to_string : (fn(ref(self) : Self) -> String)(
11
12
  match(
12
- self.*,
13
+ self,
13
14
  .Trace => String.from("TRACE"),
14
15
  .Debug => String.from("DEBUG"),
15
16
  .Info => String.from("INFO "),
@@ -60,7 +61,7 @@ _write_string :: (fn(s : String, dest : *(FILE)) -> unit)({
60
61
  cond(
61
62
  (bytes.len() > usize(0)) => {
62
63
  ptr := bytes.ptr().unwrap();
63
- fwrite(*(void)(ptr), usize(1), bytes.len(), dest);
64
+ unsafe(fwrite(*(void)(ptr), usize(1), bytes.len(), dest));
64
65
  },
65
66
  true => ()
66
67
  );
@@ -79,11 +80,11 @@ log :: (fn(level : Level, msg : String) -> unit)({
79
80
  .Stderr => stderr
80
81
  );
81
82
  // Write "[LEVEL] msg\n"
82
- fwrite(*(void)(*(u8)("[")), usize(1), usize(1), dest);
83
+ unsafe(fwrite(*(void)(*(u8)("[")), usize(1), usize(1), dest));
83
84
  _write_string(level_str, dest);
84
- fwrite(*(void)(*(u8)("] ")), usize(1), usize(2), dest);
85
+ unsafe(fwrite(*(void)(*(u8)("] ")), usize(1), usize(2), dest));
85
86
  _write_string(msg, dest);
86
- fwrite(*(void)(*(u8)("\n")), usize(1), usize(1), dest);
87
+ unsafe(fwrite(*(void)(*(u8)("\n")), usize(1), usize(1), dest));
87
88
  });
88
89
  export(log);
89
90
  // ============================================================================
package/std/net/addr.yo CHANGED
@@ -7,6 +7,7 @@
7
7
  // { IpAddr, SocketAddr } :: import "std/net/addr";
8
8
  //
9
9
  // addr := SocketAddr.new(IpAddr.loopback_v4(), u16(8080));
10
+ pragma(Pragma.AllowUnsafe);
10
11
  open(import("../string"));
11
12
  { ToString } :: import("../fmt");
12
13
  { Writer } :: import("../fmt/writer");
@@ -40,7 +41,7 @@ impl(
40
41
  val := u32(0);
41
42
  i := usize(0);
42
43
  while(runtime(i < bytes.len()), {
43
- ch := bytes.get(i).unwrap();
44
+ ch := bytes(i);
44
45
  cond(
45
46
  (ch == _ASCII_DOT) => {
46
47
  // '.' separator
@@ -145,10 +146,10 @@ impl(
145
146
  self -> {
146
147
  return(
147
148
  match(
148
- self.*,
149
+ self,
149
150
  .V4(a, b, c, d) => {
150
151
  buf := Array(u8, usize(16)).fill(u8(0));
151
- snprintf(*(char)(&(buf(usize(0)))), usize(16), "%d.%d.%d.%d", i32(a), i32(b), i32(c), i32(d));
152
+ unsafe(snprintf(*(char)(&(buf(usize(0)))), usize(16), "%d.%d.%d.%d", i32(a), i32(b), i32(c), i32(d)));
152
153
  String.from_cstr(&(buf(usize(0)))).unwrap()
153
154
  },
154
155
  .V6(segs) => {
@@ -205,7 +206,7 @@ impl(
205
206
  self -> {
206
207
  ip_str := self.ip.to_string();
207
208
  buf := Array(u8, usize(8)).fill(u8(0));
208
- snprintf(*(char)(&(buf(usize(0)))), usize(8), "%d", i32(self.port));
209
+ unsafe(snprintf(*(char)(&(buf(usize(0)))), usize(8), "%d", i32(self.port)));
209
210
  port_str := String.from_cstr(&(buf(usize(0)))).unwrap();
210
211
  return(
211
212
  match(
package/std/net/dns.yo CHANGED
@@ -9,14 +9,15 @@
9
9
  // { IpAddr } :: import "std/net/addr";
10
10
  // { Exception } :: import "std/error";
11
11
  //
12
- // main :: (fn(io : IO, exn : Exception) -> unit)({
12
+ // main :: (fn(io : Io, exn : Exception) -> unit)({
13
13
  // addrs := io.await(lookup_host(`localhost`, io), { io, exn });
14
14
  // i := usize(0);
15
15
  // while runtime((i < addrs.len())), {
16
- // println(addrs.get(i).unwrap().to_string());
16
+ // println(addrs(i).to_string());
17
17
  // i = (i + usize(1));
18
18
  // };
19
19
  // });
20
+ pragma(Pragma.AllowUnsafe);
20
21
  { GlobalAllocator } :: import("../allocator");
21
22
  { malloc, free } :: GlobalAllocator;
22
23
  { ArrayList } :: import("../collections/array_list");
@@ -24,14 +25,14 @@ open(import("../string"));
24
25
  open(import("../fmt"));
25
26
  { NetError } :: import("./errors");
26
27
  { IpAddr, SocketAddr } :: import("./addr");
27
- { Error, AnyError, Exception, IOErr } :: import("../error");
28
+ { Error, AnyError, Exception, IoExn } :: import("../error");
28
29
  IO_dns :: import("../sys/dns");
29
30
  { AF_INET, AF_INET6 } :: import("../sys/socket");
30
31
  // ============================================================================
31
32
  // DNS lookup
32
33
  // ============================================================================
33
34
  /// Resolve a hostname to a list of IP addresses.
34
- lookup_host :: (fn(host : String, io : IO) -> Impl(Future(ArrayList(IpAddr), IOErr)))(
35
+ lookup_host :: (fn(host : String, io : Io) -> Impl(Future(ArrayList(IpAddr), IoExn)))(
35
36
  io.async((e) => {
36
37
  host_cstr_bytes := host.to_cstr();
37
38
  host_cstr := host_cstr_bytes.ptr().unwrap();
@@ -82,13 +83,13 @@ lookup_host :: (fn(host : String, io : IO) -> Impl(Future(ArrayList(IpAddr), IOE
82
83
  })
83
84
  );
84
85
  /// Resolve a hostname and port to a list of socket addresses.
85
- resolve :: (fn(host : String, port : u16, io : IO) -> Impl(Future(ArrayList(SocketAddr), IOErr)))(
86
+ resolve :: (fn(host : String, port : u16, io : Io) -> Impl(Future(ArrayList(SocketAddr), IoExn)))(
86
87
  io.async((e) => {
87
88
  addrs := e.io.await(lookup_host(host, io), e);
88
89
  result := ArrayList(SocketAddr).new();
89
90
  i := usize(0);
90
91
  while(runtime(i < addrs.len()), {
91
- ip := addrs.get(i).unwrap();
92
+ ip := addrs(i);
92
93
  result.push(SocketAddr.new(ip, port));
93
94
  i = (i + usize(1));
94
95
  });
package/std/net/errors.yo CHANGED
@@ -1,12 +1,12 @@
1
1
  //! Network error types.
2
2
  // std/net/errors.yo - Network error type
3
3
  //
4
- // Higher-level network error that wraps IOError with network-specific variants.
4
+ // Higher-level network error that wraps IoError with network-specific variants.
5
5
  //
6
6
  // Example:
7
7
  // { NetError } :: import "std/net/errors";
8
8
  open(import("../string"));
9
- { IOError } :: import("../sys/errors");
9
+ { IoError } :: import("../sys/errors");
10
10
  { ToString } :: import("../fmt");
11
11
  { Error, AnyError, Exception } :: import("../error");
12
12
  // ============================================================================
@@ -33,14 +33,14 @@ NetError :: enum(
33
33
  /// DNS resolution failed.
34
34
  DNSFailed(msg : String),
35
35
  /// A wrapped lower-level I/O error.
36
- IO(err : IOError),
36
+ Io(err : IoError),
37
37
  /// An unclassified network error with a message.
38
38
  Other(msg : String)
39
39
  );
40
40
  impl(
41
41
  NetError,
42
- /// Convert an `IOError` into the corresponding `NetError` variant.
43
- from_io : (fn(err : IOError) -> Self)(
42
+ /// Convert an `IoError` into the corresponding `NetError` variant.
43
+ from_io : (fn(err : IoError) -> Self)(
44
44
  match(
45
45
  err,
46
46
  .ConnectionRefused =>.ConnectionRefused,
@@ -51,7 +51,7 @@ impl(
51
51
  .TimedOut =>.TimedOut,
52
52
  .HostUnreachable =>.HostUnreachable,
53
53
  .NetworkUnreachable =>.NetworkUnreachable,
54
- _ =>.IO(err)
54
+ _ =>.Io(err)
55
55
  )
56
56
  )
57
57
  );
@@ -71,7 +71,7 @@ impl(
71
71
  .HostUnreachable => String.from("host unreachable"),
72
72
  .NetworkUnreachable => String.from("network unreachable"),
73
73
  .DNSFailed(msg) => `DNS lookup failed: ${msg}`,
74
- .IO(err) => err.to_string(),
74
+ .Io(err) => err.to_string(),
75
75
  .Other(msg) => msg
76
76
  );
77
77
  return(s);
@@ -87,7 +87,7 @@ impl(
87
87
  check : (fn(result : i32, exn : Exception) -> i32)(
88
88
  cond(
89
89
  (result >= i32(0)) => result,
90
- true => exn.throw(dyn(Self.from_io(IOError.from_errno(i32(0) - result))))
90
+ true => exn.throw(dyn(Self.from_io(IoError.from_errno(i32(0) - result))))
91
91
  )
92
92
  )
93
93
  );