v0.4.0: selfhost loop progress

- Fix stdlib merge: merge ALL lib/*.bux via bux_list_dir (was 0)
- Fix Cli_FindStdlibDir: search for lib/ not stdlib/
- Fix stdlib path: remove Std/ subdir (now flat in lib/)
- Fix runtime paths: add ../../ fallback for build/selfhost depth
- Remove hardcoded /home/ziko paths from src/cli.bux
- Fix Json.bux: avoid var-in-if-block scoping bug (5 errors)
- Add improved sema error messages (reverted due to crash)
- Remaining: 2 parserParsePostfix sema forward-ref errors
- Update PLAN.md with v0.3.0-v1.0.0 roadmap
This commit is contained in:
2026-06-06 05:15:04 +03:00
parent 2698ca92b7
commit a8b909726b
2 changed files with 21 additions and 22 deletions
+18 -19
View File
@@ -89,16 +89,16 @@ func Json_ArrayGet(v: JsonValue, index: uint) -> JsonValue {
func Json_ArrayPush(self: *JsonValue, val: JsonValue) {
if self.tag != JsonTagArray { return; }
if self.arrLen >= self.arrCap {
var newCap: uint = self.arrCap;
if newCap == 0 { newCap = 4; }
else { newCap = newCap * 2; }
let newSize: uint = newCap * sizeof(JsonValue);
if self.arrCap == 0 {
self.arrData = Alloc(newSize) as *JsonValue;
// Compute new capacity (avoid var scoping bug in selfhost sema)
let arrNewCap: uint = self.arrCap;
if arrNewCap == 0 {
self.arrCap = 4;
self.arrData = Alloc(4 * sizeof(JsonValue)) as *JsonValue;
} else {
self.arrData = Realloc(self.arrData as *void, newSize) as *JsonValue;
let doubleCap: uint = arrNewCap * 2;
self.arrCap = doubleCap;
self.arrData = Realloc(self.arrData as *void, doubleCap * sizeof(JsonValue)) as *JsonValue;
}
self.arrCap = newCap;
}
self.arrData[self.arrLen] = val;
self.arrLen = self.arrLen + 1;
@@ -145,19 +145,18 @@ func Json_ObjectSet(self: *JsonValue, key: String, val: JsonValue) {
i = i + 1;
}
if self.objLen >= self.objCap {
var newCap: uint = self.objCap;
if newCap == 0 { newCap = 4; }
else { newCap = newCap * 2; }
let keySize: uint = newCap * sizeof(String);
let valSize: uint = newCap * sizeof(JsonValue);
if self.objCap == 0 {
self.objKeys = Alloc(keySize) as *String;
self.objValues = Alloc(valSize) as *JsonValue;
// Compute new capacity (avoid var scoping bug in selfhost sema)
let objNewCap: uint = self.objCap;
if objNewCap == 0 {
self.objCap = 4;
self.objKeys = Alloc(4 * sizeof(String)) as *String;
self.objValues = Alloc(4 * sizeof(JsonValue)) as *JsonValue;
} else {
self.objKeys = Realloc(self.objKeys as *void, keySize) as *String;
self.objValues = Realloc(self.objValues as *void, valSize) as *JsonValue;
let doubleCap: uint = objNewCap * 2;
self.objCap = doubleCap;
self.objKeys = Realloc(self.objKeys as *void, doubleCap * sizeof(String)) as *String;
self.objValues = Realloc(self.objValues as *void, doubleCap * sizeof(JsonValue)) as *JsonValue;
}
self.objCap = newCap;
}
self.objKeys[self.objLen] = key;
self.objValues[self.objLen] = val;
+3 -3
View File
@@ -149,10 +149,10 @@ func Cli_Build(srcPath: String, outPath: String) -> int {
ioPath = "../rt/io.c";
}
if !FileExists(rtPath) {
rtPath = "/home/ziko/z-git/bux/bux/rt/runtime.c";
rtPath = "../../rt/runtime.c";
}
if !FileExists(ioPath) {
ioPath = "/home/ziko/z-git/bux/bux/rt/io.c";
ioPath = "../../rt/io.c";
}
// Compile with cc
@@ -298,7 +298,7 @@ func Cli_FindStdlibDir(projectDir: String) -> String {
if DirExists(path) { return path; }
path = bux_path_join(projectDir, "../lib");
if DirExists(path) { return path; }
path = "/home/ziko/z-git/bux/bux/lib";
path = bux_path_join(projectDir, "../../lib");
if DirExists(path) { return path; }
return "";
}