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:
+18
-19
@@ -89,16 +89,16 @@ func Json_ArrayGet(v: JsonValue, index: uint) -> JsonValue {
|
|||||||
func Json_ArrayPush(self: *JsonValue, val: JsonValue) {
|
func Json_ArrayPush(self: *JsonValue, val: JsonValue) {
|
||||||
if self.tag != JsonTagArray { return; }
|
if self.tag != JsonTagArray { return; }
|
||||||
if self.arrLen >= self.arrCap {
|
if self.arrLen >= self.arrCap {
|
||||||
var newCap: uint = self.arrCap;
|
// Compute new capacity (avoid var scoping bug in selfhost sema)
|
||||||
if newCap == 0 { newCap = 4; }
|
let arrNewCap: uint = self.arrCap;
|
||||||
else { newCap = newCap * 2; }
|
if arrNewCap == 0 {
|
||||||
let newSize: uint = newCap * sizeof(JsonValue);
|
self.arrCap = 4;
|
||||||
if self.arrCap == 0 {
|
self.arrData = Alloc(4 * sizeof(JsonValue)) as *JsonValue;
|
||||||
self.arrData = Alloc(newSize) as *JsonValue;
|
|
||||||
} else {
|
} 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.arrData[self.arrLen] = val;
|
||||||
self.arrLen = self.arrLen + 1;
|
self.arrLen = self.arrLen + 1;
|
||||||
@@ -145,19 +145,18 @@ func Json_ObjectSet(self: *JsonValue, key: String, val: JsonValue) {
|
|||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
}
|
||||||
if self.objLen >= self.objCap {
|
if self.objLen >= self.objCap {
|
||||||
var newCap: uint = self.objCap;
|
// Compute new capacity (avoid var scoping bug in selfhost sema)
|
||||||
if newCap == 0 { newCap = 4; }
|
let objNewCap: uint = self.objCap;
|
||||||
else { newCap = newCap * 2; }
|
if objNewCap == 0 {
|
||||||
let keySize: uint = newCap * sizeof(String);
|
self.objCap = 4;
|
||||||
let valSize: uint = newCap * sizeof(JsonValue);
|
self.objKeys = Alloc(4 * sizeof(String)) as *String;
|
||||||
if self.objCap == 0 {
|
self.objValues = Alloc(4 * sizeof(JsonValue)) as *JsonValue;
|
||||||
self.objKeys = Alloc(keySize) as *String;
|
|
||||||
self.objValues = Alloc(valSize) as *JsonValue;
|
|
||||||
} else {
|
} else {
|
||||||
self.objKeys = Realloc(self.objKeys as *void, keySize) as *String;
|
let doubleCap: uint = objNewCap * 2;
|
||||||
self.objValues = Realloc(self.objValues as *void, valSize) as *JsonValue;
|
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.objKeys[self.objLen] = key;
|
||||||
self.objValues[self.objLen] = val;
|
self.objValues[self.objLen] = val;
|
||||||
|
|||||||
+3
-3
@@ -149,10 +149,10 @@ func Cli_Build(srcPath: String, outPath: String) -> int {
|
|||||||
ioPath = "../rt/io.c";
|
ioPath = "../rt/io.c";
|
||||||
}
|
}
|
||||||
if !FileExists(rtPath) {
|
if !FileExists(rtPath) {
|
||||||
rtPath = "/home/ziko/z-git/bux/bux/rt/runtime.c";
|
rtPath = "../../rt/runtime.c";
|
||||||
}
|
}
|
||||||
if !FileExists(ioPath) {
|
if !FileExists(ioPath) {
|
||||||
ioPath = "/home/ziko/z-git/bux/bux/rt/io.c";
|
ioPath = "../../rt/io.c";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile with cc
|
// Compile with cc
|
||||||
@@ -298,7 +298,7 @@ func Cli_FindStdlibDir(projectDir: String) -> String {
|
|||||||
if DirExists(path) { return path; }
|
if DirExists(path) { return path; }
|
||||||
path = bux_path_join(projectDir, "../lib");
|
path = bux_path_join(projectDir, "../lib");
|
||||||
if DirExists(path) { return path; }
|
if DirExists(path) { return path; }
|
||||||
path = "/home/ziko/z-git/bux/bux/lib";
|
path = bux_path_join(projectDir, "../../lib");
|
||||||
if DirExists(path) { return path; }
|
if DirExists(path) { return path; }
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user