📚 Phase 12.5 最適化戦略 & Phase 15 セルフホスティング計画
Phase 12.5: MIR15最適化戦略 - コンパイラ丸投げ作戦 - optimization-strategy.txt: 詳細戦略(MIR側は軽量、コンパイラに丸投げ) - implementation-examples.md: 具体的な実装例 - debug-safety-comparison.md: 現在のDebugBox vs ChatGPT5提案の比較分析 Phase 15: Nyashセルフホスティング - 究極の目標 - self-hosting-plan.txt: 内蔵Craneliftによる実現計画 - technical-details.md: CompilerBox設計とブートストラップ手順 - README.md: セルフホスティングのビジョン 重要な知見: - LLVM統合完了済み(Phase 11)だが依存が重すぎる - Craneliftが現実的な選択肢(3-5MB vs LLVM 50-100MB) - 「コンパイラもBox、すべてがBox」の夢へ MASTERロードマップ更新済み
This commit is contained in:
@ -153,17 +153,27 @@ impl NyashInterpreter {
|
||||
}
|
||||
|
||||
|
||||
/// await式を実行 - Execute await expression
|
||||
/// await式を実行 - Execute await expression (Result.Ok/Err統一)
|
||||
pub(super) fn execute_await(&mut self, expression: &ASTNode) -> Result<Box<dyn NyashBox>, RuntimeError> {
|
||||
let value = self.execute_expression(expression)?;
|
||||
|
||||
// FutureBoxなら待機して結果を取得
|
||||
if let Some(future) = value.as_any().downcast_ref::<FutureBox>() {
|
||||
future.wait_and_get()
|
||||
.map_err(|msg| RuntimeError::InvalidOperation { message: msg })
|
||||
let max_ms: u64 = std::env::var("NYASH_AWAIT_MAX_MS").ok().and_then(|s| s.parse().ok()).unwrap_or(5000);
|
||||
let start = std::time::Instant::now();
|
||||
let mut spins = 0usize;
|
||||
while !future.ready() {
|
||||
crate::runtime::global_hooks::safepoint_and_poll();
|
||||
std::thread::yield_now();
|
||||
spins += 1;
|
||||
if spins % 1024 == 0 { std::thread::sleep(std::time::Duration::from_millis(1)); }
|
||||
if start.elapsed() >= std::time::Duration::from_millis(max_ms) {
|
||||
let err = Box::new(crate::box_trait::StringBox::new("Timeout"));
|
||||
return Ok(Box::new(crate::boxes::result::NyashResultBox::new_err(err)));
|
||||
}
|
||||
}
|
||||
let v = future.get();
|
||||
Ok(Box::new(crate::boxes::result::NyashResultBox::new_ok(v)))
|
||||
} else {
|
||||
// FutureBoxでなければそのまま返す
|
||||
Ok(value)
|
||||
Ok(Box::new(crate::boxes::result::NyashResultBox::new_ok(value)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user