Skip to content

WebAssembly を中間言語に採用した、32 ビット整数式の x64 JIT コンパイラ

License

Notifications You must be signed in to change notification settings

tenpoku1000/int_calc_compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

int_calc_compiler

WebAssembly を中間言語に採用した、32 ビット整数式の x64 JIT コンパイラです。C 言語で書かれていて、Visual Studio の標準 C ライブラリと Windows API に依存しています。

ファイルのダウンロード時の注意事項

コマンドプロンプトで以下のコマンドを投入し、ゾーン情報を削除します。

C:\>echo.>int_calc_compiler-master.zip:Zone.Identifier

開発環境

  • Visual Studio Community 2022

Windows SDK and developer tools - Windows app development
https://developer.microsoft.com/en-us/windows/downloads/

Visual Studio Older Downloads
https://visualstudio.microsoft.com/vs/older-downloads/

Download the Windows Driver Kit (WDK) - Windows drivers | Microsoft Docs
https://docs.microsoft.com/en-us/windows-hardware/drivers/download-the-wdk

コンパイル対象のソースコードの例と文法

文字コードは UTF-8 である必要があり、変数名に漢字や仮名も使えます。NUL 文字は、空白に置き換えてコンパイルされます。

Example:
int32_t value1 = (1 + 2) * 3;
int32_t value2 = 2 + (3 * value1);
value1 = value2 + 100;

Grammer:
Program -> Statement+
Statement -> Type? variable '=' Expression ';'
Expression -> Term (('+' | '-') Term)*
Term -> Factor (('*' | '/') Factor)*
Factor -> '(' Expression ')' | ('+' | '-')? (variable | constant)
Type -> int32_t

Note:
  (1) Nesting level of expression maximum 63.

bin フォルダのコマンドの実行方法

  • 実行用コマンド・ファイル(int_calc.cmd)を実行すると、ソースコード(source.txt)がコンパイルされ、x64 の機械語と WebAssembly の実行結果が出力されます。

screen shot

  • テスト実行用コマンド・ファイル(test_int_calc.cmd)を実行すると自動テストが実行され、スナップショット格納フォルダ(test_YYYY-MM-DD_nnn)にテスト結果が出力されます。
  • プログラム本体(int_calc_compiler.exe)を実行すると、コマンドライン引数の説明が表示されます。

bin フォルダに出力されるファイルの説明

  • int_calc_compiler.exe : 実行可能ファイル(プログラム本体)
  • source.txt : コンパイル対象のソースコード(拡張子は任意で、無くても問題ありません)
  • int_calc.wasm : WebAssembly バイナリ・ファイル
  • int_calc.bin : x64 機械語イメージ・ファイル
  • int_calc.cmd : 実行用コマンド・ファイル
  • int_calc.js : 実行用 Node.js ファイル
  • int_calc_log.log : 実行時のエラーなどが格納されている log ファイル
  • int_calc_token.log : 字句解析時のトークン列を記録したファイル
  • int_calc_parse_tree.log : 構文解析で得られた構文木を記録したファイル
  • int_calc_object_hash.log : 意味解析のハッシュ表に登録されている内容のファイル
  • test_int_calc.cmd : テスト実行用コマンド・ファイル
  • test_YYYY-MM-DD_nnn : テスト実行時のスナップショット格納フォルダ(nnn: 001 ~ 999)

テスト実行時のスナップショット格納フォルダには、テストケース毎に以下のファイルが出力されます。

  • int_calc.wasm : WebAssembly バイナリ・ファイル
  • int_calc.bin : x64 機械語イメージ・ファイル
  • int_calc_log.log : 実行時のエラーなどが格納されている log ファイル
  • int_calc_token.log : 字句解析時のトークン列を記録したファイル
  • int_calc_parse_tree.log : 構文解析で得られた構文木を記録したファイル
  • int_calc_object_hash.log : 意味解析のハッシュ表に登録されている内容のファイル

ビルド方法

  • int_calc_compiler.sln ファイルをダブルクリックします。
  • ゾーン情報を削除していない場合は、Visual Studio のセキュリティ警告を回避してプロジェクトを開きます。
    warning
  • F7 キーを押下します。

ビルド後に tools フォルダに存在するファイルが、bin フォルダにコピーされます。

ライセンス

MIT license

作者

市川 真一(Shin'ichi Ichikawa) [email protected]

About

WebAssembly を中間言語に採用した、32 ビット整数式の x64 JIT コンパイラ

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages