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:
2026-06-05 20:08:17 +03:00
parent a45a2ecd49
commit 9c6b516453
75 changed files with 581 additions and 79 deletions
+11 -11
View File
@@ -31,7 +31,7 @@ func DirExists(path: String) -> bool {
}
// Import the compiler pipeline
// In self-hosting mode, these are compiled together from src_bux/
// In self-hosting mode, these are compiled together from compiler/selfhost/
// ---------------------------------------------------------------------------
// Compile a single .bux source file
@@ -140,19 +140,19 @@ func Cli_Build(srcPath: String, outPath: String) -> int {
PrintLine(cFile);
// Find runtime.c and io.c for linking
var rtPath: String = "stdlib/runtime.c";
var ioPath: String = "stdlib/io.c";
var rtPath: String = "library/runtime/runtime.c";
var ioPath: String = "library/runtime/io.c";
if !FileExists(rtPath) {
rtPath = "../stdlib/runtime.c";
rtPath = "../library/runtime/runtime.c";
}
if !FileExists(ioPath) {
ioPath = "../stdlib/io.c";
ioPath = "../library/runtime/io.c";
}
if !FileExists(rtPath) {
rtPath = "/home/ziko/z-git/bux/bux/stdlib/runtime.c";
rtPath = "/home/ziko/z-git/bux/bux/library/runtime/runtime.c";
}
if !FileExists(ioPath) {
ioPath = "/home/ziko/z-git/bux/bux/stdlib/io.c";
ioPath = "/home/ziko/z-git/bux/bux/library/runtime/io.c";
}
// Compile with cc
@@ -633,16 +633,16 @@ func Cli_BuildProject(projectDir: String) -> int {
var rtPath: String = bux_path_join(stdlibDir, "runtime.c");
var ioPath: String = bux_path_join(stdlibDir, "io.c");
if !FileExists(rtPath) {
rtPath = bux_path_join(projectDir, "stdlib/runtime.c");
rtPath = bux_path_join(projectDir, "library/runtime/runtime.c");
}
if !FileExists(ioPath) {
ioPath = bux_path_join(projectDir, "stdlib/io.c");
ioPath = bux_path_join(projectDir, "library/runtime/io.c");
}
if !FileExists(rtPath) {
rtPath = bux_path_join(projectDir, "../stdlib/runtime.c");
rtPath = bux_path_join(projectDir, "../library/runtime/runtime.c");
}
if !FileExists(ioPath) {
ioPath = bux_path_join(projectDir, "../stdlib/io.c");
ioPath = bux_path_join(projectDir, "../library/runtime/io.c");
}
// Compile with cc
+1 -1
View File
@@ -9,7 +9,7 @@ const skConst: int = 3;
const skModule: int = 4;
// Maximum symbols per scope
const maxSymbols: int = 1024;
const maxSymbols: int = 8192;
struct Symbol {
kind: int;
+19
View File
@@ -438,6 +438,7 @@ func Sema_CheckStmt(sema: *Sema, stmt: *Stmt) {
func Sema_CollectGlobals(sema: *Sema) {
var decl: *Decl = sema.module.firstItem;
var funcCount: int = 0;
while decl != null as *Decl {
let dk: int = decl.kind;
@@ -503,6 +504,24 @@ func Sema_CollectGlobals(sema: *Sema) {
}
}
// Const
if dk == dkConst {
var sym: Symbol;
Sema_ZeroInitSymbol(&sym);
sym.kind = skConst;
sym.name = decl.strValue;
if decl.constType != null as *TypeExpr {
sym.typeKind = Sema_ResolveType(sema, decl.constType);
sym.typeName = decl.constType.typeName;
} else {
sym.typeKind = tyInt;
}
sym.isMutable = false;
sym.isPublic = decl.isPublic;
sym.decl = decl;
discard Scope_Define(sema.scope, sym);
}
// Use (import)
if dk == dkUse {
if decl.useKind == 2 {