kumi 0.0.25 → 0.0.27

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.
Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/CLAUDE.md +4 -0
  4. data/README.md +86 -78
  5. data/data/functions/agg/boolean.yaml +6 -2
  6. data/data/functions/agg/numeric.yaml +32 -16
  7. data/data/functions/agg/string.yaml +4 -3
  8. data/data/functions/core/arithmetic.yaml +62 -14
  9. data/data/functions/core/boolean.yaml +12 -6
  10. data/data/functions/core/comparison.yaml +25 -13
  11. data/data/functions/core/constructor.yaml +16 -8
  12. data/data/functions/core/conversion.yaml +32 -0
  13. data/data/functions/core/select.yaml +3 -1
  14. data/data/functions/core/stencil.yaml +14 -5
  15. data/data/functions/core/string.yaml +9 -4
  16. data/data/kernels/javascript/core/coercion.yaml +20 -0
  17. data/data/kernels/ruby/agg/numeric.yaml +1 -1
  18. data/data/kernels/ruby/core/coercion.yaml +20 -0
  19. data/docs/ARCHITECTURE.md +277 -0
  20. data/docs/DEVELOPMENT.md +62 -0
  21. data/docs/FUNCTIONS.md +955 -0
  22. data/docs/SYNTAX.md +8 -0
  23. data/docs/UNSAT_DETECTION.md +83 -0
  24. data/docs/VSCODE_EXTENSION.md +114 -0
  25. data/docs/functions-reference.json +1821 -0
  26. data/golden/array_element/expected/nast.txt +1 -1
  27. data/golden/array_element/expected/schema_ruby.rb +1 -1
  28. data/golden/array_index/expected/nast.txt +7 -7
  29. data/golden/array_index/expected/schema_ruby.rb +1 -1
  30. data/golden/array_operations/expected/nast.txt +2 -2
  31. data/golden/array_operations/expected/schema_ruby.rb +1 -1
  32. data/golden/array_operations/expected/snast.txt +3 -3
  33. data/golden/cascade_logic/expected/schema_ruby.rb +1 -1
  34. data/golden/cascade_logic/expected/snast.txt +2 -2
  35. data/golden/chained_fusion/expected/nast.txt +2 -2
  36. data/golden/chained_fusion/expected/schema_ruby.rb +1 -1
  37. data/golden/decimal_explicit/expected/ast.txt +38 -0
  38. data/golden/decimal_explicit/expected/input_plan.txt +3 -0
  39. data/golden/decimal_explicit/expected/lir_00_unoptimized.txt +30 -0
  40. data/golden/decimal_explicit/expected/lir_01_hoist_scalar_references.txt +30 -0
  41. data/golden/decimal_explicit/expected/lir_02_inlined.txt +44 -0
  42. data/golden/decimal_explicit/expected/lir_03_cse.txt +40 -0
  43. data/golden/decimal_explicit/expected/lir_04_1_loop_fusion.txt +40 -0
  44. data/golden/decimal_explicit/expected/lir_04_loop_invcm.txt +40 -0
  45. data/golden/decimal_explicit/expected/lir_06_const_prop.txt +40 -0
  46. data/golden/decimal_explicit/expected/nast.txt +30 -0
  47. data/golden/decimal_explicit/expected/schema_javascript.mjs +31 -0
  48. data/golden/decimal_explicit/expected/schema_ruby.rb +57 -0
  49. data/golden/decimal_explicit/expected/snast.txt +30 -0
  50. data/golden/decimal_explicit/expected.json +1 -0
  51. data/golden/decimal_explicit/input.json +5 -0
  52. data/golden/decimal_explicit/schema.kumi +14 -0
  53. data/golden/element_arrays/expected/nast.txt +2 -2
  54. data/golden/element_arrays/expected/schema_ruby.rb +1 -1
  55. data/golden/element_arrays/expected/snast.txt +1 -1
  56. data/golden/empty_and_null_inputs/expected/nast.txt +3 -3
  57. data/golden/empty_and_null_inputs/expected/schema_ruby.rb +1 -1
  58. data/golden/function_overload/expected/ast.txt +29 -0
  59. data/golden/function_overload/expected/input_plan.txt +4 -0
  60. data/golden/function_overload/expected/lir_00_unoptimized.txt +18 -0
  61. data/golden/function_overload/expected/lir_01_hoist_scalar_references.txt +18 -0
  62. data/golden/function_overload/expected/lir_02_inlined.txt +20 -0
  63. data/golden/function_overload/expected/lir_03_cse.txt +20 -0
  64. data/golden/function_overload/expected/lir_04_1_loop_fusion.txt +20 -0
  65. data/golden/function_overload/expected/lir_04_loop_invcm.txt +20 -0
  66. data/golden/function_overload/expected/lir_06_const_prop.txt +20 -0
  67. data/golden/function_overload/expected/nast.txt +22 -0
  68. data/golden/function_overload/expected/schema_javascript.mjs +12 -0
  69. data/golden/function_overload/expected/schema_ruby.rb +39 -0
  70. data/golden/function_overload/expected/snast.txt +22 -0
  71. data/golden/function_overload/input.json +8 -0
  72. data/golden/function_overload/schema.kumi +19 -0
  73. data/golden/game_of_life/expected/lir_00_unoptimized.txt +4 -4
  74. data/golden/game_of_life/expected/lir_01_hoist_scalar_references.txt +4 -4
  75. data/golden/game_of_life/expected/lir_02_inlined.txt +16 -16
  76. data/golden/game_of_life/expected/lir_03_cse.txt +20 -16
  77. data/golden/game_of_life/expected/lir_04_1_loop_fusion.txt +20 -16
  78. data/golden/game_of_life/expected/lir_04_loop_invcm.txt +20 -16
  79. data/golden/game_of_life/expected/lir_06_const_prop.txt +20 -16
  80. data/golden/game_of_life/expected/nast.txt +4 -4
  81. data/golden/game_of_life/expected/schema_javascript.mjs +4 -2
  82. data/golden/game_of_life/expected/schema_ruby.rb +5 -3
  83. data/golden/game_of_life/expected/snast.txt +10 -10
  84. data/golden/hash_keys/expected/schema_ruby.rb +1 -1
  85. data/golden/hash_value/expected/nast.txt +1 -1
  86. data/golden/hash_value/expected/schema_ruby.rb +1 -1
  87. data/golden/hash_value/expected/snast.txt +1 -1
  88. data/golden/hierarchical_complex/expected/nast.txt +3 -3
  89. data/golden/hierarchical_complex/expected/schema_ruby.rb +1 -1
  90. data/golden/hierarchical_complex/expected/snast.txt +3 -3
  91. data/golden/inline_rename_scope_leak/expected/nast.txt +3 -3
  92. data/golden/inline_rename_scope_leak/expected/schema_ruby.rb +1 -1
  93. data/golden/input_reference/expected/nast.txt +2 -2
  94. data/golden/input_reference/expected/schema_ruby.rb +1 -1
  95. data/golden/interleaved_fusion/expected/nast.txt +2 -2
  96. data/golden/interleaved_fusion/expected/schema_ruby.rb +1 -1
  97. data/golden/let_inline/expected/nast.txt +4 -4
  98. data/golden/let_inline/expected/schema_ruby.rb +1 -1
  99. data/golden/loop_fusion/expected/nast.txt +1 -1
  100. data/golden/loop_fusion/expected/schema_ruby.rb +1 -1
  101. data/golden/min_reduce_scope/expected/nast.txt +3 -3
  102. data/golden/min_reduce_scope/expected/schema_ruby.rb +1 -1
  103. data/golden/min_reduce_scope/expected/snast.txt +1 -1
  104. data/golden/mixed_dimensions/expected/nast.txt +2 -2
  105. data/golden/mixed_dimensions/expected/schema_ruby.rb +1 -1
  106. data/golden/multirank_hoisting/expected/nast.txt +7 -7
  107. data/golden/multirank_hoisting/expected/schema_ruby.rb +1 -1
  108. data/golden/nested_hash/expected/nast.txt +1 -1
  109. data/golden/nested_hash/expected/schema_ruby.rb +1 -1
  110. data/golden/reduction_broadcast/expected/nast.txt +3 -3
  111. data/golden/reduction_broadcast/expected/schema_ruby.rb +1 -1
  112. data/golden/reduction_broadcast/expected/snast.txt +1 -1
  113. data/golden/roll/expected/schema_ruby.rb +1 -1
  114. data/golden/shift/expected/schema_ruby.rb +1 -1
  115. data/golden/shift_2d/expected/schema_ruby.rb +1 -1
  116. data/golden/simple_math/expected/lir_00_unoptimized.txt +1 -1
  117. data/golden/simple_math/expected/lir_01_hoist_scalar_references.txt +1 -1
  118. data/golden/simple_math/expected/lir_02_inlined.txt +1 -1
  119. data/golden/simple_math/expected/lir_03_cse.txt +1 -1
  120. data/golden/simple_math/expected/lir_04_1_loop_fusion.txt +1 -1
  121. data/golden/simple_math/expected/lir_04_loop_invcm.txt +1 -1
  122. data/golden/simple_math/expected/lir_06_const_prop.txt +1 -1
  123. data/golden/simple_math/expected/nast.txt +5 -5
  124. data/golden/simple_math/expected/schema_ruby.rb +1 -1
  125. data/golden/simple_math/expected/snast.txt +2 -2
  126. data/golden/streaming_basics/expected/nast.txt +8 -8
  127. data/golden/streaming_basics/expected/schema_ruby.rb +1 -1
  128. data/golden/streaming_basics/expected/snast.txt +1 -1
  129. data/golden/tuples/expected/lir_00_unoptimized.txt +5 -5
  130. data/golden/tuples/expected/lir_01_hoist_scalar_references.txt +5 -5
  131. data/golden/tuples/expected/lir_02_inlined.txt +5 -5
  132. data/golden/tuples/expected/lir_03_cse.txt +5 -5
  133. data/golden/tuples/expected/lir_04_1_loop_fusion.txt +5 -5
  134. data/golden/tuples/expected/lir_04_loop_invcm.txt +5 -5
  135. data/golden/tuples/expected/lir_06_const_prop.txt +5 -5
  136. data/golden/tuples/expected/nast.txt +4 -4
  137. data/golden/tuples/expected/schema_ruby.rb +1 -1
  138. data/golden/tuples/expected/snast.txt +6 -6
  139. data/golden/tuples_and_arrays/expected/lir_00_unoptimized.txt +1 -1
  140. data/golden/tuples_and_arrays/expected/lir_01_hoist_scalar_references.txt +1 -1
  141. data/golden/tuples_and_arrays/expected/lir_02_inlined.txt +2 -2
  142. data/golden/tuples_and_arrays/expected/lir_03_cse.txt +2 -2
  143. data/golden/tuples_and_arrays/expected/lir_04_1_loop_fusion.txt +2 -2
  144. data/golden/tuples_and_arrays/expected/lir_04_loop_invcm.txt +2 -2
  145. data/golden/tuples_and_arrays/expected/lir_06_const_prop.txt +2 -2
  146. data/golden/tuples_and_arrays/expected/nast.txt +3 -3
  147. data/golden/tuples_and_arrays/expected/schema_ruby.rb +1 -1
  148. data/golden/tuples_and_arrays/expected/snast.txt +2 -2
  149. data/golden/us_tax_2024/expected/ast.txt +63 -670
  150. data/golden/us_tax_2024/expected/input_plan.txt +8 -45
  151. data/golden/us_tax_2024/expected/lir_00_unoptimized.txt +253 -863
  152. data/golden/us_tax_2024/expected/lir_01_hoist_scalar_references.txt +253 -863
  153. data/golden/us_tax_2024/expected/lir_02_inlined.txt +1215 -5139
  154. data/golden/us_tax_2024/expected/lir_03_cse.txt +587 -2460
  155. data/golden/us_tax_2024/expected/lir_04_1_loop_fusion.txt +632 -2480
  156. data/golden/us_tax_2024/expected/lir_04_loop_invcm.txt +587 -2460
  157. data/golden/us_tax_2024/expected/lir_06_const_prop.txt +587 -2460
  158. data/golden/us_tax_2024/expected/nast.txt +123 -826
  159. data/golden/us_tax_2024/expected/schema_javascript.mjs +127 -581
  160. data/golden/us_tax_2024/expected/schema_ruby.rb +135 -610
  161. data/golden/us_tax_2024/expected/snast.txt +155 -858
  162. data/golden/us_tax_2024/expected.json +120 -1
  163. data/golden/us_tax_2024/input.json +18 -9
  164. data/golden/us_tax_2024/schema.kumi +48 -178
  165. data/golden/with_constants/expected/lir_00_unoptimized.txt +1 -1
  166. data/golden/with_constants/expected/lir_01_hoist_scalar_references.txt +1 -1
  167. data/golden/with_constants/expected/lir_02_inlined.txt +1 -1
  168. data/golden/with_constants/expected/lir_03_cse.txt +1 -1
  169. data/golden/with_constants/expected/lir_04_1_loop_fusion.txt +1 -1
  170. data/golden/with_constants/expected/lir_04_loop_invcm.txt +1 -1
  171. data/golden/with_constants/expected/lir_06_const_prop.txt +1 -1
  172. data/golden/with_constants/expected/nast.txt +2 -2
  173. data/golden/with_constants/expected/schema_ruby.rb +1 -1
  174. data/golden/with_constants/expected/snast.txt +2 -2
  175. data/lib/kumi/analyzer.rb +12 -12
  176. data/lib/kumi/configuration.rb +6 -0
  177. data/lib/kumi/core/analyzer/passes/formal_constraint_propagator.rb +236 -0
  178. data/lib/kumi/core/analyzer/passes/input_collector.rb +22 -4
  179. data/lib/kumi/core/analyzer/passes/nast_dimensional_analyzer_pass.rb +64 -18
  180. data/lib/kumi/core/analyzer/passes/normalize_to_nast_pass.rb +9 -4
  181. data/lib/kumi/core/analyzer/passes/snast_pass.rb +3 -1
  182. data/lib/kumi/core/analyzer/passes/unsat_detector.rb +172 -198
  183. data/lib/kumi/core/error_reporter.rb +36 -1
  184. data/lib/kumi/core/errors.rb +33 -1
  185. data/lib/kumi/core/functions/function_spec.rb +5 -4
  186. data/lib/kumi/core/functions/loader.rb +17 -1
  187. data/lib/kumi/core/functions/overload_resolver.rb +164 -0
  188. data/lib/kumi/core/functions/type_error_reporter.rb +118 -0
  189. data/lib/kumi/core/functions/type_rules.rb +155 -35
  190. data/lib/kumi/core/input/type_matcher.rb +8 -1
  191. data/lib/kumi/core/ruby_parser/input_builder.rb +2 -2
  192. data/lib/kumi/core/types/inference.rb +29 -22
  193. data/lib/kumi/core/types/normalizer.rb +30 -45
  194. data/lib/kumi/core/types/validator.rb +17 -28
  195. data/lib/kumi/core/types/value_objects.rb +116 -0
  196. data/lib/kumi/core/types.rb +45 -37
  197. data/lib/kumi/dev/golden/reporter.rb +9 -0
  198. data/lib/kumi/dev/golden/result.rb +3 -1
  199. data/lib/kumi/dev/golden/runtime_test.rb +25 -0
  200. data/lib/kumi/dev/golden/suite.rb +4 -4
  201. data/lib/kumi/dev/golden/value_normalizer.rb +80 -0
  202. data/lib/kumi/dev/golden.rb +21 -12
  203. data/lib/kumi/doc_generator/formatters/json.rb +39 -0
  204. data/lib/kumi/doc_generator/formatters/markdown.rb +175 -0
  205. data/lib/kumi/doc_generator/loader.rb +37 -0
  206. data/lib/kumi/doc_generator/merger.rb +54 -0
  207. data/lib/kumi/doc_generator.rb +4 -0
  208. data/lib/kumi/registry_v2/loader.rb +90 -0
  209. data/lib/kumi/registry_v2.rb +18 -1
  210. data/lib/kumi/version.rb +1 -1
  211. data/vscode-extension/.gitignore +4 -0
  212. data/vscode-extension/README.md +59 -0
  213. data/vscode-extension/TESTING.md +151 -0
  214. data/vscode-extension/package.json +51 -0
  215. data/vscode-extension/src/extension.ts +295 -0
  216. data/vscode-extension/tsconfig.json +15 -0
  217. metadata +57 -7
  218. data/lib/kumi/core/analyzer/unsat_constant_evaluator.rb +0 -59
  219. data/lib/kumi/core/atom_unsat_solver.rb +0 -396
  220. data/lib/kumi/core/constraint_relationship_solver.rb +0 -641
  221. data/lib/kumi/core/types/builder.rb +0 -23
  222. data/lib/kumi/core/types/compatibility.rb +0 -96
  223. data/lib/kumi/core/types/formatter.rb +0 -26
