kumi 0.0.30 → 0.0.33
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/CHANGELOG.md +21 -1
- data/README.md +31 -99
- data/data/kernels/ruby/core/arithmetic.yaml +2 -2
- data/docs/COMPOSED_SCHEMAS.md +137 -0
- data/docs/SCHEMA_IMPORTS.md +275 -0
- data/docs/SYNTAX.md +48 -0
- data/golden/array_element/expected/schema_ruby.rb +2 -27
- data/golden/array_index/expected/nast.txt +6 -6
- data/golden/array_index/expected/schema_ruby.rb +4 -31
- data/golden/array_operations/expected/lir_06_const_prop.txt +4 -8
- data/golden/array_operations/expected/schema_javascript.mjs +4 -8
- data/golden/array_operations/expected/schema_ruby.rb +10 -43
- data/golden/cascade_logic/expected/lir_06_const_prop.txt +7 -14
- data/golden/cascade_logic/expected/schema_javascript.mjs +7 -14
- data/golden/cascade_logic/expected/schema_ruby.rb +11 -45
- data/golden/chained_fusion/expected/lir_06_const_prop.txt +8 -18
- data/golden/chained_fusion/expected/schema_javascript.mjs +8 -18
- data/golden/chained_fusion/expected/schema_ruby.rb +14 -53
- data/golden/decimal_explicit/expected/schema_ruby.rb +4 -31
- data/golden/element_arrays/expected/lir_06_const_prop.txt +5 -11
- data/golden/element_arrays/expected/schema_javascript.mjs +5 -11
- data/golden/element_arrays/expected/schema_ruby.rb +13 -50
- data/golden/empty_and_null_inputs/expected/schema_ruby.rb +4 -31
- data/golden/example_xpto/expected/ast.txt +23 -0
- data/golden/example_xpto/expected/input_plan.txt +1 -0
- data/golden/example_xpto/expected/lir_00_unoptimized.txt +16 -0
- data/golden/example_xpto/expected/lir_01_hoist_scalar_references.txt +16 -0
- data/golden/example_xpto/expected/lir_02_inlined.txt +16 -0
- data/golden/example_xpto/expected/lir_03_cse.txt +16 -0
- data/golden/example_xpto/expected/lir_04_1_loop_fusion.txt +16 -0
- data/golden/example_xpto/expected/lir_04_loop_invcm.txt +16 -0
- data/golden/example_xpto/expected/lir_06_const_prop.txt +13 -0
- data/golden/example_xpto/expected/nast.txt +17 -0
- data/golden/example_xpto/expected/schema_javascript.mjs +13 -0
- data/golden/example_xpto/expected/schema_ruby.rb +13 -0
- data/golden/example_xpto/expected/snast.txt +17 -0
- data/golden/example_xpto/expected.json +4 -0
- data/golden/example_xpto/input.json +3 -0
- data/golden/example_xpto/schema.kumi +8 -0
- data/golden/function_overload/expected/schema_ruby.rb +2 -27
- data/golden/game_of_life/expected/lir_06_const_prop.txt +236 -287
- data/golden/game_of_life/expected/schema_javascript.mjs +32 -39
- data/golden/game_of_life/expected/schema_ruby.rb +34 -66
- data/golden/hash_keys/expected/lir_06_const_prop.txt +4 -10
- data/golden/hash_keys/expected/schema_javascript.mjs +6 -12
- data/golden/hash_keys/expected/schema_ruby.rb +8 -39
- data/golden/hash_value/expected/lir_06_const_prop.txt +3 -6
- data/golden/hash_value/expected/schema_javascript.mjs +3 -6
- data/golden/hash_value/expected/schema_ruby.rb +7 -37
- data/golden/hierarchical_complex/expected/lir_06_const_prop.txt +9 -18
- data/golden/hierarchical_complex/expected/schema_javascript.mjs +9 -18
- data/golden/hierarchical_complex/expected/schema_ruby.rb +14 -51
- data/golden/inline_rename_scope_leak/expected/lir_06_const_prop.txt +2 -6
- data/golden/inline_rename_scope_leak/expected/schema_javascript.mjs +2 -6
- data/golden/inline_rename_scope_leak/expected/schema_ruby.rb +7 -39
- data/golden/input_reference/expected/schema_ruby.rb +6 -35
- data/golden/interleaved_fusion/expected/lir_06_const_prop.txt +6 -14
- data/golden/interleaved_fusion/expected/schema_javascript.mjs +6 -14
- data/golden/interleaved_fusion/expected/schema_ruby.rb +11 -47
- data/golden/let_inline/expected/lir_06_const_prop.txt +1 -2
- data/golden/let_inline/expected/schema_javascript.mjs +1 -2
- data/golden/let_inline/expected/schema_ruby.rb +3 -29
- data/golden/loop_fusion/expected/lir_06_const_prop.txt +4 -10
- data/golden/loop_fusion/expected/schema_javascript.mjs +4 -10
- data/golden/loop_fusion/expected/schema_ruby.rb +8 -41
- data/golden/min_reduce_scope/expected/lir_06_const_prop.txt +3 -6
- data/golden/min_reduce_scope/expected/schema_javascript.mjs +3 -6
- data/golden/min_reduce_scope/expected/schema_ruby.rb +8 -39
- data/golden/mixed_dimensions/expected/lir_06_const_prop.txt +1 -2
- data/golden/mixed_dimensions/expected/schema_javascript.mjs +1 -2
- data/golden/mixed_dimensions/expected/schema_ruby.rb +5 -33
- data/golden/multirank_hoisting/expected/lir_06_const_prop.txt +9 -18
- data/golden/multirank_hoisting/expected/schema_javascript.mjs +9 -18
- data/golden/multirank_hoisting/expected/schema_ruby.rb +16 -55
- data/golden/nested_hash/expected/lir_06_const_prop.txt +1 -2
- data/golden/nested_hash/expected/schema_javascript.mjs +1 -2
- data/golden/nested_hash/expected/schema_ruby.rb +3 -29
- data/golden/reduction_broadcast/expected/schema_ruby.rb +5 -33
- data/golden/roll/expected/lir_06_const_prop.txt +8 -15
- data/golden/roll/expected/schema_javascript.mjs +8 -15
- data/golden/roll/expected/schema_ruby.rb +13 -48
- data/golden/schema_imports_broadcasting_with_imports/expected/ast.txt +26 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/input_plan.txt +5 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_00_unoptimized.txt +20 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_01_hoist_scalar_references.txt +20 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_02_inlined.txt +22 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_03_cse.txt +21 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_04_1_loop_fusion.txt +21 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_04_loop_invcm.txt +21 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/lir_06_const_prop.txt +21 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/nast.txt +12 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/schema_javascript.mjs +22 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/schema_ruby.rb +24 -0
- data/golden/schema_imports_broadcasting_with_imports/expected/snast.txt +12 -0
- data/golden/schema_imports_broadcasting_with_imports/expected.json +4 -0
- data/golden/schema_imports_broadcasting_with_imports/input.json +7 -0
- data/golden/schema_imports_broadcasting_with_imports/schema.kumi +14 -0
- data/golden/schema_imports_complex_order_calc/expected/ast.txt +82 -0
- data/golden/schema_imports_complex_order_calc/expected/input_plan.txt +16 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_00_unoptimized.txt +94 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_01_hoist_scalar_references.txt +94 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_02_inlined.txt +187 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_03_cse.txt +131 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_04_1_loop_fusion.txt +131 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_04_loop_invcm.txt +131 -0
- data/golden/schema_imports_complex_order_calc/expected/lir_06_const_prop.txt +131 -0
- data/golden/schema_imports_complex_order_calc/expected/nast.txt +56 -0
- data/golden/schema_imports_complex_order_calc/expected/schema_javascript.mjs +147 -0
- data/golden/schema_imports_complex_order_calc/expected/schema_ruby.rb +149 -0
- data/golden/schema_imports_complex_order_calc/expected/snast.txt +56 -0
- data/golden/schema_imports_complex_order_calc/expected.json +12 -0
- data/golden/schema_imports_complex_order_calc/input.json +20 -0
- data/golden/schema_imports_complex_order_calc/schema.kumi +33 -0
- data/golden/schema_imports_composed_order/expected/ast.txt +33 -0
- data/golden/schema_imports_composed_order/expected/input_plan.txt +3 -0
- data/golden/schema_imports_composed_order/expected/lir_00_unoptimized.txt +25 -0
- data/golden/schema_imports_composed_order/expected/lir_01_hoist_scalar_references.txt +25 -0
- data/golden/schema_imports_composed_order/expected/lir_02_inlined.txt +33 -0
- data/golden/schema_imports_composed_order/expected/lir_03_cse.txt +33 -0
- data/golden/schema_imports_composed_order/expected/lir_04_1_loop_fusion.txt +33 -0
- data/golden/schema_imports_composed_order/expected/lir_04_loop_invcm.txt +33 -0
- data/golden/schema_imports_composed_order/expected/lir_06_const_prop.txt +33 -0
- data/golden/schema_imports_composed_order/expected/nast.txt +25 -0
- data/golden/schema_imports_composed_order/expected/schema_javascript.mjs +35 -0
- data/golden/schema_imports_composed_order/expected/schema_ruby.rb +33 -0
- data/golden/schema_imports_composed_order/expected/snast.txt +25 -0
- data/golden/schema_imports_composed_order/expected.json +6 -0
- data/golden/schema_imports_composed_order/input.json +5 -0
- data/golden/schema_imports_composed_order/schema.kumi +15 -0
- data/golden/schema_imports_discount_with_tax/expected/ast.txt +37 -0
- data/golden/schema_imports_discount_with_tax/expected/input_plan.txt +2 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_00_unoptimized.txt +30 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_01_hoist_scalar_references.txt +30 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_02_inlined.txt +37 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_03_cse.txt +34 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_04_1_loop_fusion.txt +34 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_04_loop_invcm.txt +34 -0
- data/golden/schema_imports_discount_with_tax/expected/lir_06_const_prop.txt +34 -0
- data/golden/schema_imports_discount_with_tax/expected/nast.txt +30 -0
- data/golden/schema_imports_discount_with_tax/expected/schema_javascript.mjs +37 -0
- data/golden/schema_imports_discount_with_tax/expected/schema_ruby.rb +34 -0
- data/golden/schema_imports_discount_with_tax/expected/snast.txt +30 -0
- data/golden/schema_imports_discount_with_tax/expected.json +7 -0
- data/golden/schema_imports_discount_with_tax/input.json +4 -0
- data/golden/schema_imports_discount_with_tax/schema.kumi +15 -0
- data/golden/schema_imports_line_items/expected/ast.txt +35 -0
- data/golden/schema_imports_line_items/expected/input_plan.txt +8 -0
- data/golden/schema_imports_line_items/expected/lir_00_unoptimized.txt +19 -0
- data/golden/schema_imports_line_items/expected/lir_01_hoist_scalar_references.txt +19 -0
- data/golden/schema_imports_line_items/expected/lir_02_inlined.txt +24 -0
- data/golden/schema_imports_line_items/expected/lir_03_cse.txt +22 -0
- data/golden/schema_imports_line_items/expected/lir_04_1_loop_fusion.txt +22 -0
- data/golden/schema_imports_line_items/expected/lir_04_loop_invcm.txt +22 -0
- data/golden/schema_imports_line_items/expected/lir_06_const_prop.txt +22 -0
- data/golden/schema_imports_line_items/expected/nast.txt +19 -0
- data/golden/schema_imports_line_items/expected/schema_javascript.mjs +23 -0
- data/golden/schema_imports_line_items/expected/schema_ruby.rb +22 -0
- data/golden/schema_imports_line_items/expected/snast.txt +19 -0
- data/golden/schema_imports_line_items/expected.json +5 -0
- data/golden/schema_imports_line_items/input.json +13 -0
- data/golden/schema_imports_line_items/schema.kumi +17 -0
- data/golden/schema_imports_multiple/expected/ast.txt +35 -0
- data/golden/schema_imports_multiple/expected/input_plan.txt +2 -0
- data/golden/schema_imports_multiple/expected/lir_00_unoptimized.txt +29 -0
- data/golden/schema_imports_multiple/expected/lir_01_hoist_scalar_references.txt +29 -0
- data/golden/schema_imports_multiple/expected/lir_02_inlined.txt +41 -0
- data/golden/schema_imports_multiple/expected/lir_03_cse.txt +37 -0
- data/golden/schema_imports_multiple/expected/lir_04_1_loop_fusion.txt +37 -0
- data/golden/schema_imports_multiple/expected/lir_04_loop_invcm.txt +37 -0
- data/golden/schema_imports_multiple/expected/lir_06_const_prop.txt +37 -0
- data/golden/schema_imports_multiple/expected/nast.txt +28 -0
- data/golden/schema_imports_multiple/expected/schema_javascript.mjs +40 -0
- data/golden/schema_imports_multiple/expected/schema_ruby.rb +37 -0
- data/golden/schema_imports_multiple/expected/snast.txt +28 -0
- data/golden/schema_imports_multiple/expected.json +7 -0
- data/golden/schema_imports_multiple/input.json +4 -0
- data/golden/schema_imports_multiple/schema.kumi +15 -0
- data/golden/schema_imports_nested_expressions/expected/ast.txt +31 -0
- data/golden/schema_imports_nested_expressions/expected/input_plan.txt +3 -0
- data/golden/schema_imports_nested_expressions/expected/lir_00_unoptimized.txt +22 -0
- data/golden/schema_imports_nested_expressions/expected/lir_01_hoist_scalar_references.txt +22 -0
- data/golden/schema_imports_nested_expressions/expected/lir_02_inlined.txt +32 -0
- data/golden/schema_imports_nested_expressions/expected/lir_03_cse.txt +32 -0
- data/golden/schema_imports_nested_expressions/expected/lir_04_1_loop_fusion.txt +32 -0
- data/golden/schema_imports_nested_expressions/expected/lir_04_loop_invcm.txt +32 -0
- data/golden/schema_imports_nested_expressions/expected/lir_06_const_prop.txt +28 -0
- data/golden/schema_imports_nested_expressions/expected/nast.txt +23 -0
- data/golden/schema_imports_nested_expressions/expected/schema_javascript.mjs +29 -0
- data/golden/schema_imports_nested_expressions/expected/schema_ruby.rb +28 -0
- data/golden/schema_imports_nested_expressions/expected/snast.txt +23 -0
- data/golden/schema_imports_nested_expressions/expected.json +5 -0
- data/golden/schema_imports_nested_expressions/input.json +5 -0
- data/golden/schema_imports_nested_expressions/schema.kumi +13 -0
- data/golden/schema_imports_nested_with_reductions/expected/ast.txt +47 -0
- data/golden/schema_imports_nested_with_reductions/expected/input_plan.txt +12 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_00_unoptimized.txt +31 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_01_hoist_scalar_references.txt +31 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_02_inlined.txt +58 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_03_cse.txt +49 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_04_1_loop_fusion.txt +51 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_04_loop_invcm.txt +49 -0
- data/golden/schema_imports_nested_with_reductions/expected/lir_06_const_prop.txt +49 -0
- data/golden/schema_imports_nested_with_reductions/expected/nast.txt +23 -0
- data/golden/schema_imports_nested_with_reductions/expected/schema_javascript.mjs +49 -0
- data/golden/schema_imports_nested_with_reductions/expected/schema_ruby.rb +52 -0
- data/golden/schema_imports_nested_with_reductions/expected/snast.txt +23 -0
- data/golden/schema_imports_nested_with_reductions/expected.json +6 -0
- data/golden/schema_imports_nested_with_reductions/input.json +16 -0
- data/golden/schema_imports_nested_with_reductions/schema.kumi +23 -0
- data/golden/schema_imports_with_imports/expected/ast.txt +19 -0
- data/golden/schema_imports_with_imports/expected/input_plan.txt +1 -0
- data/golden/schema_imports_with_imports/expected/lir_00_unoptimized.txt +13 -0
- data/golden/schema_imports_with_imports/expected/lir_01_hoist_scalar_references.txt +13 -0
- data/golden/schema_imports_with_imports/expected/lir_02_inlined.txt +14 -0
- data/golden/schema_imports_with_imports/expected/lir_03_cse.txt +13 -0
- data/golden/schema_imports_with_imports/expected/lir_04_1_loop_fusion.txt +13 -0
- data/golden/schema_imports_with_imports/expected/lir_04_loop_invcm.txt +13 -0
- data/golden/schema_imports_with_imports/expected/lir_06_const_prop.txt +13 -0
- data/golden/schema_imports_with_imports/expected/nast.txt +13 -0
- data/golden/schema_imports_with_imports/expected/schema_javascript.mjs +13 -0
- data/golden/schema_imports_with_imports/expected/schema_ruby.rb +13 -0
- data/golden/schema_imports_with_imports/expected/snast.txt +13 -0
- data/golden/schema_imports_with_imports/expected.json +4 -0
- data/golden/schema_imports_with_imports/input.json +3 -0
- data/golden/schema_imports_with_imports/schema.kumi +10 -0
- data/golden/shift/expected/lir_06_const_prop.txt +18 -30
- data/golden/shift/expected/schema_javascript.mjs +18 -30
- data/golden/shift/expected/schema_ruby.rb +25 -67
- data/golden/shift_2d/expected/lir_06_const_prop.txt +36 -60
- data/golden/shift_2d/expected/schema_javascript.mjs +36 -60
- data/golden/shift_2d/expected/schema_ruby.rb +49 -109
- data/golden/simple_math/expected/lir_06_const_prop.txt +3 -6
- data/golden/simple_math/expected/schema_javascript.mjs +3 -6
- data/golden/simple_math/expected/schema_ruby.rb +8 -39
- data/golden/streaming_basics/expected/lir_06_const_prop.txt +6 -12
- data/golden/streaming_basics/expected/schema_javascript.mjs +6 -12
- data/golden/streaming_basics/expected/schema_ruby.rb +14 -51
- data/golden/tuples/expected/lir_06_const_prop.txt +5 -22
- data/golden/tuples/expected/schema_javascript.mjs +5 -22
- data/golden/tuples/expected/schema_ruby.rb +11 -57
- data/golden/tuples_and_arrays/expected/lir_06_const_prop.txt +4 -8
- data/golden/tuples_and_arrays/expected/schema_javascript.mjs +4 -8
- data/golden/tuples_and_arrays/expected/schema_ruby.rb +9 -41
- data/golden/us_tax_2024/expected/lir_06_const_prop.txt +94 -171
- data/golden/us_tax_2024/expected/schema_javascript.mjs +13 -21
- data/golden/us_tax_2024/expected/schema_ruby.rb +15 -48
- data/golden/with_constants/expected/lir_06_const_prop.txt +3 -8
- data/golden/with_constants/expected/schema_javascript.mjs +3 -8
- data/golden/with_constants/expected/schema_ruby.rb +5 -35
- data/lib/kumi/analyzer.rb +8 -7
- data/lib/kumi/configuration.rb +7 -6
- data/lib/kumi/core/analyzer/passes/attach_anchors_pass.rb +1 -1
- data/lib/kumi/core/analyzer/passes/attach_terminal_info_pass.rb +1 -1
- data/lib/kumi/core/analyzer/passes/codegen/js/declaration_emitter.rb +20 -0
- data/lib/kumi/core/analyzer/passes/codegen/ruby/declaration_emitter.rb +16 -7
- data/lib/kumi/core/analyzer/passes/codegen/ruby/output_buffer.rb +3 -35
- data/lib/kumi/core/analyzer/passes/dependency_resolver.rb +6 -0
- data/lib/kumi/core/analyzer/passes/import_analysis_pass.rb +90 -0
- data/lib/kumi/core/analyzer/passes/lir/constant_propagation_pass.rb +77 -36
- data/lib/kumi/core/analyzer/passes/lir/lower_pass.rb +26 -11
- data/lib/kumi/core/analyzer/passes/name_indexer.rb +20 -2
- data/lib/kumi/core/analyzer/passes/nast_dimensional_analyzer_pass.rb +44 -0
- data/lib/kumi/core/analyzer/passes/normalize_to_nast_pass.rb +30 -0
- data/lib/kumi/core/analyzer/passes/semantic_constraint_validator.rb +5 -1
- data/lib/kumi/core/analyzer/passes/snast_pass.rb +15 -0
- data/lib/kumi/core/lir/build.rb +27 -0
- data/lib/kumi/core/lir/peephole.rb +164 -0
- data/lib/kumi/core/nast.rb +16 -0
- data/lib/kumi/core/ruby_parser/build_context.rb +3 -1
- data/lib/kumi/core/ruby_parser/parser.rb +1 -1
- data/lib/kumi/core/ruby_parser/schema_builder.rb +33 -3
- data/lib/kumi/dev/golden/result.rb +9 -3
- data/lib/kumi/dev/golden/runtime_test.rb +16 -1
- data/lib/kumi/dev/golden.rb +18 -20
- data/lib/kumi/dev/golden_schema_modules.rb +8 -0
- data/lib/kumi/dev/golden_schema_wrapper.rb +116 -0
- data/lib/kumi/dev/support/kumi_runner.mjs +18 -0
- data/lib/kumi/schema.rb +44 -2
- data/lib/kumi/support/lir_printer.rb +21 -5
- data/lib/kumi/support/nast_printer.rb +11 -0
- data/lib/kumi/support/s_expression_printer.rb +9 -0
- data/lib/kumi/support/snast_printer.rb +6 -0
- data/lib/kumi/syntax/import_call.rb +11 -0
- data/lib/kumi/syntax/import_declaration.rb +11 -0
- data/lib/kumi/syntax/root.rb +2 -2
- data/lib/kumi/test_shared_schemas/compound.rb +21 -0
- data/lib/kumi/test_shared_schemas/discount.rb +19 -0
- data/lib/kumi/test_shared_schemas/price.rb +19 -0
- data/lib/kumi/test_shared_schemas/subtotal.rb +22 -0
- data/lib/kumi/test_shared_schemas/tax.rb +18 -0
- data/lib/kumi/version.rb +1 -1
- data/lib/kumi.rb +19 -4
- metadata +176 -3
|
@@ -2,47 +2,40 @@
|
|
|
2
2
|
(Declaration shift_right_zero
|
|
3
3
|
%t1 = load_input "cells" :: array
|
|
4
4
|
%t4 = length %t1 :: integer
|
|
5
|
-
%
|
|
6
|
-
%t7 = const 0 :: integer
|
|
7
|
-
%t12 = call core.sub(%t4, %t5) :: integer
|
|
5
|
+
%t12 = call core.sub(%t4, 1) :: integer
|
|
8
6
|
loop cells id=L1 in %t1 as el=%cells_el_2, idx=%cells_i_3
|
|
9
|
-
%t6 = call core.sub(%cells_i_3,
|
|
10
|
-
%t8 = call core.gte(%t6,
|
|
7
|
+
%t6 = call core.sub(%cells_i_3, 1) :: integer
|
|
8
|
+
%t8 = call core.gte(%t6, 0) :: boolean
|
|
11
9
|
%t9 = call core.lt(%t6, %t4) :: boolean
|
|
12
|
-
%t14 = call core.clamp(%t6,
|
|
10
|
+
%t14 = call core.clamp(%t6, 0, %t12) :: integer
|
|
13
11
|
%t10 = call core.and(%t8, %t9) :: boolean
|
|
14
12
|
%t15 = gather %t1, %t14 :: integer
|
|
15
|
-
%t17 = select %t10, %t15,
|
|
13
|
+
%t17 = select %t10, %t15, 0 :: integer
|
|
16
14
|
yield %t17
|
|
17
15
|
end_loop
|
|
18
16
|
)
|
|
19
17
|
(Declaration shift_left_zero
|
|
20
18
|
%t18 = load_input "cells" :: array
|
|
21
19
|
%t21 = length %t18 :: integer
|
|
22
|
-
%
|
|
23
|
-
%t24 = const 0 :: integer
|
|
24
|
-
%t28 = const 1 :: integer
|
|
25
|
-
%t29 = call core.sub(%t21, %t28) :: integer
|
|
20
|
+
%t29 = call core.sub(%t21, 1) :: integer
|
|
26
21
|
loop cells id=L2 in %t18 as el=%cells_el_19, idx=%cells_i_20
|
|
27
|
-
%t23 = call core.sub(%cells_i_20,
|
|
28
|
-
%t25 = call core.gte(%t23,
|
|
22
|
+
%t23 = call core.sub(%cells_i_20, -1) :: integer
|
|
23
|
+
%t25 = call core.gte(%t23, 0) :: boolean
|
|
29
24
|
%t26 = call core.lt(%t23, %t21) :: boolean
|
|
30
|
-
%t31 = call core.clamp(%t23,
|
|
25
|
+
%t31 = call core.clamp(%t23, 0, %t29) :: integer
|
|
31
26
|
%t27 = call core.and(%t25, %t26) :: boolean
|
|
32
27
|
%t32 = gather %t18, %t31 :: integer
|
|
33
|
-
%t34 = select %t27, %t32,
|
|
28
|
+
%t34 = select %t27, %t32, 0 :: integer
|
|
34
29
|
yield %t34
|
|
35
30
|
end_loop
|
|
36
31
|
)
|
|
37
32
|
(Declaration shift_right_clamp
|
|
38
33
|
%t35 = load_input "cells" :: array
|
|
39
34
|
%t38 = length %t35 :: integer
|
|
40
|
-
%
|
|
41
|
-
%t43 = const 0 :: integer
|
|
42
|
-
%t42 = call core.sub(%t38, %t39) :: integer
|
|
35
|
+
%t42 = call core.sub(%t38, 1) :: integer
|
|
43
36
|
loop cells id=L3 in %t35 as el=%cells_el_36, idx=%cells_i_37
|
|
44
|
-
%t40 = call core.sub(%cells_i_37,
|
|
45
|
-
%t44 = call core.clamp(%t40,
|
|
37
|
+
%t40 = call core.sub(%cells_i_37, 1) :: integer
|
|
38
|
+
%t44 = call core.clamp(%t40, 0, %t42) :: integer
|
|
46
39
|
%t45 = gather %t35, %t44 :: integer
|
|
47
40
|
yield %t45
|
|
48
41
|
end_loop
|
|
@@ -50,13 +43,10 @@
|
|
|
50
43
|
(Declaration shift_left_clamp
|
|
51
44
|
%t46 = load_input "cells" :: array
|
|
52
45
|
%t49 = length %t46 :: integer
|
|
53
|
-
%
|
|
54
|
-
%t52 = const 1 :: integer
|
|
55
|
-
%t54 = const 0 :: integer
|
|
56
|
-
%t53 = call core.sub(%t49, %t52) :: integer
|
|
46
|
+
%t53 = call core.sub(%t49, 1) :: integer
|
|
57
47
|
loop cells id=L4 in %t46 as el=%cells_el_47, idx=%cells_i_48
|
|
58
|
-
%t51 = call core.sub(%cells_i_48,
|
|
59
|
-
%t55 = call core.clamp(%t51,
|
|
48
|
+
%t51 = call core.sub(%cells_i_48, -1) :: integer
|
|
49
|
+
%t55 = call core.clamp(%t51, 0, %t53) :: integer
|
|
60
50
|
%t56 = gather %t46, %t55 :: integer
|
|
61
51
|
yield %t56
|
|
62
52
|
end_loop
|
|
@@ -64,9 +54,8 @@
|
|
|
64
54
|
(Declaration shift_right_wrap
|
|
65
55
|
%t57 = load_input "cells" :: array
|
|
66
56
|
%t60 = length %t57 :: integer
|
|
67
|
-
%t61 = const 1 :: integer
|
|
68
57
|
loop cells id=L5 in %t57 as el=%cells_el_58, idx=%cells_i_59
|
|
69
|
-
%t62 = call core.sub(%cells_i_59,
|
|
58
|
+
%t62 = call core.sub(%cells_i_59, 1) :: integer
|
|
70
59
|
%t63 = call core.mod(%t62, %t60) :: integer
|
|
71
60
|
%t64 = call core.add(%t63, %t60) :: integer
|
|
72
61
|
%t65 = call core.mod(%t64, %t60) :: integer
|
|
@@ -77,9 +66,8 @@
|
|
|
77
66
|
(Declaration shift_left_wrap
|
|
78
67
|
%t67 = load_input "cells" :: array
|
|
79
68
|
%t70 = length %t67 :: integer
|
|
80
|
-
%t71 = const -1 :: integer
|
|
81
69
|
loop cells id=L6 in %t67 as el=%cells_el_68, idx=%cells_i_69
|
|
82
|
-
%t72 = call core.sub(%cells_i_69,
|
|
70
|
+
%t72 = call core.sub(%cells_i_69, -1) :: integer
|
|
83
71
|
%t73 = call core.mod(%t72, %t70) :: integer
|
|
84
72
|
%t74 = call core.add(%t73, %t70) :: integer
|
|
85
73
|
%t75 = call core.mod(%t74, %t70) :: integer
|
|
@@ -2,17 +2,15 @@ export function _shift_right_zero(input) {
|
|
|
2
2
|
let out = [];
|
|
3
3
|
let t1 = input["cells"];
|
|
4
4
|
let t4 = t1.length;
|
|
5
|
-
|
|
6
|
-
const t7 = 0;
|
|
7
|
-
let t12 = t4 - t5;
|
|
5
|
+
let t12 = t4 - 1;
|
|
8
6
|
t1.forEach((cells_el_2, cells_i_3) => {
|
|
9
|
-
let t6 = cells_i_3 -
|
|
10
|
-
let t8 = t6 >=
|
|
7
|
+
let t6 = cells_i_3 - 1;
|
|
8
|
+
let t8 = t6 >= 0;
|
|
11
9
|
let t9 = t6 < t4;
|
|
12
|
-
let t14 = Math.min(Math.max(t6,
|
|
10
|
+
let t14 = Math.min(Math.max(t6, 0), t12);
|
|
13
11
|
let t10 = t8 && t9;
|
|
14
12
|
let t15 = t1[t14];
|
|
15
|
-
let t17 = t10 ? t15 :
|
|
13
|
+
let t17 = t10 ? t15 : 0;
|
|
16
14
|
out.push(t17);
|
|
17
15
|
});
|
|
18
16
|
return out;
|
|
@@ -22,18 +20,15 @@ export function _shift_left_zero(input) {
|
|
|
22
20
|
let out = [];
|
|
23
21
|
let t18 = input["cells"];
|
|
24
22
|
let t21 = t18.length;
|
|
25
|
-
|
|
26
|
-
const t24 = 0;
|
|
27
|
-
const t28 = 1;
|
|
28
|
-
let t29 = t21 - t28;
|
|
23
|
+
let t29 = t21 - 1;
|
|
29
24
|
t18.forEach((cells_el_19, cells_i_20) => {
|
|
30
|
-
let t23 = cells_i_20 -
|
|
31
|
-
let t25 = t23 >=
|
|
25
|
+
let t23 = cells_i_20 - -1;
|
|
26
|
+
let t25 = t23 >= 0;
|
|
32
27
|
let t26 = t23 < t21;
|
|
33
|
-
let t31 = Math.min(Math.max(t23,
|
|
28
|
+
let t31 = Math.min(Math.max(t23, 0), t29);
|
|
34
29
|
let t27 = t25 && t26;
|
|
35
30
|
let t32 = t18[t31];
|
|
36
|
-
let t34 = t27 ? t32 :
|
|
31
|
+
let t34 = t27 ? t32 : 0;
|
|
37
32
|
out.push(t34);
|
|
38
33
|
});
|
|
39
34
|
return out;
|
|
@@ -43,12 +38,10 @@ export function _shift_right_clamp(input) {
|
|
|
43
38
|
let out = [];
|
|
44
39
|
let t35 = input["cells"];
|
|
45
40
|
let t38 = t35.length;
|
|
46
|
-
|
|
47
|
-
const t43 = 0;
|
|
48
|
-
let t42 = t38 - t39;
|
|
41
|
+
let t42 = t38 - 1;
|
|
49
42
|
t35.forEach((cells_el_36, cells_i_37) => {
|
|
50
|
-
let t40 = cells_i_37 -
|
|
51
|
-
let t44 = Math.min(Math.max(t40,
|
|
43
|
+
let t40 = cells_i_37 - 1;
|
|
44
|
+
let t44 = Math.min(Math.max(t40, 0), t42);
|
|
52
45
|
let t45 = t35[t44];
|
|
53
46
|
out.push(t45);
|
|
54
47
|
});
|
|
@@ -59,13 +52,10 @@ export function _shift_left_clamp(input) {
|
|
|
59
52
|
let out = [];
|
|
60
53
|
let t46 = input["cells"];
|
|
61
54
|
let t49 = t46.length;
|
|
62
|
-
|
|
63
|
-
const t52 = 1;
|
|
64
|
-
const t54 = 0;
|
|
65
|
-
let t53 = t49 - t52;
|
|
55
|
+
let t53 = t49 - 1;
|
|
66
56
|
t46.forEach((cells_el_47, cells_i_48) => {
|
|
67
|
-
let t51 = cells_i_48 -
|
|
68
|
-
let t55 = Math.min(Math.max(t51,
|
|
57
|
+
let t51 = cells_i_48 - -1;
|
|
58
|
+
let t55 = Math.min(Math.max(t51, 0), t53);
|
|
69
59
|
let t56 = t46[t55];
|
|
70
60
|
out.push(t56);
|
|
71
61
|
});
|
|
@@ -76,9 +66,8 @@ export function _shift_right_wrap(input) {
|
|
|
76
66
|
let out = [];
|
|
77
67
|
let t57 = input["cells"];
|
|
78
68
|
let t60 = t57.length;
|
|
79
|
-
const t61 = 1;
|
|
80
69
|
t57.forEach((cells_el_58, cells_i_59) => {
|
|
81
|
-
let t62 = cells_i_59 -
|
|
70
|
+
let t62 = cells_i_59 - 1;
|
|
82
71
|
let t63 = ((t62 % t60) + t60) % t60;
|
|
83
72
|
let t64 = t63 + t60;
|
|
84
73
|
let t65 = ((t64 % t60) + t60) % t60;
|
|
@@ -92,9 +81,8 @@ export function _shift_left_wrap(input) {
|
|
|
92
81
|
let out = [];
|
|
93
82
|
let t67 = input["cells"];
|
|
94
83
|
let t70 = t67.length;
|
|
95
|
-
const t71 = -1;
|
|
96
84
|
t67.forEach((cells_el_68, cells_i_69) => {
|
|
97
|
-
let t72 = cells_i_69 -
|
|
85
|
+
let t72 = cells_i_69 - -1;
|
|
98
86
|
let t73 = ((t72 % t70) + t70) % t70;
|
|
99
87
|
let t74 = t73 + t70;
|
|
100
88
|
let t75 = ((t74 % t70) + t70) % t70;
|
|
@@ -1,116 +1,75 @@
|
|
|
1
1
|
# Autogenerated by Kumi Codegen
|
|
2
|
-
module Kumi::Compiled::
|
|
3
|
-
def self.
|
|
4
|
-
instance = Object.new
|
|
5
|
-
instance.extend(self)
|
|
6
|
-
instance.instance_variable_set(:@input, input_data)
|
|
7
|
-
instance
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def self.__kumi_executable__
|
|
11
|
-
instance = Object.new
|
|
12
|
-
instance.extend(self)
|
|
13
|
-
instance
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def update(input_data)
|
|
17
|
-
@input = @input.merge(input_data)
|
|
18
|
-
self
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def [](name)
|
|
22
|
-
case name
|
|
23
|
-
when :shift_right_zero then _shift_right_zero
|
|
24
|
-
when :shift_left_zero then _shift_left_zero
|
|
25
|
-
when :shift_right_clamp then _shift_right_clamp
|
|
26
|
-
when :shift_left_clamp then _shift_left_clamp
|
|
27
|
-
when :shift_right_wrap then _shift_right_wrap
|
|
28
|
-
when :shift_left_wrap then _shift_left_wrap
|
|
29
|
-
else raise KeyError, "Unknown declaration"
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def _shift_right_zero(input = @input)
|
|
2
|
+
module Kumi::Compiled::KUMI_2b7190617d4ca7038571fc2106e31ea3ee978a4e39607c21cf922cf718c95e73
|
|
3
|
+
def self._shift_right_zero(input)
|
|
34
4
|
out = []
|
|
35
5
|
t1 = input["cells"] || input[:cells]
|
|
36
6
|
t4 = t1.length
|
|
37
|
-
|
|
38
|
-
t7 = 0
|
|
39
|
-
t12 = t4 - t5
|
|
7
|
+
t12 = t4 - 1
|
|
40
8
|
t1.each_with_index do |cells_el_2, cells_i_3|
|
|
41
|
-
t6 = cells_i_3 -
|
|
42
|
-
t8 = t6 >=
|
|
9
|
+
t6 = cells_i_3 - 1
|
|
10
|
+
t8 = t6 >= 0
|
|
43
11
|
t9 = t6 < t4
|
|
44
|
-
t14 =
|
|
12
|
+
t14 = t6.clamp(0, t12)
|
|
45
13
|
t10 = t8 && t9
|
|
46
14
|
t15 = t1[t14]
|
|
47
|
-
t17 = t10 ? t15 :
|
|
15
|
+
t17 = t10 ? t15 : 0
|
|
48
16
|
out << t17
|
|
49
17
|
end
|
|
50
18
|
out
|
|
51
19
|
end
|
|
52
20
|
|
|
53
|
-
def _shift_left_zero(input
|
|
21
|
+
def self._shift_left_zero(input)
|
|
54
22
|
out = []
|
|
55
23
|
t18 = input["cells"] || input[:cells]
|
|
56
24
|
t21 = t18.length
|
|
57
|
-
|
|
58
|
-
t24 = 0
|
|
59
|
-
t28 = 1
|
|
60
|
-
t29 = t21 - t28
|
|
25
|
+
t29 = t21 - 1
|
|
61
26
|
t18.each_with_index do |cells_el_19, cells_i_20|
|
|
62
|
-
t23 = cells_i_20 -
|
|
63
|
-
t25 = t23 >=
|
|
27
|
+
t23 = cells_i_20 - -1
|
|
28
|
+
t25 = t23 >= 0
|
|
64
29
|
t26 = t23 < t21
|
|
65
|
-
t31 =
|
|
30
|
+
t31 = t23.clamp(0, t29)
|
|
66
31
|
t27 = t25 && t26
|
|
67
32
|
t32 = t18[t31]
|
|
68
|
-
t34 = t27 ? t32 :
|
|
33
|
+
t34 = t27 ? t32 : 0
|
|
69
34
|
out << t34
|
|
70
35
|
end
|
|
71
36
|
out
|
|
72
37
|
end
|
|
73
38
|
|
|
74
|
-
def _shift_right_clamp(input
|
|
39
|
+
def self._shift_right_clamp(input)
|
|
75
40
|
out = []
|
|
76
41
|
t35 = input["cells"] || input[:cells]
|
|
77
42
|
t38 = t35.length
|
|
78
|
-
|
|
79
|
-
t43 = 0
|
|
80
|
-
t42 = t38 - t39
|
|
43
|
+
t42 = t38 - 1
|
|
81
44
|
t35.each_with_index do |cells_el_36, cells_i_37|
|
|
82
|
-
t40 = cells_i_37 -
|
|
83
|
-
t44 =
|
|
45
|
+
t40 = cells_i_37 - 1
|
|
46
|
+
t44 = t40.clamp(0, t42)
|
|
84
47
|
t45 = t35[t44]
|
|
85
48
|
out << t45
|
|
86
49
|
end
|
|
87
50
|
out
|
|
88
51
|
end
|
|
89
52
|
|
|
90
|
-
def _shift_left_clamp(input
|
|
53
|
+
def self._shift_left_clamp(input)
|
|
91
54
|
out = []
|
|
92
55
|
t46 = input["cells"] || input[:cells]
|
|
93
56
|
t49 = t46.length
|
|
94
|
-
|
|
95
|
-
t52 = 1
|
|
96
|
-
t54 = 0
|
|
97
|
-
t53 = t49 - t52
|
|
57
|
+
t53 = t49 - 1
|
|
98
58
|
t46.each_with_index do |cells_el_47, cells_i_48|
|
|
99
|
-
t51 = cells_i_48 -
|
|
100
|
-
t55 =
|
|
59
|
+
t51 = cells_i_48 - -1
|
|
60
|
+
t55 = t51.clamp(0, t53)
|
|
101
61
|
t56 = t46[t55]
|
|
102
62
|
out << t56
|
|
103
63
|
end
|
|
104
64
|
out
|
|
105
65
|
end
|
|
106
66
|
|
|
107
|
-
def _shift_right_wrap(input
|
|
67
|
+
def self._shift_right_wrap(input)
|
|
108
68
|
out = []
|
|
109
69
|
t57 = input["cells"] || input[:cells]
|
|
110
70
|
t60 = t57.length
|
|
111
|
-
t61 = 1
|
|
112
71
|
t57.each_with_index do |cells_el_58, cells_i_59|
|
|
113
|
-
t62 = cells_i_59 -
|
|
72
|
+
t62 = cells_i_59 - 1
|
|
114
73
|
t63 = t62 % t60
|
|
115
74
|
t64 = t63 + t60
|
|
116
75
|
t65 = t64 % t60
|
|
@@ -120,13 +79,12 @@ module Kumi::Compiled::KUMI_d17fb0388f7014e59c7e9a892d540e54a949f21eb86a9e8e8a39
|
|
|
120
79
|
out
|
|
121
80
|
end
|
|
122
81
|
|
|
123
|
-
def _shift_left_wrap(input
|
|
82
|
+
def self._shift_left_wrap(input)
|
|
124
83
|
out = []
|
|
125
84
|
t67 = input["cells"] || input[:cells]
|
|
126
85
|
t70 = t67.length
|
|
127
|
-
t71 = -1
|
|
128
86
|
t67.each_with_index do |cells_el_68, cells_i_69|
|
|
129
|
-
t72 = cells_i_69 -
|
|
87
|
+
t72 = cells_i_69 - -1
|
|
130
88
|
t73 = t72 % t70
|
|
131
89
|
t74 = t73 + t70
|
|
132
90
|
t75 = t74 % t70
|
|
@@ -2,23 +2,21 @@
|
|
|
2
2
|
(Declaration shift_cols_right_zero
|
|
3
3
|
%t1 = load_input "rows" :: array
|
|
4
4
|
%t6 = length %t1 :: integer
|
|
5
|
-
%t12 = const 1 :: integer
|
|
6
|
-
%t14 = const 0 :: integer
|
|
7
5
|
loop rows id=L1 in %t1 as el=%rows_el_2, idx=%rows_i_3
|
|
8
6
|
%t7 = call core.mod(%rows_i_3, %t6) :: integer
|
|
9
7
|
%t8 = call core.add(%t7, %t6) :: integer
|
|
10
8
|
%t9 = call core.mod(%t8, %t6) :: integer
|
|
11
9
|
%t10 = gather %t1, %t9 :: any
|
|
12
10
|
%t11 = length %t10 :: integer
|
|
13
|
-
%t19 = call core.sub(%t11,
|
|
11
|
+
%t19 = call core.sub(%t11, 1) :: integer
|
|
14
12
|
loop col id=L2 in %rows_el_2 as el=%col_el_4, idx=%col_i_5
|
|
15
|
-
%t13 = call core.sub(%col_i_5,
|
|
16
|
-
%t15 = call core.gte(%t13,
|
|
13
|
+
%t13 = call core.sub(%col_i_5, 1) :: integer
|
|
14
|
+
%t15 = call core.gte(%t13, 0) :: boolean
|
|
17
15
|
%t16 = call core.lt(%t13, %t11) :: boolean
|
|
18
16
|
%t17 = call core.and(%t15, %t16) :: boolean
|
|
19
|
-
%t21 = call core.clamp(%t13,
|
|
17
|
+
%t21 = call core.clamp(%t13, 0, %t19) :: integer
|
|
20
18
|
%t22 = gather %t10, %t21 :: integer
|
|
21
|
-
%t24 = select %t17, %t22,
|
|
19
|
+
%t24 = select %t17, %t22, 0 :: integer
|
|
22
20
|
yield %t24
|
|
23
21
|
end_loop
|
|
24
22
|
end_loop
|
|
@@ -26,18 +24,16 @@
|
|
|
26
24
|
(Declaration shift_cols_right_clamp
|
|
27
25
|
%t25 = load_input "rows" :: array
|
|
28
26
|
%t30 = length %t25 :: integer
|
|
29
|
-
%t36 = const 1 :: integer
|
|
30
|
-
%t40 = const 0 :: integer
|
|
31
27
|
loop rows id=L3 in %t25 as el=%rows_el_26, idx=%rows_i_27
|
|
32
28
|
%t31 = call core.mod(%rows_i_27, %t30) :: integer
|
|
33
29
|
%t32 = call core.add(%t31, %t30) :: integer
|
|
34
30
|
%t33 = call core.mod(%t32, %t30) :: integer
|
|
35
31
|
%t34 = gather %t25, %t33 :: any
|
|
36
32
|
%t35 = length %t34 :: integer
|
|
37
|
-
%t39 = call core.sub(%t35,
|
|
33
|
+
%t39 = call core.sub(%t35, 1) :: integer
|
|
38
34
|
loop col id=L4 in %rows_el_26 as el=%col_el_28, idx=%col_i_29
|
|
39
|
-
%t37 = call core.sub(%col_i_29,
|
|
40
|
-
%t41 = call core.clamp(%t37,
|
|
35
|
+
%t37 = call core.sub(%col_i_29, 1) :: integer
|
|
36
|
+
%t41 = call core.clamp(%t37, 0, %t39) :: integer
|
|
41
37
|
%t42 = gather %t34, %t41 :: integer
|
|
42
38
|
yield %t42
|
|
43
39
|
end_loop
|
|
@@ -46,7 +42,6 @@
|
|
|
46
42
|
(Declaration shift_cols_right_wrap
|
|
47
43
|
%t43 = load_input "rows" :: array
|
|
48
44
|
%t48 = length %t43 :: integer
|
|
49
|
-
%t54 = const 1 :: integer
|
|
50
45
|
loop rows id=L5 in %t43 as el=%rows_el_44, idx=%rows_i_45
|
|
51
46
|
%t49 = call core.mod(%rows_i_45, %t48) :: integer
|
|
52
47
|
%t50 = call core.add(%t49, %t48) :: integer
|
|
@@ -54,7 +49,7 @@
|
|
|
54
49
|
%t52 = gather %t43, %t51 :: any
|
|
55
50
|
%t53 = length %t52 :: integer
|
|
56
51
|
loop col id=L6 in %rows_el_44 as el=%col_el_46, idx=%col_i_47
|
|
57
|
-
%t55 = call core.sub(%col_i_47,
|
|
52
|
+
%t55 = call core.sub(%col_i_47, 1) :: integer
|
|
58
53
|
%t56 = call core.mod(%t55, %t53) :: integer
|
|
59
54
|
%t57 = call core.add(%t56, %t53) :: integer
|
|
60
55
|
%t58 = call core.mod(%t57, %t53) :: integer
|
|
@@ -66,24 +61,21 @@
|
|
|
66
61
|
(Declaration shift_cols_left_zero
|
|
67
62
|
%t60 = load_input "rows" :: array
|
|
68
63
|
%t65 = length %t60 :: integer
|
|
69
|
-
%t71 = const -1 :: integer
|
|
70
|
-
%t73 = const 0 :: integer
|
|
71
|
-
%t77 = const 1 :: integer
|
|
72
64
|
loop rows id=L7 in %t60 as el=%rows_el_61, idx=%rows_i_62
|
|
73
65
|
%t66 = call core.mod(%rows_i_62, %t65) :: integer
|
|
74
66
|
%t67 = call core.add(%t66, %t65) :: integer
|
|
75
67
|
%t68 = call core.mod(%t67, %t65) :: integer
|
|
76
68
|
%t69 = gather %t60, %t68 :: any
|
|
77
69
|
%t70 = length %t69 :: integer
|
|
78
|
-
%t78 = call core.sub(%t70,
|
|
70
|
+
%t78 = call core.sub(%t70, 1) :: integer
|
|
79
71
|
loop col id=L8 in %rows_el_61 as el=%col_el_63, idx=%col_i_64
|
|
80
|
-
%t72 = call core.sub(%col_i_64,
|
|
81
|
-
%t74 = call core.gte(%t72,
|
|
72
|
+
%t72 = call core.sub(%col_i_64, -1) :: integer
|
|
73
|
+
%t74 = call core.gte(%t72, 0) :: boolean
|
|
82
74
|
%t75 = call core.lt(%t72, %t70) :: boolean
|
|
83
75
|
%t76 = call core.and(%t74, %t75) :: boolean
|
|
84
|
-
%t80 = call core.clamp(%t72,
|
|
76
|
+
%t80 = call core.clamp(%t72, 0, %t78) :: integer
|
|
85
77
|
%t81 = gather %t69, %t80 :: integer
|
|
86
|
-
%t83 = select %t76, %t81,
|
|
78
|
+
%t83 = select %t76, %t81, 0 :: integer
|
|
87
79
|
yield %t83
|
|
88
80
|
end_loop
|
|
89
81
|
end_loop
|
|
@@ -91,19 +83,16 @@
|
|
|
91
83
|
(Declaration shift_cols_left_clamp
|
|
92
84
|
%t84 = load_input "rows" :: array
|
|
93
85
|
%t89 = length %t84 :: integer
|
|
94
|
-
%t95 = const -1 :: integer
|
|
95
|
-
%t97 = const 1 :: integer
|
|
96
|
-
%t99 = const 0 :: integer
|
|
97
86
|
loop rows id=L9 in %t84 as el=%rows_el_85, idx=%rows_i_86
|
|
98
87
|
%t90 = call core.mod(%rows_i_86, %t89) :: integer
|
|
99
88
|
%t91 = call core.add(%t90, %t89) :: integer
|
|
100
89
|
%t92 = call core.mod(%t91, %t89) :: integer
|
|
101
90
|
%t93 = gather %t84, %t92 :: any
|
|
102
91
|
%t94 = length %t93 :: integer
|
|
103
|
-
%t98 = call core.sub(%t94,
|
|
92
|
+
%t98 = call core.sub(%t94, 1) :: integer
|
|
104
93
|
loop col id=L10 in %rows_el_85 as el=%col_el_87, idx=%col_i_88
|
|
105
|
-
%t96 = call core.sub(%col_i_88,
|
|
106
|
-
%t100 = call core.clamp(%t96,
|
|
94
|
+
%t96 = call core.sub(%col_i_88, -1) :: integer
|
|
95
|
+
%t100 = call core.clamp(%t96, 0, %t98) :: integer
|
|
107
96
|
%t101 = gather %t93, %t100 :: integer
|
|
108
97
|
yield %t101
|
|
109
98
|
end_loop
|
|
@@ -112,7 +101,6 @@
|
|
|
112
101
|
(Declaration shift_cols_left_wrap
|
|
113
102
|
%t102 = load_input "rows" :: array
|
|
114
103
|
%t107 = length %t102 :: integer
|
|
115
|
-
%t113 = const -1 :: integer
|
|
116
104
|
loop rows id=L11 in %t102 as el=%rows_el_103, idx=%rows_i_104
|
|
117
105
|
%t108 = call core.mod(%rows_i_104, %t107) :: integer
|
|
118
106
|
%t109 = call core.add(%t108, %t107) :: integer
|
|
@@ -120,7 +108,7 @@
|
|
|
120
108
|
%t111 = gather %t102, %t110 :: any
|
|
121
109
|
%t112 = length %t111 :: integer
|
|
122
110
|
loop col id=L12 in %rows_el_103 as el=%col_el_105, idx=%col_i_106
|
|
123
|
-
%t114 = call core.sub(%col_i_106,
|
|
111
|
+
%t114 = call core.sub(%col_i_106, -1) :: integer
|
|
124
112
|
%t115 = call core.mod(%t114, %t112) :: integer
|
|
125
113
|
%t116 = call core.add(%t115, %t112) :: integer
|
|
126
114
|
%t117 = call core.mod(%t116, %t112) :: integer
|
|
@@ -132,14 +120,12 @@
|
|
|
132
120
|
(Declaration shift_rows_down_zero
|
|
133
121
|
%t119 = load_input "rows" :: array
|
|
134
122
|
%t124 = length %t119 :: integer
|
|
135
|
-
%
|
|
136
|
-
%t127 = const 0 :: integer
|
|
137
|
-
%t132 = call core.sub(%t124, %t125) :: integer
|
|
123
|
+
%t132 = call core.sub(%t124, 1) :: integer
|
|
138
124
|
loop rows id=L13 in %t119 as el=%rows_el_120, idx=%rows_i_121
|
|
139
|
-
%t126 = call core.sub(%rows_i_121,
|
|
140
|
-
%t128 = call core.gte(%t126,
|
|
125
|
+
%t126 = call core.sub(%rows_i_121, 1) :: integer
|
|
126
|
+
%t128 = call core.gte(%t126, 0) :: boolean
|
|
141
127
|
%t129 = call core.lt(%t126, %t124) :: boolean
|
|
142
|
-
%t134 = call core.clamp(%t126,
|
|
128
|
+
%t134 = call core.clamp(%t126, 0, %t132) :: integer
|
|
143
129
|
%t130 = call core.and(%t128, %t129) :: boolean
|
|
144
130
|
%t135 = gather %t119, %t134 :: any
|
|
145
131
|
%t136 = length %t135 :: integer
|
|
@@ -148,7 +134,7 @@
|
|
|
148
134
|
%t138 = call core.add(%t137, %t136) :: integer
|
|
149
135
|
%t139 = call core.mod(%t138, %t136) :: integer
|
|
150
136
|
%t140 = gather %t135, %t139 :: integer
|
|
151
|
-
%t142 = select %t130, %t140,
|
|
137
|
+
%t142 = select %t130, %t140, 0 :: integer
|
|
152
138
|
yield %t142
|
|
153
139
|
end_loop
|
|
154
140
|
end_loop
|
|
@@ -156,12 +142,10 @@
|
|
|
156
142
|
(Declaration shift_rows_down_clamp
|
|
157
143
|
%t143 = load_input "rows" :: array
|
|
158
144
|
%t148 = length %t143 :: integer
|
|
159
|
-
%
|
|
160
|
-
%t153 = const 0 :: integer
|
|
161
|
-
%t152 = call core.sub(%t148, %t149) :: integer
|
|
145
|
+
%t152 = call core.sub(%t148, 1) :: integer
|
|
162
146
|
loop rows id=L15 in %t143 as el=%rows_el_144, idx=%rows_i_145
|
|
163
|
-
%t150 = call core.sub(%rows_i_145,
|
|
164
|
-
%t154 = call core.clamp(%t150,
|
|
147
|
+
%t150 = call core.sub(%rows_i_145, 1) :: integer
|
|
148
|
+
%t154 = call core.clamp(%t150, 0, %t152) :: integer
|
|
165
149
|
%t155 = gather %t143, %t154 :: any
|
|
166
150
|
%t156 = length %t155 :: integer
|
|
167
151
|
loop col id=L16 in %rows_el_144 as el=%col_el_146, idx=%col_i_147
|
|
@@ -176,9 +160,8 @@
|
|
|
176
160
|
(Declaration shift_rows_down_wrap
|
|
177
161
|
%t161 = load_input "rows" :: array
|
|
178
162
|
%t166 = length %t161 :: integer
|
|
179
|
-
%t167 = const 1 :: integer
|
|
180
163
|
loop rows id=L17 in %t161 as el=%rows_el_162, idx=%rows_i_163
|
|
181
|
-
%t168 = call core.sub(%rows_i_163,
|
|
164
|
+
%t168 = call core.sub(%rows_i_163, 1) :: integer
|
|
182
165
|
%t169 = call core.mod(%t168, %t166) :: integer
|
|
183
166
|
%t170 = call core.add(%t169, %t166) :: integer
|
|
184
167
|
%t171 = call core.mod(%t170, %t166) :: integer
|
|
@@ -196,15 +179,12 @@
|
|
|
196
179
|
(Declaration shift_rows_up_zero
|
|
197
180
|
%t178 = load_input "rows" :: array
|
|
198
181
|
%t183 = length %t178 :: integer
|
|
199
|
-
%
|
|
200
|
-
%t186 = const 0 :: integer
|
|
201
|
-
%t190 = const 1 :: integer
|
|
202
|
-
%t191 = call core.sub(%t183, %t190) :: integer
|
|
182
|
+
%t191 = call core.sub(%t183, 1) :: integer
|
|
203
183
|
loop rows id=L19 in %t178 as el=%rows_el_179, idx=%rows_i_180
|
|
204
|
-
%t185 = call core.sub(%rows_i_180,
|
|
205
|
-
%t187 = call core.gte(%t185,
|
|
184
|
+
%t185 = call core.sub(%rows_i_180, -1) :: integer
|
|
185
|
+
%t187 = call core.gte(%t185, 0) :: boolean
|
|
206
186
|
%t188 = call core.lt(%t185, %t183) :: boolean
|
|
207
|
-
%t193 = call core.clamp(%t185,
|
|
187
|
+
%t193 = call core.clamp(%t185, 0, %t191) :: integer
|
|
208
188
|
%t189 = call core.and(%t187, %t188) :: boolean
|
|
209
189
|
%t194 = gather %t178, %t193 :: any
|
|
210
190
|
%t195 = length %t194 :: integer
|
|
@@ -213,7 +193,7 @@
|
|
|
213
193
|
%t197 = call core.add(%t196, %t195) :: integer
|
|
214
194
|
%t198 = call core.mod(%t197, %t195) :: integer
|
|
215
195
|
%t199 = gather %t194, %t198 :: integer
|
|
216
|
-
%t201 = select %t189, %t199,
|
|
196
|
+
%t201 = select %t189, %t199, 0 :: integer
|
|
217
197
|
yield %t201
|
|
218
198
|
end_loop
|
|
219
199
|
end_loop
|
|
@@ -221,13 +201,10 @@
|
|
|
221
201
|
(Declaration shift_rows_up_clamp
|
|
222
202
|
%t202 = load_input "rows" :: array
|
|
223
203
|
%t207 = length %t202 :: integer
|
|
224
|
-
%
|
|
225
|
-
%t210 = const 1 :: integer
|
|
226
|
-
%t212 = const 0 :: integer
|
|
227
|
-
%t211 = call core.sub(%t207, %t210) :: integer
|
|
204
|
+
%t211 = call core.sub(%t207, 1) :: integer
|
|
228
205
|
loop rows id=L21 in %t202 as el=%rows_el_203, idx=%rows_i_204
|
|
229
|
-
%t209 = call core.sub(%rows_i_204,
|
|
230
|
-
%t213 = call core.clamp(%t209,
|
|
206
|
+
%t209 = call core.sub(%rows_i_204, -1) :: integer
|
|
207
|
+
%t213 = call core.clamp(%t209, 0, %t211) :: integer
|
|
231
208
|
%t214 = gather %t202, %t213 :: any
|
|
232
209
|
%t215 = length %t214 :: integer
|
|
233
210
|
loop col id=L22 in %rows_el_203 as el=%col_el_205, idx=%col_i_206
|
|
@@ -242,9 +219,8 @@
|
|
|
242
219
|
(Declaration shift_rows_up_wrap
|
|
243
220
|
%t220 = load_input "rows" :: array
|
|
244
221
|
%t225 = length %t220 :: integer
|
|
245
|
-
%t226 = const -1 :: integer
|
|
246
222
|
loop rows id=L23 in %t220 as el=%rows_el_221, idx=%rows_i_222
|
|
247
|
-
%t227 = call core.sub(%rows_i_222,
|
|
223
|
+
%t227 = call core.sub(%rows_i_222, -1) :: integer
|
|
248
224
|
%t228 = call core.mod(%t227, %t225) :: integer
|
|
249
225
|
%t229 = call core.add(%t228, %t225) :: integer
|
|
250
226
|
%t230 = call core.mod(%t229, %t225) :: integer
|