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:
nyash-codex
2025-11-02 16:24:50 +09:00
parent 8b006575c1
commit 0cd2342b05
14 changed files with 371 additions and 26 deletions

View File

@ -401,7 +401,7 @@ static box NyVmOpMirCall {
if method == "keys" {
local dst = me._read_dst(inst_json, "map keys")
if dst == null { return -1 }
// Build keys by scanning mem for receiver-specific entry slots
// Build keys by scanning mem for receiver-specific entry slots (non-null values only)
local keys_arr = new ArrayBox()
local prefix = me._map_entry_slot(recv_id, "")
// Iterate memory keys (MapBox.keys())
@ -416,8 +416,11 @@ static box NyVmOpMirCall {
if k.substring(0, prefix.length()) == prefix { ok = 1 }
}
if ok == 1 {
local tail = k.substring(prefix.length(), k.length())
keys_arr.push(tail)
local v = mem.get(k)
if v != null {
local tail = k.substring(prefix.length(), k.length())
keys_arr.push(tail)
}
}
i = i + 1
}
@ -473,7 +476,20 @@ static box NyVmOpMirCall {
return 0
}
if method == "clear" {
// clear(): set length to 0; entries are logically clearedTTL: metadataonly
// clear(): set length to 0 and remove all entries for this map from mem
local prefix = me._map_entry_slot(recv_id, "")
local all_keys = mem.keys()
local i = 0
local n = all_keys.length()
loop(i < n) {
local k = "" + all_keys.get(i)
local ok = 0
if k.length() >= prefix.length() {
if k.substring(0, prefix.length()) == prefix { ok = 1 }
}
if ok == 1 { mem.set(k, null) }
i = i + 1
}
me._map_len_set(state, recv_id, 0)
local dst_opt2 = me._read_optional_vid_field(inst_json, "dst")
if dst_opt2 != null { NyVmState.set_reg(state, dst_opt2, void) }