@@ -1,6 +1,6 @@
1
1
  (NAST
2
2
  (VALUE v_sum_y
3
- (Call :"agg.sum"
3
+ (Call :sum
4
4
  (InputRef [:x, :y, :v])
5
5
  )
6
6
  )
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_9728a32b2ef1c73739b44f006d54b23230821bda76275eb804cd9ec4c91c3089
2
+ module Kumi::Compiled::KUMI_89360babebc3896b16e46cb4cf2f0f8feb3d6f6428e9bf430575b05328fa27eb
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,12 +1,12 @@
1
1
  (NAST
2
2
  (VALUE W
3
- (Call :"core.array_size"
3
+ (Call :array_size
4
4
  (InputRef [:x, :y])
5
5
  )
6
6
  )
7
7
  (VALUE box
8
- (Call :"core.add"
9
- (Call :"core.mul"
8
+ (Call :add
9
+ (Call :multiply
10
10
  #<struct Kumi::Core::NAST::IndexRef id=83, loc=nil, meta={}>
11
11
  (Ref W)
12
12
  )
@@ -14,10 +14,10 @@
14
14
  )
15
15
  )
16
16
  (VALUE col_major
17
- (Call :"core.add"
18
- (Call :"core.mul"
17
+ (Call :add
18
+ (Call :multiply
19
19
  #<struct Kumi::Core::NAST::IndexRef id=91, loc=nil, meta={}>
20
- (Call :"core.array_size"
20
+ (Call :array_size
21
21
  (InputRef [:x])
22
22
  )
23
23
  )
@@ -25,7 +25,7 @@
25
25
  )
26
26
  )
27
27
  (VALUE sum_ij
28
- (Call :"core.add"
28
+ (Call :add
29
29
  #<struct Kumi::Core::NAST::IndexRef id=100, loc=nil, meta={}>
30
30
  #<struct Kumi::Core::NAST::IndexRef id=102, loc=nil, meta={}>
31
31
  )
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_b0b7f061a7a0eedb52d282a806e7e102921f6ab3042667bd6fc6fc7f3a1018e2
2
+ module Kumi::Compiled::KUMI_1ee54aec6cf6cfd2570cdd73e6ce47bc23c82e4faaf4a03ca6bd11d1e8d34b0e
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,12 +1,12 @@
1
1
  (NAST
2
2
  (VALUE subtotals
3
- (Call :"core.mul"
3
+ (Call :multiply
4
4
  (InputRef [:items, :item, :price])
5
5
  (InputRef [:items, :item, :quantity])
6
6
  )
7
7
  )
8
8
  (VALUE discounted_price
9
- (Call :"core.mul"
9
+ (Call :multiply
10
10
  (InputRef [:items, :item, :price])
11
11
  (Const 0.9)
12
12
  )
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_f6e8984aaae6be8cee0041865907ace29c189473e461ccf9db4a6bec97465dab
2
+ module Kumi::Compiled::KUMI_0cb193cac7097725954d884c342db7afb7158942e3608106d1d84042f47fb997
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -11,19 +11,19 @@
11
11
  (Const 0.9) :: [] -> float
12
12
  ) :: [items] -> float
13
13
  ) :: [items] -> float
14
- (TRAIT is_valid_quantity
14
+ (VALUE is_valid_quantity
15
15
  (Call :core.gt
16
16
  (InputRef items.item.quantity key_chain=[]) :: [items] -> integer
17
17
  (Const 0) :: [] -> integer
18
18
  ) :: [items] -> boolean
19
19
  ) :: [items] -> boolean
20
- (TRAIT expensive_items
20
+ (VALUE expensive_items
21
21
  (Call :core.gt
22
22
  (InputRef items.item.price key_chain=[]) :: [items] -> float
23
23
  (Const 100.0) :: [] -> float
24
24
  ) :: [items] -> boolean
25
25
  ) :: [items] -> boolean
26
- (TRAIT electronics
26
+ (VALUE electronics
27
27
  (Call :core.eq
28
28
  (InputRef items.item.category key_chain=[]) :: [items] -> string
29
29
  (Const "electronics") :: [] -> string
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_68bc018c477a94cdfe07ac690bfacdebc9208a590b464f22d499aee7aafafd19
2
+ module Kumi::Compiled::KUMI_ced9076f56216648b58d9ecbfaf37f152c120ca7fbea32964e0ef891829acbca
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -1,11 +1,11 @@
1
1
  (SNAST
2
- (TRAIT y_positive
2
+ (VALUE y_positive
3
3
  (Call :core.gt
4
4
  (InputRef y key_chain=[]) :: [] -> integer
5
5
  (Const 0) :: [] -> integer
6
6
  ) :: [] -> boolean
7
7
  ) :: [] -> boolean
8
- (TRAIT x_positive
8
+ (VALUE x_positive
9
9
  (Call :core.gt
10
10
  (InputRef x key_chain=[]) :: [] -> integer
11
11
  (Const 0) :: [] -> integer
@@ -1,6 +1,6 @@
1
1
  (NAST
2
2
  (VALUE total_payroll
3
- (Call :"agg.sum"
3
+ (Call :sum
4
4
  (InputRef [:departments, :dept, :employees, :emp, :salary])
5
5
  )
6
6
  )
@@ -29,7 +29,7 @@
29
29
  )
30
30
  )
31
31
  (VALUE max_salary
32
- (Call :"agg.max"
32
+ (Call :max
33
33
  (InputRef [:departments, :dept, :employees, :emp, :salary])
34
34
  )
35
35
  )
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_d345f8b5098b438aa322a7ee8d0a4d26f7c84aa9e453db79a0466b672d60fe36
2
+ module Kumi::Compiled::KUMI_48491984ea6dc439d6851cae7cc74e9d139f13ab6290dea881bd89a3ee853b3b
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)
@@ -0,0 +1,38 @@
1
+ (Root
2
+ inputs: [
3
+ (InputDeclaration :unit_price :string)
4
+ (InputDeclaration :quantity :integer)
5
+ (InputDeclaration :tax_rate :string)
6
+ ]
7
+ values: [
8
+ (ValueDeclaration :price
9
+ (CallExpression :to_decimal
10
+ (InputReference :unit_price)
11
+ )
12
+ )
13
+ (ValueDeclaration :rate
14
+ (CallExpression :to_decimal
15
+ (InputReference :tax_rate)
16
+ )
17
+ )
18
+ (ValueDeclaration :subtotal
19
+ (CallExpression :multiply
20
+ (DeclarationReference :price)
21
+ (InputReference :quantity)
22
+ )
23
+ )
24
+ (ValueDeclaration :tax_amount
25
+ (CallExpression :multiply
26
+ (DeclarationReference :subtotal)
27
+ (DeclarationReference :rate)
28
+ )
29
+ )
30
+ (ValueDeclaration :total
31
+ (CallExpression :add
32
+ (DeclarationReference :subtotal)
33
+ (DeclarationReference :tax_amount)
34
+ )
35
+ )
36
+ ]
37
+ traits: []
38
+ )
@@ -0,0 +1,3 @@
1
+ unit_price: string
2
+ quantity: integer
3
+ tax_rate: string
@@ -0,0 +1,30 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t5 = load_decl price :: decimal
14
+ %t6 = load_input "quantity" :: integer
15
+ %t7 = call core.mul(%t5, %t6) :: integer
16
+ yield %t7
17
+ )
18
+ (Declaration tax_amount
19
+ %t8 = load_decl subtotal :: integer
20
+ %t9 = load_decl rate :: decimal
21
+ %t10 = call core.mul(%t8, %t9) :: integer
22
+ yield %t10
23
+ )
24
+ (Declaration total
25
+ %t11 = load_decl subtotal :: integer
26
+ %t12 = load_decl tax_amount :: integer
27
+ %t13 = call core.add(%t11, %t12) :: integer
28
+ yield %t13
29
+ )
30
+ )
@@ -0,0 +1,30 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t5 = load_decl price :: decimal
14
+ %t6 = load_input "quantity" :: integer
15
+ %t7 = call core.mul(%t5, %t6) :: integer
16
+ yield %t7
17
+ )
18
+ (Declaration tax_amount
19
+ %t8 = load_decl subtotal :: integer
20
+ %t9 = load_decl rate :: decimal
21
+ %t10 = call core.mul(%t8, %t9) :: integer
22
+ yield %t10
23
+ )
24
+ (Declaration total
25
+ %t11 = load_decl subtotal :: integer
26
+ %t12 = load_decl tax_amount :: integer
27
+ %t13 = call core.add(%t11, %t12) :: integer
28
+ yield %t13
29
+ )
30
+ )
@@ -0,0 +1,44 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t14 = load_input "unit_price" :: string
14
+ %t15 = call core.to_decimal(%t14) :: decimal
15
+ %t6 = load_input "quantity" :: integer
16
+ %t7 = call core.mul(%t15, %t6) :: integer
17
+ yield %t7
18
+ )
19
+ (Declaration tax_amount
20
+ %t19 = load_input "unit_price" :: string
21
+ %t20 = call core.to_decimal(%t19) :: decimal
22
+ %t17 = load_input "quantity" :: integer
23
+ %t18 = call core.mul(%t20, %t17) :: integer
24
+ %t21 = load_input "tax_rate" :: string
25
+ %t22 = call core.to_decimal(%t21) :: decimal
26
+ %t10 = call core.mul(%t18, %t22) :: integer
27
+ yield %t10
28
+ )
29
+ (Declaration total
30
+ %t26 = load_input "unit_price" :: string
31
+ %t27 = call core.to_decimal(%t26) :: decimal
32
+ %t24 = load_input "quantity" :: integer
33
+ %t25 = call core.mul(%t27, %t24) :: integer
34
+ %t34 = load_input "unit_price" :: string
35
+ %t35 = call core.to_decimal(%t34) :: decimal
36
+ %t32 = load_input "quantity" :: integer
37
+ %t33 = call core.mul(%t35, %t32) :: integer
38
+ %t36 = load_input "tax_rate" :: string
39
+ %t37 = call core.to_decimal(%t36) :: decimal
40
+ %t30 = call core.mul(%t33, %t37) :: integer
41
+ %t13 = call core.add(%t25, %t30) :: integer
42
+ yield %t13
43
+ )
44
+ )
@@ -0,0 +1,40 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t14 = load_input "unit_price" :: string
14
+ %t15 = call core.to_decimal(%t14) :: decimal
15
+ %t6 = load_input "quantity" :: integer
16
+ %t7 = call core.mul(%t15, %t6) :: integer
17
+ yield %t7
18
+ )
19
+ (Declaration tax_amount
20
+ %t19 = load_input "unit_price" :: string
21
+ %t20 = call core.to_decimal(%t19) :: decimal
22
+ %t17 = load_input "quantity" :: integer
23
+ %t18 = call core.mul(%t20, %t17) :: integer
24
+ %t21 = load_input "tax_rate" :: string
25
+ %t22 = call core.to_decimal(%t21) :: decimal
26
+ %t10 = call core.mul(%t18, %t22) :: integer
27
+ yield %t10
28
+ )
29
+ (Declaration total
30
+ %t26 = load_input "unit_price" :: string
31
+ %t27 = call core.to_decimal(%t26) :: decimal
32
+ %t24 = load_input "quantity" :: integer
33
+ %t25 = call core.mul(%t27, %t24) :: integer
34
+ %t36 = load_input "tax_rate" :: string
35
+ %t37 = call core.to_decimal(%t36) :: decimal
36
+ %t30 = call core.mul(%t25, %t37) :: integer
37
+ %t13 = call core.add(%t25, %t30) :: integer
38
+ yield %t13
39
+ )
40
+ )
@@ -0,0 +1,40 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t14 = load_input "unit_price" :: string
14
+ %t15 = call core.to_decimal(%t14) :: decimal
15
+ %t6 = load_input "quantity" :: integer
16
+ %t7 = call core.mul(%t15, %t6) :: integer
17
+ yield %t7
18
+ )
19
+ (Declaration tax_amount
20
+ %t19 = load_input "unit_price" :: string
21
+ %t20 = call core.to_decimal(%t19) :: decimal
22
+ %t17 = load_input "quantity" :: integer
23
+ %t18 = call core.mul(%t20, %t17) :: integer
24
+ %t21 = load_input "tax_rate" :: string
25
+ %t22 = call core.to_decimal(%t21) :: decimal
26
+ %t10 = call core.mul(%t18, %t22) :: integer
27
+ yield %t10
28
+ )
29
+ (Declaration total
30
+ %t26 = load_input "unit_price" :: string
31
+ %t27 = call core.to_decimal(%t26) :: decimal
32
+ %t24 = load_input "quantity" :: integer
33
+ %t25 = call core.mul(%t27, %t24) :: integer
34
+ %t36 = load_input "tax_rate" :: string
35
+ %t37 = call core.to_decimal(%t36) :: decimal
36
+ %t30 = call core.mul(%t25, %t37) :: integer
37
+ %t13 = call core.add(%t25, %t30) :: integer
38
+ yield %t13
39
+ )
40
+ )
@@ -0,0 +1,40 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t14 = load_input "unit_price" :: string
14
+ %t15 = call core.to_decimal(%t14) :: decimal
15
+ %t6 = load_input "quantity" :: integer
16
+ %t7 = call core.mul(%t15, %t6) :: integer
17
+ yield %t7
18
+ )
19
+ (Declaration tax_amount
20
+ %t19 = load_input "unit_price" :: string
21
+ %t20 = call core.to_decimal(%t19) :: decimal
22
+ %t17 = load_input "quantity" :: integer
23
+ %t18 = call core.mul(%t20, %t17) :: integer
24
+ %t21 = load_input "tax_rate" :: string
25
+ %t22 = call core.to_decimal(%t21) :: decimal
26
+ %t10 = call core.mul(%t18, %t22) :: integer
27
+ yield %t10
28
+ )
29
+ (Declaration total
30
+ %t26 = load_input "unit_price" :: string
31
+ %t27 = call core.to_decimal(%t26) :: decimal
32
+ %t24 = load_input "quantity" :: integer
33
+ %t25 = call core.mul(%t27, %t24) :: integer
34
+ %t36 = load_input "tax_rate" :: string
35
+ %t37 = call core.to_decimal(%t36) :: decimal
36
+ %t30 = call core.mul(%t25, %t37) :: integer
37
+ %t13 = call core.add(%t25, %t30) :: integer
38
+ yield %t13
39
+ )
40
+ )
@@ -0,0 +1,40 @@
1
+ (LIR
2
+ (Declaration price
3
+ %t1 = load_input "unit_price" :: string
4
+ %t2 = call core.to_decimal(%t1) :: decimal
5
+ yield %t2
6
+ )
7
+ (Declaration rate
8
+ %t3 = load_input "tax_rate" :: string
9
+ %t4 = call core.to_decimal(%t3) :: decimal
10
+ yield %t4
11
+ )
12
+ (Declaration subtotal
13
+ %t14 = load_input "unit_price" :: string
14
+ %t15 = call core.to_decimal(%t14) :: decimal
15
+ %t6 = load_input "quantity" :: integer
16
+ %t7 = call core.mul(%t15, %t6) :: integer
17
+ yield %t7
18
+ )
19
+ (Declaration tax_amount
20
+ %t19 = load_input "unit_price" :: string
21
+ %t20 = call core.to_decimal(%t19) :: decimal
22
+ %t17 = load_input "quantity" :: integer
23
+ %t18 = call core.mul(%t20, %t17) :: integer
24
+ %t21 = load_input "tax_rate" :: string
25
+ %t22 = call core.to_decimal(%t21) :: decimal
26
+ %t10 = call core.mul(%t18, %t22) :: integer
27
+ yield %t10
28
+ )
29
+ (Declaration total
30
+ %t26 = load_input "unit_price" :: string
31
+ %t27 = call core.to_decimal(%t26) :: decimal
32
+ %t24 = load_input "quantity" :: integer
33
+ %t25 = call core.mul(%t27, %t24) :: integer
34
+ %t36 = load_input "tax_rate" :: string
35
+ %t37 = call core.to_decimal(%t36) :: decimal
36
+ %t30 = call core.mul(%t25, %t37) :: integer
37
+ %t13 = call core.add(%t25, %t30) :: integer
38
+ yield %t13
39
+ )
40
+ )
@@ -0,0 +1,30 @@
1
+ (NAST
2
+ (VALUE price
3
+ (Call :to_decimal
4
+ (InputRef [:unit_price])
5
+ )
6
+ )
7
+ (VALUE rate
8
+ (Call :to_decimal
9
+ (InputRef [:tax_rate])
10
+ )
11
+ )
12
+ (VALUE subtotal
13
+ (Call :multiply
14
+ (Ref price)
15
+ (InputRef [:quantity])
16
+ )
17
+ )
18
+ (VALUE tax_amount
19
+ (Call :multiply
20
+ (Ref subtotal)
21
+ (Ref rate)
22
+ )
23
+ )
24
+ (VALUE total
25
+ (Call :add
26
+ (Ref subtotal)
27
+ (Ref tax_amount)
28
+ )
29
+ )
30
+ )
@@ -0,0 +1,31 @@
1
+ export function _subtotal(input) {
2
+ let t14 = input["unit_price"];
3
+ let t15 = typeof t14 === 'string' ? parseFloat(t14) : Number(t14);
4
+ let t6 = input["quantity"];
5
+ let t7 = t15 * t6;
6
+ return t7;
7
+ }
8
+
9
+ export function _tax_amount(input) {
10
+ let t19 = input["unit_price"];
11
+ let t20 = typeof t19 === 'string' ? parseFloat(t19) : Number(t19);
12
+ let t17 = input["quantity"];
13
+ let t18 = t20 * t17;
14
+ let t21 = input["tax_rate"];
15
+ let t22 = typeof t21 === 'string' ? parseFloat(t21) : Number(t21);
16
+ let t10 = t18 * t22;
17
+ return t10;
18
+ }
19
+
20
+ export function _total(input) {
21
+ let t26 = input["unit_price"];
22
+ let t27 = typeof t26 === 'string' ? parseFloat(t26) : Number(t26);
23
+ let t24 = input["quantity"];
24
+ let t25 = t27 * t24;
25
+ let t36 = input["tax_rate"];
26
+ let t37 = typeof t36 === 'string' ? parseFloat(t36) : Number(t36);
27
+ let t30 = t25 * t37;
28
+ let t13 = t25 + t30;
29
+ return t13;
30
+ }
31
+
@@ -0,0 +1,57 @@
1
+ # Autogenerated by Kumi Codegen
2
+ module Kumi::Compiled::KUMI_da41527c1ad37152fb8c552f2cfddd2f9a3aba7ee79aa824456a153b8517ee5f
3
+ def self.from(input_data = nil)
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 :subtotal then _subtotal
24
+ when :tax_amount then _tax_amount
25
+ when :total then _total
26
+ else raise KeyError, "Unknown declaration"
27
+ end
28
+ end
29
+
30
+ def _subtotal(input = @input)
31
+ t14 = input["unit_price"] || input[:unit_price]
32
+ t15 = t14.is_a?(BigDecimal) ? t14 : BigDecimal(t14.to_s)
33
+ t6 = input["quantity"] || input[:quantity]
34
+ t15 * t6
35
+ end
36
+
37
+ def _tax_amount(input = @input)
38
+ t19 = input["unit_price"] || input[:unit_price]
39
+ t20 = t19.is_a?(BigDecimal) ? t19 : BigDecimal(t19.to_s)
40
+ t17 = input["quantity"] || input[:quantity]
41
+ t18 = t20 * t17
42
+ t21 = input["tax_rate"] || input[:tax_rate]
43
+ t22 = t21.is_a?(BigDecimal) ? t21 : BigDecimal(t21.to_s)
44
+ t18 * t22
45
+ end
46
+
47
+ def _total(input = @input)
48
+ t26 = input["unit_price"] || input[:unit_price]
49
+ t27 = t26.is_a?(BigDecimal) ? t26 : BigDecimal(t26.to_s)
50
+ t24 = input["quantity"] || input[:quantity]
51
+ t25 = t27 * t24
52
+ t36 = input["tax_rate"] || input[:tax_rate]
53
+ t37 = t36.is_a?(BigDecimal) ? t36 : BigDecimal(t36.to_s)
54
+ t30 = t25 * t37
55
+ t25 + t30
56
+ end
57
+ end
@@ -0,0 +1,30 @@
1
+ (SNAST
2
+ (VALUE price
3
+ (Call :core.to_decimal
4
+ (InputRef unit_price key_chain=[]) :: [] -> string
5
+ ) :: [] -> decimal
6
+ ) :: [] -> decimal
7
+ (VALUE rate
8
+ (Call :core.to_decimal
9
+ (InputRef tax_rate key_chain=[]) :: [] -> string
10
+ ) :: [] -> decimal
11
+ ) :: [] -> decimal
12
+ (VALUE subtotal
13
+ (Call :core.mul
14
+ (Ref price) :: [] -> decimal
15
+ (InputRef quantity key_chain=[]) :: [] -> integer
16
+ ) :: [] -> integer
17
+ ) :: [] -> integer
18
+ (VALUE tax_amount
19
+ (Call :core.mul
20
+ (Ref subtotal) :: [] -> integer
21
+ (Ref rate) :: [] -> decimal
22
+ ) :: [] -> integer
23
+ ) :: [] -> integer
24
+ (VALUE total
25
+ (Call :core.add
26
+ (Ref subtotal) :: [] -> integer
27
+ (Ref tax_amount) :: [] -> integer
28
+ ) :: [] -> integer
29
+ ) :: [] -> integer
30
+ )
@@ -0,0 +1 @@
1
+ {"subtotal": "99.95", "tax_amount": "7.996", "total": "107.946"}
@@ -0,0 +1,5 @@
1
+ {
2
+ "unit_price": "19.99",
3
+ "quantity": 5,
4
+ "tax_rate": "0.08"
5
+ }
@@ -0,0 +1,14 @@
1
+ schema do
2
+ input do
3
+ string :unit_price
4
+ integer :quantity
5
+ string :tax_rate
6
+ end
7
+
8
+ let :price, to_decimal(input.unit_price)
9
+ let :rate, to_decimal(input.tax_rate)
10
+
11
+ value :subtotal, price * input.quantity
12
+ value :tax_amount, subtotal * rate
13
+ value :total, subtotal + tax_amount
14
+ end
@@ -27,8 +27,8 @@
27
27
  )
28
28
  )
29
29
  (VALUE count_over_limit
30
- (Call :"agg.sum"
31
- (Call :"agg.sum"
30
+ (Call :sum
31
+ (Call :sum
32
32
  (Call :sum
33
33
  (Call :__select__
34
34
  (Ref cell_over_limit)
@@ -1,5 +1,5 @@
1
1
  # Autogenerated by Kumi Codegen
2
- module Kumi::Compiled::KUMI_2861f5d1d1e2c819036f9450880c9c966a10cf904bae70971a4845415ebaacf9
2
+ module Kumi::Compiled::KUMI_882cc1d7ef44655567dd97759a39ebfc33efef7825f606e90d0f80a8246099ab
3
3
  def self.from(input_data = nil)
4
4
  instance = Object.new
5
5
  instance.extend(self)