phase: 20.49 COMPLETE; 20.50 Flow+String minimal reps; 20.51 selfhost v0/v1 minimal (Option A/B); hv1-inline binop/unop/copy; docs + run_all + CURRENT_TASK -> 21.0
This commit is contained in:
@ -139,7 +139,7 @@ box ParserBox {
|
||||
if p.length() > 5 && me.starts_with(p, p.length()-5, ".hako") == 1 {
|
||||
p = p.substring(0, p.length()-5)
|
||||
} else {
|
||||
if p.length() > 6 && me.starts_with(p, p.length()-6, ".nyash") == 1 {
|
||||
if p.length() > 6 && me.starts_with(p, p.length()-6, ".hako") == 1 {
|
||||
p = p.substring(0, p.length()-6)
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ static box UsingCollectorBox {
|
||||
if ParserCommonUtilsBox.starts_with(target, 0, "./") == 1 { is_path = 1 }
|
||||
if ParserCommonUtilsBox.starts_with(target, 0, "/") == 1 { is_path = 1 }
|
||||
if target.length() >= 5 && ParserCommonUtilsBox.starts_with(target, target.length()-5, ".hako") == 1 { is_path = 1 }
|
||||
if target.length() >= 6 && ParserCommonUtilsBox.starts_with(target, target.length()-6, ".nyash") == 1 { is_path = 1 }
|
||||
if target.length() >= 6 && ParserCommonUtilsBox.starts_with(target, target.length()-6, ".hako") == 1 { is_path = 1 }
|
||||
}
|
||||
local name = ""
|
||||
local path = null
|
||||
@ -59,7 +59,7 @@ static box UsingCollectorBox {
|
||||
if idx >= 0 { p = p.substring(idx+1, p.length()) }
|
||||
// strip extension
|
||||
if p.length() > 5 && ParserCommonUtilsBox.starts_with(p, p.length()-5, ".hako") == 1 { p = p.substring(0, p.length()-5) }
|
||||
else { if p.length() > 6 && ParserCommonUtilsBox.starts_with(p, p.length()-6, ".nyash") == 1 { p = p.substring(0, p.length()-6) } }
|
||||
else { if p.length() > 6 && ParserCommonUtilsBox.starts_with(p, p.length()-6, ".hako") == 1 { p = p.substring(0, p.length()-6) } }
|
||||
name = p
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -45,7 +45,7 @@ Stage Guard(Stage‑2 / Stage‑3)
|
||||
|
||||
Testing
|
||||
- quick/selfhost に compare/binop/call/method/new の代表スモークがある。Compare系は Return‑only と CFG をそれぞれ確認。
|
||||
- Mini‑VM(apps/selfhost/vm/boxes/mir_vm_min.nyash)は最小仕様。算術/比較/CFGのみのスモークで品質を担保。
|
||||
- Mini‑VM(apps/selfhost/vm/boxes/mir_vm_min.hako)は最小仕様。算術/比較/CFGのみのスモークで品質を担保。
|
||||
|
||||
Notes
|
||||
- 追加の Extract 箱(Call/Method/New)を段階導入し、Stage1ExtractFlow の責務を縮小する計画。
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
// loop_scan_box.hako — If/Compare + then/else 範囲スキャンの小箱
|
||||
|
||||
using "hako.mir.builder.internal.prog_scan" as ProgScanBox
|
||||
using ProgScanBox as Scan
|
||||
using selfhost.shared.json.utils.json_frag as JsonFragBox
|
||||
|
||||
static box LoopScanBox {
|
||||
|
||||
@ -8,8 +8,6 @@
|
||||
// ])
|
||||
// Return Var("s")
|
||||
|
||||
using "hako.mir.builder.internal.prog_scan" as ProgScanBox
|
||||
using ProgScanBox as Scan
|
||||
using selfhost.shared.mir.loopform as LoopFormBox
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
using selfhost.shared.json.utils.json_frag as JsonFragBox
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
|
||||
using selfhost.shared.mir.schema as MirSchemaBox
|
||||
using "selfhost.shared.json.utils.json_frag" as JsonFragBox
|
||||
using selfhost.vm.helpers.method_alias_policy as MethodAliasPolicy
|
||||
|
||||
static box LowerReturnMethodArrayMapBox {
|
||||
try_lower(program_json) {
|
||||
@ -14,7 +15,7 @@ static box LowerReturnMethodArrayMapBox {
|
||||
local method = null
|
||||
{ local km = s.indexOf("\"method\":\"", k_m); if km < 0 { return null } method = JsonFragBox.read_string_after(s, km) }
|
||||
// Standardize: generate 'size' (len/length are accepted aliases at receiver)
|
||||
if method == "length" || method == "len" { method = "size" }
|
||||
method = MethodAliasPolicy.normalize_size(method)
|
||||
// Allow basic methods
|
||||
if !(method == "size" || method == "length" || method == "len" || method == "get" || method == "set" || method == "push") { return null }
|
||||
// Parse up to two Int args with actual values
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// mir_builder_min.nyash — Minimal MIR(JSON v0) builder for selfhost tests
|
||||
// mir_builder_min.hako — Minimal MIR(JSON v0) builder for selfhost tests
|
||||
// Scope: selfhost only (apps/selfhost/...); no core/runtime changes.
|
||||
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// mir_v1_adapter.nyash — Minimal JSON v1 (mir_call) to v0 adapter for selfhost
|
||||
// mir_v1_adapter.hako — Minimal JSON v1 (mir_call) to v0 adapter for selfhost
|
||||
// Scope: selfhost only. Transforms op:"mir_call" into legacy v0 ops (call/boxcall/newbox).
|
||||
|
||||
using selfhost.shared.json.core.json_cursor as JsonCursorBox
|
||||
|
||||
@ -106,7 +106,7 @@ static box MiniVmPrints {
|
||||
// Prefer plugin result whenever JSON route ran
|
||||
local dbg = _trace_enabled()
|
||||
local printed = 0
|
||||
printed = printed // placeholder to keep structure; logic in .nyash retained
|
||||
printed = printed // placeholder to keep structure; logic in .hako retained
|
||||
return printed
|
||||
}
|
||||
process_if_once(json) { return new MiniVmPrints().process_if_once(json) }
|
||||
|
||||
@ -6,6 +6,7 @@ using selfhost.shared.json.utils.json_frag as JsonFragBox
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
using selfhost.vm.helpers.mini_mir_v1_scan as MiniMirV1Scan
|
||||
using selfhost.vm.hakorune-vm.extern_provider as HakoruneExternProviderBox
|
||||
using selfhost.vm.helpers.method_alias_policy as MethodAliasPolicy
|
||||
|
||||
static box MirCallV1HandlerBox {
|
||||
handle(seg, regs) {
|
||||
@ -30,10 +31,11 @@ static box MirCallV1HandlerBox {
|
||||
}
|
||||
// Per‑receiver or global length counter
|
||||
local per_recv = env.get("HAKO_VM_MIRCALL_SIZESTATE_PER_RECV"); if per_recv == null { per_recv = "0" }
|
||||
local key = "__vm_len"
|
||||
if StringHelpers.int_to_str(per_recv) == "1" {
|
||||
local rid = MiniMirV1Scan.receiver_id(seg)
|
||||
if rid != null { key = "__vm_len:" + (""+rid) }
|
||||
local rid = MiniMirV1Scan.receiver_id(seg)
|
||||
local key = MethodAliasPolicy.recv_len_key(per_recv, rid)
|
||||
if env.get("HAKO_VM_MIRCALL_TRACE") == "1" {
|
||||
local rid_s = rid == null ? "null" : (""+rid)
|
||||
print("[vm/method/trace:" + mname + ",recv=" + rid_s + ",key=" + key + "]")
|
||||
}
|
||||
local cur_len_raw = regs.getField(key); if cur_len_raw == null { cur_len_raw = "0" }
|
||||
local cur_len = JsonFragBox._str_to_int(cur_len_raw)
|
||||
@ -43,7 +45,7 @@ static box MirCallV1HandlerBox {
|
||||
local d1 = JsonFragBox.get_int(seg, "dst"); if d1 != null { regs.setField(StringHelpers.int_to_str(d1), "0") }
|
||||
return
|
||||
}
|
||||
if mname == "len" || mname == "length" || mname == "size" {
|
||||
if MethodAliasPolicy.is_size_alias(mname) == 1 {
|
||||
local d2 = JsonFragBox.get_int(seg, "dst"); if d2 != null { regs.setField(StringHelpers.int_to_str(d2), StringHelpers.int_to_str(cur_len)) }
|
||||
return
|
||||
}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// mir_vm_m2.nyash — Ny製の最小MIR(JSON v0)実行器(M2: const/binop/ret)
|
||||
// mir_vm_m2.hako — Ny製の最小MIR(JSON v0)実行器(M2: const/binop/ret)
|
||||
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
using selfhost.shared.common.string_ops as StringOps
|
||||
|
||||
@ -6,14 +6,13 @@
|
||||
using selfhost.shared.json.utils.json_frag as JsonFragBox
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
using selfhost.shared.json.core.json_cursor as JsonCursorBox
|
||||
using selfhost.vm.hakorune-vm.str_cast as StrCast
|
||||
|
||||
static box RetResolveSimpleBox {
|
||||
_to_i64(s) { return StringHelpers.to_i64(s) }
|
||||
_load_reg(regs, id) {
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
local v = regs.get(StringHelpers.int_to_str(id))
|
||||
if v == null { return 0 }
|
||||
using selfhost.vm.hakorune-vm.str_cast as StrCast
|
||||
local s = StrCast.to_str(v)
|
||||
if StringHelpers.is_numeric_str(s) == 1 { return me._to_i64(s) }
|
||||
return 0
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// vm_kernel_box.nyash — NYABI Kernel (skeleton, dev-only; not wired)
|
||||
// vm_kernel_box.hako — NYABI Kernel (skeleton, dev-only; not wired)
|
||||
// Scope: Provide policy/decision helpers behind an explicit OFF toggle.
|
||||
// Notes: This box is not referenced by the VM by default.
|
||||
|
||||
|
||||
@ -62,4 +62,4 @@ static box Main {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
// migrated from .nyash to .hako (branding)
|
||||
// migrated from .hako to .hako (branding)
|
||||
|
||||
@ -11,4 +11,4 @@ static box Main {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
// migrated from .nyash to .hako (branding)
|
||||
// migrated from .hako to .hako (branding)
|
||||
|
||||
@ -20,4 +20,4 @@ static box Main {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
// migrated from .nyash to .hako (branding)
|
||||
// migrated from .hako to .hako (branding)
|
||||
|
||||
@ -9,4 +9,4 @@ static box Main {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
// migrated from .nyash to .hako (branding)
|
||||
// migrated from .hako to .hako (branding)
|
||||
|
||||
@ -16,4 +16,4 @@ static box Main {
|
||||
return 0
|
||||
}
|
||||
}
|
||||
// migrated from .nyash to .hako (branding)
|
||||
// migrated from .hako to .hako (branding)
|
||||
|
||||
@ -33,20 +33,22 @@ static box HakoruneExternProviderBox {
|
||||
// Optional C‑ABI bridge(既定OFF): タグを出力しつつ、Rust 側 extern_provider に最小接続
|
||||
if env.get("HAKO_V1_EXTERN_PROVIDER_C_ABI") == "1" {
|
||||
print("[extern/c-abi:mirbuilder.emit]")
|
||||
// Call through to Core extern dispatcher (ignore return to keep rc=0 policy in this phase)
|
||||
hostbridge.extern_invoke("env.mirbuilder", "emit", args)
|
||||
// Call through to Core extern dispatcher and return the produced JSON (v1)
|
||||
local out = hostbridge.extern_invoke("env.mirbuilder", "emit", args)
|
||||
return "" + out
|
||||
}
|
||||
// Phase‑20.38 では空文字を返して rc=0 を維持
|
||||
// Default: return empty string (verify/dev stub keeps rc=0)
|
||||
return ""
|
||||
}
|
||||
if name == "env.codegen.emit_object" {
|
||||
// Optional C‑ABI bridge(既定OFF): タグを出力しつつ、Rust 側 extern_provider に最小接続
|
||||
if env.get("HAKO_V1_EXTERN_PROVIDER_C_ABI") == "1" {
|
||||
print("[extern/c-abi:codegen.emit_object]")
|
||||
// Call through to Core extern dispatcher (ignore return to keep rc=0 policy in this phase)
|
||||
hostbridge.extern_invoke("env.codegen", "emit_object", args)
|
||||
// Call through to Core extern dispatcher and return produced object path
|
||||
local out = hostbridge.extern_invoke("env.codegen", "emit_object", args)
|
||||
return "" + out
|
||||
}
|
||||
// Phase‑20.38 では空文字を返して rc=0 を維持
|
||||
// Default: return empty string (verify/dev stub keeps rc=0)
|
||||
return ""
|
||||
}
|
||||
// Unknown: return null for now (caller decides Fail‑Fast)
|
||||
|
||||
25
lang/src/vm/helpers/method_alias_policy.hako
Normal file
25
lang/src/vm/helpers/method_alias_policy.hako
Normal file
@ -0,0 +1,25 @@
|
||||
// method_alias_policy.hako — MethodAliasPolicy
|
||||
// Responsibility: normalize common method aliases and build stable keys.
|
||||
|
||||
using selfhost.shared.common.string_helpers as StringHelpers
|
||||
|
||||
static box MethodAliasPolicy {
|
||||
is_size_alias(name) {
|
||||
if name == null { return 0 }
|
||||
if name == "size" { return 1 }
|
||||
if name == "len" { return 1 }
|
||||
if name == "length" { return 1 }
|
||||
return 0
|
||||
}
|
||||
normalize_size(name) { if me.is_size_alias(name) == 1 { return "size" } return name }
|
||||
recv_len_key(per_recv, rid) {
|
||||
if ("" + per_recv) == "1" {
|
||||
return "__vm_len:" + ("" + rid)
|
||||
}
|
||||
return "__vm_len"
|
||||
}
|
||||
itos(n) { return StringHelpers.int_to_str(n) }
|
||||
}
|
||||
|
||||
static box MethodAliasPolicyMain { method main(args) { return 0 } }
|
||||
|
||||
@ -9,4 +9,4 @@ static box Main {
|
||||
return new MiniVm().run(json)
|
||||
}
|
||||
}
|
||||
// migrated from .nyash to .hako (branding)
|
||||
// migrated from .hako to .hako (branding)
|
||||
|
||||
@ -14,4 +14,4 @@ static box Main {
|
||||
return code
|
||||
}
|
||||
}
|
||||
// migrated from .nyash to .hako (branding)
|
||||
// migrated from .hako to .hako (branding)
|
||||
|
||||
Reference in New Issue
Block a user