Skip to content

DONE.md

Satoshi Terasaki edited this page Jan 21, 2026 · 1 revision

実装済み一覧 (DONE)

最終更新: 2026-01-21 (Base exports alignment - Issue #1322)


Phase 0-2: 基盤・パーサ・Lowering (完了)

@goto/@label control flow macros ✅ (2026-01-21)

  • Issue #462 を解決: Julia の低レベル制御フロー構文を実装
  • @label name - @goto のジャンプ先を定義
  • @goto name - 指定した @label へ無条件ジャンプ
  • 機能:
    • 前方ジャンプ: @goto で後続の @label へジャンプ
    • 後方ジャンプ: @goto で前の @label へジャンプ (ループ構築可能)
    • 複数ラベル: 1つの関数内に複数の @label を定義可能
    • ネスト: for/if などの制御構造内で @goto 使用可能
  • 制限:
    • 関数境界をまたぐジャンプは不可
    • 未定義ラベルへの @goto はコンパイルエラー
  • 実装:
    • IR: subset_julia_vm/src/ir/core.rs - Stmt::LabelStmt::Goto バリアント追加
    • Lowering: subset_julia_vm/src/lowering/stmt/macros.rs - 組み込みコンパイラマクロとして実装
    • Compiler: subset_julia_vm/src/compile/mod.rs - ラベル位置追跡と goto パッチング
    • Compiler: subset_julia_vm/src/compile/stmt.rs - Stmt::LabelStmt::Goto のコンパイル
  • Tests: tests/fixtures/control_flow/goto_label_basic.jl

Base exports alignment ✅ (2026-01-21)

  • Issue #1322 を対応: Base export を upstream Julia に合わせて整理
  • 変更:
    • subset_julia_vm/src/julia/base/exports.jl の余剰 export を削除
    • fixture 側を Iterators / Base / Base.MathConstants に明示的に切替
    • Printf stdlib を追加し @printf / @sprintf を提供
    • 逸脱検知テスト追加: subset_julia_vm/tests/base_exports_consistency_tests.rs

Abstract interp: Const handling強化 ✅ (2026-01-21)

  • リテラル Const を tuple/array 推論と element_type に反映
  • 期待値を Const に合わせて compile::abstract_interp::engine テストを更新

nonmissingtype function ✅ (2026-01-21)

  • Issue #1316 を解決: Union 型から Missing を除去する関数を実装
  • 新規関数:
    • nonmissingtype(T::Type) - Union 型から Missing を除去して返す
      • nonmissingtype(Union{Int64, Missing})Int64
      • nonmissingtype(Union{String, Missing})String
      • nonmissingtype(Missing)Union{} (Bottom/空のUnion)
      • nonmissingtype(Int64)Int64 (Missing を含まない型はそのまま)
  • Implementation:
    • Builtins: subset_julia_vm/src/builtins.rs - NonMissingType
    • VM: subset_julia_vm/src/vm/builtins_types.rs - Union 型のフィルタリングロジック
    • Compiler: subset_julia_vm/src/compile/expr/builtin_types.rs - コンパイル時ディスパッチ
    • Exports: subset_julia_vm/src/julia/base/exports.jl - エクスポート追加
  • Tests: tests/fixtures/missing/nonmissingtype.jl

Subnormal float control functions ✅ (2026-01-21)

  • Issue #441 を解決: BigFloat・精度関連の残り関数を実装
  • 新規関数:
    • get_zero_subnormals() - サブノーマル (denormal) 浮動小数点数がゼロにフラッシュされるかを確認
      • SubsetJuliaVM では常に false を返す (IEEE 準拠でサブノーマル値を保持)
    • set_zero_subnormals(yes::Bool) - サブノーマルのゼロフラッシュを有効/無効化
      • yes=false の場合 true を返す (既に無効なので成功)
      • yes=true の場合 false を返す (ハードウェアがサポートしないため)
  • Note: SubsetJuliaVM は iOS App Store 制約 (JIT 禁止) のため、CPU のフラッシュ・ツー・ゼロモードを制御不可
  • Implementation:
    • Builtins: subset_julia_vm/src/builtins.rs - GetZeroSubnormals, SetZeroSubnormals
    • VM: subset_julia_vm/src/vm/builtins_numeric.rs - 実行ロジック
    • Compiler: subset_julia_vm/src/compile/expr/builtin_types.rs - コンパイル時ディスパッチ
    • Exports: subset_julia_vm/src/julia/base/exports.jl - エクスポート追加
  • Tests: tests/fixtures/floatfuncs/zero_subnormals.jl

isa() with primitive type identifiers ✅ (2026-01-19)

  • Issue #1267 を解決: isa(x, Float64) など primitive 型識別子を使った型チェックの動作確認
  • 問題の背景:
    • IOContext sprint 実装時に isa(x, Float64) が struct_ops エラーを起こすと思われていた
    • 調査の結果、VM では正常に動作していることが判明
    • io.jl のワークアラウンドコードを自然な Julia コードに置き換え
  • 修正内容:
    • _write_with_context() 関数を isa(x, Float64) に変更(以前は string(typeof(x)) == "Float64" だった)
  • Tests: tests/fixtures/io/isa_primitive_types.jl - 全 primitive 型に対する isa のテスト

BigFloat precision control functions ✅ (2026-01-19)

  • Issue #345 を解決: BigFloat の精度・丸めモード制御関数の追加
  • 精度制御関数:
    • precision(::Type{BigFloat}) - 新規 BigFloat のデフォルト精度を取得 (デフォルト: 256 bits)
    • precision(x::BigFloat) - 特定の BigFloat 値の精度を取得
    • setprecision(BigFloat, n) - 新規 BigFloat のデフォルト精度を設定
    • setprecision(n) - 便利形式 (setprecision(BigFloat, n) と同等)
  • 丸めモード制御関数:
    • rounding(::Type{BigFloat}) - 現在の丸めモードを取得 (RoundingMode 構造体を返す)
    • setrounding(::Type{BigFloat}, mode) - 丸めモードを設定
    • 対応モード: RoundNearest, RoundToZero, RoundUp, RoundDown, RoundFromZero
  • 実装:
    • Builtins: subset_julia_vm/src/builtins.rs - 5つの新しい builtin ID を追加
    • VM: subset_julia_vm/src/vm/value/mod.rs - AtomicUsize/AtomicU8 によるグローバル状態
    • Compiler: subset_julia_vm/src/compile/expr/builtin_types.rs - Builtin ディスパッチ
    • Pure Julia: subset_julia_vm/src/julia/base/bigint.jl - ラッパー関数
    • バグ修正: subset_julia_vm/src/compile/type_helpers.rs:187 - BigFloat→ValueType::BigFloat マッピングを修正
  • Tests: tests/fixtures/bigfloat/precision_basic.jl, setprecision.jl, rounding.jl

Literal syntax improvements ✅ (2026-01-19)

  • Issue #461 を解決: バージョン文字列とバイト文字列リテラルの追加
  • v"1.2.3" バージョン文字列リテラル:
    • VersionNumber(major, minor, patch) コンストラクタ呼び出しに変換
    • 部分バージョンをサポート: v"1.2" (patch=0), v"1" (minor=0, patch=0)
    • 例: v"1.2.3"VersionNumber(1, 2, 3)
  • b"data" バイト文字列リテラル:
    • 各文字を ASCII バイト値の配列に変換
    • 例: b"hello"[104, 101, 108, 108, 111]
  • 既存のリテラル: r"pattern" (正規表現), raw"..." (生文字列) は既に実装済み
  • Implementation: subset_julia_vm/src/lowering/expr/mod.rs
  • Tests: literals/test_version_literal.jl, literals/test_byte_string_literal.jl

Additional operators: nand/nor ✅ (2026-01-19)

  • Base の追加演算子を実装・利用可能に:
    • nand /
    • nor /
  • Tests: 既存の operator / integration テストでカバー

Logging macros (@debug/@info/@warn/@error) ✅ (2026-01-19)

  • 簡易版として利用可能(メッセージのみ。key=value 引数は未対応)

findmax!/findmin! in-place functions ✅ (2026-01-19)

  • Issue #434 を解決: findmax! と findmin! の追加
  • findmax!(rval, rind, arr) - 最大値を探して pre-allocated 配列に格納
  • findmin!(rval, rind, arr) - 最小値を探して pre-allocated 配列に格納
  • 戻り値: 結果格納後の (rval, rind) タプル
  • 1D 配列向けの簡略化実装(結果は先頭要素に格納)
  • Julia の base/reducedim.jl インターフェースに基づく
  • Implementation: subset_julia_vm/src/julia/base/reduce.jl
  • Tests: reduce/test_findmax_bang.jl, reduce/test_findmin_bang.jl

IOContext improvements ✅ (2026-01-19)

  • Issue #403 を解決: IOContext type for context-aware printing
  • iocontext() 関数の改善:
    • iocontext(io) - 空のプロパティで IOContext を作成
    • iocontext(io, :key => value, ...) - プロパティ付きで作成
    • iocontext(io, context) - 既存コンテキストからプロパティを継承
  • プロパティアクセス関数:
    • ioget(ctx, key, default) - プロパティ値を取得
    • iohaskey(ctx, key) - プロパティの存在確認
    • iokeys(ctx) - 全プロパティキーを取得
  • IO 委譲:
    • pipe_reader(ctx) / pipe_writer(ctx) - 基底 IO へのアクセス
  • 共通プロパティ: :compact, :limit, :color, :displaysize, :typeinfo
  • Note: SubsetJuliaVM では => は Tuple を生成し、get/haskey は Dict のビルトインとして インターセプトされるため、ioget/iohaskey を使用
  • Implementation: subset_julia_vm/src/julia/base/io.jl
  • Tests: 28 IO tests pass including IOContext tests

Regex Support ✅ (2026-01-18)

  • Issue #343 を解決: 正規表現サポートの追加
  • 新しい型 (subset_julia_vm/src/vm/value/regex.rs):
    • RegexValue: コンパイル済み正規表現 (Julia の Regex 型)
    • RegexMatchValue: マッチ結果 (Julia の RegexMatch 型)
  • r"..." リテラル構文:
    • Parser: 既存のマクロ文字列処理を使用
    • Lowering: Literal::Regex に変換 (lowering/expr/mod.rs)
    • Compiler: PushRegex 命令を生成
    • VM: Value::Regex として実行
  • フラグサポート: i (case-insensitive), m (multiline), s (dotall), x (extended)
  • 関数実装:
    • match(regex, string): 最初のマッチを返す (RegexMatch または nothing)
    • occursin(regex, string): マッチが存在するかを Bool で返す
    • eachmatch(regex, string): 全マッチを配列で返す
  • Rust の regex クレートを使用 (v1.10)
  • Fixture tests (subset_julia_vm/tests/fixtures/regex/):
    • regex_literal.jl: r"..." リテラル構文
    • occursin.jl: occursin 関数
    • match.jl: match 関数
    • eachmatch.jl: eachmatch 関数

SubArray and view function support ✅ (2026-01-18)

  • Issue #320 を解決: 配列ビューの作成 (@view/@views マクロ)
  • SubArray 構造体 (subset_julia_vm/src/julia/base/subarray.jl):
    • 親配列への参照、オフセット、長さを格納
    • 1D Float64 配列 (Vector{Float64}) をサポート
  • view(A, indices) 関数:
    • view(arr, 2:4) で要素 2, 3, 4 のビューを作成
    • 単一インデックスは要素を直接返す
  • SubArray インターフェースメソッド:
    • getindex(v, i) - ビューから要素を読み取り
    • setindex!(v, x, i) - ビューを通じて要素を書き込み (制限あり)
    • length(v), size(v), firstindex(v), lastindex(v)
    • collect(v), parent(v), parentindices(v)
  • @view および @views マクロ (簡略化実装)
  • テスト: 3件の新規 fixture tests

Bytecode Binary File Support for AoT ✅ (2026-01-17)

  • Issue #1140 を解決: バイトコードバイナリファイルの AoT コンパイルサポート
  • bytecode モジュール (subset_julia_vm/src/bytecode.rs):
    • .sjbc ファイル形式 (SubsetJuliaVM Bytecode)
    • Magic bytes: "SJBC" + バージョン + フラグ + IR データ
    • save() / load() - ファイルへの保存・読み込み
    • save_to_bytes() / load_from_bytes() - バイト配列への変換
  • CLI 拡張:
    • sjulia --compile input.jl -o output.sjbc - ソースからバイトコード生成
    • aot --bytecode program.sjbc -o output.rs - バイトコードから Rust 生成
  • AoT analyze 拡張 (subset_julia_vm/src/aot/analyze.rs):
    • load_bytecode_file() - ファイルから Program 読み込み
    • load_bytecode_bytes() - バイト配列から Program 読み込み
    • bytecode_file_to_aot_ir() - バイトコードから AoT IR への直接変換
  • テスト:
    • bytecode モジュールユニットテスト (5件)
    • bytecode_aot_tests.rs 統合テスト (8件)

Type Inference Engine v2 Infrastructure ✅ (2026-01-15)

  • Issue #850 を解決: 新しい型推論エンジンの統合と fixture tests の追加
  • infer_function_return_type_v2() 関数を追加:
    • subset_julia_vm/src/compile/inference.rs に実装
    • ラティスベースの型推論システムを使用
    • 既存の infer_function_return_type() を保持(後方互換性)
  • 新しい型システム:
    • LatticeType: Bottom, Concrete, Union, Conditional, Top
    • ConcreteType: 詳細な具体型表現
    • 型格子演算: join, meet, is_subtype_of
    • Union 型の簡約と拡大 (widening)
  • 抽象解釈エンジン (subset_julia_vm/src/compile/abstract_interp/):
    • engine.rs: 不動点反復による型推論
    • env.rs: 型環境管理
    • conditional.rs: 条件分岐での型絞り込み
    • loop_analysis.rs: ループ変数の型推論
    • struct_info.rs: 構造体型情報
  • 転送関数 (subset_julia_vm/src/compile/tfuncs/):
    • registry.rs: 転送関数レジストリ
    • arithmetic.rs: 算術演算の返り値型
    • array_ops.rs: 配列操作の返り値型
    • string_ops.rs: 文字列操作の返り値型
    • intrinsics.rs: Core.Intrinsics の返り値型
  • ブリッジモジュール (subset_julia_vm/src/compile/bridge.rs):
    • ValueTypeLatticeType の双方向変換
    • lattice_to_value_type() ヘルパー関数
  • Fixture tests (subset_julia_vm/tests/fixtures/type_inference/):
    • numeric_inference.jl: 数値型推論(合格)
    • loop_var_inference.jl: ループ変数型推論(合格)
    • conditional_narrowing.jl: 条件分岐での型絞り込み(スキップ - Issue #891)
    • union_types.jl: Union 型推論(スキップ - Issue #891)
    • manifest.toml: テスト定義
  • 全 637 テストが合格(既存 635 + 新規 2)

LinearAlgebra: eigen decomposition ✅ (2026-01-14)

  • eigen(A) を追加(固有値 values と固有ベクトル vectors を返す NamedTuple)
  • 対角化可能かつ実固有値の正方行列に対応
  • テスト: linalg_eigen_basic

Base.inv fallback and LinearAlgebra inv routing ✅ (2026-01-14)

  • Base.inv(x::Number)one(x) / x で追加
  • LinearAlgebra.inv(A::AbstractMatrix)Base.LinearAlgebra.inv にフォワード

Rational × Float64 mixed multiplication ✅ (2026-01-14)

  • *(Rational, Float64) / *(Float64, Rational) を追加

Base.LinearAlgebra.inv builtin routing ✅ (2026-01-14)

  • Base.LinearAlgebra.invBuiltinId::Inv へ接続

Base.inv module call dispatch ✅ (2026-01-14)

  • Base.inv(...)inv の通常ディスパッチに接続

Base.LinearAlgebra builtin routing ✅ (2026-01-14)

  • svd/qr/eigen/eigvals/cholesky/rank/cond/lu/detBuiltinId に接続

Base.LinearAlgebra ModuleCall inference ✅ (2026-01-14)

  • svd/qr/eigen/eigvals/cholesky/rank/cond/lu/det/inv の返り値型を推論

NamedTuple field access ✅ (2026-01-14)

  • GetFieldByName が NamedTuple を処理

NamedTuple index access ✅ (2026-01-14)

  • IndexLoad が NamedTuple の 1-based インデックスを処理

LinearAlgebra: Diagonal support ✅ (2026-01-14)

  • Issue #851 を解決: Diagonal 型の構築・インデックス・積をサポート
  • LinearAlgebra.jlDiagonal 型と size/getindex/* を追加
  • VM の size/length/getindex を構造体メソッドへディスパッチ
  • テスト: linalg_diagonal_basic, linalg_diagonal_simple

LinearAlgebra: Matrix multiplication ✅ (2026-01-14)

  • Base.:*(A::AbstractMatrix, B::AbstractMatrix) を Pure Julia 実装
  • LinearAlgebra.jl に行列積を追加
  • テスト: linalg_matmul_basic

Symbol default values fix for keyword arguments ✅ (2026-01-14)

  • Bug #830 を修正: キーワード引数のシンボルデフォルト値が Int64 に変換されていた問題
  • compile/mod.rs の以下の関数を修正:
    • eval_literal_default: Literal::SymbolValue::Symbol に変換
    • infer_default_type: Literal::SymbolValueType::Symbol に変換
  • テスト: function/test_symbol_kwarg_default.jl

@showtime, @allocated, @allocations macros ✅ (2026-01-14)

  • Issue #350 を解決: プロファイリングマクロを実装
  • @showtime ex - 式の実行時間を表示付きで計測(@time に似ているが式も表示)
  • @allocated ex - 式の実行で割り当てられたバイト数を返す(スタブ: 常に 0 を返す)
  • @allocations ex - 式の実行でのアロケーション回数を返す(スタブ: 常に 0 を返す)
  • テスト: macros/test_showtime.jl, macros/test_allocation_macros.jl

printstyled function implementation ✅ (2026-01-14)

  • Issue #381 を解決: ANSI カラー出力のための printstyled 関数を実装
  • util.jl に以下を追加:
    • ANSI カラーコード定数(16色 + reset/default)
    • printstyled(text, color) - カラー付きテキスト出力
    • printstyled(text, color, bold) - ボールド付きカラー出力
  • 対応色: :black, :red, :green, :yellow, :blue, :magenta, :cyan, :white + light_* バリアント、:normal, :default
  • テスト: io/test_printstyled.jl
  • exports.jl に printstyled を追加

String functions export ✅ (2026-01-14)

  • strings.jl の文字列操作関数を Base からエクスポート
  • エクスポートされた関数 (15種類):
    • chomp - 末尾の改行を削除
    • chop - 末尾の文字を削除
    • contains - 部分文字列の存在確認
    • endswith - 接尾辞のチェック
    • escape_string - 特殊文字をエスケープ
    • isalnum - 英数字判定
    • join - 文字列の結合
    • lowercasefirst - 先頭を小文字に
    • lstrip - 先頭の空白を削除
    • occursin - 部分文字列の出現確認
    • replace - 文字列置換
    • rstrip - 末尾の空白を削除
    • startswith - 接頭辞のチェック
    • strip - 両端の空白を削除
    • uppercasefirst - 先頭を大文字に
  • テスト: strings/test_string_exports.jl
  • Issue #497 を部分的に解決

Array functions export (popat!) ✅ (2026-01-14)

  • array.jl の配列操作関数を Base からエクスポート
  • エクスポートされた関数:
    • popat!(a, i) - インデックス i の要素を削除して返す
    • popat!(a, i, default) - 範囲外の場合は default を返す
  • テスト: arrays/popat_basic.jl, arrays/popat_with_default.jl
  • Note: fliplr, flipud were removed (not in upstream Julia Base - Issue #1322)

@something and @coalesce macros export ✅ (2026-01-14)

  • macros.jl の @something@coalesce マクロを Base からエクスポート
  • エクスポートされたマクロ:
    • @something(args...) - 最初の nothing でない値を返す(短絡評価)
    • @coalesce(args...) - 最初の missing でない値を返す(短絡評価)
  • テスト: missing/coalesce.jl
  • Issue #446 を部分的に解決
  • Note: nonmissingtype は Union 型イントロスペクションが必要なためブロック中

splitpath function implementation ✅ (2026-01-14)

  • path.jl に splitpath 関数を実装
  • パスを全てのコンポーネントに分割する機能
  • 例: splitpath("/home/user/file.txt")["/", "home", "user", "file.txt"]
  • VM の String 配列 setindex! 非対応のため、パスを2回走査するアルゴリズムで実装
  • Base からエクスポート
  • テスト: path/test_splitpath.jl
  • Issue #346 を部分的に解決

Identity operator aliases export (≡, ≢) ✅ (2026-01-14)

  • Unicode 同一性演算子エイリアスを Base からエクスポート
  • エクスポートされた演算子:
    • - === の Unicode エイリアス(オブジェクト同一性)
    • - !== の Unicode エイリアス(非同一性)
  • lowering で直接サポート(binary.rs で処理)
  • テスト: operators/unicode_identity.jl

@timev macro export ✅ (2026-01-14)

  • macros.jl の @timev マクロを Base からエクスポート
  • @timev - 詳細な実行時間情報を表示するタイミングマクロ
    • 実行時間(秒)とナノ秒単位の詳細時間を出力
  • 既存エクスポート済み: @time, @elapsed, @timed
  • テスト: macros/test_timev.jl
  • Issue #350 を部分的に解決

Exception types export ✅ (2026-01-14)

  • error.jl の例外型を Base からエクスポート
  • エクスポートされた例外型 (19種類):
    • ArgumentError, AssertionError, DivideError, DomainError
    • EOFError, ErrorException, InexactError, IOError
    • MethodError, OutOfMemoryError, OverflowError, ParseError
    • StackOverflowError, SystemError, TypeError
    • UndefKeywordError, UndefRefError, UndefVarError
  • 既存エクスポート済み: BoundsError, DimensionMismatch, Exception, InvalidStateException, KeyError, MissingException, StringIndexError
  • テスト: exceptions/test_exception_exports.jl
  • Issue #429 を部分的に解決

VersionNumber type and VERSION constant export ✅ (2026-01-14)

  • version.jl の型と定数を Base からエクスポート
  • エクスポートされた項目:
    • VersionNumber - セマンティックバージョニング型 (major, minor, patch)
    • VERSION - SubsetJuliaVM のバージョン定数
  • テスト: types/test_version.jl
  • Issue #340 を部分的に解決

nameof/nfields reflection functions export ✅ (2026-01-14)

  • reflection.jl のリフレクション関数を Base からエクスポート
  • エクスポートされた関数:
    • nameof - 型や関数の名前を Symbol として取得
    • nfields - 値のフィールド数を取得
  • テスト: types/test_nameof_nfields.jl
  • Issue #451 を部分的に解決

Path manipulation functions export ✅ (2026-01-14)

  • path.jl のパス操作関数を Base からエクスポート
  • エクスポートされた関数:
    • basename - ファイル名部分を取得
    • dirname - ディレクトリ部分を取得
    • isabspath - 絶対パスかどうかを判定
    • isdirpath - ディレクトリパスかどうかを判定
    • joinpath - パスコンポーネントを結合
    • splitdir - パスを(ディレクトリ, ファイル名)に分割
    • splitext - パスを(拡張子なしパス, 拡張子)に分割
  • テスト: path/basic.jl
  • Issue #346 を部分的に解決

Trait types (OrderStyle, ArithmeticStyle, RangeStepStyle) ✅ (2026-01-14)

  • Julia の base/traits.jl から数値トレイト型を実装
  • OrderStyle - 型の順序付け特性を表すトレイト:
    • abstract type OrderStyle end (基底型)
    • struct Ordered <: OrderStyle end (順序付け可能、例: Real, String)
    • struct Unordered <: OrderStyle end (順序なし、例: Complex)
  • ArithmeticStyle - 算術演算の特性を表すトレイト:
    • abstract type ArithmeticStyle end (基底型)
    • struct ArithmeticRounds <: ArithmeticStyle end (浮動小数点、丸め誤差あり)
    • struct ArithmeticWraps <: ArithmeticStyle end (整数、オーバーフローでラップ)
    • struct ArithmeticUnknown <: ArithmeticStyle end (未知の算術特性)
  • RangeStepStyle - Range のステップの規則性を表すトレイト:
    • abstract type RangeStepStyle end (基底型)
    • struct RangeStepRegular <: RangeStepStyle end (規則的なステップ、O(1) ハッシュ可能)
    • struct RangeStepIrregular <: RangeStepStyle end (不規則なステップ、浮動小数点用)
  • Base からエクスポート(exports.jl
  • テスト: types/test_traits.jl

Sorting algorithm types ✅ (2026-01-14)

  • abstract type Algorithm end を定義(ソートアルゴリズム選択用の基底型)
  • 4つのソートアルゴリズム型を実装:
    • InsertionSortAlg / InsertionSort (挿入ソート、安定、O(n²))
    • QuickSortAlg / QuickSort (クイックソート、不安定、O(n log n))
    • MergeSortAlg / MergeSort (マージソート、安定、O(n log n))
    • PartialQuickSort (部分クイックソート、k番目の要素を見つける)
  • Base からエクスポート(exports.jl
  • テスト: sort/test_algorithm_types.jl

IndexStyle abstract type and subtypes ✅ (2026-01-14)

  • abstract type IndexStyle end を定義
  • 配列の最適なインデックス方式を表すトレイト型
  • IndexLinear <: IndexStyle を追加(線形インデックス方式)
  • IndexCartesian <: IndexStyle を更新(既存の型を IndexStyle のサブタイプに)
  • Base からエクスポート(exports.jl
  • テスト: types/test_index_style.jl

RoundingMode type ✅ (2026-01-14)

  • struct RoundingMode を定義(mode::Symbol フィールド付き)
  • 浮動小数点演算の丸めモードを制御する型
  • 7つの標準丸めモード定数を定義:
    • RoundNearest (デフォルト: 最近接偶数丸め)
    • RoundToZero (trunc のエイリアス)
    • RoundUp (ceil のエイリアス)
    • RoundDown (floor のエイリアス)
    • RoundFromZero (ゼロから離れる方向)
    • RoundNearestTiesAway (C/C++ スタイル)
    • RoundNearestTiesUp (Java/JavaScript スタイル)
  • Base からエクスポート(exports.jl
  • テスト: types/test_rounding_mode.jl
  • Issue #428 を部分的に解決

InvalidStateException type ✅ (2026-01-14)

  • struct InvalidStateException <: Exception を定義(msg::Stringstate::Symbol フィールド付き)
  • オブジェクトが無効な状態にあるため操作を実行できない場合に使用
  • テスト: exceptions/test_exception_types.jl
  • Issue #429 を部分的に解決

MissingException type ✅ (2026-01-14)

  • struct MissingException <: Exception を定義(msg::AbstractString フィールド付き)
  • missing 値がサポートされていない状況で遭遇した場合に使用
  • テスト: exceptions/test_exception_types.jl
  • Issue #429 を部分的に解決

ENDIAN_BOM constant ✅ (2026-01-14)

  • ENDIAN_BOM 定数を追加(バイトオーダーマーク)
  • リトルエンディアン: 0x04030201、ビッグエンディアン: 0x01020304
  • #[cfg(target_endian = ...)] でコンパイル時に適切な値を選択
  • Base からエクスポート
  • テスト: io/test_endian_bom.jl
  • Issue #430 を部分的に解決

Inf32, NaN32, Inf64, NaN64 constants ✅ (2026-01-14)

  • Float32 の特殊値定数 Inf32, NaN32 を追加
  • Float64 の明示的な別名 Inf64, NaN64 を追加(Inf, NaN と同値)
  • コンパイル時に PushF32/PushF64 命令を生成
  • 型推論で適切な ValueType を返す
  • Base からエクスポート(exports.jl
  • テスト: floatprops/inf_nan_constants.jl
  • Issue #430 を部分的に解決

IOContext type ✅ (2026-01-12)

  • struct IOContext を定義(ioproperties フィールド付き)
  • IO ストリームに設定プロパティを付加するラッパー型
  • iocontext(io) で空のプロパティで作成
  • iocontext(io, :compact => true) で単一プロパティを設定
  • iocontext(io, :compact => true, :limit => true) で複数プロパティを設定
  • ioget(ctx, key, default) でプロパティ値を取得
  • iohaskey(ctx, key) でプロパティの存在を確認
  • 注意: VM の制限により IOContext() ではなく iocontext() を使用
  • テスト: io/test_iocontext.jl
  • Issue #528 を解決

Pair type ✅ (2026-01-12)

  • struct Pair を定義(firstsecond フィールド付き)
  • キーと値のペアを格納するコンテナ型
  • Pair(key, value) コンストラクタでペアを作成
  • テスト: collections/test_pair.jl
  • Issue #531 を解決

VersionNumber type and VERSION constant ✅ (2026-01-12)

  • struct VersionNumber を定義(major::Int64minor::Int64patch::Int64 フィールド付き)
  • セマンティックバージョニング (semver) 形式のバージョン番号を表現
  • 2引数コンストラクタ VersionNumber(major, minor) でパッチを0に設定
  • 1引数コンストラクタ VersionNumber(major) でマイナーとパッチを0に設定
  • VERSION 定数を SubsetJuliaVM のバージョン (0.5.1) として定義
  • テスト: reflection/version_constant.jl
  • Issue #532 を解決

ParseError exception type ✅ (2026-01-12)

  • struct ParseError <: Exception を定義(msg::AbstractStringdetail フィールド付き)
  • 文字列の構文エラーを報告する際に使用
  • デフォルトコンストラクタ ParseError(msg) も提供(detailnothing
  • テスト: exceptions/test_exception_types.jl
  • Issue #547 を解決

SystemError exception type ✅ (2026-01-12)

  • struct SystemError <: Exception を定義(prefix::AbstractStringerrnum::Int64 フィールド付き)
  • システムコールがエラーコードで失敗した場合に使用
  • テスト: exceptions/test_exception_types.jl
  • Issue #551 を解決

IOError exception type ✅ (2026-01-12)

  • struct IOError <: Exception を定義(msg::AbstractStringcode::Int64 フィールド付き)
  • I/O操作が失敗した場合に使用
  • テスト: exceptions/test_exception_types.jl
  • Issue #552 を解決

WrappedException abstract type ✅ (2026-01-12)

  • abstract type WrappedException <: Exception end を定義
  • 他の例外をラップする例外型の基底型
  • LoadError の親型として使用

LoadError exception type ✅ (2026-01-12)

  • struct LoadError <: WrappedException を定義(file::AbstractStringline::Int64error フィールド付き)
  • includerequireusing でファイル読み込み中にエラーが発生した場合に使用
  • テスト: exceptions/test_exception_types.jl
  • Issue #553 を解決

UndefVarError exception type ✅ (2026-01-12)

  • struct UndefVarError <: Exception を定義(var::Symbol フィールド付き)
  • 現在のスコープで変数が定義されていない場合に使用
  • テスト: exceptions/test_exception_types.jl
  • Issue #542 を解決

MethodError exception type ✅ (2026-01-12)

  • struct MethodError <: Exception を定義(fargs フィールド付き)
  • 必要な型シグネチャを持つメソッドが存在しない場合に使用
  • Julia 本家の world フィールドは省略した簡略版
  • テスト: exceptions/test_exception_types.jl
  • Issue #541 を解決

UndefKeywordError exception type ✅ (2026-01-12)

  • struct UndefKeywordError <: Exception を定義(var::Symbol フィールド付き)
  • 必須キーワード引数が割り当てられていない場合に使用
  • テスト: exceptions/test_exception_types.jl
  • Issue #543 を解決

EOFError exception type ✅ (2026-01-12)

  • struct EOFError <: Exception end を定義
  • ファイルやストリームからデータを読み取れなくなった場合に使用
  • テスト: exceptions/test_exception_types.jl
  • Issue #546 を解決

ArgumentError exception type ✅ (2026-01-12)

  • struct ArgumentError <: Exception を定義(msg::AbstractString フィールド付き)
  • 関数呼び出しのパラメータが有効なシグネチャと一致しない場合に使用
  • テスト: exceptions/test_exception_types.jl
  • Issue #535 を解決

ErrorException exception type ✅ (2026-01-12)

  • struct ErrorException <: Exception を定義(msg::AbstractString フィールド付き)
  • 汎用エラー型、error("msg") で使用
  • テスト: exceptions/test_exception_types.jl
  • Issue #534 を解決

TypeError exception type ✅ (2026-01-12)

  • struct TypeError <: Exception を定義(func::Symbol, context::AbstractString, expected::Type, got フィールド付き)
  • 型アサーション失敗時や組み込み関数の引数型エラー時に使用
  • テスト: exceptions/test_exception_types.jl
  • Issue #540 を解決

InexactError exception type ✅ (2026-01-12)

  • struct InexactError <: Exception を定義(func::Symbol, T, val フィールド付き)
  • 値を型に正確に変換できない場合に使用
  • テスト: exceptions/test_exception_types.jl
  • Issue #539 を解決

DomainError exception type ✅ (2026-01-12)

  • struct DomainError <: Exception を定義(valmsg::AbstractString フィールド付き)
  • 関数の引数が有効なドメイン外の場合に使用
  • デフォルトコンストラクタ DomainError(val) も提供
  • テスト: exceptions/test_exception_types.jl
  • Issue #538 を解決

DivideError exception type ✅ (2026-01-12)

  • struct DivideError <: Exception end を定義
  • 整数のゼロ除算時に使用可能
  • テスト: exceptions/test_exception_types.jl
  • Issue #537 を解決

AssertionError exception type ✅ (2026-01-12)

  • struct AssertionError <: Exception を定義(msg::AbstractString フィールド付き)
  • @assert マクロで参照される例外型
  • デフォルトコンストラクタ AssertionError() も提供
  • テスト: exceptions/test_exception_types.jl
  • Issue #536 を解決

UndefRefError exception type ✅ (2026-01-12)

  • struct UndefRefError <: Exception end を定義
  • 未定義のフィールドやアイテムへのアクセス時に使用可能
  • テスト: exceptions/test_exception_types.jl
  • Issue #545 を解決

OutOfMemoryError exception type ✅ (2026-01-12)

  • struct OutOfMemoryError <: Exception end を定義
  • メモリ不足時に使用可能
  • テスト: exceptions/test_exception_types.jl
  • Issue #549 を解決

StackOverflowError exception type ✅ (2026-01-12)

  • struct StackOverflowError <: Exception end を定義
  • 無限再帰によるスタックオーバーフロー時に使用可能
  • テスト: exceptions/test_exception_types.jl
  • Issue #550 を解決

OverflowError exception type ✅ (2026-01-12)

  • struct OverflowError <: Exception を定義
  • 整数演算のオーバーフロー時に使用可能
  • 例: OverflowError("21 is too large...")
  • テスト: exceptions/test_exception_types.jl
  • Issue #548 を解決

factorial(::BigInt) ✅ (2026-01-12)

  • factorial(n) を Int64 と BigInt の両方でサポート
  • Int64: n <= 20 のみ対応、n > 20 は OverflowError (Julia互換)
  • BigInt: 任意精度の階乗計算をサポート
  • factorial(big(50)) などの大きな値に対応
  • 新しい VmError::OverflowError 型を追加
  • テスト: combinatorics/factorial.jl
  • Issue #507 を解決

foldl/reduce with string arrays ✅ (2026-01-12)

  • foldl, reduce が文字列配列やその他の非数値配列に対応
  • 値ベースの reduce パスを追加 (start_reduce_call_values)
  • 初期値付き reduce (ReduceFuncWithInit) も非数値配列に対応
  • handle_hof_return_valueHofOpKind::Reduce ハンドラを追加
  • テスト: hof/test_foldl_strings.jl
  • Issue #409 を解決

gcd/lcm BigInt サポート ✅ (2026-01-12)

  • gcd(::BigInt, ::BigInt), lcm(::BigInt, ::BigInt) を Rust builtin として実装
  • gcd(BigInt(48), BigInt(18)), lcm(big(12), big(18)) が動作
  • BigInt と Int64 の混合演算: gcd(BigInt(48), 18), lcm(12, BigInt(18))
  • num-integer クレートの Integer::gcd/Integer::lcm を使用
  • Float64/Int64 混合型の modulo 演算をランタイムで処理
  • Float64 と Int64 の混合型比較演算を修正
  • テスト: comparison/gcd_lcm_bigint.jl
  • Issue #505 を解決

BigInt/Int64 比較演算 ✅ (2026-01-12)

  • big(2) < 3 などの BigInt と Int64 の混合比較演算をサポート
  • 対応演算子: ==, <, <=, >, >=
  • VM のランタイムディスパッチ (call_dynamic.rs) で BigInt 操作を処理
  • pop_bigint が I64/I128 を自動的に BigInt に昇格
  • テスト: comparison/bigint_comparison.jl
  • Issue #512, #522, #523, #524, #525, #526 を解決

プロジェクト管理

Base 未実装型/例外の Issue 分割 ✅ (2026-01-11)

  • Base 具象型/例外の未実装調査を Issue に分割(P0/P1)
  • P1 具象型: Issue #527#533
  • P0 例外型: Issue #534#553

Phase 0-2: 基盤・パーサ・Lowering (完了)

sprint(f, args...) with user-defined functions ✅ (2026-01-11)

  • sprint(f, args...) でユーザー定義関数 f(io, args...) を呼び出し、結果を文字列として返す
  • 新しい VM 命令: SprintFunc(usize, usize) - (func_index, arg_count)
  • 新しい VM 状態: SprintState - IOBuffer とフレーム深度を追跡
  • HOF スタイルの実装: 関数インデックスでユーザー定義関数を解決
  • handle_sprint_return - 関数リターン時に IOBuffer から文字列を抽出
  • テスト: io/sprint_function.jl, io/sprint_varargs.jl
  • Issue #379 を解決

グローバル定数 VERSION, ARGS, PROGRAM_FILE ✅ (2026-01-11)

  • VERSION - SubsetJuliaVM のバージョン文字列(Cargo.toml から取得)
  • ARGS - 空の文字列配列(コマンドライン引数)
  • PROGRAM_FILE - 空文字列(実行中スクリプトのパス)
  • コンパイル時に定数として解決(pi, Inf, NaN と同様の仕組み)
  • Julia との互換性: VERSION は String(Julia は VersionNumber)、ARGS/PROGRAM_FILE は互換
  • テスト: reflection/version_constant.jl, reflection/args_constant.jl, reflection/program_file_constant.jl
  • Issue #340 を部分的に解決

displaysize 関数 ✅ (2026-01-11)

  • displaysize() - ターミナルサイズを (rows, cols) タプルで返す
  • デフォルト値 (24, 80) を返す(SubsetJuliaVMはターミナル環境なしで動作するため)
  • Rust builtin として実装 (BuiltinId::Displaysize)
  • テスト: io/displaysize.jl
  • Issue #380 を解決

issetequal 関数 ✅ (2026-01-11)

  • issetequal(a, b) - 2つのコレクションが同じ要素を持つか(集合として)をチェック
  • Set同士、Array同士、Set-Array間の比較をサポート
  • Rust builtin として実装 (BuiltinId::SetIssetequal)
  • テスト: collections/issetequal.jl
  • Issue #351 の一部を解決

isperm/invperm 順列関数 ✅ (2026-01-11)

  • isperm(v) - 配列が有効な順列(1からnまでの各整数がちょうど1回ずつ出現)かチェック
  • invperm(v) - 逆順列を計算(p[i]=j なら invperm(p)[j]=i)
  • Pure Julia 実装(base/combinatorics.jl
  • テスト: combinatorics/isperm.jl, combinatorics/invperm.jl
  • Issue #353 の一部を解決

map! / filter! インプレース関数 ✅ (2026-01-11)

  • map!(f, dest, src) - インプレース map 操作
  • filter!(f, arr) - インプレース filter 操作
  • 新しい VM 命令: MapFuncInPlace, FilterFuncInPlace
  • 新しい HofOpKind: MapInPlace, FilterInPlace
  • Issue #351 を部分的に解決
  • テスト: hof/test_map_inplace.jl, hof/test_filter_inplace.jl

mapfoldl / mapfoldr 関数 ✅ (2026-01-11)

  • mapfoldl(f, op, arr) - 各要素に f を適用後、左結合で fold
  • mapfoldr(f, op, arr) - 各要素に f を適用後、右結合で fold
  • mapfoldlmapreduce のエイリアス(両方とも左結合)
  • mapfoldr は配列を反転し、引数順序を入れ替えて fold
  • 新規 VM 命令: MapFoldrFunc, MapFoldrFuncWithInit
  • 新規 HofOpKind: MapFoldr
  • テスト: collections/mapfoldl_mapfoldr.jl
  • Issue #351 の一部を解決

連鎖比較演算子の修正 ✅ (2026-01-11)

  • 1 <= 0 <= 5true を返すバグを修正 (Issue #368)
  • Julia では a < b < c(a < b) && (b < c) に展開される
  • Lowering 段階で連鎖比較を検出し、&& 演算子で結合された比較に展開
  • 新規関数: is_comparison_operator(), collect_chained_comparisons()
  • 対応演算子: <, >, <=, >=, ==, !=, ===, !==
  • 任意の長さの連鎖比較に対応(例: 1 <= 2 <= 3 <= 4
  • テスト: comparison/chained_comparison.jl

untyped struct field String アクセス修正 ✅ (2026-01-11)

  • 型指定なしの struct フィールドに String を格納した場合のコンパイルエラーを修正
  • 原因: compile_expr_as で Str -> Any の変換ケースが欠落していた
  • 修正: 12 種類の型から Any への変換ケースを追加
  • テスト: struct/untyped_string_field.jl
  • Issue #361 を解決

global compound assignment 構文サポート ✅ (2026-01-11)

  • global x += expr, global x -= expr, global x *= expr 等の構文をサポート
  • Parser: parse_var_declaration_item で compound assignment を認識
  • Lowering: lower_global_statement で compound assignment を適切に処理
  • テスト: scope/global_compound_assignment.jl, scope/global_compound_assignment_sub.jl, scope/global_compound_assignment_mul.jl
  • Issue #357 を解決

baremodule 構文サポート ✅ (2026-01-11)

  • baremodule Name ... end 構文を完全サポート
  • パーサー: BaremoduleDefinition ノードタイプ(既存)を VM で認識
  • IR: Module 構造体に is_bare: bool フラグを追加
  • Lowering: NodeKind::BaremoduleDefinitionis_bare=true でモジュール変換
  • 注: 現時点では module と同じセマンティクス(Base は自動インポート)
  • 将来の改善: is_bare=true 時に Base 自動インポートを抑制

REPL Expr Persistence ✅ (2026-01-11)

  • Expr, Symbol, QuoteNode, LineNumberNode 型の変数が REPL 評価間で正しく保持されるように修正
  • Literal enum に新バリアント追加: Symbol(String), Expr { head, args }, QuoteNode(Box<Literal>), LineNumberNode { line, file }
  • VM 命令追加: PushSymbol, CreateExpr, CreateQuoteNode, PushLineNumberNode
  • これにより Meta.parse で作成した式を後から eval できるようになった

マクロ多重ディスパッチ ✅ (2026-01-11)

  • 引数の数(arity)によるディスパッチ
  • AST型に基づくディスパッチ: ::Symbol, ::Expr, ::Int, ::Float64, ::String
  • 特異性順序: Symbol/Int/Float/String > Expr > Any
  • Julia仕様に完全準拠(AST型ベース、実行時型ではない)
  • テスト: dispatch_type.jl, dispatch_arity.jl, dispatch_specificity.jl, dispatch_int.jl, dispatch_literals.jl

@kwdef マクロ ✅ (2026-01-10)

  • 構造体にキーワード引数コンストラクタを自動生成
  • @kwdef struct Point; x::Float64 = 0.0; y::Float64 = 0.0; end
  • Point(), Point(x=1.0), Point(x=1.0, y=2.0) などの呼び出しをサポート
  • mutable struct もサポート
  • 必須フィールド (デフォルト値なし) をサポート - 未提供時は UndefKeywordError
  • 実装: Rust lowering でマクロ展開 (struct定義 + コンストラクタ関数を生成)
  • パーサー拡張: マクロ引数として struct 定義を受け入れ
  • テスト追加 (2026-01-19): kwdef/basic.jl, kwdef/required.jl, kwdef/mutable.jl

統一パーサーパイプライン ✅ 完了 (2025-12-30)

Pure Rust パーサー統一完了。tree-sitter-julia 依存を完全に削除。

Pure Rust パーサー(subset_julia_vm_parser)✅

  • WASM/Native 両対応の Pure Rust パーサー
  • C 依存なし、完全にポータブル
  • サポートする構文:
    • ::Type{T} パターン(匿名型パラメータ) ✅ 2025-12-30
    • where {T, S} 構文(複数型変数の where 節) ✅ 2025-12-30
    • Base.:- など修飾演算子名 ✅ 2025-12-30
    • マクロ定義・呼び出し ✅ 2025-12-30
    • アロー関数、相対インポート ✅ 2025-12-30
    • juxtaposition 式 (3.0im, 2x) ✅ 2025-12-30
    • 関数定義、構造体、パラメトリック型、制御フロー
  • パースエラー時は panic で停止(早期発見)
  • テスト結果: 373+ parser tests, 624 integration tests, 252 fixture tests

Lowering 層

  • CST → Core IR の変換層実装(expr.rs, stmt.rs, function.rs, struct_.rs)
  • UnsupportedFeature エラー設計(span + hint 付き)
  • LoweringWithInclude: include() 対応(ファイル読み込み、循環検出、相対パス解決)
  • IncludeContext: include 処理のコンテキスト管理

Core IR・コンパイラ

  • Core IR 定義(Block, If, While, For, Break, Continue, Return, Struct, Module)
  • すべてのノードに Span 情報を含む
  • IR → バイトコード変換コンパイラ
  • パラメトリック型のサポート
  • 型インスタンス化

コンパイラ/VM 安定性改善 ✅ (2026-01-01〜03)

  • 配列リテラルで有理数昇格が正しく行われるよう型推論でパラメトリック型を自動生成
  • peephole 最適化時に PushHandler の catch/finally 先を更新し try/catch が安定動作

Arrow 関数サポート ✅ (2026-01-01)

  • lower_binary_expr_with_ctx を新規作成(コンテキスト対応のバイナリ式 lowering)
  • パイプ演算子 |> 内の arrow function が動作
  • ラムダ関数のバイナリコンテキストでの適切な処理

Power 演算子の型推論改善 ✅ (2026-01-01)

  • BinaryOp::PowBinaryOp::Div から分離して個別に処理
  • Int^Int -> Int 型推論を実装
  • PowFloat intrinsic 選択を追加
  • HOF での power 操作の型推論を修正
  • 参照: POWER_OPERATOR_FIX_REPORT.md

HOF 型推論の修正 ✅ (2026-01-01〜04)

  • 配列要素のサブタイプに対する isa を改善
  • Rational の pow と HOF での struct 配列を処理
  • mixed numeric map で I64 配列型を保持
  • map(x -> x^2, [1,2,3]) がコンパイル時に Vector{Int64} 型を推論
    • get_function_return_type + ValueType::ArrayOf(elem_type) で実装(compile/expr/builtin.rs:711-717
  • filter は入力配列の要素型を保持
  • reduce は関数の戻り値型を返す

三項演算子の型推論 ✅ (2026-01-05 PR #124)

  • a ? b : c 式の型推論を追加
  • expr/infer.rsTernary パターンのマッチングを実装

モジュール定数サポート ✅ (2026-01-05 PR #123)

  • Dates モジュールの定数(DAYSINMONTH 等)が使用可能に
  • compile/mod.rs でモジュール定数の処理を実装

eval() ランタイム実装 ✅ (2026-01-06 PR #154, 2026-01-10 拡張)

  • eval(expr) - Expr オブジェクトをランタイムで評価
  • eval(Module, expr) - 指定モジュールスコープで評価 ✅ (2026-01-10)
    • ModuleValuenamespace_id フィールド追加
    • ModuleNamespace 構造体でシンボルテーブル管理
  • マクロ展開後のコード実行に必要な基盤機能

メタプログラミング機能強化 ✅ (2026-01-06〜10)

  • Symbol(str) 関数 - 文字列からシンボルを生成
  • @something マクロ - 最初の non-nothing 値を返す(マクロ版)
  • モジュール値のファーストクラスサポート
  • @gensym x y z マクロ - 複数のユニークシンボルを一度に生成 ✅ (2026-01-10)
  • @macroexpand @macro(args) - マクロ展開結果を Expr として返す ✅ (2026-01-10)
  • @macroexpand1 @macro(args) - マクロ1レベル展開結果を Expr として返す ✅ (2026-01-10)
  • QuoteNode(value) - 値を評価から保護するラッパー ✅ (2026-01-10)
  • qn.value - QuoteNode のラップされた値を取得 ✅ (2026-01-10)
  • Expr(:head, args...) - 完全な AST ノード構築 ✅ (確認済み)
  • @__LINE__ - 現在の行番号を返す ✅ (2026-01-10)
  • @__FILE__ - 現在のファイル名を返す ✅ (2026-01-10)
  • @__MODULE__ - 現在のモジュールを返す ✅ (2026-01-10)
  • getfield(x, idx) - 構造体フィールドを1-basedインデックスで取得 ✅ (2026-01-10)
  • isdefined(x, idx) - フィールドが定義されているか確認 ✅ (2026-01-10)
  • dump() 改善 - 汎用構造体、LineNumberNode、QuoteNode サポート ✅ (2026-01-10)
  • LineNumberNode(line) / LineNumberNode(line, file) - ソース位置情報の構築 ✅ (2026-01-10)
  • ln.line / ln.file - LineNumberNode のフィールドアクセス ✅ (2026-01-10)

引用演算子シンボル ✅ (2026-01-06 PR #158)

  • :+, :-, :* などの引用演算子シンボルをパース可能に

エラー設計

  • SyntaxError / UnsupportedFeature / RuntimeError の 3 系統エラー
  • IncludeError: FileNotFound, CircularInclude, ParseError, LowerError, IoError, NotSupported
  • span 付きエラー、ヒントメッセージ

Phase 4: エラー表示 (Rust 側完了)

C ABI 拡張

  • compile_and_run_detailed FFI 実装
  • CExecutionResult, CSpan, CErrorKind 構造体
  • free_execution_result メモリ解放
  • 詳細エラー情報(span + hint)の FFI 伝播

Swift 側

  • ErrorView コンポーネント実装済み
  • span 情報のハイライト実装済み
  • ContentView 統合済み
  • ✅ コード補完後のカーソル位置ジャンプを修正 (2025-12-30)
  • ✅ Debug ペインの出力表示を改善 (2025-12-30)

Phase 5: 対応構文の拡張 (完了)

制御フロー

  • if/elseif/else
  • forstart:end, start:step:end, イテラブル対応)
  • ForEach ループ: for c in "string", for x in array
  • for ループでのタプル分解: for (i, x) in pairs(arr), for (a, b) in tuples ✅ 2026-01-04 (PR #102)
  • while ... end
  • break, continue, return
  • try/catch/finally, try/catch e/finally, try/catch/else/finally
  • try/finally 内での return - finally ブロックを実行してから返す ✅ (2026-01-10)

関数

  • 通常定義: function f(x, y) ... end
  • ショート定義: f(x) = expr
  • ラムダ/アロー関数: x -> x^2, (x, y) -> x + y
  • 再帰呼び出し
  • キーワード引数: f(; x=1, y=2)
  • do 構文: map(arr) do x; x^2 end
  • Splat 演算子: f(args...) で配列/タプルを引数として展開 ✅ 2026-01-04 (PR #98)
  • 関数パラメータ Varargs: function f(args...), function f(a, b, rest...) ✅ 2026-01-06 (PR #135)

データ構造

  • 配列(1D/2D)、インデックス、スライス(arr[1:5], arr[:], mat[:, :], mat[1:2, :]
  • 線形インデックス: 多次元配列への A[i] アクセス(column-major 順序)✅ 2026-01-04
  • 配列内包表記(フィルタ付き)
  • zeros(), ones(), fill(), trues(), falses(), range(), similar()
  • vcat(), hcat(), vec() - 配列連結・変形 ✅ 2026-01-04
  • axes(), reshape() - 配列次元操作 ✅ 2026-01-04
  • findfirst(), findlast(), findall(), findnext(), findprev() ✅ 2026-01-04
  • fill!(), copyto!() - インプレース操作 ✅ 2026-01-04
  • CartesianIndex, CartesianIndices - 多次元インデックス操作 ✅ 2026-01-06 (PR #144)
  • LinearIndices - 線形インデックス範囲 ✅ 2026-01-06 (PR #145)
  • broadcast(f, A, B) - ユーザー定義関数のブロードキャスト ✅ 2026-01-06 (PR #146)
  • broadcast!(f, dest, A, B) - インプレースブロードキャスト ✅ 2026-01-06 (PR #148)
  • 構造体(struct, mutable struct
  • パラメトリック型: struct Point{T}
  • 抽象型: abstract type Animal end, struct Dog <: Mammal
  • 内部コンストラクタ: new(), new(args...) splat, 部分初期化
  • Tuple: (1, 2, 3), 分解代入: a, b = (1, 2)
  • NamedTuple: (x = 1, y = 2), nt.x
  • Dict: Dict("a" => 1), d["key"], d["key"] = v
  • Dict 内包表記: Dict(k => v for k in iter [if cond]) ✅ 2026-01-11
  • Set: Set([1, 2, 3]), Set 内包表記: Set(x for x in iter [if cond]) ✅ 2026-01-11
  • Range: 1:10, 1:2:10 を値として扱う
  • Generator(遅延評価)

Iterator Protocol ✅ 完了 (2026-01-04〜05 PR #107, #126)

  • iterate(collection), iterate(collection, state) - カスタム型対応
  • collect(iterable) - Pure Julia 実装、カスタムイテレータ対応 ✅ 2026-01-05 (PR #126)
  • IterateDynamic VM 命令 - Any 型のランタイム iterate ディスパッチ ✅ 2026-01-05 (PR #126)
  • 文字列・配列・タプル・レンジ対応
  • enumerate(collection) - インデックス付きイテレーション(Pure Julia: iteration.jl
  • zip(a, b, ...) - 並列イテレーション(Pure Julia: iteration.jl
  • take(xs, n) - 先頭 N 要素のみイテレート(Pure Julia: iteration.jl
  • drop(xs, n) - 先頭 N 要素スキップ(Pure Julia: iteration.jl
  • countfrom(), countfrom(start), countfrom(start, step) - 無限カウンタイテレータ(Pure Julia: iteration.jl)✅ 2026-01-13
  • カスタムイテレータ型のサポート
  • テスト: iteration_enumerate_basic, iteration_zip_basic, iteration_custom_iterator, iteration_take_basic, iteration_drop_basic, iterators_countfrom_*

演算

  • 二項演算: +, -, *, /, %, ^, //(有理数演算)
  • 比較: <, >, <=, >=, ==, !=
  • 論理: &&, ||(短絡評価)
  • 同一性・等価性: ===/ (egal), !==/, isequal (NaN/±0.0 対応)
  • サブタイプ式: <: (Int64 <: Number のような式評価)
  • ブロードキャスト: .+, .-, .*, ./, .^, .<, .>, .<=, .>=, .==, .!=, .&, .|, .!
  • ブロードキャスト代入: .+=, .-=, .*=, ./=, .=
  • 行列演算: A * B, transpose(), ' (adjoint)
  • 複素数配列ブロードキャスト: zs .+ zs, zs .* zs

その他構文

  • 文字列補間: "x = $(x)"
  • let 式: let a = 1; a + 1 end
  • 数学定数: pi, π
  • 暗黙の乗算: 2x2 * x
  • const 定数宣言
  • global キーワード
  • include("path.jl")(ネイティブ専用、iOS/WASM では無効)

モジュールシステム (完了)

基本機能

  • module Name ... end
  • using Module - モジュールの全 export をスコープに取り込む
  • import Module - モジュール名のみをスコープに取り込む
  • export func - モジュールから関数を公開
  • Module.func() - モジュール修飾呼び出し
  • import Module: func - 特定の関数のみインポート
  • using Module: func - 特定の関数のみ using

高度な機能

  • ネストモジュール: module A; module B; end; end
  • Base.func() - 組み込み関数への修飾アクセス
  • シャドウイング - ユーザー定義関数が組み込みを上書き可能
  • Module 型 - モジュールをファーストクラスの値として扱う
  • モジュール別名: S = Statistics; S.mean(...)

stdlib モジュール

  • Base, Core, Main
  • Statistics (mean, var, std, median, cov, cor, quantile)
  • Random (rand, randn)
  • Test

型システム (完了)

ランタイムディスパッチ ✅ 完了 (2025-12-30)

動的型に対する二項演算のランタイムディスパッチを実装。

  • CallDynamicBinaryBoth: 両オペランドが Any 型の場合
  • CallDynamicBinaryLeft: 左オペランドが Any 型の場合
  • CallDynamicBinaryRight: 右オペランドが Any 型の場合
  • パラメトリック構造体型の特異度計算を改善
  • (Struct, Any) 二項演算でランタイムディスパッチを優先

Bool 型処理 ✅ 完了 (2025-12-30)

Bool 型の正しい処理を実装。

  • 比較演算・論理演算の Bool 戻り値型を修正
  • HOF(map, filter 等)での Bool 処理を修正
  • 配列内包表記フィルタでの Bool 処理を修正
  • assert, ifelse での Bool 処理を修正
  • Bool 型の型推論を改善

Julia 型階層

  • Any, Number, Real, Integer, AbstractFloat
  • 具象型: Int64, Float64, Complex{T}, String, Char, Array, Module, Nothing
  • Union 型: Union{Int, Float64}, Union{} (Bottom)

型操作

  • typeof - 値の型を返す
  • isa - 型チェック(抽象型階層を走査)
  • convert - 基本的な型変換
  • promote - 型昇格
  • promote_type - 共通型を求める
  • promote_rule - 型昇格ルール定義(Julia 準拠、Union{} を返す)
  • サブタイプチェック (<: 演算子)
  • Union サブタイプ: Int <: Union{Int, Float64} → true
  • Multiple dispatch のための型特異度計算
  • 型パラメータ境界(UnionAll):
    • 上限: Array{<:Number}
    • 下限: Array{>:Int}
  • const による型エイリアス: const MyInt = Int64

DataType と Type{T}

  • 型自体もオブジェクト(DataType 型のインスタンス)
  • typeof(Int64)DataType
  • isconcretetype(T) - 具体型(インスタンス化可能な型)かどうか判定 ✅ 2026-01-07
  • supertype(T) - 親型を取得(Int64 → Signed → Integer → Real → Number → Any)✅ 2026-01-07
  • fieldcount(T) - 型のフィールド数を取得 ✅ 2026-01-07
  • hasfield(T, name) - 型が指定フィールドを持つか確認 ✅ 2026-01-07
  • Type{T} dispatch パターン: f(::Type{T}) where T で型オブジェクトを受け取る
  • promote_rule(::Type{Float64}, ::Type{Int64}) のような型ディスパッチ

組み込み関数 (完了)

数学関数

  • 三角関数: sin, cos, tan, asin, acos, atan
  • 双曲線関数: sinh, cosh, tanh, asinh, acosh, atanh
  • 指数対数: exp, exp2, exp10, expm1, log, log2, log10, log1p, sqrt, cbrt
  • 丸め: floor, ceil, round, trunc, abs
  • 浮動小数点: nextfloat, prevfloat (IEEE 754 隣接値)
  • 浮動小数点分解: exponent, significand, frexp (IEEE 754 ビット操作) ✅ 2026-01-07 (PR #190)
  • 浮動小数点検査: issubnormal, maxintfloat ✅ 2026-01-07 (PR #190)
  • Fused 演算: fma, muladd (融合積和演算) ✅ 2026-01-07 (PR #190)
  • ルート: fourthroot, , , ✅ 2026-01-07 (PR #188)
  • 近似比較: (isapprox), ✅ 2026-01-07 (PR #188)
  • その他: gcd, lcm, hypot, clamp

ビット操作関数 ✅ 2026-01-07 (PR #189, #190)

  • ビットカウント: count_ones, count_zeros, leading_ones, leading_zeros, trailing_ones, trailing_zeros
  • ビット操作: bitreverse, bitrotate, bswap

符号判定関数 ✅ 2026-01-07 (PR #190)

  • isnegative, ispositive (Pure Julia 実装)

配列関数

  • length, size, ndims, eltype
  • push!, pop!, pushfirst!, popfirst!
  • zeros, ones, fill, zero, trues, falses
  • range(start, stop; length=N) - 線形補間配列生成
  • repeat(arr, n), repeat(arr, m, n) - 配列繰り返し ✅ 2026-01-06
  • copy, deepcopy, similar

集計関数

  • sum, prod, minimum, maximum, mean
  • argmin, argmax

高階関数

  • map, filter, reduce, foreach
  • any, all, count
  • any(f, arr), all(f, arr), count(f, arr) - 関数付きバージョン
  • sum(f, arr) - 関数適用後の sum ✅ 2026-01-05 (PR #127)
  • ntuple(f, n) - 関数を n 回適用してタプルを生成(Rust builtin)

複素数

  • complex, real, imag, conj, abs, abs2, im
  • cis, cispi - 複素指数関数 ✅ 2026-01-06
  • reim - 複素数を (real, imag) タプルに分解 ✅ 2026-01-06

乱数

  • rand(), rand(n), rand(m, n), rand(Int, n)
  • randn(), randn(n)
  • 決定的 RNG(LehmerRNG、StableRNGs.jl 互換)

I/O

  • print, println
  • IOBuffer(), write(io, x), take!(io), takestring!(io) ✅ 2026-01-06 (PR #134)
  • sprint(x), sprint(f, x, ...) - 文字列への出力 ✅ 2026-01-06 (PR #134)
  • @sprintf(fmt, args...), @printf(fmt, args...) - フォーマット付き出力マクロ ✅ 2026-01-06 (PR #134)

型検査・リフレクション

  • typeof, isa
  • deepcopy, nfields, fieldnames
  • hash
  • methods(f) - 関数の全メソッドを取得 ✅ 2026-01-11 (Issue #303)
  • hasmethod(f, Tuple{...}) - メソッドの存在確認 ✅ 2026-01-11 (Issue #303)
  • which(f, Tuple{...}) - 特定シグネチャのメソッドを取得 ✅ 2026-01-11 (Issue #303)

例外

  • error, throw

Dict

  • haskey, get, keys, values, pairs, merge

Set ✅ 2026-01-11

  • union - 和集合: union(a, b)
  • intersect - 積集合: intersect(a, b)
  • setdiff - 差集合: setdiff(a, b)
  • symdiff - 対称差: symdiff(a, b)
  • issubset - 部分集合判定: issubset(a, b) (Set/Array 両対応)
  • push! - 要素追加: push!(set, x) (Set 対応)
  • delete! - 要素削除: delete!(set, x) (Set 対応)

時間

  • time_ns, sleep
  • time - 現在時刻を秒で取得 ✅ 2026-01-06

イテレーション

  • only - コレクションの単一要素を取得 ✅ 2026-01-06

ユーティリティ

  • something - 最初の non-nothing 値を返す ✅ 2026-01-06
  • identity - 引数をそのまま返す ✅ 2026-01-06

数学定数

  • - オイラー数 (2.718281828...) ✅ 2026-01-06

マクロ (完了)

組み込みマクロ

  • @time - 実行時間計測(Pure Julia 実装、変数永続化対応 ✅ PR #95)
  • @assert - アサーション
  • @show - デバッグ出力
  • @elapsed, @timed - 実行時間計測(簡易)
  • @eval, @deprecate - 簡易実装
  • @doc - no-op
  • @test, @testset, @test_throws - テストフレームワーク(using Test が必要)

ユーザー定義マクロ ✅ (2026-01-04)

  • macro name(args) ... end 構文
  • quote ... end ブロック(式としても使用可能)
  • 式の補間 ($expr)
  • esc() 関数(hygiene escape)
  • esc(quote ... end) パターン ✅
  • $(esc(expr)) - 変数永続化(REPL セッションで変数が保持される) ✅ PR #95
  • local キーワード in quote ブロック ✅
  • gensym() で変数名衝突回避(hygiene)✅
  • マルチステートメント quote ブロック
  • Base マクロの一部を簡易実装(@eval, @deprecate, @doc

@generated マクロ ✅ (2026-01-04〜05)

  • Phase 1: フォールバック実行
    • if @generated ... else fallback end パターンをサポート
    • @generatedfalse に置換し、else ブランチ(フォールバック)を実行
    • iOS App Store 制限(JIT 禁止)に準拠
    • テスト: generated_fallback_basic, generated_fallback_tuple, generated_fallback_where
  • Phase 2: Val{N} 静的特殊化
    • Val{N} 型パラメータから整数値 N を抽出
    • コンパイラ: val_type_params: HashSet<String> で Val{N} パターンを追跡
    • ランタイム: 型名 Val{5} から整数 5 を抽出し frame.locals_i64 に格納
    • LoadI64 命令で N を整数として読み込み、ループ等で使用可能
    • テスト: generated_val_basic, generated_val_loop
  • Phase 3: Quote アンクォート
    • シンプルな quoted expression を「アンクォート」して直接実行
    • try_unquote_generated_block 関数で quote 式を検出・変換
    • サポートパターン: :(expr) 単独、または var = :(expr) 代入形式
    • result = :(x^2)result = x^2 に変換して実行
    • テスト: generated_phase3_unquote(SubsetJuliaVM 固有)
  • 詳細設計: docs/vm/GENERATED_FUNCTION_PLAN.md

衛生システム (Hygiene) ✅ (2026-01-04)

  • HygieneContext による変数追跡
  • 2パスアルゴリズム: 変数収集 → リネーム適用
  • ローカル変数の自動 gensym リネーム
  • esc() 内の変数はリネームから除外
  • マクロのローカル変数がユーザー変数と衝突しない

Stdlib マクロ展開基盤 ✅ (確認: 2026-01-10)

  • 三層マクロレジストリ:
    • User-defined: LambdaContext.macros
    • Base: base_loader::BASE_MACROS
    • Stdlib: stdlib_loader::STDLIB_MACROS
  • Stdlib マクロの早期ロード:
    • using Module 時に ensure_stdlib_macros_loaded() が呼ばれる
    • Lowering フェーズでマクロが利用可能
  • マクロ検索チェーン: user → Base → stdlib の順で検索
  • Test モジュール:
    • @test, @testset マクロを Pure Julia で定義 (Test.jl)
    • using Test 後にマクロが利用可能
    • VM builtins: _test_record!, _testset_begin!, _testset_end!
  • テスト: macro/test_macro_basic.jl

メタプログラミング拡張 ✅ (2026-01-09 PR #229)

Meta モジュール

  • Meta.quot(ex) - 式を quote して Expr(:quote, ex) を生成
  • Meta.isexpr(ex, head) - 式のヘッドをチェック
  • Meta.isexpr(ex, head, n) - 式のヘッドと引数数をチェック
  • Meta.parse(str) - 文字列を式にパース
  • Meta.parse(str, start) - 指定位置からパース、(expr, next_pos) を返す

ランタイムスプラット補間

  • :(f($(args...))) - quote 内でのタプル展開(ランタイム)
  • 例: args = (:a, :b); :(f($(args...))):(f(a, b))
  • 空タプル、単一要素タプル、複数スプラットの混合をサポート
  • テスト: metaprogramming/runtime_splat.jl

タプルブロードキャスト

  • f.(tuple) - タプルへの関数ブロードキャスト
  • map(f, tuple) - タプルへの map 関数
  • 例: abs.((-1, -2, -3))(1.0, 2.0, 3.0)
  • テスト: broadcast/tuple_broadcast.jl, broadcast/tuple_broadcast_syntax.jl

可変長マクロ引数

  • macro f(p...) - マクロ定義での可変長引数
  • has_varargs フラグで実装

@evalpoly マクロの Pure Julia 化 ✅ (2026-01-09)

  • Rust 実装 (lowering/expr/mod.rs) を削除
  • Pure Julia 実装 (base/macros.jl) に移行
  • スプラット補間 $(p...) を使用した実装
  • テスト: operators/evalpoly_test.jl

@something マクロの Pure Julia 化 ✅ (2026-01-09)

  • Rust 実装 (lowering/expr/mod.rs) を削除
  • Pure Julia 実装 (base/macros.jl) に移行
  • something 関数への展開: @something(a, b, c)something(a, b, c)
  • テスト: macro/something_macro.jl

@assert マクロの Pure Julia 化 ✅ (2026-01-10)

  • Pure Julia 実装 (base/macros.jl) を追加
  • ヘルパー関数 _do_assert(condition, msg) を使用
  • カスタムメッセージ対応: @assert(cond, "msg")
  • 注: Rust lowering ハンドラ (lowering/stmt/macros.rs) が残っており、Rust 実装が優先される
  • 完全移行には macros.rs の該当 match 分岐削除が必要
  • テスト: macro/assert_pure_julia.jl

@show マクロの Pure Julia 化 ✅ (2026-01-10)

  • Pure Julia 実装 (base/macros.jl) を追加
  • ヘルパー関数 _do_show(expr_str, value) を使用
  • string(expr) で式を文字列化して表示
  • 注: Rust lowering ハンドラ (lowering/stmt/macros.rs) が残っており、Rust 実装が優先される
  • 完全移行には macros.rs の該当 match 分岐削除が必要
  • テスト: macro/show_pure_julia.jl

Quote の制限解消 ✅ (2026-01-09)

  • TernaryExpression のサポート: :(a ? b : c)Expr(:if, a, b, c)
  • IfStatement のサポート: quote if x ... end endExpr(:if, ...)
  • WhileStatement のサポート: quote while cond ... end endExpr(:while, cond, body)
  • ForStatement のサポート: quote for i in iter ... end endExpr(:for, :(i = iter), body)
  • ArrowFunctionExpression のサポート: :(x -> x + 1)Expr(:(->), :x, body)
  • elseif のサポート: quote if a; elseif b; else; end endExpr(:if, ..., Expr(:elseif, ...))
  • RangeExpression のサポート: :(1:10)Expr(:call, :(:), 1, 10)
  • CompoundAssignment のサポート: :(x -= 1)Expr(:-=, :x, 1)
  • :() 形式でのステートメント: :(while true break end), :(for x in xs x end) など
  • .head / .args フィールドアクセス: ex.head, ex.args[1] がサポート
  • cst_to_expr_constructor 関数で構文のハンドリングを追加
  • テスト: metaprogramming/quote_ternary.jl, metaprogramming/quote_if.jl, metaprogramming/quote_while.jl, metaprogramming/quote_for.jl, metaprogramming/quote_arrow.jl, metaprogramming/quote_elseif.jl

Symbol 比較演算子 ✅ (2026-01-09)

  • Symbol == Symbol の実行時比較をサポート
  • ex.args[1] == :+ などのメタプログラミングでの Symbol 比較が可能に
  • CallDynamicBinaryBoth 命令で Symbol-Symbol 比較を処理
  • テスト: metaprogramming/symbol_equality.jl

gensym の機能強化 ✅ (2026-01-09)

  • gensym(:tag) で Symbol 引数をサポート(既存の gensym("tag") に加えて)
  • マクロハイジーンで一意のシンボル名を生成
  • テスト: metaprogramming/gensym.jl

VM 実装 (完了)

スタックベース VM

  • 対応型: I64, F64, Str, Unit, Array, Complex, Struct, Tuple, NamedTuple, Dict, Range, Rng, Module
  • 制御フロー: Jump, JumpIfZero, Return

命令セット

  • 配列: ArrayNew, ArrayGet, ArraySet, ArrayPush, ArrayPop, ArrayLen
  • 行列: MatMul, Transpose, Adjoint
  • 構造体: NewStruct, GetField, SetField
  • 複素数配列: ComplexArrayNew, BroadcastComplexBinOp, BroadcastComplexUnaryOp
  • ブロードキャスト: BroadcastBinOp, BroadcastUnaryOp, BroadcastAssign (.=)
  • 数学関数: Sin, Cos, Tan, Asin, Acos, Atan, Exp, Log, Sqrt
  • Dict 操作: NewDict, DictGet, DictSet, DictHasKey
  • Set 操作: NewSet, SetAdd, StoreSet, LoadSet, ReturnSet ✅ 2026-01-11
  • ランタイムディスパッチ: CallDynamicBinaryBoth, CallDynamicBinaryLeft, CallDynamicBinaryRight
  • イテレータディスパッチ: IterateDynamic - Any 型のランタイム iterate ディスパッチ ✅ 2026-01-05 (PR #126)

最近の変更:

  • Abs 命令を削除(Builtin 関数に移行)
  • IterateDynamic 命令を追加 (2026-01-05 PR #126) - Any 型のランタイム iterate ディスパッチ
  • モジュール存在時のメインコードジャンプ修正 (2026-01-05 PR #125)
  • 12 個の融合命令を追加 (2026-01-01):
    • Load-Op fusion: LoadAddI64, LoadSubI64, LoadMulI64, LoadModI64
    • Store-Op fusion: IncVarI64, DecVarI64
    • Compare-Jump fusion: JumpIfNeI64, JumpIfEqI64, JumpIfLtI64, JumpIfGtI64, JumpIfLeI64, JumpIfGeI64

VM 命令プロファイラ ✅ (2026-01-01)

  • スレッドローカルプロファイリングシステム (src/vm/profiler.rs)
  • 命令実行頻度のトラッキング
  • Top 20 命令の出力とパーセンテージ分析
  • 無効時はオーバーヘッドなし(atomic bool チェックのみ)

Peephole オプティマイザ ✅ (2026-01-01, Base キャッシュ統合: 2026-01-04)

  • パターンマッチングベースの最適化 (src/compile/peephole.rs)
  • ジャンプターゲットの自動修正
  • 検出パターン:
    • LoadI64(x) + {Add,Sub,Mul,Mod}I64Load{Add,Sub,Mul,Mod}I64(x)
    • LoadI64(x) + AddI64 + StoreI64(x)IncVarI64(x)
    • {Ne,Eq,Lt,Gt,Le,Ge}I64 + JumpIfZero(addr)JumpIf{Eq,Ne,Ge,Le,Gt,Lt}I64(addr)
  • ✅ Base キャッシュとの完全統合 (PR #100):
    • optimize_with_protected_ranges で Base キャッシュ関数を保護しながら最適化
    • キャッシュされた関数の code_start/code_end/entry を最適化後に正しく更新

実行制御

  • 実行キャンセル機能(vm_request_cancel / vm_reset_cancel

FFI (完了)

C ABI エクスポート

  • compile_and_run(src, seed) - パース、コンパイル、実行
  • compile_and_run_with_output(src, seed) - 出力文字列を返す
  • compile_and_run_detailed(src, seed) - 詳細エラー情報付き実行
  • compile_to_ir(src) - JSON IR へパース
  • free_string(ptr) - Rust 割り当て文字列の解放
  • free_execution_result(result) - ExecutionResult 解放
  • vm_request_cancel / vm_reset_cancel - 実行キャンセル
  • run_ir_json_f_N_seed / run_ir_json_f64_N_seed - IR 直接実行

Bundle 機能 ✅ 完了 (2025-12-30)

  • スタンドアロン実行可能ファイル生成ツール
  • Julia ソースを内包した単一バイナリを生成
  • 使用方法: cargo run --bin bundle -- <source.jl> -o <output>

Pure Julia 実装 (進行中)

Base ローダーアーキテクチャ ✅ 完了

プリコンパイル JSON 機構を廃止し、起動時に Base Julia ソースをパースする方式に移行。

  • base_loader モジュール: 起動時に Base Julia ソースをパース(Pure Rust パーサー使用)
  • PRELUDE_PROGRAM: 起動時にプリロード
  • PackageLoader: stdlib モジュールの動的読み込み

実装済み

  • subset_julia_vm/src/julia/base/ - Base ライブラリ
    • array.jl: sum, prod, minimum, maximum, vcat, hcat, vec, axes, findfirst, findlast, findall, findnext, findprev, fill!, copyto! など ✅ 2026-01-04
    • strings.jl: lstrip, rstrip, strip, chomp, chop, lpad, rpad, chopprefix, chopsuffix, lowercasefirst, uppercasefirst, escape_string など ✅ 2026-01-07 (PR #193)
    • 文字列 Rust builtins: rsplit, bitstring, ascii, nextind, prevind ✅ 2026-01-07 (PR #194)
    • 文字列 Rust builtins: bytes2hex, hex2bytes, thisind, reverseind ✅ 2026-01-07 (PR #195)
    • 文字列 Rust builtins: unescape_string, isnumeric, isvalid ✅ 2026-01-07 (PR #196)
    • math.jl: gcd, lcm, hypot, clamp など
    • intfuncs.jl: factorial, isqrt, binomial, gcdx など
    • floatfuncs.jl: eps, floatmin, floatmax, typemin, typemax, isnan, isinf, isfinite, ldexp, modf, time, ℯ ✅ 2026-01-06
    • complex.jl: Complex 構造体と演算, cis, cispi, reim (Pure Julia) ✅ 2026-01-06
    • rational.jl: Rational 構造体と演算 (Pure Julia)
    • promotion.jl: promote_rule, promote_type, promote, convert (Pure Julia, Julia 準拠)
    • types.jl: 型定義とヘルパー
    • operators.jl: 演算子オーバーロード
    • iteration.jl: enumerate, zip, only など ✅ 2026-01-06
    • functional.jl: cumsum, cumprod, any, all, something, identity ✅ 2026-01-06
  • subset_julia_vm/src/julia/stdlib/ - 標準ライブラリ
    • Statistics/: mean, var, std, median, cov, cor, quantile
    • Random/: rand, randn

Rational Pure Julia 実装 ✅ 完了

Rational を Julia 準拠のパラメトリック型として実装済み。

実装済み:

  • struct Rational{T<:Integer} <: Real - Julia 準拠のパラメトリック型
  • ✅ 内部コンストラクタで正規化(gcd による約分、分母の正規化)
  • Rational(num, den) 外部コンストラクタ
  • numerator(x), denominator(x) アクセサ
  • ✅ 算術演算子 (+, -, *, /, ^)
  • ✅ 比較演算子 (==, <, <=, >, >=)
  • ✅ 整数との混合演算
  • ✅ 数学関数 (abs, sign, floor, ceil, round, inv)
  • gcd, lcm の Rational 版

参照: subset_julia_vm/src/julia/base/rational.jl

Complex Pure Julia リファクタリング ✅ 完了

Complex を Julia 準拠のパラメトリック型として実装済み。

実装済み:

  • struct Complex{T<:Real} <: Number - Julia 準拠のパラメトリック型
  • ✅ Complex リテラル (1.0 + 2.0im) → NewStruct 命令で生成
  • im 定数 (Complex{Bool}(false, true)) - Julia 準拠
    • lowering: src/lowering/expr.rs で正しく Complex{Bool} に変換
  • ✅ パラメトリック型サポート (Complex{Bool}, Complex{Int64}, Complex{Float64})
  • ✅ 型プロモーション規則 (promote_rule)
  • typeof(complex_val) が正しく Complex{T} を返す
  • ✅ 演算子オーバーロード (+, -, *, /, ^ 等)

既知の制限:

  • 未型付きパラメータ: function f(c, maxiter) のように未型付きパラメータで Complex を受け取る場合、z^2 + c のような演算でランタイムディスパッチが失敗する可能性がある
  • 回避策: パラメータに型注釈を付ける: function f(c::Complex, maxiter::Int64)
  • 2D ブロードキャスト: xs' .+ im .* ys のような式で Complex (StructRef) と配列のブロードキャストが未対応

参照: subset_julia_vm/src/julia/base/complex.jl


Union 型サポート ✅ 完了

Union 型 (Union{T1, T2, ...}) のサブタイプチェックが実装済み。

実装済み:

  • JuliaType::Union(Vec<JuliaType>) バリアント
  • is_subtype_of() での Union 型サブタイプチェック
    • T <: Union{T1, T2}T <: T1 || T <: T2
    • Union{T1, T2} <: UT1 <: U && T2 <: U
  • from_name() での Union{...} パース
  • Union{} (Bottom) のサポート
  • <: 演算子での Union 型チェック

例:

Int64 <: Union{Int64, Float64}        # => true
Float64 <: Union{Int64, Float64}     # => true
String <: Union{Int64, Float64}      # => false
Union{Int64, Float64} <: Number      # => true
Union{Int64, String} <: Any          # => true

参考: UNION_TYPE_PLAN.md - 実装計画(完了済み)


ファイル分割リファクタリング ✅ 完了

大規模ファイルを分割し、保守性を向上。

vm.rs の分割 ✅ 完了

src/vm.rs (5,452行) を以下の構造に分割:

src/vm/
├── mod.rs           # Vm struct、公開API
├── value.rs         # Value enum、ArrayValue、RangeValue等
├── instr.rs         # Instr enum (194命令)
├── error.rs         # VmError enum
├── frame.rs         # Frame、Handler、BroadcastState
├── exec.rs          # Vm::run() 実行ループ
├── util.rs          # ユーティリティ関数
├── matmul.rs        # 行列演算
├── broadcast.rs     # ブロードキャスト演算
├── type_ops.rs      # 型操作
├── builtins_exec.rs # Builtin 実行
├── intrinsics_exec.rs # Intrinsics 実行
└── hof_exec.rs      # 高階関数実行

compile_core.rs の分割 ✅ 完了

src/compile_core.rs (7,146行) を以下の構造に分割:

src/compile/
├── mod.rs      # compile_core_program、CoreCompiler struct
├── types.rs    # InstantiationKey、ParametricStructDef、CompileError
├── inference.rs # 型推論エンジン (infer_* 関数群)
├── context.rs  # SharedCompileContext
├── stmt.rs     # compile_stmt() と関連メソッド
└── expr.rs     # compile_expr()、compile_call() 等

参考: FILE_SPLIT_PLAN.md - 分割計画(完了済み)


Typed Array 実装 ✅ 完了 (Phase 1-4)

型付き配列システムの全フェーズが完了。

Phase 1: Complex 配列の効率化 ✅ (PR #132)

  • Complex 配列を interleaved 形式 [re1, im1, re2, im2, ...] で格納
  • キャッシュ効率の高いメモリレイアウト

Phase 2: Tuple 配列サポート ✅ (PR #134)

  • ArrayElementType::TupleOf(Vec<ArrayElementType>) バリアント追加
  • [(1, 2.0), (3, 4.0)] のようなタプル配列が動作
  • ヘルパーメソッド: is_tuple(), tuple_field_types(), tuple_arity()

Phase 3: 型情報の統合 ✅ (PR #136)

  • ArrayElementTypeto_value_type() / from_value_type() メソッド追加
  • 重複した型変換コードを統合

Phase 4: isbits 構造体のインライン AoS 格納 ✅ (PR #136)

  • ArrayElementType::StructInlineOf(type_id, field_count) バリアント追加
  • isbits 構造体(全フィールドが primitive)を AoS 形式でインライン格納
  • ヘルパーメソッド: is_isbits(), is_struct_inline(), struct_inline_info()
  • ストレージ形式: [f1_1, f2_1, f1_2, f2_2, ...](Point{x, y} の場合)

基盤:

  • ArrayData enum による型別ストレージ (src/vm/value.rs)
    • F32, F64, I8-I64, U8-U64, Bool, String, Char, StructRefs, Any
  • ArrayElementType enum による要素型の表現
  • ✅ 型付き配列の基本操作(作成、アクセス、設定、sum_as_f64 等)

参考: TYPED_ARRAY_PLAN.md - 実装計画(完了済み)


WebAssembly サポート (部分完了)

SubsetJuliaVM の WebAssembly 化が進行中。

完了済み:

  • subset_julia_vm_web/ クレート実装
  • run_ir_json() - Core IR JSON からの実行
  • run_ir_simple() - シンプルな数値結果返却
  • get_version() - バージョン取得
  • get_supported_features() / get_unsupported_features() - 機能一覧
  • ✅ Web Playground 基本 UI (web/)

未完了:

  • ⏳ GitHub Pages デプロイ設定

参考: WASM_PLAN.md - 実装計画


Mandelbrot サポート (完了)

Mandelbrot 集合の計算に必要な全機能が実装済み:

  • スカラー版 Mandelbrot - iOS サンプルに追加済み
  • ブロードキャスト版 Mandelbrot - 複素数配列演算で実現
  • range(start, stop; length=N) - 線形補間配列
  • 複素数配列ブロードキャスト(.+, .*, .^ 等)
  • ifelse.(), .&, .|, .! ブロードキャスト
  • .+=, .&= 複合代入

テスト基盤 ✅ 完了

テストフレームワーク

  • insta (version 1.41) - スナップショットテスト基盤 (Cargo.toml に追加済み)
  • criterion (version 0.5) - ベンチマークフレームワーク
  • benches/vm_benchmark.rs - VM ベンチマーク

テスト状況

  • cargo test --release624件 パス(integration_tests.rs)
  • unit / dispatch / integration / fixture 等
  • 複素数配列・多重ディスパッチの追加テスト済み
  • Fixture テスト: 238件36カテゴリ: abstract, arithmetic, array, arrays, broadcast, complex, control_flow, conversion, dates, floatprops, function, generated, getindex, io, iteration, linalg, macro, mixed, module, operators, promotion, pure_julia, rational, reflection, splat, strings, struct, ternary, timing, tuple, types, varargs, where)
    • 注: Dates モジュールテスト(14件)は manifest.toml でコメントアウト中(モジュール型修飾システムの修正待ち)
  • コードサンプルテスト: 64 サンプル動作確認済み
  • Mandelbrot テスト: 型付きパラメータで全パス

ベンチマーク結果 (2026-01-01, 更新: 2026-01-04)

  • Parse/Lower: 28-45% 改善
  • Compile: 14-52% 改善
  • VM 実行: Peephole オプティマイザ統合により最適化(PR #100 で Base キャッシュ統合完了)
  • 詳細: subset_julia_vm/docs/optimization/VM_OPTIMIZATION_STATUS.md

パイプライン状況

Pure Rust パーサー統一完了 (2025-12-30)

  • WASM/Native 両方で Pure Rust パーサー (subset_julia_vm_parser) を使用
  • tree-sitter-julia 依存を完全に削除
  • C 依存なし、すべてのプラットフォームで同一コード

実装済み関数一覧(参考)

Pure Julia 実装(202+ 関数)

  • 三角関数: sin, cos, tan, asin, acos, atan, sind, cosd, tand, asind, acosd, atand, sincos, sincosd, sincospi
  • 双曲線関数: sinh, cosh, tanh, asinh, acosh, atanh, sinc, cosc, sec, csc, cot, secd, cscd, cotd, sech, csch, coth, asec, acsc, acot, asecd, acscd, acotd
  • 指数/対数: exp, log, log2, log10, log1p, expm1, exp2, exp10, cbrt, hypot
  • 丸め: floor, ceil, trunc, round
  • 配列操作: length, size, eachindex, firstindex, lastindex, first, last, reverse, reverse!, fill, copy, circshift, rot180, rotl90, rotr90
  • リダクション: sum, prod, minimum, maximum, extrema, argmin, argmax, findmin, findmax, diff, cumsum, cumprod
  • 整数演算: abs, abs2, sign, signbit, copysign, flipsign, div, rem, mod, fld, fld1, divrem, fldmod, fldmod1, gcd, gcdx, lcm, powermod, isqrt, trailing_zeros
  • 判定関数: isnan, isinf, isfinite, isinteger, isreal, iseven, isodd, isone, iszero
  • Missing 値: ismissing, coalesce, skipmissingmissing は builtin)
  • 集合操作: unique, intersect, union, setdiff, symdiff, issubset
  • ソート: sort, sort!, issorted, partialsort, partialsort!, sortperm, searchsortedfirst, searchsortedlast, insorted
  • 比較: isless, isequal, isapprox, allequal, allunique
  • 組み合わせ: binomial, factorial

Rust Builtin 実装(125+ 関数)

  • 配列作成: zeros, ones, trues, falses, fill, similar, copy
  • 配列操作: push!, pop!, pushfirst!, popfirst!, insert!, deleteat!, append!, prepend!
  • 高階関数: map, filter, reduce, foreach, any, all, count
  • 文字列: string, repr, uppercase, lowercase, titlecase, strip, split, join, replace, repeat
  • 型変換: typeof, isa, convert, promote
  • 数値型: Int8Int128, UInt8UInt128, Float32, Float64, BigInt, BigFloat
  • Statistics: mean, var, std, median, quantile, cov, cor
  • 乱数: rand, randn
  • I/O: print, println, sprintf, IOBuffer, write, take!, takestring!

詳細は BUILTIN_FUNCTIONS.md を参照。


完了したアクション項目

1. Peephole オプティマイザの完全統合 ✅ 実装済み (PR #100)

  • optimize_with_protected_ranges で Base キャッシュ関数を保護しながら最適化を実行
  • キャッシュされた関数の code_start/code_end/entry を最適化後に正しく更新
  • 詳細: subset_julia_vm/docs/optimization/VM_OPTIMIZATION_STATUS.md

2. VM slot 化 (Phase 2) ✅ 実装済み

  • build_slot_info + slotize_code で HashMap → Vec 変換を実現
  • 全関数およびグローバルスコープに適用(常時有効)

3. 配列型の統一 ✅ Phase 1-4 完了 (PR #132, #136)

  • Phase 1 完了: Complex 配列の interleaved 格納
  • Phase 2 完了: Tuple 配列サポート(TupleOf バリアント追加)
  • Phase 3 完了: 型情報の統合(to_value_type(), from_value_type() メソッド追加)
  • Phase 4 完了: isbits 構造体のインライン AoS 格納(StructInlineOf バリアント追加)
  • 詳細: TYPED_ARRAY_PLAN.md

4. stdlib struct サポート ✅ 実装済み

  • Parser, Lowering, IR, Compiler 全レイヤーで struct/abstract type をサポート
  • Dates モジュール(725行)の完全な Julia 実装が存在
  • ✅ Dates テスト(14個)が全てパス

5. HOF の戻り値型推論(コンパイル時)✅ 実装済み

  • map(x -> x^2, [1,2,3])Vector{Int64} を返す
  • コンパイル時: get_function_return_type で関数戻り値型を取得し ValueType::ArrayOf(elem_type) を推論(compile/expr/builtin.rs:711-717
  • 実行時: 関数戻り値型を参照して配列バッファを正しい型で初期化(hof_exec.rs:23-37

6. Pure Julia 実装拡張 ✅ 実装済み

Builtin の Julia コードへの移行を完了。

  • 詳細計画: PURE_JULIA_MIGRATION_PLAN.md
  • Phase 1: 統計関数(9個) - Statistics.jl で Pure Julia 実装
  • Phase 2: 文字列操作(5個)
    • strip, lstrip, rstrip, chomp, chop は Pure Julia 実装に移行
    • コンパイラの型推論を改善し、変数インデックスの文字列スライスを正しく処理
  • Phase 3: 配列ユーティリティ - repeat(arr, n), repeat(arr, m, n)array.jl で実装済み
  • Phase 4: 浮動小数点プロパティ - eps, floatmin, floatmax, typemin, typemaxfloatfuncs.jl

7. enumerate / zip の実装 ✅ 実装済み (PR #107)

  • iterate プロトコルと共に Pure Julia で実装
  • iteration.jlEnumerate, Zip 構造体とイテレータを定義
  • テスト: iteration_enumerate_basic, iteration_zip_basic

8. collect() の Pure Julia 実装 ✅ 実装済み (PR #126)

  • IterateDynamic VM 命令を追加(ランタイム iterate ディスパッチ)
  • カスタムイテレータの collect() が動作
  • iteration.jl で実装

9. sum(f, arr) 高階関数サポート ✅ 実装済み (PR #127)

  • sum(x -> x^2, [1, 2, 3]) のような関数付き sum が動作
  • compile/expr/builtin.rs で2引数バージョンを処理

10. 戻り値型注釈 ✅ 完全実装 (Issue #318, #415)

  • f(x)::Int = x 形式の戻り値型注釈がパース可能
  • Function IR に return_type: Option<JuliaType> フィールドを追加
  • 型注釈はコンパイル時の型推論に使用される
  • 完了: convert() 呼び出しによる実行時型変換が有効化 (Issue #415)
    • f(x)::Int = x; f(1.0)convert(Int, 1.0) を適用して 1 を返す
    • 明示的な return 文と暗黙的な戻り値の両方で convert() が適用される

11. sprint 可変長引数対応 ✅ 実装済み (Issue #326)

  • sprint(f, args...) 形式で任意個数の引数をサポート
  • sprint(f, args...; context=nothing) のキーワード引数版も追加
  • 以前の 1-4 引数固定版から可変長引数版に移行
  • 制限: context 引数は現在無視される(IOContext 未実装)

12. 例外型の実装 ✅ 実装済み (Issue #342)

  • Julia Base の例外型を Pure Julia で実装
  • Exception 抽象型を追加
  • DimensionMismatch - 次元不一致例外(msg::AbstractString フィールド)
  • KeyError - キーエラー例外(key::String フィールド)
  • StringIndexError - 文字列インデックスエラー(string::AbstractString, index::Int フィールド)
  • 実装ファイル: subset_julia_vm/src/julia/base/error.jl
  • 制限: KeyError の key フィールドは String 型のみ(Any 型フィールドの問題により - Issue #361)

13. catch ブロックで例外フィールドアクセス ✅ 実装済み (Issue #362)

  • throw(DimensionMismatch("msg")) で投げた例外を catch e で捕捉し、e.msg でフィールドにアクセス可能
  • 新しい VM 命令:
    • ThrowValue: 構造体を保持したまま例外を throw
    • PushExceptionValue: 保持された例外値をスタックに push
  • VM に pending_exception_value フィールドを追加し、例外構造体を保持
  • catch 変数は Any 型として扱い、実行時に構造体フィールドアクセス
  • テスト: exceptions/test_exception_field_access.jl

Clone this wiki locally