CLI
CeruneのCLIはソースの検査、各中間表現による実行、コード生成に使用します。正確なオプションと制限は本体のCLIリファレンスを参照してください。
| コマンド | 用途 |
|---|---|
check |
構文・意味・型の検査。実行はしない |
run / run-ir |
Cerune IRを直接実行 |
run-mir |
MIRを独立に実行 |
run-vm |
Bytecodeに変換してVMで実行 |
--version |
バージョン表示 |
cerune check examples/hello.cerucerune run examples/hello.cerucerune run-vm examples/hello.cerurunはVM実行ではありません。 run-irはrunの別名です。checkに成功してもすべての生成経路で実行可能とは限りません。
中間表現とソースの出力
Section titled “中間表現とソースの出力”| コマンド | 出力 |
|---|---|
emit-sources |
依存ファイル名とソース本文のJSON一覧 |
emit-ir |
型・参照を解決したCerune IR |
emit-mir |
MIRの観測テキスト |
emit-lir |
Native LIRの観測テキスト(--target必須) |
emit-bytecode |
Bytecodeテキスト |
cerune emit-ir examples/hello.cerucerune emit-mir examples/hello.ceru -o hello.mir.txtcerune emit-sources examples/modules/main.ceru -o sources.jsonテキストを出すemit-*は通常stdoutへ出力し、-oで保存できます。emit-sourcesにはソース本文が含まれるため共有前に確認してください。生成したIRテキストはrunの入力形式ではありません。
| コマンド | 形式 |
|---|---|
emit-c |
C(.c) |
emit-llvm |
LLVM IR(.ll) |
emit-qbe |
QBE IR(.ssa) |
emit-wat |
WebAssembly Text(.wat) |
emit-asm |
x86-64アセンブリ(.s) |
emit-obj |
ネイティブオブジェクト(.o / .obj) |
cerune emit-c examples/hello.ceru -o hello.ccerune emit-llvm examples/hello.ceru --target x86_64-unknown-linux-gnu -o hello.ll生成はリンクや実行を行いません。 C、LLVM IR、QBE IR、アセンブリ、オブジェクトの実行には外部ツールが必要です。WATの実行には必要なhost関数を持つ環境が必要です。
LLVMとQBEの--targetは文字列、動的配列、標準出力、検査付き演算などで必要です。対象はx86_64-unknown-linux-gnuとx86_64-pc-windows-msvcです。emit-objでは--targetと-oが必須です。emit-asmのターゲット省略時はホストOSに関係なくWindows向けになります。
コンパイルの観測(observe)
Section titled “コンパイルの観測(observe)”observeは同一コンパイルのsources、HIR、MIR、注釈付きASM、manifestをまとめて保存します。
cerune observe examples/hello.ceru --target x86_64-unknown-linux-gnu -o target/hello-observe--targetと-oが必須です。出力先には存在しないディレクトリを指定し、親ディレクトリを先に作成してください。--ssa、--lirも選択できます。ソース本文が記録されますが、プログラム実行・外部ツール起動・リンクは行いません。
cerune run-vm examples/hello.ceru --diagnostic-format runtime-v1cerune run examples/dynamic_arrays/copy.ceru --array-heap-limit 1024--diagnostic-format runtime-v1は停止理由、NodeId、ソース位置を記録します。--string-heap-limit <bytes>と--array-heap-limit <bytes>は、それぞれ既定64 MiBの独立した予算です。プロセス全体のメモリ上限ではなく、checkとemit-sourcesには指定できません。
未対応のコマンドと関連情報
Section titled “未対応のコマンドと関連情報”統合されたbuild/release、run-lirは現行CLIにありません。