📚 Phase 15計画を詳細化・更新: Python/llvmlite正式採用とプラグイン全方向ビルド戦略

 主な更新内容:
- Python/llvmlite実装の正式採用を明記(開発速度10倍、~2400行)
- プラグイン全方向ビルド戦略(.so/.o/.a同時生成)で単一EXE生成可能に
- 各実装の予想コード量を具体化(パーサー800行、MIR Builder 2500行、VM 5000行)
- 循環依存問題の解決を明記(nyrtがC ABI経由で提供)
- 現実的なスケジュール調整(2025年9月~2026年3月)

🎉 最新進捗:
- dep_tree_min_string.nyashオブジェクト生成成功(10.4KB)
- LLVM verifier green - dominance違反解決
- Resolver patternでSSA安全性確保

🚀 次のマイルストーン:
- Python/llvmliteでEXE生成パイプライン完成
- nyash-llvm-compiler分離設計
- NyashパーサーMVP実装開始

Everything is Boxの究極形が、ついに実現へ!

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-13 15:37:58 +09:00
parent 8e4f6d774d
commit 1d6fab4eda
44 changed files with 1653 additions and 598 deletions

View File

@ -91,7 +91,20 @@ pub(in super::super) fn lower_boxcall<'ctx, 'b>(
}
// getField/setField
if fields::try_handle_field_method(codegen, cursor, cur_bid, vmap, dst, method, args, recv_h, resolver, bb_map, preds, block_end_values)? {
if fields::try_handle_field_method(
codegen,
cursor,
cur_bid,
vmap,
dst,
method,
args,
recv_h,
resolver,
bb_map,
preds,
block_end_values,
)? {
return Ok(());
}
@ -294,6 +307,50 @@ pub(in super::super) fn lower_boxcall_boxed<'ctx, 'b>(
)
}
// Convenience wrapper: construct LowerFnCtx/BlockCtx inside to keep caller borrow scopes short.
pub(in super::super) fn lower_boxcall_via_ctx<'ctx, 'b>(
codegen: &'ctx CodegenContext<'ctx>,
cursor: &'b mut BuilderCursor<'ctx, 'b>,
resolver: &'b mut super::Resolver<'ctx>,
cur_bid: BasicBlockId,
func: &'b MirFunction,
vmap: &'b mut HashMap<ValueId, inkwell::values::BasicValueEnum<'ctx>>,
dst: &Option<ValueId>,
box_val: &ValueId,
method: &str,
method_id: &Option<u16>,
args: &[ValueId],
box_type_ids: &'b HashMap<String, i64>,
entry_builder: &inkwell::builder::Builder<'ctx>,
bb_map: &'b std::collections::HashMap<crate::mir::BasicBlockId, inkwell::basic_block::BasicBlock<'ctx>>,
preds: &'b std::collections::HashMap<crate::mir::BasicBlockId, Vec<crate::mir::BasicBlockId>>,
block_end_values: &'b std::collections::HashMap<crate::mir::BasicBlockId, std::collections::HashMap<ValueId, inkwell::values::BasicValueEnum<'ctx>>>,
) -> Result<(), String> {
let llbb = *bb_map.get(&cur_bid).ok_or("missing cur bb")?;
let blkctx = BlockCtx::new(cur_bid, llbb);
let mut fnctx = LowerFnCtx::new(
codegen,
func,
cursor,
resolver,
vmap,
bb_map,
preds,
block_end_values,
)
.with_box_type_ids(box_type_ids);
lower_boxcall_boxed(
&mut fnctx,
&blkctx,
dst,
box_val,
method,
method_id,
args,
entry_builder,
)
}
fn coerce_to_type<'ctx>(
codegen: &CodegenContext<'ctx>,
val: inkwell::values::BasicValueEnum<'ctx>,

View File

@ -21,7 +21,7 @@ pub(super) use blocks::{create_basic_blocks, precreate_phis};
pub(super) use flow::{emit_branch, emit_jump, emit_return};
pub(super) use externcall::lower_externcall;
pub(super) use newbox::lower_newbox;
pub(super) use boxcall::{lower_boxcall, lower_boxcall_boxed};
pub(super) use boxcall::{lower_boxcall, lower_boxcall_boxed, lower_boxcall_via_ctx};
pub(super) use arith::lower_compare;
pub(super) use mem::{lower_load, lower_store};
pub(super) use consts::lower_const;

View File

@ -50,6 +50,7 @@ fn lower_one_function<'ctx>(
func: &crate::mir::function::MirFunction,
name: &str,
box_type_ids: &HashMap<String, i64>,
llvm_funcs: &HashMap<String, FunctionValue<'ctx>>,
) -> Result<(), String> {
// Create basic blocks (prefix names with function label to avoid any ambiguity)
let fn_label = sanitize_symbol(name);
@ -226,7 +227,7 @@ fn lower_one_function<'ctx>(
callee,
args,
&build_const_str_map(func),
&std::collections::HashMap::new(),
llvm_funcs,
&bb_map,
&preds,
&block_end_values,
@ -579,7 +580,7 @@ impl LLVMCompiler {
// Lower all functions
for (name, func) in &mir_module.functions {
let llvm_func = *llvm_funcs.get(name).ok_or("predecl not found")?;
lower_one_function(&codegen, llvm_func, func, name, &box_type_ids)?;
lower_one_function(&codegen, llvm_func, func, name, &box_type_ids, &llvm_funcs)?;
}
// Build entry wrapper and emit object
@ -587,7 +588,7 @@ impl LLVMCompiler {
}
}
/* BEGIN_OLD_BLOCK
/*
MirInstruction::NewBox { dst, box_type, args } => {
instructions::lower_newbox(
&codegen,
@ -1127,7 +1128,8 @@ impl LLVMCompiler {
}
}
}
END_OLD_BLOCK */
Old duplicate lowering block removed
*/
#[cfg(test)]
mod tests {