feat(stageb): add shallow recursion guards to bundle and using resolvers
This commit is contained in:
@ -7,6 +7,15 @@ 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) {
|
||||
// Shallow recursion guard to prevent accidental self-recursion in Stage‑B bundler.
|
||||
{
|
||||
local depth = env.get("HAKO_STAGEB_BUNDLE_DEPTH")
|
||||
if depth != null && ("" + depth) != "0" {
|
||||
print("[stageb/recursion] BundleResolver.resolve recursion detected")
|
||||
return null
|
||||
}
|
||||
env.set("HAKO_STAGEB_BUNDLE_DEPTH", "1")
|
||||
}
|
||||
// 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")
|
||||
@ -101,6 +110,8 @@ static box BundleResolver {
|
||||
local i2 = 0; local m2 = bundle_mod_srcs.length()
|
||||
loop(i2 < m2) { merged = merged + bundle_mod_srcs.get(i2) + "\n" i2 = i2 + 1 }
|
||||
}
|
||||
// Clear depth guard before returning
|
||||
env.set("HAKO_STAGEB_BUNDLE_DEPTH", "0")
|
||||
return merged
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user