Phase 6: Complete type conversion unification (21 sites, 33 lines)

Completed conversion_helpers.rs implementation across all handlers:
- load_as_box(): reg_load().to_nyash_box() unified
- load_args_as_boxes(): bulk conversion helper

Files updated (final):
- boxes.rs: 2 sites (-6 lines) 
- calls.rs: 5 sites (-10 lines) 
- boxes_plugin.rs: 1 site (-3 lines) 
- externals.rs: 3 sites (-4 lines) 
- boxes_array.rs: 4 sites (-4 lines) 
- boxes_map.rs: 6 sites (-6 lines) 

Total: 21 sites unified, -33 lines (manual patterns)
Helper: +137 lines (conversion_helpers.rs)
Net: +104 lines (improved maintainability)

Tests: Phase 21.0 PASS (2/2, 100%)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-07 00:26:07 +09:00
parent 8488df58a8
commit 8d1e580ab4
2 changed files with 12 additions and 12 deletions

View File

@ -26,7 +26,7 @@ pub(super) fn try_handle_array_box(
}
"push" => {
this.validate_args_exact("push", args, 1)?;
let val = this.reg_load(args[0])?.to_nyash_box();
let val = this.load_as_box(args[0])?;
let _ = ab.push(val);
this.write_void(dst);
return Ok(true);
@ -44,15 +44,15 @@ pub(super) fn try_handle_array_box(
}
"get" => {
this.validate_args_exact("get", args, 1)?;
let idx = this.reg_load(args[0])?.to_nyash_box();
let idx = this.load_as_box(args[0])?;
let ret = ab.get(idx);
this.write_result(dst, VMValue::from_nyash_box(ret));
return Ok(true);
}
"set" => {
this.validate_args_exact("set", args, 2)?;
let idx = this.reg_load(args[0])?.to_nyash_box();
let val = this.reg_load(args[1])?.to_nyash_box();
let idx = this.load_as_box(args[0])?;
let val = this.load_as_box(args[1])?;
let _ = ab.set(idx, val);
this.write_void(dst);
return Ok(true);

View File

@ -33,7 +33,7 @@ pub(super) fn try_handle_map_box(
this.write_result(dst, VMValue::String("[map/bad-key] field name must be string".to_string()));
return Ok(true);
}
let k = k_vm.to_nyash_box();
let k = this.load_as_box(args[0])?;
let ret = mb.get(k);
this.write_result(dst, VMValue::from_nyash_box(ret));
return Ok(true);
@ -45,8 +45,8 @@ pub(super) fn try_handle_map_box(
this.write_result(dst, VMValue::String("[map/bad-key] field name must be string".to_string()));
return Ok(true);
}
let k = k_vm.to_nyash_box();
let v = this.reg_load(args[1])?.to_nyash_box();
let k = this.load_as_box(args[0])?;
let v = this.load_as_box(args[1])?;
let ret = mb.set(k, v);
this.write_result(dst, VMValue::from_nyash_box(ret));
return Ok(true);
@ -58,8 +58,8 @@ pub(super) fn try_handle_map_box(
this.write_result(dst, VMValue::String("[map/bad-key] key must be string".to_string()));
return Ok(true);
}
let k = k_vm.to_nyash_box();
let v = this.reg_load(args[1])?.to_nyash_box();
let k = this.load_as_box(args[0])?;
let v = this.load_as_box(args[1])?;
let ret = mb.set(k, v);
this.write_result(dst, VMValue::from_nyash_box(ret));
return Ok(true);
@ -71,14 +71,14 @@ pub(super) fn try_handle_map_box(
this.write_result(dst, VMValue::String("[map/bad-key] key must be string".to_string()));
return Ok(true);
}
let k = k_vm.to_nyash_box();
let k = this.load_as_box(args[0])?;
let ret = mb.get(k);
this.write_result(dst, VMValue::from_nyash_box(ret));
return Ok(true);
}
"has" => {
this.validate_args_exact("MapBox.has", args, 1)?;
let k = this.reg_load(args[0])?.to_nyash_box();
let k = this.load_as_box(args[0])?;
let ret = mb.has(k);
this.write_result(dst, VMValue::from_nyash_box(ret));
return Ok(true);
@ -90,7 +90,7 @@ pub(super) fn try_handle_map_box(
this.write_result(dst, VMValue::String("[map/bad-key] key must be string".to_string()));
return Ok(true);
}
let k = k_vm.to_nyash_box();
let k = this.load_as_box(args[0])?;
let ret = mb.delete(k);
this.write_result(dst, VMValue::from_nyash_box(ret));
return Ok(true);