- Gemini先生のアドバイスに基づく実装計画策定 - C ABI + libloading による安定した動的ライブラリ実装 - 段階的移行戦略:インタープリターExternCall → プラグイン化 - FFI-ABI file実装(stdlib方式)完了 - MIRビルダーにfile.read/write/exists追加 - ビルド時間2分→15秒、バイナリ15MB→2MBを目標 - docs/予定/native-plan/issues/phase_9_75f_dynamic_library_architecture.md作成 - CURRENT_TASK.md更新 次のステップ: - インタープリターでExternCall直接実行実装 - 元のFileBox実装を探して置き換え - プラグインアーキテクチャ基盤構築
46 lines
1.3 KiB
Plaintext
46 lines
1.3 KiB
Plaintext
// FFI-ABI File I/O test
|
|
// 純粋FFI-ABI方式でのファイル操作デモ
|
|
|
|
using nyashstd
|
|
|
|
// テスト用のファイル名
|
|
local test_file = "test_output.txt"
|
|
|
|
// ファイルに書き込み
|
|
file.write(test_file, "Hello from Nyash FFI-ABI!\nThis is a test of file I/O.")
|
|
console.log("✅ File written: " + test_file)
|
|
|
|
// ファイルの存在確認
|
|
if file.exists(test_file) {
|
|
console.log("✅ File exists!")
|
|
|
|
// ファイルを読み込み
|
|
local content = file.read(test_file)
|
|
if content != null {
|
|
console.log("✅ File content:")
|
|
console.log(content)
|
|
|
|
// 内容を追記
|
|
file.write(test_file, content + "\nAdded line at: " + new StringBox("timestamp"))
|
|
console.log("✅ Content appended")
|
|
|
|
// 再度読み込み
|
|
local updated = file.read(test_file)
|
|
console.log("✅ Updated content:")
|
|
console.log(updated)
|
|
} else {
|
|
console.log("❌ Failed to read file")
|
|
}
|
|
} else {
|
|
console.log("❌ File does not exist")
|
|
}
|
|
|
|
// 存在しないファイルを読もうとする
|
|
local missing = file.read("non_existent_file.txt")
|
|
if missing == null {
|
|
console.log("✅ Non-existent file correctly returns null")
|
|
} else {
|
|
console.log("❌ Unexpected content from non-existent file")
|
|
}
|
|
|
|
console.log("\n🎉 FFI-ABI File I/O test complete!") |