core: add Core Direct string canaries (substring/charAt/replace); Stage‑B: alias table (ENV) support with BundleResolver; docs: Exit Code Policy tag→rc rules and checklist updates.
This commit is contained in:
@ -7,6 +7,62 @@ static box BundleResolver {
|
||||
// - --require-mod Name must appear in named bundles ([bundle/missing] Name)
|
||||
// - Merge order: bundle-src* → bundle-mod* (in given order)
|
||||
resolve(bundle_srcs, bundle_names, bundle_mod_srcs, require_mods) {
|
||||
// Alias table via env: HAKO_BUNDLE_ALIAS_TABLE / NYASH_BUNDLE_ALIAS_TABLE
|
||||
// Format: entries separated by '|||', each entry as 'Name:code'
|
||||
local table = env.get("HAKO_BUNDLE_ALIAS_TABLE")
|
||||
if table == null || table == "" { table = env.get("NYASH_BUNDLE_ALIAS_TABLE") }
|
||||
if table != null && table != "" {
|
||||
local i = 0
|
||||
loop(i < table.length()) {
|
||||
// find next delimiter or end
|
||||
local j = table.indexOf("|||", i)
|
||||
local seg = ""
|
||||
if j >= 0 { seg = table.substring(i, j) } else { seg = table.substring(i, table.length()) }
|
||||
if seg != "" {
|
||||
local pos = -1
|
||||
local k = 0
|
||||
loop(k < seg.length()) { if seg.substring(k,k+1) == ":" { pos = k break } k = k + 1 }
|
||||
if pos >= 0 {
|
||||
local name = seg.substring(0, pos)
|
||||
local code = seg.substring(pos+1, seg.length())
|
||||
if name != "" && code != "" {
|
||||
if bundle_names == null { bundle_names = new ArrayBox() }
|
||||
if bundle_mod_srcs == null { bundle_mod_srcs = new ArrayBox() }
|
||||
bundle_names.push(name)
|
||||
bundle_mod_srcs.push(code)
|
||||
}
|
||||
}
|
||||
}
|
||||
if j < 0 { break }
|
||||
i = j + 3
|
||||
}
|
||||
}
|
||||
// Env alias injection (TTL, dev-only): HAKO_BUNDLE_ALIAS_<Name> / NYASH_BUNDLE_ALIAS_<Name>
|
||||
// If a required module is not provided via --bundle-mod, but an env alias
|
||||
// supplies its code, synthesize a named bundle entry before checks/merge.
|
||||
if require_mods != null {
|
||||
local i0 = 0; local rn0 = require_mods.length()
|
||||
loop(i0 < rn0) {
|
||||
local need = "" + require_mods.get(i0)
|
||||
local present = 0
|
||||
if bundle_names != null {
|
||||
local j0 = 0; local bn0 = bundle_names.length()
|
||||
loop(j0 < bn0) { if ("" + bundle_names.get(j0)) == need { present = 1 break } j0 = j0 + 1 }
|
||||
}
|
||||
if present == 0 {
|
||||
local alias_key = "HAKO_BUNDLE_ALIAS_" + need
|
||||
local code = env.get(alias_key)
|
||||
if code == null || code == "" { code = env.get("NYASH_BUNDLE_ALIAS_" + need) }
|
||||
if code != null && code != "" {
|
||||
if bundle_names == null { bundle_names = new ArrayBox() }
|
||||
if bundle_mod_srcs == null { bundle_mod_srcs = new ArrayBox() }
|
||||
bundle_names.push(need)
|
||||
bundle_mod_srcs.push("" + code)
|
||||
}
|
||||
}
|
||||
i0 = i0 + 1
|
||||
}
|
||||
}
|
||||
// Fail on duplicate names
|
||||
if bundle_names != null && bundle_names.length() > 1 {
|
||||
local i = 0; local n = bundle_names.length()
|
||||
@ -50,4 +106,3 @@ static box BundleResolver {
|
||||
return merged
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user