feat: 配列/Mapリテラル糖衣構文の実装とネームスペース解決の改善計画

- ArrayLiteral/MapLiteralのAST定義追加
- パーサーで[...]と{...}構文をサポート
- MIR Builderでnew Box() + push/setへのdesugaring実装
- テストケースとスモークスクリプト追加
- CURRENT_TASK.mdにネームスペース解決Phase-1計画を追記
- 3段階解決順序(ローカル→エイリアス→プラグイン)の設計合意
This commit is contained in:
Selfhosting Dev
2025-09-16 06:13:44 +09:00
parent 18bc386bc5
commit 6ca56b0652
27 changed files with 446 additions and 50 deletions

View File

@ -86,6 +86,12 @@ pub(crate) fn execute_file_with_backend(runner: &NyashRunner, filename: &str) {
}
runner.execute_mir_mode(filename);
}
"vm" => {
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {
println!("🚀 Nyash VM Backend - Executing file: {} 🚀", filename);
}
runner.execute_vm_mode(filename);
}
#[cfg(feature = "cranelift-jit")]
"jit-direct" => {
if std::env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") {

View File

@ -6,20 +6,8 @@
*/
use nyash_rust::cli::CliConfig;
use nyash_rust::{
box_trait::{StringBox, IntegerBox, BoolBox, VoidBox, AddBox},
tokenizer::{NyashTokenizer},
ast::ASTNode,
parser::NyashParser,
interpreter::NyashInterpreter,
mir::{MirCompiler, MirPrinter, MirInstruction},
backend::VM,
};
use nyash_rust::runtime::{NyashRuntime, NyashRuntimeBuilder};
use nyash_rust::interpreter::SharedState;
use nyash_rust::box_factory::user_defined::UserDefinedBoxFactory;
use nyash_rust::core::model::BoxDeclaration as CoreBoxDecl;
use std::sync::Arc;
// prune heavy unused imports here; modules import what they need locally
// pruned unused runtime imports in this module
#[cfg(feature = "wasm-backend")]
use nyash_rust::backend::{wasm::WasmBackend, aot::AotBackend};

View File

@ -183,7 +183,7 @@ impl NyashRunner {
// Prefer MIR signature when available, but fall back to runtime coercions to keep VM/JIT consistent.
let (ety, sval) = if let Some(func) = compile_result.module.functions.get("main") {
use nyash_rust::mir::MirType;
use nyash_rust::box_trait::{NyashBox, IntegerBox, BoolBox, StringBox};
use nyash_rust::box_trait::{IntegerBox, BoolBox, StringBox};
use nyash_rust::boxes::FloatBox;
match &func.signature.return_type {
MirType::Float => {
@ -272,7 +272,7 @@ impl NyashRunner {
format!("./{}", filename)
}
use std::collections::{HashSet, VecDeque};
use std::collections::HashSet;
fn walk_with_state(node: &ASTNode, runtime: &NyashRuntime, stack: &mut Vec<String>, visited: &mut HashSet<String>) {
match node {