@shd101wyy/yo 0.1.29 → 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.
- package/.github/skills/yo-async-effects/SKILL.md +3 -3
- package/.github/skills/yo-async-effects/async-effects-recipes.md +19 -11
- package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +33 -13
- package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +1 -1
- package/.github/skills/yo-syntax/syntax-cheatsheet.md +59 -21
- package/README.md +4 -3
- package/out/cjs/index.cjs +771 -676
- package/out/cjs/yo-cli.cjs +1003 -898
- package/out/cjs/yo-lsp.cjs +834 -739
- package/out/esm/index.mjs +716 -621
- package/out/types/src/codegen/exprs/async.d.ts +2 -0
- package/out/types/src/codegen/exprs/await.d.ts +1 -0
- package/out/types/src/codegen/exprs/closures.d.ts +4 -0
- package/out/types/src/codegen/functions/context.d.ts +6 -0
- package/out/types/src/env.d.ts +2 -0
- package/out/types/src/evaluator/builtins/pragma.d.ts +9 -0
- package/out/types/src/evaluator/builtins/unsafe.d.ts +8 -0
- package/out/types/src/evaluator/context.d.ts +2 -0
- package/out/types/src/evaluator/index.d.ts +1 -1
- package/out/types/src/evaluator/memory-safety.d.ts +14 -0
- package/out/types/src/evaluator/types/flowability.d.ts +6 -0
- package/out/types/src/expr-traversal.d.ts +1 -0
- package/out/types/src/expr.d.ts +4 -1
- package/out/types/src/public-safe-report.d.ts +19 -0
- package/out/types/src/tests/comptime-ref-gate.test.d.ts +1 -0
- package/out/types/src/tests/pragma-validation.test.d.ts +1 -0
- package/out/types/src/tests/public-safe-report.test.d.ts +1 -0
- package/out/types/src/tests/type-representation-pointer.test.d.ts +1 -0
- package/out/types/src/tests/unsafe-gate.test.d.ts +1 -0
- package/out/types/src/tests/unsafe-report-classify.test.d.ts +1 -0
- package/out/types/src/types/definitions.d.ts +2 -0
- package/out/types/src/types/utils.d.ts +4 -0
- package/out/types/src/unsafe-report.d.ts +29 -0
- package/out/types/src/value.d.ts +1 -0
- package/out/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/scripts/add-pragma-for-pointer-decls.ts +134 -0
- package/scripts/add-pragma.ts +58 -0
- package/scripts/migrate-amp-method-calls.ts +186 -0
- package/scripts/migrate-clone-calls.ts +93 -0
- package/scripts/migrate-get-unwrap.ts +166 -0
- package/scripts/migrate-index-patterns.ts +210 -0
- package/scripts/migrate-index-trait.ts +142 -0
- package/scripts/migrate-iterator.ts +150 -0
- package/scripts/migrate-self-ptr.ts +220 -0
- package/scripts/migrate-skip-pragmas.ts +109 -0
- package/scripts/migrate-tostring.ts +134 -0
- package/scripts/trim-pragma.ts +130 -0
- package/scripts/wrap-extern-calls.ts +161 -0
- package/std/alg/hash.yo +3 -2
- package/std/allocator.yo +6 -5
- package/std/async.yo +2 -2
- package/std/collections/array_list.yo +59 -40
- package/std/collections/btree_map.yo +19 -18
- package/std/collections/deque.yo +9 -8
- package/std/collections/hash_map.yo +101 -13
- package/std/collections/hash_set.yo +5 -4
- package/std/collections/linked_list.yo +39 -4
- package/std/collections/ordered_map.yo +3 -3
- package/std/collections/priority_queue.yo +14 -13
- package/std/crypto/md5.yo +2 -1
- package/std/crypto/random.yo +16 -15
- package/std/crypto/sha256.yo +2 -1
- package/std/encoding/base64.yo +14 -14
- package/std/encoding/hex.yo +3 -3
- package/std/encoding/json.yo +59 -10
- package/std/encoding/punycode.yo +24 -23
- package/std/encoding/toml.yo +4 -3
- package/std/encoding/utf16.yo +2 -2
- package/std/env.yo +43 -28
- package/std/error.yo +6 -6
- package/std/fmt/display.yo +2 -2
- package/std/fmt/index.yo +6 -5
- package/std/fmt/to_string.yo +39 -38
- package/std/fmt/writer.yo +9 -8
- package/std/fs/dir.yo +34 -33
- package/std/fs/file.yo +52 -51
- package/std/fs/metadata.yo +10 -9
- package/std/fs/temp.yo +24 -13
- package/std/fs/walker.yo +10 -9
- package/std/gc.yo +1 -0
- package/std/glob.yo +7 -7
- package/std/http/client.yo +15 -14
- package/std/http/http.yo +6 -6
- package/std/http/index.yo +1 -1
- package/std/imm/list.yo +33 -0
- package/std/imm/map.yo +2 -1
- package/std/imm/set.yo +1 -0
- package/std/imm/sorted_map.yo +1 -0
- package/std/imm/sorted_set.yo +1 -0
- package/std/imm/string.yo +27 -23
- package/std/imm/vec.yo +18 -2
- package/std/io/reader.yo +2 -1
- package/std/io/writer.yo +3 -2
- package/std/libc/assert.yo +1 -0
- package/std/libc/ctype.yo +1 -0
- package/std/libc/dirent.yo +1 -0
- package/std/libc/errno.yo +1 -0
- package/std/libc/fcntl.yo +1 -0
- package/std/libc/float.yo +1 -0
- package/std/libc/limits.yo +1 -0
- package/std/libc/math.yo +1 -0
- package/std/libc/signal.yo +1 -0
- package/std/libc/stdatomic.yo +1 -0
- package/std/libc/stdint.yo +1 -0
- package/std/libc/stdio.yo +1 -0
- package/std/libc/stdlib.yo +1 -0
- package/std/libc/string.yo +1 -0
- package/std/libc/sys/stat.yo +1 -0
- package/std/libc/time.yo +1 -0
- package/std/libc/unistd.yo +1 -0
- package/std/libc/wctype.yo +1 -0
- package/std/libc/windows.yo +2 -0
- package/std/log.yo +7 -6
- package/std/net/addr.yo +5 -4
- package/std/net/dns.yo +7 -6
- package/std/net/errors.yo +8 -8
- package/std/net/tcp.yo +19 -18
- package/std/net/udp.yo +13 -12
- package/std/os/signal.yo +3 -3
- package/std/path.yo +1 -0
- package/std/prelude.yo +353 -182
- package/std/process/command.yo +40 -23
- package/std/process/index.yo +2 -1
- package/std/regex/compiler.yo +10 -9
- package/std/regex/index.yo +41 -41
- package/std/regex/match.yo +2 -2
- package/std/regex/parser.yo +21 -21
- package/std/regex/vm.yo +42 -41
- package/std/string/string.yo +95 -40
- package/std/string/string_builder.yo +9 -9
- package/std/string/unicode.yo +50 -49
- package/std/sync/channel.yo +2 -1
- package/std/sync/cond.yo +5 -4
- package/std/sync/mutex.yo +4 -3
- package/std/sys/advise.yo +1 -0
- package/std/sys/bufio/buf_reader.yo +17 -16
- package/std/sys/bufio/buf_writer.yo +10 -9
- package/std/sys/clock.yo +1 -0
- package/std/sys/copy.yo +1 -0
- package/std/sys/dir.yo +10 -9
- package/std/sys/dns.yo +6 -5
- package/std/sys/errors.yo +11 -11
- package/std/sys/events.yo +1 -0
- package/std/sys/externs.yo +38 -37
- package/std/sys/file.yo +17 -16
- package/std/sys/future.yo +4 -3
- package/std/sys/iov.yo +1 -0
- package/std/sys/mmap.yo +1 -0
- package/std/sys/path.yo +1 -0
- package/std/sys/perm.yo +2 -1
- package/std/sys/pipe.yo +1 -0
- package/std/sys/process.yo +5 -4
- package/std/sys/signal.yo +1 -0
- package/std/sys/socketpair.yo +1 -0
- package/std/sys/sockinfo.yo +1 -0
- package/std/sys/statfs.yo +2 -1
- package/std/sys/statx.yo +1 -0
- package/std/sys/sysinfo.yo +1 -0
- package/std/sys/tcp.yo +15 -14
- package/std/sys/temp.yo +1 -0
- package/std/sys/time.yo +2 -1
- package/std/sys/timer.yo +6 -6
- package/std/sys/tty.yo +2 -1
- package/std/sys/udp.yo +13 -12
- package/std/sys/unix.yo +12 -11
- package/std/testing/bench.yo +4 -3
- package/std/thread.yo +7 -6
- package/std/time/datetime.yo +18 -15
- package/std/time/duration.yo +11 -10
- package/std/time/instant.yo +4 -4
- package/std/time/sleep.yo +1 -0
- package/std/url/index.yo +3 -3
- package/std/worker.yo +4 -3
package/std/time/duration.yo
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
//! println(d.as_secs()); // 0
|
|
10
10
|
//! println(d.as_millis()); // 500
|
|
11
11
|
//! ```
|
|
12
|
+
pragma(Pragma.AllowUnsafe);
|
|
12
13
|
{ String } :: import("../string");
|
|
13
14
|
{ ToString } :: import("../fmt");
|
|
14
15
|
{ snprintf } :: import("../libc/stdio");
|
|
@@ -40,27 +41,27 @@ impl(
|
|
|
40
41
|
Self(secs : (nanos / i64(1000000000)), nanos : (nanos % i64(1000000000)))
|
|
41
42
|
),
|
|
42
43
|
// Total whole seconds in the duration.
|
|
43
|
-
as_secs : (fn(self :
|
|
44
|
+
as_secs : (fn(ref(self) : Self) -> i64)(
|
|
44
45
|
self.secs
|
|
45
46
|
),
|
|
46
47
|
// Total milliseconds (truncated).
|
|
47
|
-
as_millis : (fn(self :
|
|
48
|
+
as_millis : (fn(ref(self) : Self) -> i64)(
|
|
48
49
|
(self.secs * i64(1000)) + (self.nanos / i64(1000000))
|
|
49
50
|
),
|
|
50
51
|
// Total microseconds (truncated).
|
|
51
|
-
as_micros : (fn(self :
|
|
52
|
+
as_micros : (fn(ref(self) : Self) -> i64)(
|
|
52
53
|
(self.secs * i64(1000000)) + (self.nanos / i64(1000))
|
|
53
54
|
),
|
|
54
55
|
// Total nanoseconds.
|
|
55
|
-
as_nanos : (fn(self :
|
|
56
|
+
as_nanos : (fn(ref(self) : Self) -> i64)(
|
|
56
57
|
(self.secs * i64(1000000000)) + self.nanos
|
|
57
58
|
),
|
|
58
59
|
// Total seconds as a floating-point number.
|
|
59
|
-
as_secs_f64 : (fn(self :
|
|
60
|
+
as_secs_f64 : (fn(ref(self) : Self) -> f64)(
|
|
60
61
|
f64(self.secs) + (f64(self.nanos) / f64(1000000000.0))
|
|
61
62
|
),
|
|
62
63
|
// Add two durations together.
|
|
63
|
-
add : (fn(self :
|
|
64
|
+
add : (fn(ref(self) : Self, other : Duration) -> Duration)({
|
|
64
65
|
total_nanos := (self.nanos + other.nanos);
|
|
65
66
|
carry := (total_nanos / i64(1000000000));
|
|
66
67
|
Duration(
|
|
@@ -69,7 +70,7 @@ impl(
|
|
|
69
70
|
)
|
|
70
71
|
}),
|
|
71
72
|
// Subtract another duration (saturates to zero if negative).
|
|
72
|
-
sub : (fn(self :
|
|
73
|
+
sub : (fn(ref(self) : Self, other : Duration) -> Duration)({
|
|
73
74
|
self_ns := self.as_nanos();
|
|
74
75
|
other_ns := other.as_nanos();
|
|
75
76
|
cond(
|
|
@@ -78,17 +79,17 @@ impl(
|
|
|
78
79
|
)
|
|
79
80
|
}),
|
|
80
81
|
// Return true if this duration is zero.
|
|
81
|
-
is_zero : (fn(self :
|
|
82
|
+
is_zero : (fn(ref(self) : Self) -> bool)(
|
|
82
83
|
(self.secs == i64(0)) && (self.nanos == i64(0))
|
|
83
84
|
)
|
|
84
85
|
);
|
|
85
86
|
impl(
|
|
86
87
|
Duration,
|
|
87
88
|
ToString(
|
|
88
|
-
to_string : (fn(self :
|
|
89
|
+
to_string : (fn(ref(self) : Self) -> String)({
|
|
89
90
|
buf := Array(u8, usize(64)).fill(u8(0));
|
|
90
91
|
buf_ptr := &(buf(usize(0)));
|
|
91
|
-
snprintf(*(char)(buf_ptr), usize(64), "%llds %lldns", self.secs, self.nanos);
|
|
92
|
+
unsafe(snprintf(*(char)(buf_ptr), usize(64), "%llds %lldns", self.secs, self.nanos));
|
|
92
93
|
String.from_cstr(buf_ptr).unwrap()
|
|
93
94
|
})
|
|
94
95
|
)
|
package/std/time/instant.yo
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
//! elapsed := start.elapsed();
|
|
11
11
|
//! println(elapsed.as_millis());
|
|
12
12
|
//! ```
|
|
13
|
+
pragma(Pragma.AllowUnsafe);
|
|
13
14
|
{ Duration } :: import("./duration");
|
|
14
15
|
{ CLOCK_MONOTONIC, clock_gettime } :: import("../sys/clock");
|
|
15
16
|
/// Snapshot from the monotonic clock. Use `elapsed` to measure durations.
|
|
@@ -29,7 +30,7 @@ impl(
|
|
|
29
30
|
}),
|
|
30
31
|
// Duration between this instant and an earlier one.
|
|
31
32
|
// Returns Duration.zero() if `earlier` is actually later.
|
|
32
|
-
duration_since : (fn(self :
|
|
33
|
+
duration_since : (fn(ref(self) : Self, earlier : Instant) -> Duration)({
|
|
33
34
|
self_ns := ((self.secs * i64(1000000000)) + self.nanos);
|
|
34
35
|
earlier_ns := ((earlier.secs * i64(1000000000)) + earlier.nanos);
|
|
35
36
|
cond(
|
|
@@ -38,10 +39,9 @@ impl(
|
|
|
38
39
|
)
|
|
39
40
|
}),
|
|
40
41
|
// Duration elapsed since this instant was created.
|
|
41
|
-
elapsed : (fn(self :
|
|
42
|
+
elapsed : (fn(ref(self) : Self) -> Duration)({
|
|
42
43
|
current := Instant.now();
|
|
43
|
-
|
|
44
|
-
cur_ptr.duration_since(self.*)
|
|
44
|
+
current.duration_since(self)
|
|
45
45
|
})
|
|
46
46
|
);
|
|
47
47
|
export(Instant);
|
package/std/time/sleep.yo
CHANGED
package/std/url/index.yo
CHANGED
|
@@ -234,7 +234,7 @@ impl(
|
|
|
234
234
|
after_bracket := (bracket_end + usize(1));
|
|
235
235
|
cond(
|
|
236
236
|
((after_bracket < auth_end) && (s.bytes(after_bracket) == _COLON)) => {
|
|
237
|
-
port =.Some(_parse_port(s, after_bracket + usize(1), auth_end));
|
|
237
|
+
port =.Some(_parse_port(s, after_bracket + usize(1), auth_end, exn));
|
|
238
238
|
},
|
|
239
239
|
true => ()
|
|
240
240
|
);
|
|
@@ -264,7 +264,7 @@ impl(
|
|
|
264
264
|
hh2 = (hh2 + usize(1));
|
|
265
265
|
});
|
|
266
266
|
host =.Some(String.from_bytes(host_b));
|
|
267
|
-
port =.Some(_parse_port(s, cp_val + usize(1), auth_end));
|
|
267
|
+
port =.Some(_parse_port(s, cp_val + usize(1), auth_end, exn));
|
|
268
268
|
},
|
|
269
269
|
.None => {
|
|
270
270
|
// No port, entire range is host
|
|
@@ -363,7 +363,7 @@ impl(
|
|
|
363
363
|
);
|
|
364
364
|
// Ensure authority-based URLs have a path starting with "/" or empty
|
|
365
365
|
cond(
|
|
366
|
-
(has_authority && ((!(path_str.is_empty())) && (path_str.as_bytes()
|
|
366
|
+
(has_authority && ((!(path_str.is_empty())) && (path_str.as_bytes()(usize(0)) != _SLASH))) => {
|
|
367
367
|
exn.throw(dyn(UrlError.Other(`authority path must start with '/'`)));
|
|
368
368
|
},
|
|
369
369
|
true => ()
|
package/std/worker.yo
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
//! Thread pool with per-core thread affinity and round-robin task distribution.
|
|
2
2
|
//!
|
|
3
3
|
//! Each task is pinned to a worker thread (no work stealing).
|
|
4
|
-
//! Each worker thread has its own GC heap and async
|
|
4
|
+
//! Each worker thread has its own GC heap and async Io event loop.
|
|
5
|
+
pragma(Pragma.AllowUnsafe);
|
|
5
6
|
extern(
|
|
6
7
|
"Yo",
|
|
7
|
-
__yo_worker_spawn : (fn(cb : Impl(Fn(io :
|
|
8
|
+
__yo_worker_spawn : (fn(cb : Impl(Fn(io : Io) -> unit, Send)) -> unit),
|
|
8
9
|
__yo_worker_get_num_threads : (fn() -> usize),
|
|
9
10
|
__yo_worker_set_num_threads : (fn(num : usize) -> unit)
|
|
10
11
|
);
|
|
11
12
|
/// Spawn a task on the thread pool. Returns immediately; the task runs in the background.
|
|
12
13
|
/// Tasks are distributed round-robin to worker threads.
|
|
13
|
-
spawn :: (fn(cb : Impl(Fn(io :
|
|
14
|
+
spawn :: (fn(cb : Impl(Fn(io : Io) -> unit, Send)) -> unit)({
|
|
14
15
|
__yo_worker_spawn(cb);
|
|
15
16
|
});
|
|
16
17
|
/// Get the number of worker threads in the pool.
|