feat(plugins): ArrayBox/MapBoxプラグイン実装とPhase 10.1計画
🎯 革命的発見: プラグインC ABI = JIT→EXE変換の統一基盤 ## 主な変更点 - ArrayBoxプラグイン: get/set/push/size/is_empty実装 - MapBoxプラグイン: size/get/has実装(ROメソッドのみ) - Phase 10.1ドキュメント: プラグインBox統一化計画 - デモファイル3種: プラグイン動作確認用 ## 技術的詳細 - BID-FFI (Box ID Foreign Function Interface) 活用 - 既存のプラグインシステムでJIT/AOT統一可能 - スタティックリンクでオーバーヘッド解消 - "Everything is Box → Everything is Plugin → Everything is Executable" ## テスト済み - array_plugin_demo.nyash: 基本動作確認 ✅ - array_plugin_set_demo.nyash: set操作確認 ✅ - map_plugin_ro_demo.nyash: RO操作確認 ✅ 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
22
examples/array_plugin_demo.nyash
Normal file
22
examples/array_plugin_demo.nyash
Normal file
@ -0,0 +1,22 @@
|
||||
// ArrayBox plugin demo
|
||||
// Requires: plugins/nyash-array-plugin built (release) and nyash.toml updated
|
||||
// Run:
|
||||
// NYASH_CLI_VERBOSE=1 ./target/release/nyash --backend vm examples/array_plugin_demo.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
local a, i
|
||||
a = new ArrayBox()
|
||||
// push integers 1..5
|
||||
i = 1
|
||||
loop (i <= 5) {
|
||||
a.push(i)
|
||||
i = i + 1
|
||||
}
|
||||
me.console.log("len=", a.length())
|
||||
me.console.log("get(0)=", a.get(0))
|
||||
me.console.log("get(4)=", a.get(4))
|
||||
return a.length()
|
||||
}
|
||||
}
|
||||
|
||||
20
examples/array_plugin_set_demo.nyash
Normal file
20
examples/array_plugin_set_demo.nyash
Normal file
@ -0,0 +1,20 @@
|
||||
// ArrayBox plugin demo (set)
|
||||
// Build plugin:
|
||||
// (cd plugins/nyash-array-plugin && cargo build --release)
|
||||
// Run (plugin host auto-loads from nyash.toml):
|
||||
// NYASH_CLI_VERBOSE=1 ./target/release/nyash --backend vm examples/array_plugin_set_demo.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
local a
|
||||
a = new ArrayBox()
|
||||
a.push(10)
|
||||
a.push(20)
|
||||
a.push(30)
|
||||
me.console.log("before set, len=", a.length(), ", get(2)=", a.get(2))
|
||||
a.set(2, 42)
|
||||
me.console.log("after set, len=", a.length(), ", get(2)=", a.get(2))
|
||||
return a.get(2)
|
||||
}
|
||||
}
|
||||
|
||||
20
examples/map_plugin_ro_demo.nyash
Normal file
20
examples/map_plugin_ro_demo.nyash
Normal file
@ -0,0 +1,20 @@
|
||||
// MapBox plugin demo (RO via plugin: size/get/has), set is VM path.
|
||||
// Build plugins:
|
||||
// (cd plugins/nyash-map-plugin && cargo build --release)
|
||||
// Run:
|
||||
// NYASH_CLI_VERBOSE=1 ./target/release/nyash --backend vm examples/map_plugin_ro_demo.nyash
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
local m
|
||||
m = new MapBox()
|
||||
// mutating ops (VM path)
|
||||
m.set(1, 100)
|
||||
m.set(2, 200)
|
||||
me.console.log("size=", m.size())
|
||||
me.console.log("get(1)=", m.get(1))
|
||||
me.console.log("has(2)=", m.has(2))
|
||||
return m.get(2)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user