Files
hakorune/examples/test_python_compiler.c
Moe Charm c13d9c045e 📚 Phase 12: Nyashスクリプトプラグインシステム設計と埋め込みVM構想
## 主な成果
- Nyashスクリプトでプラグイン作成可能という革命的発見
- C ABI制約の分析と埋め込みVMによる解決策
- MIR/VM/JIT層での箱引数サポートの詳細分析

## ドキュメント作成
- Phase 12基本構想(README.md)
- Gemini/Codex先生の技術分析
- C ABIとの整合性問題と解決策
- 埋め込みVM実装ロードマップ
- 箱引数サポートの技術詳細

## 重要な洞察
- 制約は「リンク時にC ABI必要」のみ
- 埋め込みVMでMIRバイトコード実行により解決可能
- Nyashスクリプト→C ABIプラグイン変換が実現可能

Everything is Box → Everything is Plugin → Everything is Possible!
2025-08-30 22:52:16 +09:00

35 lines
1.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// PythonCompilerBox 簡易テスト
// 環境変数 NYASH_PY_IR からJSON IRを読み取ってNyashコードを生成
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// 超簡易的なコンパイラJSONパースなし
const char* compile_simple(const char* ir) {
// JSONをちゃんとパースせずに、簡単なパターンマッチング
if (strstr(ir, "\"name\":\"main\"") && strstr(ir, "\"return_value\":0")) {
return "// Generated from Python\n"
"static box Main {\n"
" main() {\n"
" return 0\n"
" }\n"
"}\n";
}
return "// Unsupported IR\n";
}
int main() {
const char* ir = getenv("NYASH_PY_IR");
if (!ir) {
ir = "{\"module\":{\"functions\":[{\"name\":\"main\",\"return_value\":0}]}}";
printf("Using default IR: %s\n\n", ir);
} else {
printf("Compiling IR from NYASH_PY_IR: %s\n\n", ir);
}
printf("=== Generated Nyash Code ===\n");
printf("%s", compile_simple(ir));
return 0;
}