stage3: unify to cleanup; MIR return-defer; docs+smokes updated; LLVM(harness): finalize_phis ownership, ret.py simplified, uses-predeclare; cleanup return override green; method-postfix cleanup return WIP (PHI head)

This commit is contained in:
Selfhosting Dev
2025-09-19 02:07:38 +09:00
parent 951a050592
commit 5e818eeb7e
205 changed files with 9671 additions and 1849 deletions

View File

@ -0,0 +1,40 @@
/*!
* Async Operations Module
*
* Extracted from expressions.rs lines 1020-1031 (~11 lines)
* Handles await expression processing for asynchronous operations
* Core philosophy: "Everything is Box" with async support
*/
use super::*;
use crate::boxes::result::NyashResultBox;
use crate::box_trait::StringBox;
impl NyashInterpreter {
/// await式を実行 - 非同期操作の結果を待機
pub(super) fn execute_await(&mut self, expression: &ASTNode) -> Result<Box<dyn NyashBox>, RuntimeError> {
let value = self.execute_expression(expression)?;
// FutureBoxなら協調待機して Result.Ok/Err を返す
if let Some(future) = value.as_any().downcast_ref::<FutureBox>() {
let max_ms: u64 = crate::config::env::await_max_ms();
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(StringBox::new("Timeout"));
return Ok(Box::new(NyashResultBox::new_err(err)));
}
}
let v = future.get();
Ok(Box::new(NyashResultBox::new_ok(v)))
} else {
// FutureBoxでなければ Ok(value) で返す
Ok(Box::new(NyashResultBox::new_ok(value)))
}
}
}