2025-08-30 07:47:21 +09:00
|
|
|
// Python math.sqrt demo via plugin (autodecode on)
|
|
|
|
|
// @env NYASH_PLUGIN_ONLY=1
|
|
|
|
|
// @env NYASH_PY_AUTODECODE=1
|
|
|
|
|
// @env NYASH_DEBUG_PLUGIN=1
|
|
|
|
|
// Build:
|
|
|
|
|
// cargo build --release && (cd plugins/nyash-python-plugin && cargo build --release)
|
2025-08-29 10:22:44 +09:00
|
|
|
// Run:
|
2025-08-30 07:47:21 +09:00
|
|
|
// ./target/release/nyash --backend vm examples/py_math_sqrt_demo.nyash
|
2025-08-29 10:22:44 +09:00
|
|
|
|
|
|
|
|
static box Main {
|
|
|
|
|
main() {
|
2025-08-30 07:47:21 +09:00
|
|
|
local py, math, sqrt, r
|
2025-08-29 10:22:44 +09:00
|
|
|
py = new PyRuntimeBox()
|
2025-08-30 07:47:21 +09:00
|
|
|
math = py.import("math")
|
|
|
|
|
sqrt = math.getattr("sqrt")
|
|
|
|
|
r = sqrt.call(9)
|
|
|
|
|
me.console.println(r) // expects 3.0
|
2025-08-29 10:22:44 +09:00
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|