chore: Phase 25.1 完了 - LoopForm v2/Stage1 CLI/環境変数削減 + Phase 26-D からの変更
Phase 25.1 完了成果: - ✅ LoopForm v2 テスト・ドキュメント・コメント完備 - 4ケース(A/B/C/D)完全テストカバレッジ - 最小再現ケース作成(SSAバグ調査用) - SSOT文書作成(loopform_ssot.md) - 全ソースに [LoopForm] コメントタグ追加 - ✅ Stage-1 CLI デバッグ環境構築 - stage1_cli.hako 実装 - stage1_bridge.rs ブリッジ実装 - デバッグツール作成(stage1_debug.sh/stage1_minimal.sh) - アーキテクチャ改善提案文書 - ✅ 環境変数削減計画策定 - 25変数の完全調査・分類 - 6段階削減ロードマップ(25→5、80%削減) - 即時削除可能変数特定(NYASH_CONFIG/NYASH_DEBUG) Phase 26-D からの累積変更: - PHI実装改善(ExitPhiBuilder/HeaderPhiBuilder等) - MIRビルダーリファクタリング - 型伝播・最適化パス改善 - その他約300ファイルの累積変更 🎯 技術的成果: - SSAバグ根本原因特定(条件分岐内loop変数変更) - Region+next_iパターン適用完了(UsingCollectorBox等) - LoopFormパターン文書化・テスト化完了 - セルフホスティング基盤強化 Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: ChatGPT <noreply@openai.com> Co-Authored-By: Task Assistant <task@anthropic.com>
This commit is contained in:
@ -52,7 +52,7 @@ pub(super) fn invoke_plugin_box(
|
||||
}
|
||||
Err(e) => Err(this.err_with_context(
|
||||
&format!("BoxCall {}.{}", p.box_type, method),
|
||||
&format!("{:?}", e)
|
||||
&format!("{:?}", e),
|
||||
)),
|
||||
}
|
||||
} else if recv_box.type_name() == "StringBox" {
|
||||
@ -99,10 +99,7 @@ pub(super) fn invoke_plugin_box(
|
||||
if let Some(arg_id) = args.get(0) {
|
||||
let ch = this.reg_load(*arg_id)?.to_string();
|
||||
let c = ch.chars().next().unwrap_or('\0');
|
||||
let is_alpha =
|
||||
('A'..='Z').contains(&c) ||
|
||||
('a'..='z').contains(&c) ||
|
||||
c == '_';
|
||||
let is_alpha = ('A'..='Z').contains(&c) || ('a'..='z').contains(&c) || c == '_';
|
||||
this.write_result(dst, VMValue::Bool(is_alpha));
|
||||
Ok(())
|
||||
} else {
|
||||
@ -115,14 +112,21 @@ pub(super) fn invoke_plugin_box(
|
||||
// Special-case: minimal runtime fallback for common InstanceBox methods when
|
||||
// lowered functions are not available (dev robustness). Keeps behavior stable
|
||||
// without changing semantics in the normal path.
|
||||
if let Some(inst) = recv_box.as_any().downcast_ref::<crate::instance_v2::InstanceBox>() {
|
||||
if let Some(inst) = recv_box
|
||||
.as_any()
|
||||
.downcast_ref::<crate::instance_v2::InstanceBox>()
|
||||
{
|
||||
// Generic current() fallback: if object has integer 'position' and string 'text',
|
||||
// return one character at that position (or empty at EOF). This covers JsonScanner
|
||||
// and compatible scanners without relying on class name.
|
||||
if method == "current" && args.is_empty() {
|
||||
if let Some(crate::value::NyashValue::Integer(pos)) = inst.get_field_ng("position") {
|
||||
if let Some(crate::value::NyashValue::String(text)) = inst.get_field_ng("text") {
|
||||
let s = if pos < 0 || (pos as usize) >= text.len() { String::new() } else {
|
||||
if let Some(crate::value::NyashValue::Integer(pos)) = inst.get_field_ng("position")
|
||||
{
|
||||
if let Some(crate::value::NyashValue::String(text)) = inst.get_field_ng("text")
|
||||
{
|
||||
let s = if pos < 0 || (pos as usize) >= text.len() {
|
||||
String::new()
|
||||
} else {
|
||||
let bytes = text.as_bytes();
|
||||
let i = pos as usize;
|
||||
let j = (i + 1).min(bytes.len());
|
||||
@ -137,7 +141,11 @@ pub(super) fn invoke_plugin_box(
|
||||
// Generic toString fallback for any non-plugin box
|
||||
if method == "toString" {
|
||||
// Map VoidBox.toString → "null" for JSON-friendly semantics
|
||||
let s = if recv_box.as_any().downcast_ref::<crate::box_trait::VoidBox>().is_some() {
|
||||
let s = if recv_box
|
||||
.as_any()
|
||||
.downcast_ref::<crate::box_trait::VoidBox>()
|
||||
.is_some()
|
||||
{
|
||||
"null".to_string()
|
||||
} else {
|
||||
recv_box.to_string_box().value
|
||||
@ -148,7 +156,10 @@ pub(super) fn invoke_plugin_box(
|
||||
// Minimal runtime fallback for common InstanceBox.is_eof when lowered function is not present.
|
||||
// This avoids cross-class leaks and hard errors in union-like flows.
|
||||
if method == "is_eof" && args.is_empty() {
|
||||
if let Some(inst) = recv_box.as_any().downcast_ref::<crate::instance_v2::InstanceBox>() {
|
||||
if let Some(inst) = recv_box
|
||||
.as_any()
|
||||
.downcast_ref::<crate::instance_v2::InstanceBox>()
|
||||
{
|
||||
if inst.class_name == "JsonToken" {
|
||||
let is = match inst.get_field_ng("type") {
|
||||
Some(crate::value::NyashValue::String(ref s)) => s == "EOF",
|
||||
@ -158,8 +169,14 @@ pub(super) fn invoke_plugin_box(
|
||||
return Ok(());
|
||||
}
|
||||
if inst.class_name == "JsonScanner" {
|
||||
let pos = match inst.get_field_ng("position") { Some(crate::value::NyashValue::Integer(i)) => i, _ => 0 };
|
||||
let len = match inst.get_field_ng("length") { Some(crate::value::NyashValue::Integer(i)) => i, _ => 0 };
|
||||
let pos = match inst.get_field_ng("position") {
|
||||
Some(crate::value::NyashValue::Integer(i)) => i,
|
||||
_ => 0,
|
||||
};
|
||||
let len = match inst.get_field_ng("length") {
|
||||
Some(crate::value::NyashValue::Integer(i)) => i,
|
||||
_ => 0,
|
||||
};
|
||||
let is = pos >= len;
|
||||
this.write_result(dst, VMValue::Bool(is));
|
||||
return Ok(());
|
||||
@ -167,7 +184,10 @@ pub(super) fn invoke_plugin_box(
|
||||
}
|
||||
}
|
||||
// Dynamic fallback for user-defined InstanceBox: dispatch to lowered function "Class.method/Arity"
|
||||
if let Some(inst) = recv_box.as_any().downcast_ref::<crate::instance_v2::InstanceBox>() {
|
||||
if let Some(inst) = recv_box
|
||||
.as_any()
|
||||
.downcast_ref::<crate::instance_v2::InstanceBox>()
|
||||
{
|
||||
let class_name = inst.class_name.clone();
|
||||
let arity = args.len(); // function name arity excludes 'me'
|
||||
let fname = format!("{}.{}{}", class_name, method, format!("/{}", arity));
|
||||
@ -190,10 +210,10 @@ pub(super) fn invoke_plugin_box(
|
||||
this.write_string(dst, String::new());
|
||||
return Ok(());
|
||||
}
|
||||
// VoidBox graceful handling for common container-like methods
|
||||
// Treat null.receiver.* as safe no-ops that return null/0 where appropriate
|
||||
if recv_box.type_name() == "VoidBox" {
|
||||
match method {
|
||||
// VoidBox graceful handling for common container-like methods
|
||||
// Treat null.receiver.* as safe no-ops that return null/0 where appropriate
|
||||
if recv_box.type_name() == "VoidBox" {
|
||||
match method {
|
||||
"object_get" | "array_get" | "toString" => {
|
||||
this.write_void(dst);
|
||||
return Ok(());
|
||||
|
||||
Reference in New Issue
Block a user