Phase 25.1b: Step2完了(FuncBodyBasicLowerBox導入)
Step2実装内容: - FuncBodyBasicLowerBox導入(defs専用下請けモジュール) - _try_lower_local_if_return実装(Local+単純if) - _inline_local_ints実装(軽い正規化) - minimal lowers統合(Return/BinOp/IfCompare/MethodArray系) Fail-Fast体制確立: - MirBuilderBox: defs_onlyでも必ずタグ出力 - [builder/selfhost-first:unsupported:defs_only] - [builder/selfhost-first:unsupported:no_match] Phase構造整備: - Phase 25.1b README新設(Step0-3計画) - Phase 25.2b README新設(次期計画) - UsingResolverBox追加(using system対応準備) スモークテスト: - stage1_launcher_program_to_mir_canary_vm.sh追加 Next: Step3 LoopForm対応 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -12,7 +12,7 @@ static box LoopFormBox {
|
||||
// i = i + 1;
|
||||
// }
|
||||
// Builds LoopForm structure with Header/Latch PHI + Exit PHI (continue/break aware)
|
||||
loop_counter(limit, skip_value, break_value) {
|
||||
method loop_counter(limit, skip_value, break_value) {
|
||||
if skip_value == null { skip_value = 2 }
|
||||
if break_value == null { break_value = limit }
|
||||
|
||||
@ -109,7 +109,7 @@ static box LoopFormBox {
|
||||
// body: r12 = i + step, jump latch
|
||||
// latch: jump header (PHI incoming from body)
|
||||
// exit: ret r10
|
||||
loop_count(limit) {
|
||||
method loop_count(limit) {
|
||||
// Preheader
|
||||
local pre = new ArrayBox()
|
||||
pre.push(MirSchemaBox.inst_const(1, 0))
|
||||
@ -148,10 +148,10 @@ static box LoopFormBox {
|
||||
|
||||
// loop_count_param — counting loop with init/step parameters
|
||||
// Returns final i value, starting from init, incremented by step while i < limit
|
||||
loop_count_param(init, limit, step) {
|
||||
method build_loop_count_param(start_value, limit, step) {
|
||||
// Preheader
|
||||
local pre = new ArrayBox()
|
||||
pre.push(MirSchemaBox.inst_const(1, init))
|
||||
pre.push(MirSchemaBox.inst_const(1, start_value))
|
||||
pre.push(MirSchemaBox.inst_const(2, limit))
|
||||
pre.push(MirSchemaBox.inst_const(3, step))
|
||||
pre.push(MirSchemaBox.inst_jump(1))
|
||||
@ -185,13 +185,13 @@ static box LoopFormBox {
|
||||
|
||||
// Extended param variant: allow custom compare op ("Lt"/"Le"/"Gt"/"Ge") via opts
|
||||
// and negative step (handled by passing negative string for step)
|
||||
loop_count_param_ex(init, limit, step, cmp) {
|
||||
method build_loop_count_param_ex(start_value, limit, step, cmp) {
|
||||
local cmpop = "" + cmp
|
||||
if cmpop == null || cmpop == "" { cmpop = "Lt" }
|
||||
|
||||
// Preheader
|
||||
local pre = new ArrayBox()
|
||||
pre.push(MirSchemaBox.inst_const(1, init))
|
||||
pre.push(MirSchemaBox.inst_const(1, start_value))
|
||||
pre.push(MirSchemaBox.inst_const(2, limit))
|
||||
pre.push(MirSchemaBox.inst_const(3, step))
|
||||
pre.push(MirSchemaBox.inst_jump(1))
|
||||
@ -227,18 +227,18 @@ static box LoopFormBox {
|
||||
// mode:
|
||||
// - "count" : counting loop that returns final i (uses loop_count)
|
||||
// - "sum_bc" : sum with break/continue sentinels (uses loop_counter)
|
||||
build(mode, limit, skip_value, break_value) {
|
||||
method build(mode, limit, skip_value, break_value) {
|
||||
local m = "" + mode
|
||||
if m == "count" {
|
||||
return me.loop_count(limit)
|
||||
}
|
||||
if m == "count_param" {
|
||||
// Here, skip_value carries init and break_value carries step (temporary param slots)
|
||||
local init = skip_value
|
||||
local start_value = skip_value
|
||||
local step = break_value
|
||||
if init == null { init = 0 }
|
||||
if start_value == null { start_value = 0 }
|
||||
if step == null { step = 1 }
|
||||
return me.loop_count_param(init, limit, step)
|
||||
return me.build_loop_count_param(start_value, limit, step)
|
||||
}
|
||||
if m == "sum_bc" {
|
||||
if skip_value == null { skip_value = 2 }
|
||||
@ -250,20 +250,20 @@ static box LoopFormBox {
|
||||
}
|
||||
|
||||
// Map-based builder: build2({ mode, init, limit, step, skip, break })
|
||||
build2(opts) {
|
||||
method build2(opts) {
|
||||
if opts == null { return null }
|
||||
local mode = "" + opts.get("mode")
|
||||
local init = opts.get("init")
|
||||
local start_value = opts.get("init")
|
||||
local limit = opts.get("limit")
|
||||
local step = opts.get("step")
|
||||
local skip_v = opts.get("skip")
|
||||
local break_v = opts.get("break")
|
||||
if mode == "count" {
|
||||
if init == null { init = 0 }
|
||||
if start_value == null { start_value = 0 }
|
||||
if step == null { step = 1 }
|
||||
local cmp = opts.get("cmp") // optional: "Lt"/"Le"/"Gt"/"Ge"
|
||||
if cmp == null { cmp = "Lt" }
|
||||
return me.loop_count_param_ex(init, limit, step, cmp)
|
||||
return me.build_loop_count_param_ex(start_value, limit, step, cmp)
|
||||
}
|
||||
if mode == "sum_bc" { return me.loop_counter(limit, skip_v, break_v) }
|
||||
print("[loopform/unsupported-mode] " + mode)
|
||||
|
||||
Reference in New Issue
Block a user