Files
hakorune/lang/src/shared/mir/control_form_box.hako

43 lines
1.3 KiB
Plaintext
Raw Normal View History

// selfhost/shared/mir/control_form_box.hako
// ControlFormBox — Loop / If 共通ビューの Hakorune 実装版Layer 2
//
// 目的:
// - Rust 側の LoopShape / IfShape / ControlForm に対応する箱を .hako 側に用意して、
// StageB / LoopSSA からも同じモデルで制御構造を扱えるようにすることだよ。
// - 現時点では「構造定義のみ」の箱で、コンパイルを通すための最小限の実装になっているよ。
static box ControlFormBox {
// 共通フィールド
kind_name: StringBox // "loop" or "if"
entry: IntegerBox // BasicBlockId 相当整数ID
exits: ArrayBox // of IntegerBox (BlockId)
// Loop 用フィールドkind_name == "loop" の時のみ意味を持つ)
loop_preheader: IntegerBox
loop_header: IntegerBox
loop_body: IntegerBox
loop_latch: IntegerBox
loop_exit: IntegerBox
// If 用フィールドkind_name == "if" の時のみ意味を持つ)
if_cond: IntegerBox
if_then: IntegerBox
if_else: IntegerBox
if_merge: IntegerBox
// コンストラクタ相当: kind_name を設定し、exits 配列を初期化するよ。
birth(kind) {
me.kind_name = kind
me.exits = new ArrayBox()
}
is_loop() {
return me.kind_name == "loop"
}
is_if() {
return me.kind_name == "if"
}
}