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:
@ -1,108 +1,6 @@
|
||||
/*!
|
||||
* Nyash Interpreter - Modular Rust Implementation
|
||||
*
|
||||
* Refactored from massive 2,633-line interpreter.rs into logical modules
|
||||
* Everything is Box philosophy with clean separation of concerns
|
||||
*/
|
||||
#![cfg(feature = "interpreter-legacy")]
|
||||
// Shim module to re-export legacy interpreter from archive path
|
||||
#[path = "../archive/interpreter_legacy/mod.rs"]
|
||||
mod legacy_interpreter_mod;
|
||||
pub use legacy_interpreter_mod::*;
|
||||
|
||||
// Import all necessary dependencies
|
||||
use crate::ast::{ASTNode, CatchClause};
|
||||
use crate::box_trait::{BoolBox, BoxCore, ErrorBox, NyashBox, StringBox, VoidBox};
|
||||
use crate::boxes::debug_box::DebugBox;
|
||||
use crate::boxes::math_box::MathBox;
|
||||
use crate::boxes::random_box::RandomBox;
|
||||
use crate::boxes::time_box::TimerBox;
|
||||
use crate::boxes::FutureBox;
|
||||
use crate::channel_box::ChannelBox;
|
||||
use crate::instance_v2::InstanceBox;
|
||||
|
||||
// WASM-specific Box types (conditionally included)
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
use crate::boxes::web::{WebCanvasBox, WebConsoleBox, WebDisplayBox};
|
||||
use crate::exception_box;
|
||||
use std::collections::HashMap;
|
||||
|
||||
// Module declarations
|
||||
mod async_methods;
|
||||
mod box_methods;
|
||||
mod calls;
|
||||
mod core;
|
||||
pub mod errors;
|
||||
mod eval;
|
||||
mod expressions;
|
||||
mod functions;
|
||||
mod io;
|
||||
mod math_methods;
|
||||
mod methods;
|
||||
mod methods_dispatch;
|
||||
pub mod objects;
|
||||
mod objects_basic_constructors;
|
||||
mod special_methods;
|
||||
pub mod state;
|
||||
mod statements;
|
||||
mod system_methods;
|
||||
pub mod utils;
|
||||
mod web_methods;
|
||||
|
||||
// Main interpreter implementation - will be moved from interpreter.rs
|
||||
pub use core::NyashInterpreter;
|
||||
pub use errors::RuntimeError;
|
||||
pub use state::SharedState;
|
||||
|
||||
/// 実行制御フロー
|
||||
#[derive(Debug)]
|
||||
pub enum ControlFlow {
|
||||
None,
|
||||
Break,
|
||||
Continue,
|
||||
Return(Box<dyn NyashBox>),
|
||||
Throw(Box<dyn NyashBox>),
|
||||
}
|
||||
|
||||
/// コンストラクタ実行コンテキスト
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ConstructorContext {
|
||||
pub class_name: String,
|
||||
pub parent_class: Option<String>,
|
||||
}
|
||||
|
||||
// Re-export core model so existing interpreter modules keep working
|
||||
pub use crate::core::model::BoxDeclaration;
|
||||
|
||||
/// 🔥 Static Box定義を保持する構造体
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StaticBoxDefinition {
|
||||
pub name: String,
|
||||
pub fields: Vec<String>,
|
||||
pub methods: HashMap<String, ASTNode>,
|
||||
pub init_fields: Vec<String>,
|
||||
pub weak_fields: Vec<String>, // 🔗 weak修飾子が付いたフィールドのリスト
|
||||
pub static_init: Option<Vec<ASTNode>>, // static { } ブロック
|
||||
pub extends: Vec<String>, // 🚀 Multi-delegation: Changed from Option<String> to Vec<String>
|
||||
pub implements: Vec<String>,
|
||||
pub type_parameters: Vec<String>,
|
||||
/// 初期化状態
|
||||
pub initialization_state: StaticBoxState,
|
||||
}
|
||||
|
||||
/// 🔥 Static Box初期化状態
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum StaticBoxState {
|
||||
NotInitialized, // 未初期化
|
||||
Initializing, // 初期化中(循環参照検出用)
|
||||
Initialized, // 初期化完了
|
||||
}
|
||||
|
||||
/// 関数宣言を保持する構造体
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct FunctionDeclaration {
|
||||
pub name: String,
|
||||
pub params: Vec<String>,
|
||||
pub body: Vec<ASTNode>,
|
||||
}
|
||||
|
||||
// Re-export core interpreter types
|
||||
pub use core::*;
|
||||
|
||||
// Import and re-export stdlib for interpreter modules
|
||||
pub use crate::stdlib::BuiltinStdlib;
|
||||
|
||||
Reference in New Issue
Block a user