restore(lang): full lang tree from ff3ef452 (306 files) — compiler, vm, shared, runner, c-abi, etc.\n\n- Restores lang/ directory (files≈306, dirs≈64) as per historical branch with selfhost sources\n- Keeps our recent parser index changes in compiler/* (merged clean by checkout)\n- Unblocks selfhost development and documentation references
This commit is contained in:
@ -14,11 +14,13 @@ using lang.compiler.parser.stmt.parser_control_box
|
||||
box ParserBox {
|
||||
gpos
|
||||
usings_json
|
||||
externs_json
|
||||
stage3
|
||||
|
||||
birth() {
|
||||
me.gpos = 0
|
||||
me.usings_json = "[]"
|
||||
me.externs_json = "[]"
|
||||
me.stage3 = 0
|
||||
return 0
|
||||
}
|
||||
@ -152,6 +154,36 @@ box ParserBox {
|
||||
return me.usings_json
|
||||
}
|
||||
|
||||
// === extern_c annotations ===
|
||||
add_extern_c(symbol, func) {
|
||||
// Entry shape: {"symbol":"hako_add","func":"Name/Arity"}
|
||||
local sym = match symbol { null => "", _ => symbol }
|
||||
local fn = match func { null => "", _ => func }
|
||||
local entry = "{\"symbol\":\"" + me.esc_json(sym) + "\",\"func\":\"" + me.esc_json(fn) + "\"}"
|
||||
local cur = me.externs_json
|
||||
if cur == null || cur.size() == 0 { cur = "[]" }
|
||||
if cur == "[]" {
|
||||
me.externs_json = "[" + entry + "]"
|
||||
return 0
|
||||
}
|
||||
local pos = cur.lastIndexOf("]")
|
||||
if pos < 0 {
|
||||
me.externs_json = "[" + entry + "]"
|
||||
return 0
|
||||
}
|
||||
me.externs_json = cur.substring(0, pos) + "," + entry + "]"
|
||||
return 0
|
||||
}
|
||||
|
||||
extract_externs(_src) {
|
||||
// MVP: rely on ParserStmtBox to call add_extern_c during parse; here no-op for now.
|
||||
return 0
|
||||
}
|
||||
|
||||
get_externs_json() {
|
||||
return me.externs_json
|
||||
}
|
||||
|
||||
// === Delegation to ParserExprBox ===
|
||||
parse_expr2(src, i) {
|
||||
local expr = new ParserExprBox()
|
||||
@ -236,4 +268,3 @@ static box ParserStub {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user