fix(llvm): Implement handle-based console.log functions for plugin return values
- Add nyash.console.log_handle(i64) -> i64 family functions to nyrt - Replace invalid int-to-pointer conversion with proper handle-based calls - Fix bool(i1) -> i64 type conversion in LLVM compiler - Resolve LLVM function verification errors - Enable plugin method execution without NYASH_LLVM_ALLOW_BY_NAME - Merge codex TLV fixes for plugin return value handling (2000+ lines) Technical Details: - Root cause: build_int_to_ptr(handle_value, i8*, "arg_i2p") treated handle IDs as memory addresses (invalid operation) - Solution: Direct i64 handle passing to nyrt functions with proper handle registry lookup and to_string_box() conversion - Type safety: Added proper i1/i32/i64 -> i64 conversion handling Status: Console.log type errors resolved, plugin return value display still under investigation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -2386,6 +2386,54 @@ pub extern "C" fn nyash_console_log_export(ptr: *const i8) -> i64 {
|
||||
0
|
||||
}
|
||||
|
||||
// Exported as: nyash.console.log_handle(i64 handle) -> i64
|
||||
#[export_name = "nyash.console.log_handle"]
|
||||
pub extern "C" fn nyash_console_log_handle(handle: i64) -> i64 {
|
||||
if handle <= 0 { return 0; }
|
||||
|
||||
if let Some(obj) = nyash_rust::jit::rt::handles::get(handle as u64) {
|
||||
let s = obj.to_string_box().value; // 既存の統一文字列変換メソッド
|
||||
println!("{}", s);
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
// Exported as: nyash.console.warn_handle(i64 handle) -> i64
|
||||
#[export_name = "nyash.console.warn_handle"]
|
||||
pub extern "C" fn nyash_console_warn_handle(handle: i64) -> i64 {
|
||||
if handle <= 0 { return 0; }
|
||||
|
||||
if let Some(obj) = nyash_rust::jit::rt::handles::get(handle as u64) {
|
||||
let s = obj.to_string_box().value;
|
||||
eprintln!("WARN: {}", s);
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
// Exported as: nyash.console.error_handle(i64 handle) -> i64
|
||||
#[export_name = "nyash.console.error_handle"]
|
||||
pub extern "C" fn nyash_console_error_handle(handle: i64) -> i64 {
|
||||
if handle <= 0 { return 0; }
|
||||
|
||||
if let Some(obj) = nyash_rust::jit::rt::handles::get(handle as u64) {
|
||||
let s = obj.to_string_box().value;
|
||||
eprintln!("ERROR: {}", s);
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
// Exported as: nyash.debug.trace_handle(i64 handle) -> i64
|
||||
#[export_name = "nyash.debug.trace_handle"]
|
||||
pub extern "C" fn nyash_debug_trace_handle(handle: i64) -> i64 {
|
||||
if handle <= 0 { return 0; }
|
||||
|
||||
if let Some(obj) = nyash_rust::jit::rt::handles::get(handle as u64) {
|
||||
let s = obj.to_string_box().value;
|
||||
eprintln!("TRACE: {}", s);
|
||||
}
|
||||
0
|
||||
}
|
||||
|
||||
// Exported as: nyash.console.warn(i8* cstr) -> i64
|
||||
#[export_name = "nyash.console.warn"]
|
||||
pub extern "C" fn nyash_console_warn_export(ptr: *const i8) -> i64 {
|
||||
|
||||
Reference in New Issue
Block a user