feat: restructure repo, borrow checker, expanded stdlib
- Reorganize repository to Rust-style layout: compiler/bootstrap/ compiler/selfhost/ compiler/tests/ library/std/ library/runtime/ tests/ tools/ - Add buxs/ Windows-compatible project root - Add borrow checker tests and implement: - Alias analysis (double mutable borrow detection) - Use-after-move detection for own T - Expand standard library: - Std::Os: Args, Env, Cwd, Chdir - Std::Time: NowMs, NowUs, SleepMs - Std::Process: Run, Output - Std::Io: PrintInt64 (fixes 32-bit truncation bug) - Add examples: os_time.bux, process.bux - Fix PrintInt to use int64_t in C runtime
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
module Std::Channel {
|
||||
|
||||
extern func bux_channel_new(capacity: int64, elem_size: int64) -> *void;
|
||||
extern func bux_channel_send(handle: *void, elem: *void);
|
||||
extern func bux_channel_recv(handle: *void, out: *void) -> int;
|
||||
extern func bux_channel_close(handle: *void);
|
||||
extern func bux_channel_free(handle: *void);
|
||||
|
||||
struct Channel<T> {
|
||||
handle: *void;
|
||||
}
|
||||
|
||||
func Channel_New<T>(capacity: int64) -> Channel<T> {
|
||||
return Channel<T> { handle: bux_channel_new(capacity, sizeof(T)) };
|
||||
}
|
||||
|
||||
func Channel_Send<T>(ch: *Channel<T>, value: T) {
|
||||
bux_channel_send(ch.handle, &value);
|
||||
}
|
||||
|
||||
func Channel_Recv<T>(ch: *Channel<T>) -> T {
|
||||
var result: T;
|
||||
bux_channel_recv(ch.handle, &result);
|
||||
return result;
|
||||
}
|
||||
|
||||
func Channel_Close<T>(ch: *Channel<T>) {
|
||||
bux_channel_close(ch.handle);
|
||||
}
|
||||
|
||||
func Channel_Free<T>(ch: *Channel<T>) {
|
||||
bux_channel_free(ch.handle);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user