ast_lowerer.rs → ast_lowerer/ (10 files): - mod.rs: public surface + entry dispatch - context.rs: ExtractCtx helpers - expr.rs: expression-to-JoinIR extraction - if_return.rs: simple if→Select lowering - loop_patterns.rs: loop variants (simple/break/continue) - read_quoted.rs: read_quoted_from lowering (Phase 45-46) - nested_if.rs: NestedIfMerge lowering - analysis.rs: loop if-var analysis + metadata helpers - tests.rs: frontend lowering tests - README.md: module documentation join_ir_vm_bridge.rs → join_ir_vm_bridge/ (5 files): - mod.rs: public surface + shared helpers - convert.rs: JoinIR→MIR lowering - runner.rs: VM execution entry (run_joinir_via_vm) - meta.rs: experimental metadata-aware hooks - tests.rs: bridge-specific unit tests - README.md: module documentation Benefits: - Clear separation of concerns per pattern - Easier navigation and maintenance - Each file has single responsibility - README documents module boundaries Co-authored-by: ChatGPT <noreply@openai.com> 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
use super::VarId;
|
|
use std::collections::BTreeMap;
|
|
|
|
/// Phase 34-5: 式から値を抽出する際のコンテキスト
|
|
///
|
|
/// extract_value ヘルパ関数で使用する内部状態
|
|
pub(crate) struct ExtractCtx {
|
|
/// 次に使える ValueId カウンタ
|
|
pub(crate) next_var_id: u32,
|
|
/// 変数名 → ValueId のマップ(パラメータなど)
|
|
pub(crate) var_map: BTreeMap<String, VarId>,
|
|
}
|
|
|
|
impl ExtractCtx {
|
|
/// 新しいコンテキストを作成
|
|
pub(crate) fn new(start_var_id: u32) -> Self {
|
|
Self {
|
|
next_var_id: start_var_id,
|
|
var_map: BTreeMap::new(),
|
|
}
|
|
}
|
|
|
|
/// パラメータを登録
|
|
pub(crate) fn register_param(&mut self, name: String, var_id: VarId) {
|
|
self.var_map.insert(name, var_id);
|
|
}
|
|
|
|
/// 新しい ValueId を割り当て
|
|
pub(crate) fn alloc_var(&mut self) -> VarId {
|
|
let id = crate::mir::ValueId(self.next_var_id);
|
|
self.next_var_id += 1;
|
|
id
|
|
}
|
|
|
|
/// 変数名から ValueId を取得
|
|
pub(crate) fn get_var(&self, name: &str) -> Option<VarId> {
|
|
self.var_map.get(name).copied()
|
|
}
|
|
}
|