kumi 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -1
- data/.ruby-version +1 -0
- data/CHANGELOG.md +27 -0
- data/CLAUDE.md +26 -139
- data/README.md +143 -372
- data/data/functions/agg/boolean.yaml +14 -0
- data/data/functions/agg/numeric.yaml +80 -0
- data/data/functions/agg/string.yaml +8 -0
- data/data/functions/core/arithmetic.yaml +50 -0
- data/data/functions/core/boolean.yaml +18 -0
- data/data/functions/core/comparison.yaml +42 -0
- data/data/functions/core/constructor.yaml +32 -0
- data/data/functions/core/select.yaml +7 -0
- data/data/functions/core/stencil.yaml +21 -0
- data/data/functions/core/string.yaml +19 -0
- data/data/kernels/javascript/agg/boolean.yaml +12 -0
- data/data/kernels/javascript/agg/numeric.yaml +27 -0
- data/data/kernels/javascript/agg/string.yaml +5 -0
- data/data/kernels/javascript/core/arithmetic.yaml +32 -0
- data/data/kernels/javascript/core/boolean.yaml +12 -0
- data/data/kernels/javascript/core/comparison.yaml +24 -0
- data/data/kernels/javascript/core/constructor.yaml +15 -0
- data/data/kernels/javascript/core/select.yaml +7 -0
- data/data/kernels/javascript/core/string.yaml +12 -0
- data/data/kernels/ruby/agg/boolean.yaml +18 -0
- data/data/kernels/ruby/agg/numeric.yaml +29 -0
- data/data/kernels/ruby/agg/string.yaml +5 -0
- data/data/kernels/ruby/core/arithmetic.yaml +38 -0
- data/data/kernels/ruby/core/boolean.yaml +15 -0
- data/data/kernels/ruby/core/comparison.yaml +30 -0
- data/data/kernels/ruby/core/constructor.yaml +17 -0
- data/data/kernels/ruby/core/select.yaml +4 -0
- data/data/kernels/ruby/core/string.yaml +15 -0
- data/debug_ordering.rb +52 -0
- data/docs/FORM_SCHEMA.md +85 -0
- data/docs/OUTPUT_SCHEMA.md +69 -0
- data/docs/SYNTAX.md +626 -373
- data/golden/array_element/expected/ast.txt +21 -0
- data/golden/array_element/expected/input_plan.txt +5 -0
- data/golden/array_element/expected/lir_00_unoptimized.txt +13 -0
- data/golden/array_element/expected/lir_01_hoist_scalar_references.txt +13 -0
- data/golden/array_element/expected/lir_02_inlined.txt +13 -0
- data/golden/array_element/expected/lir_03_cse.txt +13 -0
- data/golden/array_element/expected/lir_04_1_loop_fusion.txt +13 -0
- data/golden/array_element/expected/lir_04_loop_invcm.txt +13 -0
- data/golden/array_element/expected/lir_06_const_prop.txt +13 -0
- data/golden/array_element/expected/nast.txt +7 -0
- data/golden/array_element/expected/schema_javascript.mjs +13 -0
- data/golden/array_element/expected/schema_ruby.rb +41 -0
- data/golden/array_element/expected/snast.txt +7 -0
- data/golden/array_element/expected.json +5 -0
- data/golden/array_element/input.json +9 -0
- data/golden/array_element/schema.kumi +11 -0
- data/golden/array_index/expected/ast.txt +59 -0
- data/golden/array_index/expected/input_plan.txt +5 -0
- data/golden/array_index/expected/lir_00_unoptimized.txt +41 -0
- data/golden/array_index/expected/lir_01_hoist_scalar_references.txt +41 -0
- data/golden/array_index/expected/lir_02_inlined.txt +42 -0
- data/golden/array_index/expected/lir_03_cse.txt +40 -0
- data/golden/array_index/expected/lir_04_1_loop_fusion.txt +40 -0
- data/golden/array_index/expected/lir_04_loop_invcm.txt +40 -0
- data/golden/array_index/expected/lir_06_const_prop.txt +40 -0
- data/golden/array_index/expected/nast.txt +33 -0
- data/golden/array_index/expected/schema_javascript.mjs +46 -0
- data/golden/array_index/expected/schema_ruby.rb +75 -0
- data/golden/array_index/expected/snast.txt +33 -0
- data/golden/array_index/expected.json +5 -0
- data/golden/array_index/input.json +1 -0
- data/golden/array_index/schema.kumi +19 -0
- data/golden/array_operations/expected/ast.txt +50 -0
- data/golden/array_operations/expected/input_plan.txt +10 -0
- data/golden/array_operations/expected/lir_00_unoptimized.txt +47 -0
- data/golden/array_operations/expected/lir_01_hoist_scalar_references.txt +47 -0
- data/golden/array_operations/expected/lir_02_inlined.txt +47 -0
- data/golden/array_operations/expected/lir_03_cse.txt +47 -0
- data/golden/array_operations/expected/lir_04_1_loop_fusion.txt +47 -0
- data/golden/array_operations/expected/lir_04_loop_invcm.txt +47 -0
- data/golden/array_operations/expected/lir_06_const_prop.txt +47 -0
- data/golden/array_operations/expected/nast.txt +32 -0
- data/golden/array_operations/expected/schema_javascript.mjs +60 -0
- data/golden/array_operations/expected/schema_ruby.rb +91 -0
- data/golden/array_operations/expected/snast.txt +32 -0
- data/golden/array_operations/expected.json +27 -0
- data/golden/array_operations/input.json +8 -0
- data/golden/array_operations/schema.kumi +12 -10
- data/golden/cascade_logic/expected/ast.txt +37 -0
- data/golden/cascade_logic/expected/input_plan.txt +2 -0
- data/golden/cascade_logic/expected/lir_00_unoptimized.txt +29 -0
- data/golden/cascade_logic/expected/lir_01_hoist_scalar_references.txt +29 -0
- data/golden/cascade_logic/expected/lir_02_inlined.txt +37 -0
- data/golden/cascade_logic/expected/lir_03_cse.txt +30 -0
- data/golden/cascade_logic/expected/lir_04_1_loop_fusion.txt +30 -0
- data/golden/cascade_logic/expected/lir_04_loop_invcm.txt +30 -0
- data/golden/cascade_logic/expected/lir_06_const_prop.txt +30 -0
- data/golden/cascade_logic/expected/nast.txt +32 -0
- data/golden/cascade_logic/expected/schema_javascript.mjs +31 -0
- data/golden/cascade_logic/expected/schema_ruby.rb +57 -0
- data/golden/cascade_logic/expected/snast.txt +32 -0
- data/golden/cascade_logic/expected.json +5 -0
- data/golden/cascade_logic/input.json +4 -0
- data/golden/cascade_logic/schema.kumi +1 -3
- data/golden/chained_fusion/expected/ast.txt +57 -0
- data/golden/chained_fusion/expected/input_plan.txt +13 -0
- data/golden/chained_fusion/expected/lir_00_unoptimized.txt +76 -0
- data/golden/chained_fusion/expected/lir_01_hoist_scalar_references.txt +76 -0
- data/golden/chained_fusion/expected/lir_02_inlined.txt +114 -0
- data/golden/chained_fusion/expected/lir_03_cse.txt +97 -0
- data/golden/chained_fusion/expected/lir_04_1_loop_fusion.txt +99 -0
- data/golden/chained_fusion/expected/lir_04_loop_invcm.txt +97 -0
- data/golden/chained_fusion/expected/lir_06_const_prop.txt +97 -0
- data/golden/chained_fusion/expected/nast.txt +55 -0
- data/golden/chained_fusion/expected/schema_javascript.mjs +116 -0
- data/golden/chained_fusion/expected/schema_ruby.rb +149 -0
- data/golden/chained_fusion/expected/snast.txt +55 -0
- data/golden/chained_fusion/expected.json +45 -0
- data/golden/chained_fusion/input.json +51 -0
- data/golden/chained_fusion/schema.kumi +52 -0
- data/golden/element_arrays/expected/ast.txt +55 -0
- data/golden/element_arrays/expected/input_plan.txt +7 -0
- data/golden/element_arrays/expected/lir_00_unoptimized.txt +81 -0
- data/golden/element_arrays/expected/lir_01_hoist_scalar_references.txt +81 -0
- data/golden/element_arrays/expected/lir_02_inlined.txt +85 -0
- data/golden/element_arrays/expected/lir_03_cse.txt +83 -0
- data/golden/element_arrays/expected/lir_04_1_loop_fusion.txt +83 -0
- data/golden/element_arrays/expected/lir_04_loop_invcm.txt +83 -0
- data/golden/element_arrays/expected/lir_06_const_prop.txt +83 -0
- data/golden/element_arrays/expected/nast.txt +42 -0
- data/golden/element_arrays/expected/schema_javascript.mjs +106 -0
- data/golden/element_arrays/expected/schema_ruby.rb +141 -0
- data/golden/element_arrays/expected/snast.txt +42 -0
- data/golden/element_arrays/expected.json +55 -0
- data/golden/element_arrays/input.json +12 -0
- data/golden/element_arrays/schema.kumi +21 -0
- data/golden/empty_and_null_inputs/expected/ast.txt +42 -0
- data/golden/empty_and_null_inputs/expected/input_plan.txt +12 -0
- data/golden/empty_and_null_inputs/expected/lir_00_unoptimized.txt +31 -0
- data/golden/empty_and_null_inputs/expected/lir_01_hoist_scalar_references.txt +31 -0
- data/golden/empty_and_null_inputs/expected/lir_02_inlined.txt +51 -0
- data/golden/empty_and_null_inputs/expected/lir_03_cse.txt +49 -0
- data/golden/empty_and_null_inputs/expected/lir_04_1_loop_fusion.txt +49 -0
- data/golden/empty_and_null_inputs/expected/lir_04_loop_invcm.txt +49 -0
- data/golden/empty_and_null_inputs/expected/lir_06_const_prop.txt +49 -0
- data/golden/empty_and_null_inputs/expected/nast.txt +18 -0
- data/golden/empty_and_null_inputs/expected/schema_javascript.mjs +47 -0
- data/golden/empty_and_null_inputs/expected/schema_ruby.rb +79 -0
- data/golden/empty_and_null_inputs/expected/snast.txt +18 -0
- data/golden/empty_and_null_inputs/expected.json +8 -0
- data/golden/empty_and_null_inputs/input.json +16 -0
- data/golden/empty_and_null_inputs/schema.kumi +30 -0
- data/golden/game_of_life/expected/ast.txt +118 -0
- data/golden/game_of_life/expected/input_plan.txt +5 -0
- data/golden/game_of_life/expected/lir_00_unoptimized.txt +343 -0
- data/golden/game_of_life/expected/lir_01_hoist_scalar_references.txt +343 -0
- data/golden/game_of_life/expected/lir_02_inlined.txt +1918 -0
- data/golden/game_of_life/expected/lir_03_cse.txt +766 -0
- data/golden/game_of_life/expected/lir_04_1_loop_fusion.txt +766 -0
- data/golden/game_of_life/expected/lir_04_loop_invcm.txt +766 -0
- data/golden/game_of_life/expected/lir_06_const_prop.txt +766 -0
- data/golden/game_of_life/expected/nast.txt +104 -0
- data/golden/game_of_life/expected/schema_javascript.mjs +98 -0
- data/golden/game_of_life/expected/schema_ruby.rb +125 -0
- data/golden/game_of_life/expected/snast.txt +104 -0
- data/golden/game_of_life/expected.json +3 -0
- data/golden/game_of_life/input.json +8 -0
- data/golden/game_of_life/schema.kumi +33 -0
- data/golden/hash_keys/expected/ast.txt +29 -0
- data/golden/hash_keys/expected/input_plan.txt +2 -0
- data/golden/hash_keys/expected/lir_00_unoptimized.txt +18 -0
- data/golden/hash_keys/expected/lir_01_hoist_scalar_references.txt +18 -0
- data/golden/hash_keys/expected/lir_02_inlined.txt +18 -0
- data/golden/hash_keys/expected/lir_03_cse.txt +18 -0
- data/golden/hash_keys/expected/lir_04_1_loop_fusion.txt +18 -0
- data/golden/hash_keys/expected/lir_04_loop_invcm.txt +18 -0
- data/golden/hash_keys/expected/lir_06_const_prop.txt +18 -0
- data/golden/hash_keys/expected/nast.txt +46 -0
- data/golden/hash_keys/expected/schema_javascript.mjs +34 -0
- data/golden/hash_keys/expected/schema_ruby.rb +61 -0
- data/golden/hash_keys/expected/snast.txt +46 -0
- data/golden/hash_keys/expected.json +20 -0
- data/golden/hash_keys/input.json +4 -0
- data/golden/hash_keys/schema.kumi +14 -0
- data/golden/hash_value/expected/ast.txt +37 -0
- data/golden/hash_value/expected/input_plan.txt +7 -0
- data/golden/hash_value/expected/lir_00_unoptimized.txt +30 -0
- data/golden/hash_value/expected/lir_01_hoist_scalar_references.txt +30 -0
- data/golden/hash_value/expected/lir_02_inlined.txt +36 -0
- data/golden/hash_value/expected/lir_03_cse.txt +33 -0
- data/golden/hash_value/expected/lir_04_1_loop_fusion.txt +33 -0
- data/golden/hash_value/expected/lir_04_loop_invcm.txt +33 -0
- data/golden/hash_value/expected/lir_06_const_prop.txt +33 -0
- data/golden/hash_value/expected/nast.txt +25 -0
- data/golden/hash_value/expected/schema_javascript.mjs +46 -0
- data/golden/hash_value/expected/schema_ruby.rb +75 -0
- data/golden/hash_value/expected/snast.txt +25 -0
- data/golden/hash_value/expected.json +19 -0
- data/golden/hash_value/input.json +12 -0
- data/golden/hash_value/schema.kumi +19 -0
- data/golden/hierarchical_complex/expected/ast.txt +85 -0
- data/golden/hierarchical_complex/expected/input_plan.txt +23 -0
- data/golden/hierarchical_complex/expected/lir_00_unoptimized.txt +87 -0
- data/golden/hierarchical_complex/expected/lir_01_hoist_scalar_references.txt +87 -0
- data/golden/hierarchical_complex/expected/lir_02_inlined.txt +115 -0
- data/golden/hierarchical_complex/expected/lir_03_cse.txt +89 -0
- data/golden/hierarchical_complex/expected/lir_04_1_loop_fusion.txt +89 -0
- data/golden/hierarchical_complex/expected/lir_04_loop_invcm.txt +89 -0
- data/golden/hierarchical_complex/expected/lir_06_const_prop.txt +89 -0
- data/golden/hierarchical_complex/expected/nast.txt +49 -0
- data/golden/hierarchical_complex/expected/schema_javascript.mjs +121 -0
- data/golden/hierarchical_complex/expected/schema_ruby.rb +151 -0
- data/golden/hierarchical_complex/expected/snast.txt +49 -0
- data/golden/hierarchical_complex/expected.json +34 -0
- data/golden/hierarchical_complex/input.json +26 -0
- data/golden/hierarchical_complex/schema.kumi +38 -0
- data/golden/input_reference/expected/ast.txt +46 -0
- data/golden/input_reference/expected/input_plan.txt +15 -0
- data/golden/input_reference/expected/lir_00_unoptimized.txt +39 -0
- data/golden/input_reference/expected/lir_01_hoist_scalar_references.txt +39 -0
- data/golden/input_reference/expected/lir_02_inlined.txt +39 -0
- data/golden/input_reference/expected/lir_03_cse.txt +39 -0
- data/golden/input_reference/expected/lir_04_1_loop_fusion.txt +39 -0
- data/golden/input_reference/expected/lir_04_loop_invcm.txt +39 -0
- data/golden/input_reference/expected/lir_06_const_prop.txt +39 -0
- data/golden/input_reference/expected/nast.txt +21 -0
- data/golden/input_reference/expected/schema_javascript.mjs +45 -0
- data/golden/input_reference/expected/schema_ruby.rb +74 -0
- data/golden/input_reference/expected/snast.txt +21 -0
- data/golden/input_reference/expected.json +7 -0
- data/golden/input_reference/input.json +11 -0
- data/golden/input_reference/schema.kumi +22 -0
- data/golden/interleaved_fusion/expected/ast.txt +51 -0
- data/golden/interleaved_fusion/expected/input_plan.txt +13 -0
- data/golden/interleaved_fusion/expected/lir_00_unoptimized.txt +53 -0
- data/golden/interleaved_fusion/expected/lir_01_hoist_scalar_references.txt +53 -0
- data/golden/interleaved_fusion/expected/lir_02_inlined.txt +89 -0
- data/golden/interleaved_fusion/expected/lir_03_cse.txt +77 -0
- data/golden/interleaved_fusion/expected/lir_04_1_loop_fusion.txt +77 -0
- data/golden/interleaved_fusion/expected/lir_04_loop_invcm.txt +77 -0
- data/golden/interleaved_fusion/expected/lir_06_const_prop.txt +77 -0
- data/golden/interleaved_fusion/expected/nast.txt +41 -0
- data/golden/interleaved_fusion/expected/schema_javascript.mjs +86 -0
- data/golden/interleaved_fusion/expected/schema_ruby.rb +122 -0
- data/golden/interleaved_fusion/expected/snast.txt +41 -0
- data/golden/interleaved_fusion/expected.json +37 -0
- data/golden/interleaved_fusion/input.json +26 -0
- data/golden/interleaved_fusion/schema.kumi +57 -0
- data/golden/let_inline/expected/ast.txt +33 -0
- data/golden/let_inline/expected/input_plan.txt +2 -0
- data/golden/let_inline/expected/lir_00_unoptimized.txt +26 -0
- data/golden/let_inline/expected/lir_01_hoist_scalar_references.txt +26 -0
- data/golden/let_inline/expected/lir_02_inlined.txt +36 -0
- data/golden/let_inline/expected/lir_03_cse.txt +30 -0
- data/golden/let_inline/expected/lir_04_1_loop_fusion.txt +30 -0
- data/golden/let_inline/expected/lir_04_loop_invcm.txt +30 -0
- data/golden/let_inline/expected/lir_06_const_prop.txt +30 -0
- data/golden/let_inline/expected/nast.txt +26 -0
- data/golden/let_inline/expected/schema_javascript.mjs +11 -0
- data/golden/let_inline/expected/schema_ruby.rb +37 -0
- data/golden/let_inline/expected/snast.txt +26 -0
- data/golden/let_inline/expected.json +1 -0
- data/golden/let_inline/input.json +1 -0
- data/golden/let_inline/schema.kumi +11 -0
- data/golden/loop_fusion/expected/ast.txt +44 -0
- data/golden/loop_fusion/expected/input_plan.txt +13 -0
- data/golden/loop_fusion/expected/lir_00_unoptimized.txt +43 -0
- data/golden/loop_fusion/expected/lir_01_hoist_scalar_references.txt +43 -0
- data/golden/loop_fusion/expected/lir_02_inlined.txt +62 -0
- data/golden/loop_fusion/expected/lir_03_cse.txt +57 -0
- data/golden/loop_fusion/expected/lir_04_1_loop_fusion.txt +57 -0
- data/golden/loop_fusion/expected/lir_04_loop_invcm.txt +57 -0
- data/golden/loop_fusion/expected/lir_06_const_prop.txt +57 -0
- data/golden/loop_fusion/expected/nast.txt +32 -0
- data/golden/loop_fusion/expected/schema_javascript.mjs +64 -0
- data/golden/loop_fusion/expected/schema_ruby.rb +97 -0
- data/golden/loop_fusion/expected/snast.txt +32 -0
- data/golden/loop_fusion/expected.json +30 -0
- data/golden/loop_fusion/input.json +28 -0
- data/golden/loop_fusion/schema.kumi +32 -0
- data/golden/min_reduce_scope/expected/ast.txt +49 -0
- data/golden/min_reduce_scope/expected/input_plan.txt +9 -0
- data/golden/min_reduce_scope/expected/lir_00_unoptimized.txt +59 -0
- data/golden/min_reduce_scope/expected/lir_01_hoist_scalar_references.txt +59 -0
- data/golden/min_reduce_scope/expected/lir_02_inlined.txt +63 -0
- data/golden/min_reduce_scope/expected/lir_03_cse.txt +60 -0
- data/golden/min_reduce_scope/expected/lir_04_1_loop_fusion.txt +60 -0
- data/golden/min_reduce_scope/expected/lir_04_loop_invcm.txt +60 -0
- data/golden/min_reduce_scope/expected/lir_06_const_prop.txt +60 -0
- data/golden/min_reduce_scope/expected/nast.txt +29 -0
- data/golden/min_reduce_scope/expected/schema_javascript.mjs +66 -0
- data/golden/min_reduce_scope/expected/schema_ruby.rb +99 -0
- data/golden/min_reduce_scope/expected/snast.txt +29 -0
- data/golden/min_reduce_scope/expected.json +9 -0
- data/golden/min_reduce_scope/input.json +18 -0
- data/golden/min_reduce_scope/schema.kumi +25 -0
- data/golden/mixed_dimensions/expected/ast.txt +54 -0
- data/golden/mixed_dimensions/expected/input_plan.txt +15 -0
- data/golden/mixed_dimensions/expected/lir_00_unoptimized.txt +42 -0
- data/golden/mixed_dimensions/expected/lir_01_hoist_scalar_references.txt +42 -0
- data/golden/mixed_dimensions/expected/lir_02_inlined.txt +48 -0
- data/golden/mixed_dimensions/expected/lir_03_cse.txt +48 -0
- data/golden/mixed_dimensions/expected/lir_04_1_loop_fusion.txt +48 -0
- data/golden/mixed_dimensions/expected/lir_04_loop_invcm.txt +48 -0
- data/golden/mixed_dimensions/expected/lir_06_const_prop.txt +48 -0
- data/golden/mixed_dimensions/expected/nast.txt +22 -0
- data/golden/mixed_dimensions/expected/schema_javascript.mjs +53 -0
- data/golden/mixed_dimensions/expected/schema_ruby.rb +84 -0
- data/golden/mixed_dimensions/expected/snast.txt +22 -0
- data/golden/mixed_dimensions/expected.json +6 -0
- data/golden/mixed_dimensions/input.json +22 -0
- data/golden/mixed_dimensions/schema.kumi +35 -0
- data/golden/multirank_hoisting/expected/ast.txt +72 -0
- data/golden/multirank_hoisting/expected/input_plan.txt +18 -0
- data/golden/multirank_hoisting/expected/lir_00_unoptimized.txt +75 -0
- data/golden/multirank_hoisting/expected/lir_01_hoist_scalar_references.txt +75 -0
- data/golden/multirank_hoisting/expected/lir_02_inlined.txt +126 -0
- data/golden/multirank_hoisting/expected/lir_03_cse.txt +109 -0
- data/golden/multirank_hoisting/expected/lir_04_1_loop_fusion.txt +109 -0
- data/golden/multirank_hoisting/expected/lir_04_loop_invcm.txt +109 -0
- data/golden/multirank_hoisting/expected/lir_06_const_prop.txt +109 -0
- data/golden/multirank_hoisting/expected/nast.txt +39 -0
- data/golden/multirank_hoisting/expected/schema_javascript.mjs +128 -0
- data/golden/multirank_hoisting/expected/schema_ruby.rb +162 -0
- data/golden/multirank_hoisting/expected/snast.txt +39 -0
- data/golden/multirank_hoisting/expected.json +15 -0
- data/golden/multirank_hoisting/input.json +19 -0
- data/golden/multirank_hoisting/schema.kumi +38 -0
- data/golden/nested_hash/expected/ast.txt +22 -0
- data/golden/nested_hash/expected/input_plan.txt +5 -0
- data/golden/nested_hash/expected/lir_00_unoptimized.txt +10 -0
- data/golden/nested_hash/expected/lir_01_hoist_scalar_references.txt +10 -0
- data/golden/nested_hash/expected/lir_02_inlined.txt +10 -0
- data/golden/nested_hash/expected/lir_03_cse.txt +10 -0
- data/golden/nested_hash/expected/lir_04_1_loop_fusion.txt +10 -0
- data/golden/nested_hash/expected/lir_04_loop_invcm.txt +10 -0
- data/golden/nested_hash/expected/lir_06_const_prop.txt +10 -0
- data/golden/nested_hash/expected/nast.txt +8 -0
- data/golden/nested_hash/expected/schema_javascript.mjs +9 -0
- data/golden/nested_hash/expected/schema_ruby.rb +35 -0
- data/golden/nested_hash/expected/snast.txt +8 -0
- data/golden/nested_hash/expected.json +3 -0
- data/golden/nested_hash/input.json +7 -0
- data/golden/nested_hash/schema.kumi +11 -0
- data/golden/reduction_broadcast/expected/ast.txt +49 -0
- data/golden/reduction_broadcast/expected/input_plan.txt +13 -0
- data/golden/reduction_broadcast/expected/lir_00_unoptimized.txt +49 -0
- data/golden/reduction_broadcast/expected/lir_01_hoist_scalar_references.txt +49 -0
- data/golden/reduction_broadcast/expected/lir_02_inlined.txt +80 -0
- data/golden/reduction_broadcast/expected/lir_03_cse.txt +68 -0
- data/golden/reduction_broadcast/expected/lir_04_1_loop_fusion.txt +68 -0
- data/golden/reduction_broadcast/expected/lir_04_loop_invcm.txt +68 -0
- data/golden/reduction_broadcast/expected/lir_06_const_prop.txt +68 -0
- data/golden/reduction_broadcast/expected/nast.txt +24 -0
- data/golden/reduction_broadcast/expected/schema_javascript.mjs +74 -0
- data/golden/reduction_broadcast/expected/schema_ruby.rb +110 -0
- data/golden/reduction_broadcast/expected/snast.txt +24 -0
- data/golden/reduction_broadcast/expected.json +25 -0
- data/golden/reduction_broadcast/input.json +19 -0
- data/golden/reduction_broadcast/schema.kumi +34 -0
- data/golden/roll/expected/ast.txt +36 -0
- data/golden/roll/expected/input_plan.txt +3 -0
- data/golden/roll/expected/lir_00_unoptimized.txt +56 -0
- data/golden/roll/expected/lir_01_hoist_scalar_references.txt +56 -0
- data/golden/roll/expected/lir_02_inlined.txt +56 -0
- data/golden/roll/expected/lir_03_cse.txt +55 -0
- data/golden/roll/expected/lir_04_1_loop_fusion.txt +55 -0
- data/golden/roll/expected/lir_04_loop_invcm.txt +55 -0
- data/golden/roll/expected/lir_06_const_prop.txt +55 -0
- data/golden/roll/expected/nast.txt +26 -0
- data/golden/roll/expected/schema_javascript.mjs +65 -0
- data/golden/roll/expected/schema_ruby.rb +95 -0
- data/golden/roll/expected/snast.txt +26 -0
- data/golden/roll/expected.json +6 -0
- data/golden/roll/input.json +1 -0
- data/golden/roll/schema.kumi +13 -0
- data/golden/shift/expected/ast.txt +48 -0
- data/golden/shift/expected/input_plan.txt +3 -0
- data/golden/shift/expected/lir_00_unoptimized.txt +96 -0
- data/golden/shift/expected/lir_01_hoist_scalar_references.txt +96 -0
- data/golden/shift/expected/lir_02_inlined.txt +96 -0
- data/golden/shift/expected/lir_03_cse.txt +90 -0
- data/golden/shift/expected/lir_04_1_loop_fusion.txt +90 -0
- data/golden/shift/expected/lir_04_loop_invcm.txt +90 -0
- data/golden/shift/expected/lir_06_const_prop.txt +90 -0
- data/golden/shift/expected/nast.txt +38 -0
- data/golden/shift/expected/schema_javascript.mjs +106 -0
- data/golden/shift/expected/schema_ruby.rb +138 -0
- data/golden/shift/expected/snast.txt +38 -0
- data/golden/shift/expected.json +8 -0
- data/golden/shift/input.json +1 -0
- data/golden/shift/schema.kumi +15 -0
- data/golden/shift_2d/expected/ast.txt +88 -0
- data/golden/shift_2d/expected/input_plan.txt +5 -0
- data/golden/shift_2d/expected/lir_00_unoptimized.txt +274 -0
- data/golden/shift_2d/expected/lir_01_hoist_scalar_references.txt +274 -0
- data/golden/shift_2d/expected/lir_02_inlined.txt +274 -0
- data/golden/shift_2d/expected/lir_03_cse.txt +262 -0
- data/golden/shift_2d/expected/lir_04_1_loop_fusion.txt +262 -0
- data/golden/shift_2d/expected/lir_04_loop_invcm.txt +262 -0
- data/golden/shift_2d/expected/lir_06_const_prop.txt +262 -0
- data/golden/shift_2d/expected/nast.txt +74 -0
- data/golden/shift_2d/expected/schema_javascript.mjs +320 -0
- data/golden/shift_2d/expected/schema_ruby.rb +358 -0
- data/golden/shift_2d/expected/snast.txt +74 -0
- data/golden/shift_2d/expected.json +15 -0
- data/golden/shift_2d/input.json +14 -0
- data/golden/shift_2d/schema.kumi +25 -0
- data/golden/simple_math/expected/ast.txt +40 -0
- data/golden/simple_math/expected/input_plan.txt +2 -0
- data/golden/simple_math/expected/lir_00_unoptimized.txt +31 -0
- data/golden/simple_math/expected/lir_01_hoist_scalar_references.txt +31 -0
- data/golden/simple_math/expected/lir_02_inlined.txt +31 -0
- data/golden/simple_math/expected/lir_03_cse.txt +31 -0
- data/golden/simple_math/expected/lir_04_1_loop_fusion.txt +31 -0
- data/golden/simple_math/expected/lir_04_loop_invcm.txt +31 -0
- data/golden/simple_math/expected/lir_06_const_prop.txt +31 -0
- data/golden/simple_math/expected/nast.txt +33 -0
- data/golden/simple_math/expected/schema_javascript.mjs +33 -0
- data/golden/simple_math/expected/schema_ruby.rb +59 -0
- data/golden/simple_math/expected/snast.txt +33 -0
- data/golden/simple_math/expected.json +1 -0
- data/golden/simple_math/input.json +4 -0
- data/golden/simple_math/schema.kumi +2 -1
- data/golden/streaming_basics/expected/ast.txt +64 -0
- data/golden/streaming_basics/expected/input_plan.txt +8 -0
- data/golden/streaming_basics/expected/lir_00_unoptimized.txt +73 -0
- data/golden/streaming_basics/expected/lir_01_hoist_scalar_references.txt +73 -0
- data/golden/streaming_basics/expected/lir_02_inlined.txt +100 -0
- data/golden/streaming_basics/expected/lir_03_cse.txt +84 -0
- data/golden/streaming_basics/expected/lir_04_1_loop_fusion.txt +84 -0
- data/golden/streaming_basics/expected/lir_04_loop_invcm.txt +84 -0
- data/golden/streaming_basics/expected/lir_06_const_prop.txt +84 -0
- data/golden/streaming_basics/expected/nast.txt +48 -0
- data/golden/streaming_basics/expected/schema_javascript.mjs +94 -0
- data/golden/streaming_basics/expected/schema_ruby.rb +127 -0
- data/golden/streaming_basics/expected/snast.txt +48 -0
- data/golden/streaming_basics/expected.json +10 -0
- data/golden/streaming_basics/input.json +8 -0
- data/golden/streaming_basics/schema.kumi +24 -0
- data/golden/tuples/expected/ast.txt +48 -0
- data/golden/tuples/expected/input_plan.txt +1 -0
- data/golden/tuples/expected/lir_00_unoptimized.txt +40 -0
- data/golden/tuples/expected/lir_01_hoist_scalar_references.txt +40 -0
- data/golden/tuples/expected/lir_02_inlined.txt +48 -0
- data/golden/tuples/expected/lir_03_cse.txt +48 -0
- data/golden/tuples/expected/lir_04_1_loop_fusion.txt +48 -0
- data/golden/tuples/expected/lir_04_loop_invcm.txt +48 -0
- data/golden/tuples/expected/lir_06_const_prop.txt +48 -0
- data/golden/tuples/expected/nast.txt +42 -0
- data/golden/tuples/expected/schema_javascript.mjs +51 -0
- data/golden/tuples/expected/schema_ruby.rb +77 -0
- data/golden/tuples/expected/snast.txt +42 -0
- data/golden/tuples/expected.json +7 -0
- data/golden/tuples/input.json +3 -0
- data/golden/tuples/schema.kumi +11 -0
- data/golden/tuples_and_arrays/expected/ast.txt +44 -0
- data/golden/tuples_and_arrays/expected/input_plan.txt +7 -0
- data/golden/tuples_and_arrays/expected/lir_00_unoptimized.txt +41 -0
- data/golden/tuples_and_arrays/expected/lir_01_hoist_scalar_references.txt +41 -0
- data/golden/tuples_and_arrays/expected/lir_02_inlined.txt +62 -0
- data/golden/tuples_and_arrays/expected/lir_03_cse.txt +51 -0
- data/golden/tuples_and_arrays/expected/lir_04_1_loop_fusion.txt +51 -0
- data/golden/tuples_and_arrays/expected/lir_04_loop_invcm.txt +51 -0
- data/golden/tuples_and_arrays/expected/lir_06_const_prop.txt +51 -0
- data/golden/tuples_and_arrays/expected/nast.txt +28 -0
- data/golden/tuples_and_arrays/expected/schema_javascript.mjs +58 -0
- data/golden/tuples_and_arrays/expected/schema_ruby.rb +88 -0
- data/golden/tuples_and_arrays/expected/snast.txt +28 -0
- data/golden/tuples_and_arrays/expected.json +18 -0
- data/golden/tuples_and_arrays/input.json +7 -0
- data/golden/tuples_and_arrays/schema.kumi +38 -0
- data/golden/with_constants/expected/ast.txt +28 -0
- data/golden/with_constants/expected/input_plan.txt +2 -0
- data/golden/with_constants/expected/lir_00_unoptimized.txt +17 -0
- data/golden/with_constants/expected/lir_01_hoist_scalar_references.txt +17 -0
- data/golden/with_constants/expected/lir_02_inlined.txt +17 -0
- data/golden/with_constants/expected/lir_03_cse.txt +17 -0
- data/golden/with_constants/expected/lir_04_1_loop_fusion.txt +17 -0
- data/golden/with_constants/expected/lir_04_loop_invcm.txt +17 -0
- data/golden/with_constants/expected/lir_06_const_prop.txt +17 -0
- data/golden/with_constants/expected/nast.txt +21 -0
- data/golden/with_constants/expected/schema_javascript.mjs +18 -0
- data/golden/with_constants/expected/schema_ruby.rb +44 -0
- data/golden/with_constants/expected/snast.txt +15 -0
- data/golden/with_constants/schema.kumi +10 -0
- data/lib/kumi/analyzer.rb +76 -24
- data/lib/kumi/configuration.rb +60 -0
- data/lib/kumi/core/analyzer/binder.rb +121 -0
- data/lib/kumi/core/analyzer/checkpoint.rb +15 -9
- data/lib/kumi/core/analyzer/constant_evaluator.rb +32 -37
- data/lib/kumi/core/analyzer/constant_folding_helpers.rb +55 -0
- data/lib/kumi/core/analyzer/debug.rb +14 -16
- data/lib/kumi/core/analyzer/fn_aliases.rb +46 -0
- data/lib/kumi/core/analyzer/folder.rb +94 -0
- data/lib/kumi/core/analyzer/macro_expander.rb +69 -0
- data/lib/kumi/core/analyzer/passes/assemble_irv2_pass.rb +130 -0
- data/lib/kumi/core/analyzer/passes/attach_anchors_pass.rb +71 -0
- data/lib/kumi/core/analyzer/passes/attach_terminal_info_pass.rb +181 -0
- data/lib/kumi/core/analyzer/passes/codegen/js/declaration_emitter.rb +317 -0
- data/lib/kumi/core/analyzer/passes/codegen/js/emitter.rb +75 -0
- data/lib/kumi/core/analyzer/passes/codegen/js/output_buffer.rb +103 -0
- data/lib/kumi/core/analyzer/passes/codegen/js_pass.rb +27 -0
- data/lib/kumi/core/analyzer/passes/codegen/ruby/declaration_emitter.rb +321 -0
- data/lib/kumi/core/analyzer/passes/codegen/ruby/emitter.rb +85 -0
- data/lib/kumi/core/analyzer/passes/codegen/ruby/output_buffer.rb +111 -0
- data/lib/kumi/core/analyzer/passes/codegen/ruby_pass.rb +32 -0
- data/lib/kumi/core/analyzer/passes/constant_folding_pass.rb +33 -0
- data/lib/kumi/core/analyzer/passes/contract_checker_pass.rb +220 -0
- data/lib/kumi/core/analyzer/passes/dependency_resolver.rb +5 -6
- data/lib/kumi/core/analyzer/passes/input_access_planner_pass.rb +7 -3
- data/lib/kumi/core/analyzer/passes/input_collector.rb +74 -122
- data/lib/kumi/core/analyzer/passes/input_form_schema_pass.rb +43 -0
- data/lib/kumi/core/analyzer/passes/ir_dependency_pass.rb +1 -1
- data/lib/kumi/core/analyzer/passes/ir_execution_schedule_pass.rb +1 -1
- data/lib/kumi/core/analyzer/passes/join_reduce_planning_pass.rb +21 -23
- data/lib/kumi/core/analyzer/passes/lir/constant_propagation_pass.rb +84 -0
- data/lib/kumi/core/analyzer/passes/lir/dead_code_elimination_pass.rb +93 -0
- data/lib/kumi/core/analyzer/passes/lir/hoist_scalar_references_pass.rb +115 -0
- data/lib/kumi/core/analyzer/passes/lir/inline_declarations_pass.rb +274 -0
- data/lib/kumi/core/analyzer/passes/lir/instruction_scheduling_pass.rb +198 -0
- data/lib/kumi/core/analyzer/passes/lir/kernel_binding_pass.rb +30 -0
- data/lib/kumi/core/analyzer/passes/lir/local_cse_pass.rb +121 -0
- data/lib/kumi/core/analyzer/passes/lir/loop_fusion_pass.rb +156 -0
- data/lib/kumi/core/analyzer/passes/lir/loop_invariant_code_motion_pass.rb +148 -0
- data/lib/kumi/core/analyzer/passes/lir/lower_pass.rb +407 -0
- data/lib/kumi/core/analyzer/passes/lir/stencil_emitter.rb +243 -0
- data/lib/kumi/core/analyzer/passes/lir/validation_pass.rb +83 -0
- data/lib/kumi/core/analyzer/passes/load_input_cse.rb +17 -16
- data/lib/kumi/core/analyzer/passes/lower_to_ir_pass.rb +4 -2
- data/lib/kumi/core/analyzer/passes/lower_to_irv2_pass.rb +197 -0
- data/lib/kumi/core/analyzer/passes/name_indexer.rb +4 -1
- data/lib/kumi/core/analyzer/passes/nast_dimensional_analyzer_pass.rb +237 -0
- data/lib/kumi/core/analyzer/passes/normalize_to_nast_pass.rb +156 -0
- data/lib/kumi/core/analyzer/passes/output_schema_pass.rb +38 -0
- data/lib/kumi/core/analyzer/passes/pass_base.rb +30 -4
- data/lib/kumi/core/analyzer/passes/precompute_access_paths_pass.rb +93 -0
- data/lib/kumi/core/analyzer/passes/scope_resolution_pass.rb +33 -30
- data/lib/kumi/core/analyzer/passes/semantic_constraint_validator.rb +5 -26
- data/lib/kumi/core/analyzer/passes/snast_pass.rb +229 -0
- data/lib/kumi/core/analyzer/passes/toposorter.rb +1 -0
- data/lib/kumi/core/analyzer/passes/type_checker.rb +13 -0
- data/lib/kumi/core/analyzer/passes/type_inferencer_pass.rb +14 -16
- data/lib/kumi/core/analyzer/passes/unsat_detector.rb +2 -1
- data/lib/kumi/core/analyzer/plans.rb +12 -0
- data/lib/kumi/core/analyzer/state_serde.rb +4 -4
- data/lib/kumi/core/analyzer/structs/access_plan.rb +2 -2
- data/lib/kumi/core/analyzer/unsat_constant_evaluator.rb +59 -0
- data/lib/kumi/core/compiler/access_codegen.rb +1 -1
- data/lib/kumi/core/compiler/access_emit/base.rb +9 -5
- data/lib/kumi/core/compiler/access_emit/each_indexed.rb +10 -3
- data/lib/kumi/core/compiler/access_emit/materialize.rb +12 -5
- data/lib/kumi/core/compiler/access_emit/ravel.rb +10 -3
- data/lib/kumi/core/compiler/access_emit/read.rb +4 -1
- data/lib/kumi/core/compiler/access_planner.rb +42 -4
- data/lib/kumi/core/compiler/access_planner_v2.rb +164 -0
- data/lib/kumi/core/explain.rb +18 -11
- data/lib/kumi/core/functions/loader.rb +47 -0
- data/lib/kumi/core/functions/model.rb +10 -0
- data/lib/kumi/core/functions/type_rules.rb +108 -0
- data/lib/kumi/core/ir/execution_engine/interpreter.rb +1 -1
- data/lib/kumi/core/ir/execution_engine/profiler.rb +107 -97
- data/lib/kumi/core/ir.rb +6 -2
- data/lib/kumi/core/irv2/builder.rb +48 -0
- data/lib/kumi/core/irv2/declaration.rb +28 -0
- data/lib/kumi/core/irv2/module.rb +108 -0
- data/lib/kumi/core/irv2/value.rb +28 -0
- data/lib/kumi/core/lir/analyze.rb +64 -0
- data/lib/kumi/core/lir/build.rb +363 -0
- data/lib/kumi/core/lir/emit.rb +62 -0
- data/lib/kumi/core/lir/structs/instruction.rb +44 -0
- data/lib/kumi/core/lir/structs/literal.rb +14 -0
- data/lib/kumi/core/lir/structs/stamp.rb +13 -0
- data/lib/kumi/core/lir/support/error.rb +9 -0
- data/lib/kumi/core/lir/support/ids.rb +34 -0
- data/lib/kumi/core/lir/validate.rb +74 -0
- data/lib/kumi/core/lir.rb +34 -0
- data/lib/kumi/core/nast.rb +216 -0
- data/lib/kumi/core/ruby_parser/dsl.rb +2 -2
- data/lib/kumi/core/ruby_parser/dsl_cascade_builder.rb +1 -1
- data/lib/kumi/core/ruby_parser/expression_converter.rb +10 -0
- data/lib/kumi/core/ruby_parser/input_builder.rb +16 -17
- data/lib/kumi/core/ruby_parser/schema_builder.rb +36 -10
- data/lib/kumi/core/ruby_parser/sugar.rb +64 -0
- data/lib/kumi/core/types/builder.rb +2 -2
- data/lib/kumi/core/types/normalizer.rb +2 -0
- data/lib/kumi/core/types/validator.rb +10 -3
- data/lib/kumi/core/types.rb +7 -0
- data/lib/kumi/dev/codegen.rb +194 -0
- data/lib/kumi/dev/golden/generator.rb +105 -0
- data/lib/kumi/dev/golden/reporter.rb +160 -0
- data/lib/kumi/dev/golden/representation.rb +45 -0
- data/lib/kumi/dev/golden/result.rb +98 -0
- data/lib/kumi/dev/golden/runtime_test.rb +93 -0
- data/lib/kumi/dev/golden/suite.rb +131 -0
- data/lib/kumi/dev/golden/verifier.rb +76 -0
- data/lib/kumi/dev/golden.rb +75 -0
- data/lib/kumi/dev/ir.rb +4 -4
- data/lib/kumi/dev/parse.rb +1 -1
- data/lib/kumi/dev/pretty_printer.rb +229 -0
- data/lib/kumi/dev/printer/irv2_formatter.rb +163 -0
- data/lib/kumi/dev/printer/width_aware_json.rb +44 -0
- data/lib/kumi/dev/profile_aggregator.rb +36 -38
- data/lib/kumi/dev/profile_runner.rb +19 -23
- data/lib/kumi/dev/runner.rb +12 -22
- data/lib/kumi/dev/support/kumi_runner.mjs +39 -0
- data/lib/kumi/dev.rb +3 -3
- data/lib/kumi/frontends/ruby.rb +12 -12
- data/lib/kumi/frontends/text.rb +26 -21
- data/lib/kumi/frontends.rb +6 -8
- data/lib/kumi/kernel_registry.rb +59 -0
- data/lib/kumi/pack/builder.rb +229 -0
- data/lib/kumi/pack.rb +15 -0
- data/lib/kumi/registry_v2/loader.rb +81 -0
- data/lib/kumi/registry_v2.rb +118 -0
- data/lib/kumi/schema.rb +83 -43
- data/lib/kumi/support/diff.rb +3 -2
- data/lib/kumi/support/ir_render.rb +1 -1
- data/lib/kumi/support/lir_printer.rb +143 -0
- data/lib/kumi/support/nast_printer.rb +93 -0
- data/lib/kumi/support/s_expression_printer.rb +5 -4
- data/lib/kumi/support/snast_printer.rb +111 -0
- data/lib/kumi/syntax/call_expression.rb +1 -1
- data/lib/kumi/syntax/input_declaration.rb +2 -2
- data/lib/kumi/syntax/node.rb +4 -12
- data/lib/kumi/syntax/root.rb +10 -0
- data/lib/kumi/syntax/trait_declaration.rb +1 -0
- data/lib/kumi/syntax/value_declaration.rb +1 -0
- data/lib/kumi/version.rb +1 -1
- data/lib/kumi.rb +46 -4
- metadata +571 -54
- data/docs/AST.md +0 -133
- data/docs/DSL.md +0 -154
- data/docs/FUNCTIONS.md +0 -176
- data/docs/VECTOR_SEMANTICS.md +0 -286
- data/docs/compiler_design_principles.md +0 -86
- data/docs/dev/analyzer-debug.md +0 -52
- data/docs/dev/parse-command.md +0 -64
- data/docs/dev/vm-profiling.md +0 -95
- data/docs/development/README.md +0 -120
- data/docs/development/error-reporting.md +0 -361
- data/docs/features/README.md +0 -58
- data/docs/features/analysis-type-inference.md +0 -42
- data/docs/features/analysis-unsat-detection.md +0 -71
- data/docs/features/hierarchical-broadcasting.md +0 -415
- data/docs/features/input-declaration-system.md +0 -58
- data/docs/features/performance.md +0 -14
- data/docs/features/s-expression-printer.md +0 -77
- data/docs/schema_metadata/broadcasts.md +0 -53
- data/docs/schema_metadata/cascades.md +0 -45
- data/docs/schema_metadata/declarations.md +0 -54
- data/docs/schema_metadata/dependencies.md +0 -57
- data/docs/schema_metadata/evaluation_order.md +0 -29
- data/docs/schema_metadata/examples.md +0 -95
- data/docs/schema_metadata/inferred_types.md +0 -46
- data/docs/schema_metadata/inputs.md +0 -86
- data/docs/schema_metadata.md +0 -108
- data/golden/mixed_nesting/schema.kumi +0 -42
- data/lib/kumi/core/function_registry/collection_functions.rb +0 -298
- data/lib/kumi/core/function_registry/comparison_functions.rb +0 -33
- data/lib/kumi/core/function_registry/conditional_functions.rb +0 -48
- data/lib/kumi/core/function_registry/function_builder.rb +0 -184
- data/lib/kumi/core/function_registry/logical_functions.rb +0 -214
- data/lib/kumi/core/function_registry/math_functions.rb +0 -74
- data/lib/kumi/core/function_registry/stat_functions.rb +0 -156
- data/lib/kumi/core/function_registry/string_functions.rb +0 -57
- data/lib/kumi/core/function_registry/type_functions.rb +0 -53
- data/lib/kumi/core/function_registry.rb +0 -176
- data/lib/kumi/registry.rb +0 -32
- data/lib/kumi/runtime/executable.rb +0 -135
- data/lib/kumi/runtime/run.rb +0 -105
- data/performance_results.txt +0 -63
- data/scripts/analyze_broadcast_methods.rb +0 -68
- data/scripts/analyze_cascade_methods.rb +0 -74
- data/scripts/check_broadcasting_coverage.rb +0 -51
- data/scripts/find_dead_code.rb +0 -114
- data/scripts/generate_function_docs.rb +0 -71
- data/scripts/test_mixed_nesting_performance.rb +0 -206
data/lib/kumi/frontends.rb
CHANGED
@@ -3,27 +3,25 @@
|
|
3
3
|
module Kumi
|
4
4
|
module Frontends
|
5
5
|
def self.load(path:, inputs: {})
|
6
|
-
mode =
|
6
|
+
mode = ENV["KUMI_PARSER"] || "auto" # auto|text|ruby
|
7
7
|
ext = File.extname(path)
|
8
8
|
|
9
9
|
# Explicit mode selection
|
10
10
|
return Text.load(path:, inputs:) if mode == "text"
|
11
11
|
return Ruby.load(path:, inputs:) if mode == "ruby"
|
12
|
-
|
12
|
+
|
13
13
|
# Auto mode: prefer .kumi if present
|
14
14
|
if mode == "auto" && ext == ".rb"
|
15
15
|
kumi_path = path.sub(/\.rb\z/, ".kumi")
|
16
|
-
if File.exist?(kumi_path)
|
17
|
-
return Text.load(path: kumi_path, inputs: inputs)
|
18
|
-
end
|
16
|
+
return Text.load(path: kumi_path, inputs: inputs) if File.exist?(kumi_path)
|
19
17
|
end
|
20
|
-
|
18
|
+
|
21
19
|
# File extension based selection
|
22
20
|
return Text.load(path:, inputs:) if ext == ".kumi"
|
23
21
|
return Ruby.load(path:, inputs:) if ext == ".rb"
|
24
|
-
|
22
|
+
|
25
23
|
# Default fallback
|
26
24
|
Ruby.load(path:, inputs:)
|
27
25
|
end
|
28
26
|
end
|
29
|
-
end
|
27
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require "yaml"
|
2
|
+
require "json"
|
3
|
+
require "digest"
|
4
|
+
|
5
|
+
module Kumi
|
6
|
+
class KernelRegistry
|
7
|
+
KERNEL_DIRS = {
|
8
|
+
ruby: "data/kernels/ruby"
|
9
|
+
}
|
10
|
+
Entry = Struct.new(:id, :fn, :impl, :identity, keyword_init: true)
|
11
|
+
|
12
|
+
def self.load_ruby
|
13
|
+
load_dir(KERNEL_DIRS[:ruby])
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.load_dir(dir)
|
17
|
+
files = Dir.glob(File.join(dir, "**", "*.y{a,}ml")).sort
|
18
|
+
entries = files.flat_map { |p| (YAML.load_file(p) || {}).fetch("kernels", []) }
|
19
|
+
.map { |h| Entry.new(id: h["id"], fn: h["fn"], impl: h["impl"], identity: h["identity"]) }
|
20
|
+
new(entries)
|
21
|
+
end
|
22
|
+
|
23
|
+
def initialize(entries)
|
24
|
+
@by_fn = Hash.new { |h, k| h[k] = [] }
|
25
|
+
@by_id = {}
|
26
|
+
entries.each { |e| (@by_fn[e.fn] << e) && (@by_id[e.id] = e) }
|
27
|
+
@by_fn.each { |fn, arr| raise "multiple kernels for #{fn}" if arr.size > 1 }
|
28
|
+
end
|
29
|
+
|
30
|
+
def pick(fn)
|
31
|
+
(@by_fn[fn]&.first || raise("no kernel for #{fn}")).id
|
32
|
+
end
|
33
|
+
|
34
|
+
def registry_ref
|
35
|
+
stable = { kernels: @by_id.values.map { |e| { "id" => e.id, "fn" => e.fn, "impl" => e.impl } }.sort_by { _1["id"] } }
|
36
|
+
"sha256:#{Digest::SHA256.hexdigest(JSON.generate(stable))}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def identity(kernel_id, dtype)
|
40
|
+
e = @by_id[kernel_id] or raise "unknown kernel id #{kernel_id}"
|
41
|
+
identity_map = e.identity or raise "no identity map for #{kernel_id}"
|
42
|
+
|
43
|
+
(identity_map[dtype.to_s] || identity_map["any"]) or raise "no identity with dtype `#{dtype}` for #{kernel_id}"
|
44
|
+
end
|
45
|
+
|
46
|
+
# Late-bind the Ruby implementation
|
47
|
+
# Returns implementation structure for the kernel
|
48
|
+
def impl_for(kernel_id)
|
49
|
+
e = @by_id[kernel_id] or raise "unknown kernel id #{kernel_id}"
|
50
|
+
e.impl
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def constantize(path)
|
56
|
+
path.split("::").inject(Object) { |ctx, name| ctx.const_get(name) }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,229 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "digest"
|
5
|
+
require "fileutils"
|
6
|
+
|
7
|
+
module Kumi
|
8
|
+
module Pack
|
9
|
+
module Builder
|
10
|
+
VERSION = "0.1"
|
11
|
+
|
12
|
+
module_function
|
13
|
+
|
14
|
+
def build(schema:, out_dir:, targets: %w[ruby], include_ir: false)
|
15
|
+
ir, planning, bindings, inputs, module_id = generate_artifacts(schema)
|
16
|
+
FileUtils.mkdir_p(out_dir)
|
17
|
+
write_json("#{out_dir}/irv2.json", ir)
|
18
|
+
write_json("#{out_dir}/planning.json", planning)
|
19
|
+
write_json("#{out_dir}/bindings.json", bindings)
|
20
|
+
write_json("#{out_dir}/inputs.json", inputs)
|
21
|
+
|
22
|
+
pack = assemble_pack(module_id, ir, planning, bindings, inputs, targets, include_ir)
|
23
|
+
write_json("#{out_dir}/pack.json", pack)
|
24
|
+
canonical_json(pack)
|
25
|
+
end
|
26
|
+
|
27
|
+
def print(schema:, targets: %w[ruby], include_ir: false)
|
28
|
+
ir, planning, bindings, inputs, module_id = generate_artifacts(schema)
|
29
|
+
pack = assemble_pack(module_id, ir, planning, bindings, inputs, targets, include_ir)
|
30
|
+
canonical_json(pack)
|
31
|
+
end
|
32
|
+
|
33
|
+
def build_for_golden(schema_path, golden_dir, targets: %w[ruby])
|
34
|
+
ir, planning, bindings, inputs, module_id = generate_artifacts(schema_path)
|
35
|
+
|
36
|
+
targets.each do |target|
|
37
|
+
pack = assemble_pack(module_id, ir, planning, bindings, inputs, [target], false)
|
38
|
+
|
39
|
+
filename = targets.size == 1 ? "pack.json" : "pack_#{target}.json"
|
40
|
+
pack_file = File.join(golden_dir, filename)
|
41
|
+
File.write(pack_file, canonical_json(pack))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def generate_artifacts(schema_path)
|
46
|
+
schema, = Kumi::Frontends.load(path: schema_path)
|
47
|
+
res = Kumi::Analyzer.analyze!(schema, side_tables: true)
|
48
|
+
|
49
|
+
irv2 = stringify_keys(res.state[:irv2]) or raise "No IRV2"
|
50
|
+
module_id = irv2["module"] || irv2["module_id"] || "kumi_module"
|
51
|
+
|
52
|
+
require_relative "../codegen/planning"
|
53
|
+
plan_bundle = Kumi::Codegen::Planning.from_ir(res.state[:irv2])
|
54
|
+
planning = Kumi::Codegen::Planning.to_json(plan_bundle)
|
55
|
+
|
56
|
+
bindings = stringify_keys(res.state[:binding_manifest] || {})
|
57
|
+
inputs = stringify_keys(res.state[:input_table] || {})
|
58
|
+
|
59
|
+
[irv2, planning, bindings, inputs, module_id]
|
60
|
+
end
|
61
|
+
|
62
|
+
def assemble_pack(module_id, ir, planning, bindings, inputs, _targets, include_ir)
|
63
|
+
plan_obj = planning["plan"] || planning
|
64
|
+
plan_declarations = plan_obj["declarations"] || {}
|
65
|
+
|
66
|
+
pack = {
|
67
|
+
"pack_version" => VERSION,
|
68
|
+
"module_id" => module_id,
|
69
|
+
"declarations" => extract_ops_by_decl_with_planning(ir, plan_declarations),
|
70
|
+
"inputs" => extract_inputs(inputs),
|
71
|
+
"bindings" => format_bindings_for_pack(bindings),
|
72
|
+
"capabilities" => { "layout" => "nested_array" }
|
73
|
+
}
|
74
|
+
pack["ir_debug"] = ir if include_ir
|
75
|
+
pack["hashes"] = compute_hashes(pack)
|
76
|
+
pack
|
77
|
+
end
|
78
|
+
|
79
|
+
def extract_ops_by_decl_with_planning(ir, plan_declarations)
|
80
|
+
declarations = ir["declarations"] || {}
|
81
|
+
declarations.keys.map do |name|
|
82
|
+
d = declarations[name]
|
83
|
+
ops = (d["operations"] || []).map do |op|
|
84
|
+
{
|
85
|
+
"id" => op["id"],
|
86
|
+
"op" => op["op"] || op["kind"],
|
87
|
+
"args" => op["args"] || [],
|
88
|
+
"attrs" => op["attrs"] || {}
|
89
|
+
}
|
90
|
+
end
|
91
|
+
|
92
|
+
# Start with IRV2 operations
|
93
|
+
result = { "name" => name, "operations" => ops }
|
94
|
+
result["result_op_id"] = d["result"] if d.key?("result")
|
95
|
+
result["axes"] = d["axes"] if d.key?("axes")
|
96
|
+
|
97
|
+
# Merge in planning metadata in sorted key order
|
98
|
+
plan_data = plan_declarations[name] || {}
|
99
|
+
plan_data.keys.sort.each do |key|
|
100
|
+
# Don't override IRV2 fields, but add planning fields
|
101
|
+
result[key] = plan_data[key] unless result.key?(key)
|
102
|
+
end
|
103
|
+
|
104
|
+
result
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def extract_ops_by_decl(ir)
|
109
|
+
declarations = ir["declarations"] || {}
|
110
|
+
declarations.keys.sort.map do |name|
|
111
|
+
d = declarations[name]
|
112
|
+
ops = (d["operations"] || []).map do |op|
|
113
|
+
{
|
114
|
+
"id" => op["id"],
|
115
|
+
"op" => op["op"] || op["kind"],
|
116
|
+
"args" => op["args"] || [],
|
117
|
+
"attrs" => op["attrs"] || {}
|
118
|
+
}
|
119
|
+
end
|
120
|
+
result = { "name" => name, "operations" => ops }
|
121
|
+
result["result_op_id"] = d["result"] if d.key?("result")
|
122
|
+
result["axes"] = d["axes"] if d.key?("axes")
|
123
|
+
result
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def extract_inputs(input_table)
|
128
|
+
# input_table is already in the new format with navigation_steps
|
129
|
+
input_table.map do |entry|
|
130
|
+
path_fqn = entry.path_fqn
|
131
|
+
navigation_steps = stringify_keys(entry.navigation_steps)
|
132
|
+
|
133
|
+
{
|
134
|
+
"name" => path_fqn,
|
135
|
+
"path_fqn" => path_fqn,
|
136
|
+
"axes" => entry.axes.map(&:to_s),
|
137
|
+
"dtype" => entry.dtype.to_s,
|
138
|
+
"accessor_name" => accessor_name_for(path_fqn),
|
139
|
+
"navigation_steps" => navigation_steps
|
140
|
+
}
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def format_bindings_for_pack(bindings)
|
145
|
+
return {} unless bindings.is_a?(Hash)
|
146
|
+
|
147
|
+
formatted = {}
|
148
|
+
target = bindings["target"]
|
149
|
+
kernels_array = bindings["kernels"].map do |kernel_data|
|
150
|
+
kernel_id = kernel_data["kernel_id"]
|
151
|
+
impl = kernel_data["impl"]
|
152
|
+
attrs = kernel_data["attrs"] || {}
|
153
|
+
|
154
|
+
# Extract the function name from kernel_id (e.g., "core.add:ruby:v1" -> "core.add")
|
155
|
+
fn_name = kernel_id.split(":").first
|
156
|
+
# Format the implementation as proper Ruby lambda
|
157
|
+
ruby_impl = format_ruby_lambda(impl)
|
158
|
+
|
159
|
+
{
|
160
|
+
"kernel_id" => fn_name,
|
161
|
+
"impl" => ruby_impl,
|
162
|
+
"attrs" => attrs
|
163
|
+
}
|
164
|
+
end
|
165
|
+
formatted[target] = { "kernels" => kernels_array }
|
166
|
+
|
167
|
+
formatted
|
168
|
+
end
|
169
|
+
|
170
|
+
def format_ruby_lambda(impl)
|
171
|
+
# Convert "(a, b)\n a + b" to "->(a, b) { a + b }"
|
172
|
+
lines = impl.strip.split("\n")
|
173
|
+
if lines.length >= 2
|
174
|
+
params = lines[0].strip.gsub(/^\(|\)$/, "") # Remove outer parentheses
|
175
|
+
body = lines[1..-1].map(&:strip).join("; ")
|
176
|
+
"->(#{params}) { #{body} }"
|
177
|
+
else
|
178
|
+
# Fallback for single line
|
179
|
+
"->(#{impl.strip})"
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
def stringify_keys(obj)
|
184
|
+
case obj
|
185
|
+
when Hash
|
186
|
+
obj.transform_keys(&:to_s).transform_values { |v| stringify_keys(v) }
|
187
|
+
when Array
|
188
|
+
obj.map { |v| stringify_keys(v) }
|
189
|
+
else
|
190
|
+
obj
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def accessor_name_for(name)
|
195
|
+
name.gsub(/[^a-zA-Z0-9_]/, "_").downcase
|
196
|
+
end
|
197
|
+
|
198
|
+
def write_json(file_path, data)
|
199
|
+
File.write(file_path, JSON.pretty_generate(data))
|
200
|
+
end
|
201
|
+
|
202
|
+
# Compute canonical section hashes (sorted-key JSON)
|
203
|
+
def compute_hashes(pack)
|
204
|
+
keys = %w[declarations inputs bindings]
|
205
|
+
keys << "ir_debug" if pack.key?("ir_debug")
|
206
|
+
keys.to_h { |k| [k, sha256(pack[k])] }
|
207
|
+
end
|
208
|
+
|
209
|
+
# Stable JSON for hashing
|
210
|
+
def canonical_json(obj)
|
211
|
+
case obj
|
212
|
+
when Hash
|
213
|
+
"{#{obj.keys.map(&:to_s).sort.map { |k| "\"#{k}\":#{canonical_json(obj[k])}" }.join(',')}}"
|
214
|
+
when Array
|
215
|
+
"[#{obj.map { |v| canonical_json(v) }.join(',')}]"
|
216
|
+
when String then JSON.generate(obj)
|
217
|
+
when Numeric then obj.to_s
|
218
|
+
when true, false then obj.to_s
|
219
|
+
when NilClass then "null"
|
220
|
+
else JSON.generate(obj)
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
def sha256(obj)
|
225
|
+
Digest::SHA256.hexdigest(canonical_json(obj))
|
226
|
+
end
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
data/lib/kumi/pack.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Kumi
|
4
|
+
module Pack
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def build(schema:, out_dir:, targets: %w[ruby], include_ir: false)
|
8
|
+
Builder.build(schema: schema, out_dir: out_dir, targets: targets, include_ir: include_ir)
|
9
|
+
end
|
10
|
+
|
11
|
+
def print(schema:, targets: %w[ruby], include_ir: false)
|
12
|
+
Builder.print(schema: schema, targets: targets, include_ir: include_ir)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "yaml"
|
4
|
+
|
5
|
+
module Kumi
|
6
|
+
module RegistryV2
|
7
|
+
module Loader
|
8
|
+
module_function
|
9
|
+
|
10
|
+
# { "core.mul" => Function(id: "core.mul", kind: :elementwise, params: [...]) }
|
11
|
+
def load_functions(dir, func_struct)
|
12
|
+
files = Dir.glob(File.join(dir, "**", "*.y{a,}ml")).sort
|
13
|
+
funcs = files.flat_map { |p| (YAML.load_file(p) || {}).fetch("functions", []) }
|
14
|
+
# funcs.each_with_object({}) do |h, acc|
|
15
|
+
# acc[h.fetch("id").to_s] = {
|
16
|
+
# kind: h.fetch("kind").to_s.to_sym,
|
17
|
+
# aliases: Array(h["aliases"]).map!(&:to_s),
|
18
|
+
# params: h.fetch("params")
|
19
|
+
# }
|
20
|
+
# end
|
21
|
+
funcs.each_with_object({}) do |h, acc|
|
22
|
+
f = func_struct.new(
|
23
|
+
id: h.fetch("id").to_s,
|
24
|
+
kind: h.fetch("kind").to_s.to_sym,
|
25
|
+
aliases: Array(h["aliases"]).map!(&:to_s),
|
26
|
+
params: h.fetch("params"),
|
27
|
+
dtype: h["dtype"],
|
28
|
+
expand: h["expand"],
|
29
|
+
options: symbolize_keys(h["options"] || {}),
|
30
|
+
folding_class_method: h["folding_class_method"],
|
31
|
+
reduction_strategy: h["reduction_strategy"]&.to_sym
|
32
|
+
)
|
33
|
+
raise "duplicate function id `#{f.id}`" if acc.key?(f.id)
|
34
|
+
|
35
|
+
acc[f.id] = f
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def symbolize_keys(h)
|
40
|
+
h.each_with_object({}) { |(k, v), out| out[k.to_sym] = v }
|
41
|
+
end
|
42
|
+
|
43
|
+
def deep_symbolize_keys(obj)
|
44
|
+
case obj
|
45
|
+
when Hash
|
46
|
+
obj.each_with_object({}) { |(k, v), out| out[k.to_sym] = deep_symbolize_keys(v) }
|
47
|
+
when Array
|
48
|
+
obj.map { |v| deep_symbolize_keys(v) }
|
49
|
+
else
|
50
|
+
obj
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# { ["core.mul", :ruby] => Kernel }
|
55
|
+
def load_kernels(root, kernel_struct)
|
56
|
+
targets = Dir.glob(File.join(root, "*")).select { |p| File.directory?(p) }.map { |p| File.basename(p).to_sym }
|
57
|
+
out = {}
|
58
|
+
targets.each do |t|
|
59
|
+
Dir.glob(File.join(root, t.to_s, "**", "*.y{a,}ml")).sort.each do |p|
|
60
|
+
(YAML.load_file(p) || {}).fetch("kernels", []).each do |h|
|
61
|
+
k = kernel_struct.new(
|
62
|
+
id: h.fetch("id"),
|
63
|
+
fn_id: h.fetch("fn").to_s,
|
64
|
+
target: t,
|
65
|
+
impl: h["impl"],
|
66
|
+
identity: h["identity"],
|
67
|
+
inline: h["inline"],
|
68
|
+
fold_inline: h["fold_inline"]
|
69
|
+
)
|
70
|
+
key = [k.fn_id, t]
|
71
|
+
raise "duplicate kernel for #{key}" if out.key?(key)
|
72
|
+
|
73
|
+
out[key] = k
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
out
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
require "digest"
|
5
|
+
require_relative "registry_v2/loader" # Assuming loader is in a sub-file
|
6
|
+
|
7
|
+
module Kumi
|
8
|
+
module RegistryV2
|
9
|
+
DEFAULT_FUNCTIONS_DIR = File.expand_path("../../data/functions", __dir__)
|
10
|
+
DEFAULT_KERNELS_DIR = File.expand_path("../../data/kernels", __dir__)
|
11
|
+
SELECT_ID = "__select__"
|
12
|
+
|
13
|
+
# --- NEW: Define the Function struct ---
|
14
|
+
Function = Struct.new(:id, :kind, :dtype, :aliases, :params, :options, :expand, :folding_class_method, :reduction_strategy,
|
15
|
+
keyword_init: true) do
|
16
|
+
def reduce? = kind == :reduce
|
17
|
+
def select? = id == SELECT_ID
|
18
|
+
def elementwise? = kind == :elementwise
|
19
|
+
|
20
|
+
def param_names
|
21
|
+
@param_names ||= params.map { |p| p["name"].to_sym }
|
22
|
+
end
|
23
|
+
|
24
|
+
def dtype_rule
|
25
|
+
@dtype_rule ||= Core::Functions::TypeRules.compile_dtype_rule(dtype, param_names)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
Kernel = Struct.new(:id, :fn_id, :target, :impl, :identity, :inline, :fold_inline, keyword_init: true)
|
30
|
+
|
31
|
+
class Instance
|
32
|
+
def initialize(functions_by_id, kernels_by_key)
|
33
|
+
@functions = functions_by_id # "core.mul" => Function<...>
|
34
|
+
@alias = build_alias(@functions) # "count" => "agg.count"
|
35
|
+
@kernels = kernels_by_key # [fn_id, target_sym] => Kernel
|
36
|
+
@by_id = @kernels.values.to_h { |k| [k.id, k] }
|
37
|
+
end
|
38
|
+
|
39
|
+
# -------- functions --------
|
40
|
+
def function(id)
|
41
|
+
@functions.fetch(resolve_function(id))
|
42
|
+
end
|
43
|
+
|
44
|
+
def resolve_function(id)
|
45
|
+
s = id.to_s
|
46
|
+
return s if @functions.key?(s)
|
47
|
+
|
48
|
+
@alias.fetch(s) do
|
49
|
+
raise "unknown function #{id}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def function_kind(id) = function(id).kind
|
54
|
+
def function_reduce?(id) = function(id).reduce?
|
55
|
+
def function_elementwise?(id) = function(id).elementwise?
|
56
|
+
def function_select?(id) = resolve_function(id) == SELECT_ID
|
57
|
+
|
58
|
+
# -------- kernels (no changes here) --------
|
59
|
+
def kernel_for(id, target:)
|
60
|
+
fid = resolve_function(id)
|
61
|
+
@kernels[[fid, target.to_sym]] or raise "no kernel for #{fid} on #{target}"
|
62
|
+
end
|
63
|
+
|
64
|
+
def kernel_id_for(id, target:)
|
65
|
+
fid = resolve_function(id)
|
66
|
+
k = @kernels[[fid, target.to_sym]] or raise "no kernel for #{fid} on #{target}"
|
67
|
+
k.id
|
68
|
+
end
|
69
|
+
|
70
|
+
def kernel_identity_for(id, dtype:, target:)
|
71
|
+
fid = resolve_function(id)
|
72
|
+
k = @kernels[[fid, target.to_sym]] or raise "no kernel for #{fid} on #{target}"
|
73
|
+
|
74
|
+
map = k.identity or raise "no identity for #{fid} on #{target}"
|
75
|
+
|
76
|
+
identity = map[dtype.to_s] || map["any"]
|
77
|
+
|
78
|
+
return identity if identity
|
79
|
+
|
80
|
+
raise "no identity for dtype #{dtype} on #{fid}"
|
81
|
+
end
|
82
|
+
|
83
|
+
def impl_for(kernel_id)
|
84
|
+
(@by_id[kernel_id] or raise "unknown kernel #{kernel_id}").impl
|
85
|
+
end
|
86
|
+
|
87
|
+
def registry_ref
|
88
|
+
# ... (implementation is fine, but needs to access struct attributes) ...
|
89
|
+
stable = {
|
90
|
+
kernels: @by_id.values.map do |k|
|
91
|
+
{ "id" => k.id, "fn" => k.fn_id, "target" => k.target.to_s, "impl" => k.impl }
|
92
|
+
end.sort_by { _1["id"] },
|
93
|
+
functions: @functions.transform_values do |f|
|
94
|
+
{ "kind" => f.kind.to_s, "aliases" => f.aliases, "params" => f.params }
|
95
|
+
end
|
96
|
+
}
|
97
|
+
"sha256:#{Digest::SHA256.hexdigest(JSON.generate(stable))}"
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
|
102
|
+
def build_alias(functions)
|
103
|
+
functions.values.each_with_object({}) do |func, acc|
|
104
|
+
func.aliases.each { |al| acc[al] = func.id }
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
module_function
|
110
|
+
|
111
|
+
def load(functions_dir: DEFAULT_FUNCTIONS_DIR, kernels_root: DEFAULT_KERNELS_DIR)
|
112
|
+
# Pass the new struct to the loader.
|
113
|
+
fn_map = Loader.load_functions(functions_dir, Function)
|
114
|
+
kn_map = Loader.load_kernels(kernels_root, Kernel)
|
115
|
+
Instance.new(fn_map, kn_map)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|