feat: Phase 10.5 Python統合プラグインとAOTビルド対応

- Pythonプラグイン(PyRuntimeBox/PyObjectBox)を追加
  - eval, import, getattr, call, callKw, strメソッド実装
  - math.sqrtデモ等のサンプルコード追加
- AOTビルドサポート追加
  - libnyrtランタイムライブラリ
  - build_aot.shビルドスクリプト
- .gitignore改善
  - JSONLとDOTファイル除外
  - プラグインのビルド成果物除外
- 不要ファイル削除
  - nekocode-temp, zenn_articles
  - 一時的なログファイル類

Phase 10.1の新計画に基づいて、プラグインBox統一化を推進
This commit is contained in:
Moe Charm
2025-08-29 10:22:44 +09:00
parent 12adde9477
commit d24149d0a1
24 changed files with 1057 additions and 867 deletions

View File

@ -0,0 +1,16 @@
// Python plugin demo (Phase 10.5 scaffold)
// Requires: plugins/nyash-python-plugin built (release) and nyash.toml updated
// Run:
// NYASH_CLI_VERBOSE=1 ./target/release/nyash --backend vm examples/py_eval_demo.nyash
static box Main {
main() {
local py, obj
py = new PyRuntimeBox()
// Evaluate simple Python expression and print its string form
obj = py.eval("'hello' * 3")
me.console.log("py.eval.str=", obj.str())
return 0
}
}

View File

@ -0,0 +1,18 @@
// Python plugin demo: kwargs call via callKw
// Build plugin:
// (cd plugins/nyash-python-plugin && cargo build --release)
// Run (with auto-decode optional):
// NYASH_PY_AUTODECODE=1 NYASH_CLI_VERBOSE=1 ./target/release/nyash --backend vm examples/py_kw_round_demo.nyash
static box Main {
main() {
local py, bi, roundf, r
py = new PyRuntimeBox()
bi = py.import("builtins")
f = bi.getattr("int")
// int(x="FF", base=16) => 255
r = f.callKw("x", "FF", "base", 16)
me.console.log("int(x='FF', base=16)=", r.str())
return 0
}
}

View File

@ -0,0 +1,22 @@
// Python plugin demo: import math, getattr sqrt, call(9), str()
// Build plugin:
// (cd plugins/nyash-python-plugin && cargo build --release)
// Run:
// NYASH_CLI_VERBOSE=1 ./target/release/nyash --backend vm examples/py_math_sqrt_demo.nyash
static box Main {
init { console }
main() {
me.console = new ConsoleBox()
local py, m, f, r
py = new PyRuntimeBox()
m = py.import("math")
f = m.getattr("sqrt")
r = f.call(9)
print("sqrt(9) = " + r.str())
return 0
}
}