numbl 0.3.0 → 0.4.0

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 (403) hide show
  1. package/binding.gyp +17 -33
  2. package/dist-cli/cli.js +61511 -46223
  3. package/dist-lib/graphics/types.d.ts +22 -0
  4. package/dist-lib/lib.js +37582 -22275
  5. package/dist-lib/numbl-core/executeCode.d.ts +11 -16
  6. package/dist-lib/numbl-core/executors/cache.d.ts +26 -0
  7. package/dist-lib/numbl-core/executors/classification.d.ts +134 -0
  8. package/dist-lib/numbl-core/executors/context.d.ts +76 -0
  9. package/dist-lib/numbl-core/executors/handleInline.d.ts +42 -0
  10. package/dist-lib/numbl-core/executors/index.d.ts +14 -0
  11. package/dist-lib/numbl-core/executors/jit/cJitCallExecutor.d.ts +35 -0
  12. package/dist-lib/numbl-core/executors/jit/cJitLoopExecutor.d.ts +31 -0
  13. package/dist-lib/numbl-core/executors/jit/cJitTopLevelExecutor.d.ts +29 -0
  14. package/dist-lib/numbl-core/executors/jit/callExecutor.d.ts +45 -0
  15. package/dist-lib/numbl-core/executors/jit/compileC.d.ts +51 -0
  16. package/dist-lib/numbl-core/executors/jit/compileC.node.d.ts +25 -0
  17. package/dist-lib/numbl-core/executors/jit/hostHelpers.d.ts +27 -0
  18. package/dist-lib/numbl-core/executors/jit/loopExecutor.d.ts +41 -0
  19. package/dist-lib/numbl-core/executors/jit/session.d.ts +17 -0
  20. package/dist-lib/numbl-core/executors/jit/topLevelExecutor.d.ts +36 -0
  21. package/dist-lib/numbl-core/executors/jit/typeAdapter.d.ts +28 -0
  22. package/dist-lib/numbl-core/executors/jit/typeAdapterC.d.ts +73 -0
  23. package/dist-lib/numbl-core/executors/jit/valueAdapter.d.ts +48 -0
  24. package/dist-lib/numbl-core/executors/jit/valueAdapterC.d.ts +108 -0
  25. package/dist-lib/numbl-core/executors/lowering.d.ts +120 -0
  26. package/dist-lib/numbl-core/executors/plugins.d.ts +32 -0
  27. package/dist-lib/numbl-core/executors/registry.d.ts +148 -0
  28. package/dist-lib/numbl-core/executors/types.d.ts +103 -0
  29. package/dist-lib/numbl-core/functionResolve.d.ts +7 -0
  30. package/dist-lib/numbl-core/helpers/check-helpers.d.ts +4 -5
  31. package/dist-lib/numbl-core/helpers/linsolve.d.ts +2 -3
  32. package/dist-lib/numbl-core/helpers/prng.d.ts +1 -2
  33. package/dist-lib/numbl-core/helpers/reduction-helpers.d.ts +4 -1
  34. package/dist-lib/numbl-core/interpreter/builtins/datetime.d.ts +2 -1
  35. package/dist-lib/numbl-core/interpreter/builtins/index.d.ts +1 -1
  36. package/dist-lib/numbl-core/interpreter/builtins/misc.d.ts +4 -1
  37. package/dist-lib/numbl-core/interpreter/builtins/types.d.ts +4 -109
  38. package/dist-lib/numbl-core/interpreter/interpreter.d.ts +51 -49
  39. package/dist-lib/numbl-core/interpreter/interpreterExec.d.ts +6 -0
  40. package/dist-lib/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +6 -3
  41. package/dist-lib/numbl-core/interpreter/types.d.ts +27 -12
  42. package/dist-lib/numbl-core/jit/builtins/defs/_shared.d.ts +43 -0
  43. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/_elemwise.d.ts +123 -0
  44. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/minus.d.ts +2 -0
  45. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/mpower.d.ts +12 -0
  46. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/mrdivide.d.ts +5 -0
  47. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/mtimes.d.ts +2 -0
  48. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/plus.d.ts +2 -0
  49. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/power.d.ts +30 -0
  50. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/rdivide.d.ts +2 -0
  51. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/times.d.ts +2 -0
  52. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/uminus.d.ts +2 -0
  53. package/dist-lib/numbl-core/jit/builtins/defs/compare/_compare.d.ts +12 -0
  54. package/dist-lib/numbl-core/jit/builtins/defs/compare/eq.d.ts +2 -0
  55. package/dist-lib/numbl-core/jit/builtins/defs/compare/ge.d.ts +2 -0
  56. package/dist-lib/numbl-core/jit/builtins/defs/compare/gt.d.ts +2 -0
  57. package/dist-lib/numbl-core/jit/builtins/defs/compare/le.d.ts +2 -0
  58. package/dist-lib/numbl-core/jit/builtins/defs/compare/lt.d.ts +2 -0
  59. package/dist-lib/numbl-core/jit/builtins/defs/compare/ne.d.ts +2 -0
  60. package/dist-lib/numbl-core/jit/builtins/defs/diag/assert.d.ts +6 -0
  61. package/dist-lib/numbl-core/jit/builtins/defs/io/_format_args.d.ts +17 -0
  62. package/dist-lib/numbl-core/jit/builtins/defs/io/disp.d.ts +2 -0
  63. package/dist-lib/numbl-core/jit/builtins/defs/io/error.d.ts +2 -0
  64. package/dist-lib/numbl-core/jit/builtins/defs/io/fprintf.d.ts +2 -0
  65. package/dist-lib/numbl-core/jit/builtins/defs/io/sprintf.d.ts +2 -0
  66. package/dist-lib/numbl-core/jit/builtins/defs/io/warning.d.ts +15 -0
  67. package/dist-lib/numbl-core/jit/builtins/defs/logical/_shortcircuit.d.ts +30 -0
  68. package/dist-lib/numbl-core/jit/builtins/defs/logical/_unary_pred.d.ts +30 -0
  69. package/dist-lib/numbl-core/jit/builtins/defs/logical/and.d.ts +5 -0
  70. package/dist-lib/numbl-core/jit/builtins/defs/logical/andand.d.ts +1 -0
  71. package/dist-lib/numbl-core/jit/builtins/defs/logical/boolconst.d.ts +3 -0
  72. package/dist-lib/numbl-core/jit/builtins/defs/logical/classBuiltin.d.ts +21 -0
  73. package/dist-lib/numbl-core/jit/builtins/defs/logical/fieldnames.d.ts +15 -0
  74. package/dist-lib/numbl-core/jit/builtins/defs/logical/isa.d.ts +13 -0
  75. package/dist-lib/numbl-core/jit/builtins/defs/logical/iscell.d.ts +8 -0
  76. package/dist-lib/numbl-core/jit/builtins/defs/logical/isempty.d.ts +2 -0
  77. package/dist-lib/numbl-core/jit/builtins/defs/logical/isequal.d.ts +2 -0
  78. package/dist-lib/numbl-core/jit/builtins/defs/logical/isfield.d.ts +20 -0
  79. package/dist-lib/numbl-core/jit/builtins/defs/logical/isinf.d.ts +2 -0
  80. package/dist-lib/numbl-core/jit/builtins/defs/logical/isnan.d.ts +1 -0
  81. package/dist-lib/numbl-core/jit/builtins/defs/logical/isnumeric.d.ts +7 -0
  82. package/dist-lib/numbl-core/jit/builtins/defs/logical/isreal.d.ts +2 -0
  83. package/dist-lib/numbl-core/jit/builtins/defs/logical/isscalar.d.ts +20 -0
  84. package/dist-lib/numbl-core/jit/builtins/defs/logical/isstruct.d.ts +7 -0
  85. package/dist-lib/numbl-core/jit/builtins/defs/logical/logical.d.ts +1 -0
  86. package/dist-lib/numbl-core/jit/builtins/defs/logical/not.d.ts +15 -0
  87. package/dist-lib/numbl-core/jit/builtins/defs/logical/or.d.ts +11 -0
  88. package/dist-lib/numbl-core/jit/builtins/defs/logical/oror.d.ts +1 -0
  89. package/dist-lib/numbl-core/jit/builtins/defs/logical/strcmp.d.ts +21 -0
  90. package/dist-lib/numbl-core/jit/builtins/defs/logical/typequery.d.ts +10 -0
  91. package/dist-lib/numbl-core/jit/builtins/defs/logical/xor.d.ts +12 -0
  92. package/dist-lib/numbl-core/jit/builtins/defs/math/_complex_fold.d.ts +34 -0
  93. package/dist-lib/numbl-core/jit/builtins/defs/math/_unary_real.d.ts +51 -0
  94. package/dist-lib/numbl-core/jit/builtins/defs/math/abs.d.ts +7 -0
  95. package/dist-lib/numbl-core/jit/builtins/defs/math/angle.d.ts +7 -0
  96. package/dist-lib/numbl-core/jit/builtins/defs/math/asinh.d.ts +1 -0
  97. package/dist-lib/numbl-core/jit/builtins/defs/math/atan.d.ts +1 -0
  98. package/dist-lib/numbl-core/jit/builtins/defs/math/atan2.d.ts +3 -0
  99. package/dist-lib/numbl-core/jit/builtins/defs/math/besselh.d.ts +2 -0
  100. package/dist-lib/numbl-core/jit/builtins/defs/math/ceil.d.ts +4 -0
  101. package/dist-lib/numbl-core/jit/builtins/defs/math/conj.d.ts +7 -0
  102. package/dist-lib/numbl-core/jit/builtins/defs/math/constants.d.ts +7 -0
  103. package/dist-lib/numbl-core/jit/builtins/defs/math/cos.d.ts +1 -0
  104. package/dist-lib/numbl-core/jit/builtins/defs/math/cosh.d.ts +1 -0
  105. package/dist-lib/numbl-core/jit/builtins/defs/math/dot.d.ts +20 -0
  106. package/dist-lib/numbl-core/jit/builtins/defs/math/double.d.ts +28 -0
  107. package/dist-lib/numbl-core/jit/builtins/defs/math/exp.d.ts +1 -0
  108. package/dist-lib/numbl-core/jit/builtins/defs/math/fix.d.ts +4 -0
  109. package/dist-lib/numbl-core/jit/builtins/defs/math/floor.d.ts +4 -0
  110. package/dist-lib/numbl-core/jit/builtins/defs/math/hypot.d.ts +3 -0
  111. package/dist-lib/numbl-core/jit/builtins/defs/math/imag.d.ts +7 -0
  112. package/dist-lib/numbl-core/jit/builtins/defs/math/linspace.d.ts +6 -0
  113. package/dist-lib/numbl-core/jit/builtins/defs/math/log.d.ts +4 -0
  114. package/dist-lib/numbl-core/jit/builtins/defs/math/log10.d.ts +3 -0
  115. package/dist-lib/numbl-core/jit/builtins/defs/math/log2.d.ts +5 -0
  116. package/dist-lib/numbl-core/jit/builtins/defs/math/logspace.d.ts +8 -0
  117. package/dist-lib/numbl-core/jit/builtins/defs/math/mod.d.ts +1 -0
  118. package/dist-lib/numbl-core/jit/builtins/defs/math/norm.d.ts +2 -0
  119. package/dist-lib/numbl-core/jit/builtins/defs/math/real.d.ts +7 -0
  120. package/dist-lib/numbl-core/jit/builtins/defs/math/rem.d.ts +3 -0
  121. package/dist-lib/numbl-core/jit/builtins/defs/math/round.d.ts +1 -0
  122. package/dist-lib/numbl-core/jit/builtins/defs/math/sign.d.ts +5 -0
  123. package/dist-lib/numbl-core/jit/builtins/defs/math/sin.d.ts +1 -0
  124. package/dist-lib/numbl-core/jit/builtins/defs/math/sinh.d.ts +1 -0
  125. package/dist-lib/numbl-core/jit/builtins/defs/math/sqrt.d.ts +11 -0
  126. package/dist-lib/numbl-core/jit/builtins/defs/math/tan.d.ts +1 -0
  127. package/dist-lib/numbl-core/jit/builtins/defs/math/tanh.d.ts +1 -0
  128. package/dist-lib/numbl-core/jit/builtins/defs/math/uniquetol.d.ts +22 -0
  129. package/dist-lib/numbl-core/jit/builtins/defs/plot/dispatch.d.ts +6 -0
  130. package/dist-lib/numbl-core/jit/builtins/defs/reduction/_cumulative.d.ts +49 -0
  131. package/dist-lib/numbl-core/jit/builtins/defs/reduction/_shape.d.ts +126 -0
  132. package/dist-lib/numbl-core/jit/builtins/defs/reduction/_variance.d.ts +17 -0
  133. package/dist-lib/numbl-core/jit/builtins/defs/reduction/all.d.ts +1 -0
  134. package/dist-lib/numbl-core/jit/builtins/defs/reduction/any.d.ts +1 -0
  135. package/dist-lib/numbl-core/jit/builtins/defs/reduction/cummax.d.ts +1 -0
  136. package/dist-lib/numbl-core/jit/builtins/defs/reduction/cummin.d.ts +1 -0
  137. package/dist-lib/numbl-core/jit/builtins/defs/reduction/cumprod.d.ts +1 -0
  138. package/dist-lib/numbl-core/jit/builtins/defs/reduction/cumsum.d.ts +1 -0
  139. package/dist-lib/numbl-core/jit/builtins/defs/reduction/diff.d.ts +16 -0
  140. package/dist-lib/numbl-core/jit/builtins/defs/reduction/length.d.ts +2 -0
  141. package/dist-lib/numbl-core/jit/builtins/defs/reduction/max.d.ts +1 -0
  142. package/dist-lib/numbl-core/jit/builtins/defs/reduction/mean.d.ts +1 -0
  143. package/dist-lib/numbl-core/jit/builtins/defs/reduction/min.d.ts +1 -0
  144. package/dist-lib/numbl-core/jit/builtins/defs/reduction/numel.d.ts +2 -0
  145. package/dist-lib/numbl-core/jit/builtins/defs/reduction/prod.d.ts +1 -0
  146. package/dist-lib/numbl-core/jit/builtins/defs/reduction/std.d.ts +1 -0
  147. package/dist-lib/numbl-core/jit/builtins/defs/reduction/sum.d.ts +1 -0
  148. package/dist-lib/numbl-core/jit/builtins/defs/reduction/var.d.ts +1 -0
  149. package/dist-lib/numbl-core/jit/builtins/defs/shape/_construct.d.ts +67 -0
  150. package/dist-lib/numbl-core/jit/builtins/defs/shape/_triangular.d.ts +34 -0
  151. package/dist-lib/numbl-core/jit/builtins/defs/shape/cat.d.ts +33 -0
  152. package/dist-lib/numbl-core/jit/builtins/defs/shape/diag.d.ts +29 -0
  153. package/dist-lib/numbl-core/jit/builtins/defs/shape/eye.d.ts +5 -0
  154. package/dist-lib/numbl-core/jit/builtins/defs/shape/flip.d.ts +7 -0
  155. package/dist-lib/numbl-core/jit/builtins/defs/shape/meshgrid.d.ts +12 -0
  156. package/dist-lib/numbl-core/jit/builtins/defs/shape/ones.d.ts +1 -0
  157. package/dist-lib/numbl-core/jit/builtins/defs/shape/repmat.d.ts +37 -0
  158. package/dist-lib/numbl-core/jit/builtins/defs/shape/reshape.d.ts +39 -0
  159. package/dist-lib/numbl-core/jit/builtins/defs/shape/size.d.ts +20 -0
  160. package/dist-lib/numbl-core/jit/builtins/defs/shape/sort.d.ts +19 -0
  161. package/dist-lib/numbl-core/jit/builtins/defs/shape/transpose.d.ts +6 -0
  162. package/dist-lib/numbl-core/jit/builtins/defs/shape/tril.d.ts +16 -0
  163. package/dist-lib/numbl-core/jit/builtins/defs/shape/triu.d.ts +16 -0
  164. package/dist-lib/numbl-core/jit/builtins/defs/shape/zeros.d.ts +1 -0
  165. package/dist-lib/numbl-core/jit/builtins/defs/system/deal.d.ts +20 -0
  166. package/dist-lib/numbl-core/jit/builtins/defs/system/feval.d.ts +36 -0
  167. package/dist-lib/numbl-core/jit/builtins/defs/system/pathBuiltins.d.ts +4 -0
  168. package/dist-lib/numbl-core/jit/builtins/defs/system/tic.d.ts +8 -0
  169. package/dist-lib/numbl-core/jit/builtins/defs/system/toc.d.ts +5 -0
  170. package/dist-lib/numbl-core/jit/builtins/index.d.ts +16 -0
  171. package/dist-lib/numbl-core/jit/builtins/registry.d.ts +138 -0
  172. package/dist-lib/numbl-core/jit/builtins/runtime/cell/cell.d.ts +24 -0
  173. package/dist-lib/numbl-core/jit/builtins/runtime/indexing/loop_count.d.ts +1 -0
  174. package/dist-lib/numbl-core/jit/builtins/runtime/indexing/range_value.d.ts +1 -0
  175. package/dist-lib/numbl-core/jit/builtins/runtime/indexing/scalar_index.d.ts +11 -0
  176. package/dist-lib/numbl-core/jit/builtins/runtime/indexing/tensor_make_range.d.ts +5 -0
  177. package/dist-lib/numbl-core/jit/builtins/runtime/io/assert_fmt.d.ts +1 -0
  178. package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_complex.d.ts +1 -0
  179. package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_double.d.ts +1 -0
  180. package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_struct.d.ts +1 -0
  181. package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_tensor.d.ts +1 -0
  182. package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_tensor_complex.d.ts +1 -0
  183. package/dist-lib/numbl-core/jit/builtins/runtime/io/error_fmt.d.ts +2 -0
  184. package/dist-lib/numbl-core/jit/builtins/runtime/io/format_complex.d.ts +1 -0
  185. package/dist-lib/numbl-core/jit/builtins/runtime/io/format_double.d.ts +1 -0
  186. package/dist-lib/numbl-core/jit/builtins/runtime/io/format_engine.d.ts +1 -0
  187. package/dist-lib/numbl-core/jit/builtins/runtime/io/fprintf.d.ts +1 -0
  188. package/dist-lib/numbl-core/jit/builtins/runtime/io/sprintf.d.ts +5 -0
  189. package/dist-lib/numbl-core/jit/builtins/runtime/io/warning_fmt.d.ts +2 -0
  190. package/dist-lib/numbl-core/jit/builtins/runtime/plot/plot_dispatch.d.ts +1 -0
  191. package/dist-lib/numbl-core/jit/builtins/runtime/snippets.gen.d.ts +86 -0
  192. package/dist-lib/numbl-core/jit/builtins/runtime/system/cdiv.d.ts +4 -0
  193. package/dist-lib/numbl-core/jit/builtins/runtime/system/cscalar.d.ts +103 -0
  194. package/dist-lib/numbl-core/jit/builtins/runtime/system/deep_clone.d.ts +1 -0
  195. package/dist-lib/numbl-core/jit/builtins/runtime/system/isequal.d.ts +2 -0
  196. package/dist-lib/numbl-core/jit/builtins/runtime/system/tictoc.d.ts +5 -0
  197. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor.d.ts +6 -0
  198. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc.d.ts +5 -0
  199. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc_complex.d.ts +6 -0
  200. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc_nd.d.ts +5 -0
  201. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc_nd_complex.d.ts +6 -0
  202. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_copy_complex.d.ts +6 -0
  203. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_matrix.d.ts +5 -0
  204. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_matrix_complex.d.ts +6 -0
  205. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_row.d.ts +5 -0
  206. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_row_complex.d.ts +6 -0
  207. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_cat.d.ts +11 -0
  208. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_cumulative.d.ts +32 -0
  209. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_diag.d.ts +33 -0
  210. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_diff.d.ts +5 -0
  211. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_dot.d.ts +16 -0
  212. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_complex.d.ts +90 -0
  213. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real.d.ts +75 -0
  214. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real_fn.d.ts +95 -0
  215. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_eye.d.ts +10 -0
  216. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_fill_nd.d.ts +11 -0
  217. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_fill_square.d.ts +5 -0
  218. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_flip.d.ts +11 -0
  219. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_linspace.d.ts +5 -0
  220. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_logical_real.d.ts +10 -0
  221. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_logspace.d.ts +5 -0
  222. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_meshgrid.d.ts +29 -0
  223. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_mtimes_complex.d.ts +10 -0
  224. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_mtimes_real.d.ts +6 -0
  225. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_norm.d.ts +4 -0
  226. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_ones_nd.d.ts +5 -0
  227. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_ones_square.d.ts +5 -0
  228. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_predicate.d.ts +42 -0
  229. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_complex.d.ts +53 -0
  230. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_real.d.ts +42 -0
  231. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_repmat.d.ts +11 -0
  232. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reshape_nd.d.ts +5 -0
  233. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reshape_nd_complex.d.ts +6 -0
  234. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_size.d.ts +5 -0
  235. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_sort_real.d.ts +36 -0
  236. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_transpose.d.ts +5 -0
  237. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_transpose_complex.d.ts +6 -0
  238. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_triangular.d.ts +22 -0
  239. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_complex_math.d.ts +128 -0
  240. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_real_math.d.ts +95 -0
  241. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_uniquetol.d.ts +5 -0
  242. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_var.d.ts +12 -0
  243. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_zeros_nd.d.ts +5 -0
  244. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_zeros_square.d.ts +5 -0
  245. package/dist-lib/numbl-core/jit/builtins/runtime/text/strcmp.d.ts +2 -0
  246. package/dist-lib/numbl-core/jit/codegen/cFormat.d.ts +36 -0
  247. package/dist-lib/numbl-core/jit/codegen/cHelpers.d.ts +48 -0
  248. package/dist-lib/numbl-core/jit/codegen/emit.d.ts +55 -0
  249. package/dist-lib/numbl-core/jit/codegen/emitCellTypedef.d.ts +23 -0
  250. package/dist-lib/numbl-core/jit/codegen/emitExpr.d.ts +33 -0
  251. package/dist-lib/numbl-core/jit/codegen/emitIndex.d.ts +56 -0
  252. package/dist-lib/numbl-core/jit/codegen/emitJs.d.ts +64 -0
  253. package/dist-lib/numbl-core/jit/codegen/emitNamedTypedef.d.ts +58 -0
  254. package/dist-lib/numbl-core/jit/codegen/emitStmt.d.ts +76 -0
  255. package/dist-lib/numbl-core/jit/codegen/emitTensorConcat.d.ts +23 -0
  256. package/dist-lib/numbl-core/jit/codegen/emitTensorConcatJs.d.ts +16 -0
  257. package/dist-lib/numbl-core/jit/codegen/emitTensorFused.d.ts +77 -0
  258. package/dist-lib/numbl-core/jit/codegen/inlinePass.d.ts +66 -0
  259. package/dist-lib/numbl-core/jit/codegen/liveness.d.ts +58 -0
  260. package/dist-lib/numbl-core/jit/codegen/prettyIR.d.ts +24 -0
  261. package/dist-lib/numbl-core/jit/codegen/runtime.d.ts +150 -0
  262. package/dist-lib/numbl-core/jit/compileSpec.d.ts +84 -0
  263. package/dist-lib/numbl-core/jit/compileSpecC.d.ts +93 -0
  264. package/dist-lib/numbl-core/jit/index.d.ts +13 -5
  265. package/dist-lib/numbl-core/jit/lowering/classDefs.d.ts +109 -0
  266. package/dist-lib/numbl-core/jit/lowering/errors.d.ts +35 -0
  267. package/dist-lib/numbl-core/jit/lowering/indexFold.d.ts +31 -0
  268. package/dist-lib/numbl-core/jit/lowering/indexResolve.d.ts +100 -0
  269. package/dist-lib/numbl-core/jit/lowering/ir.d.ts +584 -0
  270. package/dist-lib/numbl-core/jit/lowering/lower.d.ts +271 -0
  271. package/dist-lib/numbl-core/jit/lowering/lowerCellIndex.d.ts +41 -0
  272. package/dist-lib/numbl-core/jit/lowering/lowerCellLit.d.ts +19 -0
  273. package/dist-lib/numbl-core/jit/lowering/lowerClassConstructor.d.ts +55 -0
  274. package/dist-lib/numbl-core/jit/lowering/lowerFuncCall.d.ts +34 -0
  275. package/dist-lib/numbl-core/jit/lowering/lowerHandle.d.ts +57 -0
  276. package/dist-lib/numbl-core/jit/lowering/lowerIndexLoad.d.ts +16 -0
  277. package/dist-lib/numbl-core/jit/lowering/lowerIndexSlice.d.ts +29 -0
  278. package/dist-lib/numbl-core/jit/lowering/lowerIndexSliceStore.d.ts +19 -0
  279. package/dist-lib/numbl-core/jit/lowering/lowerIndexStore.d.ts +14 -0
  280. package/dist-lib/numbl-core/jit/lowering/lowerMethodCall.d.ts +45 -0
  281. package/dist-lib/numbl-core/jit/lowering/lowerMultiAssign.d.ts +36 -0
  282. package/dist-lib/numbl-core/jit/lowering/lowerTensorLit.d.ts +25 -0
  283. package/dist-lib/numbl-core/jit/lowering/rangeCount.d.ts +19 -0
  284. package/dist-lib/numbl-core/jit/lowering/specialize.d.ts +93 -0
  285. package/dist-lib/numbl-core/jit/lowering/types.d.ts +503 -0
  286. package/dist-lib/numbl-core/jit/lowering/walk.d.ts +17 -0
  287. package/dist-lib/numbl-core/jit/numbl/index.d.ts +30 -0
  288. package/dist-lib/numbl-core/jit/parser/astUtils.d.ts +43 -0
  289. package/dist-lib/numbl-core/jit/parser/index.d.ts +12 -0
  290. package/dist-lib/numbl-core/jit/parser/sourceLoc.d.ts +12 -0
  291. package/dist-lib/numbl-core/jit/runtime/context.d.ts +23 -0
  292. package/dist-lib/numbl-core/jit/runtime/inferType.d.ts +10 -0
  293. package/dist-lib/numbl-core/jit/runtime/value.d.ts +101 -0
  294. package/dist-lib/numbl-core/jit/workspace/driverPrologue.d.ts +59 -0
  295. package/dist-lib/numbl-core/jit/workspace/mtoc2UserFunctionLoader.d.ts +62 -0
  296. package/dist-lib/numbl-core/jit/workspace/workspace.d.ts +243 -0
  297. package/dist-lib/numbl-core/jitTypes.d.ts +94 -0
  298. package/dist-lib/numbl-core/jsUserFunctions.d.ts +10 -2
  299. package/dist-lib/numbl-core/lowering/loweringContext.d.ts +24 -0
  300. package/dist-lib/numbl-core/native/lapack-bridge.d.ts +3 -3
  301. package/dist-lib/numbl-core/parser/ClassParser.d.ts +3 -0
  302. package/dist-lib/numbl-core/parser/types.d.ts +20 -0
  303. package/dist-lib/numbl-core/runtime/alloc.d.ts +12 -23
  304. package/dist-lib/numbl-core/runtime/constructors.d.ts +6 -6
  305. package/dist-lib/numbl-core/runtime/cow.d.ts +33 -0
  306. package/dist-lib/numbl-core/runtime/index.d.ts +4 -3
  307. package/dist-lib/numbl-core/runtime/indexing.d.ts +17 -2
  308. package/dist-lib/numbl-core/runtime/plotBuiltinDispatch.d.ts +86 -0
  309. package/dist-lib/numbl-core/runtime/plotUtils.d.ts +17 -2
  310. package/dist-lib/numbl-core/runtime/refcount.d.ts +85 -0
  311. package/dist-lib/numbl-core/runtime/runtime.d.ts +43 -67
  312. package/dist-lib/numbl-core/runtime/runtimeDispatch.d.ts +2 -2
  313. package/dist-lib/numbl-core/runtime/runtimeIndexing.d.ts +2 -2
  314. package/dist-lib/numbl-core/runtime/runtimeMemberAccess.d.ts +1 -1
  315. package/dist-lib/numbl-core/runtime/runtimePlot.d.ts +1 -0
  316. package/dist-lib/numbl-core/runtime/struct-access.d.ts +2 -1
  317. package/dist-lib/numbl-core/runtime/types.d.ts +117 -62
  318. package/dist-lib/numbl-core/runtime/utils.d.ts +2 -8
  319. package/dist-lib/numbl-core/version.d.ts +1 -1
  320. package/dist-lib/numbl-core/workspace/types.d.ts +8 -0
  321. package/dist-plot-viewer/assets/index-COAM8o1E.js +4426 -0
  322. package/dist-plot-viewer/index.html +1 -1
  323. package/dist-site-viewer/404.html +33 -0
  324. package/dist-site-viewer/assets/index-CgBUy7v7.js +4748 -0
  325. package/dist-site-viewer/assets/index-D5YY8PKx.css +1 -0
  326. package/dist-site-viewer/assets/numbl-worker-VkVtodCX.js +11836 -0
  327. package/dist-site-viewer/coi-serviceworker.js +70 -0
  328. package/dist-site-viewer/favicon.svg +23 -0
  329. package/dist-site-viewer/index.html +16 -0
  330. package/dist-site-viewer/logo.svg +26 -0
  331. package/dist-site-viewer/numbl-embed.js +111 -0
  332. package/dist-site-viewer/vite.svg +1 -0
  333. package/native/lapack_linsolve.cpp +1 -1
  334. package/native/numbl_addon_common.h +2 -2
  335. package/native/ops/comparison.c +1 -1
  336. package/native/ops/real_unary_elemwise.c +3 -1
  337. package/package.json +16 -13
  338. package/dist-lib/numbl-core/jit/c/abi.d.ts +0 -90
  339. package/dist-lib/numbl-core/jit/c/assemble.d.ts +0 -56
  340. package/dist-lib/numbl-core/jit/c/classify.d.ts +0 -70
  341. package/dist-lib/numbl-core/jit/c/compile.d.ts +0 -37
  342. package/dist-lib/numbl-core/jit/c/context.d.ts +0 -152
  343. package/dist-lib/numbl-core/jit/c/emit/assign.d.ts +0 -20
  344. package/dist-lib/numbl-core/jit/c/emit/complexScalar.d.ts +0 -18
  345. package/dist-lib/numbl-core/jit/c/emit/fused.d.ts +0 -42
  346. package/dist-lib/numbl-core/jit/c/emit/helpers.d.ts +0 -40
  347. package/dist-lib/numbl-core/jit/c/emit/index.d.ts +0 -14
  348. package/dist-lib/numbl-core/jit/c/emit/scalar.d.ts +0 -23
  349. package/dist-lib/numbl-core/jit/c/emit/stmt.d.ts +0 -25
  350. package/dist-lib/numbl-core/jit/c/emit/tensor.d.ts +0 -127
  351. package/dist-lib/numbl-core/jit/c/emit/userCall.d.ts +0 -58
  352. package/dist-lib/numbl-core/jit/c/epilogue.d.ts +0 -26
  353. package/dist-lib/numbl-core/jit/c/feasibility.d.ts +0 -44
  354. package/dist-lib/numbl-core/jit/c/prelude.d.ts +0 -37
  355. package/dist-lib/numbl-core/jit/c/visit.d.ts +0 -63
  356. package/dist-lib/numbl-core/jit/e1/complexKernelEmit.d.ts +0 -46
  357. package/dist-lib/numbl-core/jit/e1/hash.d.ts +0 -10
  358. package/dist-lib/numbl-core/jit/e1/install.d.ts +0 -13
  359. package/dist-lib/numbl-core/jit/e1/kernelEmit.d.ts +0 -54
  360. package/dist-lib/numbl-core/jit/e1/multiReductionKernel.d.ts +0 -66
  361. package/dist-lib/numbl-core/jit/e1/openmpFlag.d.ts +0 -13
  362. package/dist-lib/numbl-core/jit/e1/scalarFnKernel.d.ts +0 -44
  363. package/dist-lib/numbl-core/jit/e2/assignKernel.d.ts +0 -34
  364. package/dist-lib/numbl-core/jit/e2/astToJitExpr.d.ts +0 -25
  365. package/dist-lib/numbl-core/jit/e2/cache.d.ts +0 -80
  366. package/dist-lib/numbl-core/jit/e2/chainKernelEmit.d.ts +0 -55
  367. package/dist-lib/numbl-core/jit/e2/classify.d.ts +0 -119
  368. package/dist-lib/numbl-core/jit/e2/compileFn.d.ts +0 -16
  369. package/dist-lib/numbl-core/jit/e2/complexChainKernelEmit.d.ts +0 -79
  370. package/dist-lib/numbl-core/jit/e2/emitShared.d.ts +0 -71
  371. package/dist-lib/numbl-core/jit/e2/install.d.ts +0 -11
  372. package/dist-lib/numbl-core/jit/e2/liveness.d.ts +0 -29
  373. package/dist-lib/numbl-core/jit/e2/loopKernel.d.ts +0 -49
  374. package/dist-lib/numbl-core/jit/e2/loopKernelEmit.d.ts +0 -75
  375. package/dist-lib/numbl-core/jit/e2/multiReductionDriver.d.ts +0 -24
  376. package/dist-lib/numbl-core/jit/e2/reductionKernelEmit.d.ts +0 -72
  377. package/dist-lib/numbl-core/jit/e2/scalarFnDriver.d.ts +0 -29
  378. package/dist-lib/numbl-core/jit/fusedChainHelpers.d.ts +0 -65
  379. package/dist-lib/numbl-core/jit/fusedScalarEmit.d.ts +0 -69
  380. package/dist-lib/numbl-core/jit/fusion.d.ts +0 -71
  381. package/dist-lib/numbl-core/jit/fusionOps.d.ts +0 -25
  382. package/dist-lib/numbl-core/jit/heavyOps.d.ts +0 -15
  383. package/dist-lib/numbl-core/jit/jitBailSafety.d.ts +0 -41
  384. package/dist-lib/numbl-core/jit/jitLoop.d.ts +0 -25
  385. package/dist-lib/numbl-core/jit/jitLoopAnalysis.d.ts +0 -37
  386. package/dist-lib/numbl-core/jit/jitLower.d.ts +0 -122
  387. package/dist-lib/numbl-core/jit/jitLowerExpr.d.ts +0 -27
  388. package/dist-lib/numbl-core/jit/jitLowerStmt.d.ts +0 -9
  389. package/dist-lib/numbl-core/jit/jitLowerTypes.d.ts +0 -29
  390. package/dist-lib/numbl-core/jit/jitTopLevel.d.ts +0 -22
  391. package/dist-lib/numbl-core/jit/jitTypes.d.ts +0 -394
  392. package/dist-lib/numbl-core/jit/js/jitCodegen.d.ts +0 -7
  393. package/dist-lib/numbl-core/jit/js/jitCodegenHoist.d.ts +0 -70
  394. package/dist-lib/numbl-core/jit/js/jitHelpers.d.ts +0 -34
  395. package/dist-lib/numbl-core/jit/js/jitHelpersComplex.d.ts +0 -21
  396. package/dist-lib/numbl-core/jit/js/jitHelpersIndex.d.ts +0 -33
  397. package/dist-lib/numbl-core/jit/js/jitHelpersTensor.d.ts +0 -34
  398. package/dist-lib/numbl-core/jit/js/jsFusedCodegen.d.ts +0 -17
  399. package/dist-lib/numbl-core/jit/js/jsMultiReduction.d.ts +0 -70
  400. package/dist-lib/numbl-core/jit/scalarEmit.d.ts +0 -58
  401. package/dist-plot-viewer/assets/index-GiUNnMQg.js +0 -4426
  402. package/native/jit_runtime/jit_runtime.c +0 -261
  403. package/native/jit_runtime/jit_runtime.h +0 -204
@@ -0,0 +1,584 @@
1
+ /**
2
+ * mtoc2 intermediate representation. Built from scratch; only what the
3
+ * MVP scope needs (scalar real double, arith + comparisons, disp,
4
+ * if/while/for, user functions with specialization).
5
+ *
6
+ * Every node carries a `Span` for error attribution. Every IRExpr
7
+ * carries a `Type`.
8
+ */
9
+ import type { Span } from "../parser/index.js";
10
+ import type { NumericType, Type } from "./types.js";
11
+ import { BinaryOperation, UnaryOperation } from "../parser/index.js";
12
+ export interface NumLit {
13
+ kind: "NumLit";
14
+ value: number;
15
+ ty: Type;
16
+ span: Span;
17
+ }
18
+ /** Imaginary-unit literal — produced for `1i`, `2.5i`, etc. `value` is
19
+ * the imaginary coefficient (`2.5` for `2.5i`); the corresponding
20
+ * real part is implicitly `0`. The lowerer collapses the parser's
21
+ * `Number * ImagUnit` shape and bare-`ImagUnit` reads into this node;
22
+ * codegen emits `(<value> * I)` (using `<complex.h>`'s `I` macro). */
23
+ export interface ImagLit {
24
+ kind: "ImagLit";
25
+ value: number;
26
+ ty: Type;
27
+ span: Span;
28
+ }
29
+ /** Source-level string or char literal. Today only consumed by
30
+ * reducer builtins (`sum(A, 'all')`, `min(A, [], 'all')`, etc.) at
31
+ * transfer time — they read `ty.exact` to dispatch on the literal.
32
+ * Codegen renders the IR node as a C string literal so the bare
33
+ * expression compiles, but the reducer builtins' `codegenC` ignores
34
+ * the slot entirely (the dim choice is encoded in the helper name).
35
+ * No other context accepts a `String`-typed value; the lowerer
36
+ * rejects it via `requireValueType`-adjacent checks per call site. */
37
+ export interface StringLit {
38
+ kind: "StringLit";
39
+ value: string;
40
+ ty: Type;
41
+ span: Span;
42
+ }
43
+ /** Runtime tensor construction for every tensor source-literal. Codegen
44
+ * emits `mtoc2_tensor_from_row` (1×N) or `mtoc2_tensor_from_matrix`
45
+ * (rows×cols) with a C99 compound literal of the per-element
46
+ * expressions. The shape is statically known; the element values may
47
+ * be any IR expressions (NumLit for literal cells, Var/Binary/... for
48
+ * computed cells).
49
+ *
50
+ * `elements` is column-major and length-matches `shape`. */
51
+ export interface TensorBuild {
52
+ kind: "TensorBuild";
53
+ elements: IRExpr[];
54
+ shape: number[];
55
+ ty: Type;
56
+ span: Span;
57
+ }
58
+ export interface Var {
59
+ kind: "Var";
60
+ /** Source name (for diagnostics). */
61
+ name: string;
62
+ /** Allocated C identifier. Each SSA-like assignment gets a fresh one. */
63
+ cName: string;
64
+ ty: Type;
65
+ span: Span;
66
+ }
67
+ export interface Binary {
68
+ kind: "Binary";
69
+ /** Builtin name (e.g. "plus", "minus"). */
70
+ builtin: string;
71
+ op: BinaryOperation;
72
+ left: IRExpr;
73
+ right: IRExpr;
74
+ ty: Type;
75
+ span: Span;
76
+ }
77
+ export interface Unary {
78
+ kind: "Unary";
79
+ builtin: string;
80
+ op: UnaryOperation;
81
+ operand: IRExpr;
82
+ ty: Type;
83
+ span: Span;
84
+ }
85
+ /** Single-output function call. `Call` covers three distinct emit
86
+ * paths discriminated by how codegen interprets `cName`:
87
+ *
88
+ * 1. **User-function specialization** — the lowerer's `buildUserFunctionCall`
89
+ * path. `cName` is the mangled spec name returned by
90
+ * `specializeUserFunction` (e.g. `apply__a1b2c3d4`); codegen emits
91
+ * a direct call to that symbol. The `IRFunc` for the spec lives in
92
+ * `IRProgram.functions[cName]`.
93
+ * 2. **Bundled builtin** — `cName` equals the source-level builtin
94
+ * name (e.g. `sqrt`, `zeros`, `disp`). Codegen routes through
95
+ * `getBuiltin(cName).codegenC(argsC, argTypes)` to synthesize the
96
+ * emitted C expression — there's no Standalone IRFunc.
97
+ * 3. **Synthesized runtime call** — emitted by the lowerer for a
98
+ * handful of fixed runtime helpers (`mtoc2_toc_print`,
99
+ * `mtoc2_toc_handle_print`, the complex `'` rewrite to
100
+ * `transpose(conj(z))`, etc.). The `name` field carries the
101
+ * source-facing identifier the lowerer wants in diagnostics; the
102
+ * pattern is the same as the builtin route — codegen treats them
103
+ * as builtin-name lookups.
104
+ *
105
+ * The `name` field is purely for diagnostics (user-facing call name
106
+ * e.g. `pkg.foo` or `Class.method` or `f`). The semantic key is
107
+ * `cName`. */
108
+ export interface Call {
109
+ kind: "Call";
110
+ /** Resolved name. For user functions: mangled spec name. For
111
+ * builtins / synthesized runtime calls: the source-level builtin
112
+ * name routed through `getBuiltin`. */
113
+ cName: string;
114
+ /** Source-level name (for diagnostics). */
115
+ name: string;
116
+ args: IRExpr[];
117
+ ty: Type;
118
+ span: Span;
119
+ }
120
+ /** Function-handle literal — produced by `@user_func` (no captures) or
121
+ * `@(p1, ..., pN) <body>` (zero+ captures). `ty` is a `HandleType`
122
+ * whose `targetName`/`ast` identify the underlying user function and
123
+ * whose `captures` list shapes the C struct. The literal renders as a
124
+ * C compound literal: `(mtoc2_handle_empty_t){0}` for no captures, or
125
+ * `(mtoc2_handle__<hex>){.cap_<name> = <value>, ...}` per shape.
126
+ *
127
+ * Dispatch is static — every `h(args)` call site reads the handle
128
+ * variable's type, specializes against the target AST with
129
+ * `[...argTypes, ...captureTypes]`, and emits a direct call. The
130
+ * handle struct only carries captures. */
131
+ export interface HandleLit {
132
+ kind: "HandleLit";
133
+ /** One entry per `ty.captures` field, in the same order. Each value
134
+ * is the lowered IR expression for the captured local at the
135
+ * `@(...)` site (typically a `Var` read of the enclosing scope's
136
+ * binding). v1 restricts capture types to scalar real numeric, so
137
+ * these values are plain `double` C expressions. */
138
+ captures: ReadonlyArray<{
139
+ name: string;
140
+ value: IRExpr;
141
+ }>;
142
+ ty: Type;
143
+ span: Span;
144
+ }
145
+ /** Field read of a captured value inside a handle struct. Used at
146
+ * `h(args)` dispatch sites: each capture of `h`'s `HandleType` becomes
147
+ * a `HandleCaptureLoad` IR node that reads `h.cap_<name>` and is
148
+ * passed as an extra positional arg to the underlying specialization.
149
+ * Codegen emits `<base.cName>.cap_<captureName>`. */
150
+ export interface HandleCaptureLoad {
151
+ kind: "HandleCaptureLoad";
152
+ base: Var;
153
+ captureName: string;
154
+ ty: Type;
155
+ span: Span;
156
+ }
157
+ /** Struct/class construction. Produced by `struct('f1', v1, ...)`
158
+ * literals and by the synthesized initial-receiver of a class
159
+ * constructor call (a StructLit whose `ty` is the constructor's
160
+ * initial `ClassType`). The fields list is in canonical (sorted-by-
161
+ * name) order to match the typedef-shape hash.
162
+ *
163
+ * Codegen emits a C99 designated initializer like
164
+ * `(<typedef>){.f1 = <v1>, .f2 = <v2>}`. Owned-typed field values
165
+ * must be fresh producers (ANF in the lowerer guarantees this). */
166
+ export interface StructLit {
167
+ kind: "StructLit";
168
+ fields: ReadonlyArray<{
169
+ name: string;
170
+ value: IRExpr;
171
+ }>;
172
+ ty: Type;
173
+ span: Span;
174
+ }
175
+ /** Field/property read: `s.f` (struct) or `obj.prop` (class instance),
176
+ * one level. Chained reads like `s.inner.f` are nested
177
+ * MemberLoads. `ty` is the field/property's static type. In an
178
+ * owned-consuming context (Assign RHS, Call arg of owned param) the
179
+ * codegen wraps the read in the field helper's `_copy` so the
180
+ * consumer receives a freshly-owned value. */
181
+ export interface MemberLoad {
182
+ kind: "MemberLoad";
183
+ base: IRExpr;
184
+ field: string;
185
+ ty: Type;
186
+ span: Span;
187
+ }
188
+ /** Scalar element read of a multi-element tensor `base`. `indices` has
189
+ * length 1 (linear addressing into the column-major buffer) or
190
+ * `base.ty.dims.length` (full per-axis addressing). Each index lowers
191
+ * to a scalar real IR expression; the result `ty` is the base's
192
+ * element scalar type. Codegen emits `<base.cName>.real[<offset>]`.
193
+ *
194
+ * The base is typed `IRExpr` rather than `Var` so the lowerer can
195
+ * install a `MemberLoad` (e.g. `obj.field(i)`) before ANF runs; the
196
+ * ANF pass hoists any non-`Var` owned producer to a fresh temp so
197
+ * emit-time code always sees a `Var` here. */
198
+ export interface IndexLoad {
199
+ kind: "IndexLoad";
200
+ base: IRExpr;
201
+ indices: IRExpr[];
202
+ ty: Type;
203
+ span: Span;
204
+ }
205
+ /** Slice arg shape for `IndexSlice` / `IndexSliceStore`. `Range`'s
206
+ * `step` is always populated (defaults to scalar `1` when omitted in
207
+ * the source); v1 requires `step` to be a `NumLit` so codegen can
208
+ * derive the loop count and source-index arithmetic at compile time
209
+ * for index-position ranges. `IndexVec` carries a tensor expression
210
+ * whose values are 1-based indices into the corresponding axis —
211
+ * gather-style fancy indexing (read-only on v1's IndexSlice; not yet
212
+ * plumbed through IndexSliceStore). `LogicalMask` carries a logical-
213
+ * typed tensor whose truthy positions select indices into the
214
+ * corresponding axis (or the linear column-major flat buffer for
215
+ * the single-slot form). The result-axis size equals `sum(mask)`,
216
+ * which is only known at runtime. The carried expression is ANF'd
217
+ * to a `Var` so codegen can iterate it without re-evaluation. */
218
+ export type IndexSliceArg = {
219
+ kind: "Range";
220
+ start: IRExpr;
221
+ step: IRExpr;
222
+ end: IRExpr;
223
+ span: Span;
224
+ } | {
225
+ kind: "Colon";
226
+ span: Span;
227
+ } | {
228
+ kind: "Scalar";
229
+ expr: IRExpr;
230
+ span: Span;
231
+ } | {
232
+ kind: "IndexVec";
233
+ expr: IRExpr;
234
+ span: Span;
235
+ } | {
236
+ kind: "LogicalMask";
237
+ expr: IRExpr;
238
+ span: Span;
239
+ };
240
+ /** Range / colon / scalar-mix slice read. `index.length` is 1
241
+ * (linear) or `base.ty.dims.length` (per-axis). The result is a freshly-
242
+ * allocated tensor; this IR node is an owned producer and ANFs like
243
+ * every other tensor-producing expression.
244
+ *
245
+ * The base is typed `IRExpr` for the same reason as `IndexLoad.base`:
246
+ * the lowerer can install a `MemberLoad` directly for `obj.f(args)`,
247
+ * and ANF hoists it to a fresh `Var` before emit. */
248
+ export interface IndexSlice {
249
+ kind: "IndexSlice";
250
+ base: IRExpr;
251
+ index: ReadonlyArray<IndexSliceArg>;
252
+ ty: Type;
253
+ span: Span;
254
+ }
255
+ /** Reference to the `end` keyword inside an index slot. Renders as an
256
+ * axis size of the enclosing index's base — `numel(base)` for a
257
+ * single-slot context (`axis === "linear"`) or `base.dims[axis]`
258
+ * otherwise. */
259
+ export interface EndRef {
260
+ kind: "EndRef";
261
+ baseCName: string;
262
+ baseTy: Type;
263
+ axis: number | "linear";
264
+ ty: Type;
265
+ span: Span;
266
+ }
267
+ /** Bracket concatenation `[a, b; c, d]` where one or more cells is a
268
+ * multi-element tensor (not just a scalar). The all-scalar case
269
+ * stays on `TensorBuild` for the existing fast-path emission.
270
+ *
271
+ * Layout discipline (column-major destination throughout):
272
+ * - `cells` is a list of rows; each row is a list of cells in source
273
+ * order. After lowering, every cell is either a scalar real
274
+ * numeric or a multi-element tensor `Var` (ANF hoists owned-
275
+ * producing non-Var cells to temps first).
276
+ * - `rowHeights[i]` is the row count of every cell in row `i` (rows
277
+ * are vertically aligned). `null` means at least one cell on the
278
+ * row has a runtime-only row count — codegen queries the witness
279
+ * cell's `dims[0]` and trusts that all cells on the row match
280
+ * (`mtoc2_check_concat_*` validates at runtime when both sides
281
+ * are uncertain).
282
+ * - `cellCols[i][j]` is the column count of cell `j` in row `i`
283
+ * (cells horizontally concatenate along the row). `null` mirrors
284
+ * `rowHeights`: runtime-only, queried from the cell's `dims[1]`.
285
+ * - The result's shape `[totalRows, totalCols]` may contain `null`
286
+ * for runtime-only axes; codegen computes the value from per-row
287
+ * / per-cell dim queries and feeds it to `mtoc2_tensor_alloc_nd`.
288
+ *
289
+ * Empty cells (any cell whose shape contains a statically-known 0)
290
+ * are filtered out during lowering — they evaporate per numbl's
291
+ * `catAlongDim` rule. The cell grid here only contains cells whose
292
+ * product is statically positive OR runtime-only.
293
+ *
294
+ * Owned producer. Same ANF discipline as `TensorBuild`. */
295
+ export interface TensorConcat {
296
+ kind: "TensorConcat";
297
+ cells: IRExpr[][];
298
+ rowHeights: (number | null)[];
299
+ cellCols: (number | null)[][];
300
+ shape: (number | null)[];
301
+ ty: Type;
302
+ span: Span;
303
+ }
304
+ /** Cell-array source literal `{a, b, c; d, e, f}`. `elements` lists
305
+ * the slot expressions in column-major order; `shape` is the
306
+ * declared `[rows, cols]` of the literal. `ty` is a `CellType`
307
+ * whose `mode` is always `"tuple"` for literals — one slot type per
308
+ * slot, even when several happen to coincide. Owned producer; ANFs
309
+ * like other owned-producing expressions.
310
+ *
311
+ * An empty literal `{}` produces a `CellLit` with `elements: []` and
312
+ * `shape: [0, 0]`, matching numbl. */
313
+ export interface CellLit {
314
+ kind: "CellLit";
315
+ elements: IRExpr[];
316
+ shape: number[];
317
+ ty: Type;
318
+ span: Span;
319
+ }
320
+ /** Runtime cell construction from `cell(n, m, ...)` (or `cell(n)`
321
+ * → `n×n`). `dims` carries the IR expressions for each axis size
322
+ * (parallel to `ty.dims`). When every axis is statically exact and
323
+ * the slot count fits the exact cap, `ty.mode === "tuple"` and the
324
+ * emitted code lays out per-slot empty-double slots inline;
325
+ * otherwise `ty.mode === "uniform"` with `elem` set to the empty-
326
+ * double sentinel and the helper allocates the slot buffer at
327
+ * runtime. Owned producer; ANFs. */
328
+ export interface CellEmpty {
329
+ kind: "CellEmpty";
330
+ dims: IRExpr[];
331
+ ty: Type;
332
+ span: Span;
333
+ }
334
+ /** Brace-indexed cell read: `c{i}`, `c{i, j}`, `c{linear}`. Yields
335
+ * the slot's value (no cell-wrapping). `base` is always a `Var`
336
+ * after ANF; `indices` is one expr per source-level subscript
337
+ * (1-D linear access or per-axis). `ty` is the static slot type:
338
+ * - Tuple mode + every index exact → the specific slot's `Type`.
339
+ * - Tuple mode + at least one non-exact → the unified slot type
340
+ * (the lowerer rejects with `UnsupportedConstruct` if not all
341
+ * slots unify).
342
+ * - Uniform mode → the cell's `elem` type. */
343
+ export interface CellIndexLoad {
344
+ kind: "CellIndexLoad";
345
+ base: IRExpr;
346
+ indices: IRExpr[];
347
+ ty: Type;
348
+ span: Span;
349
+ }
350
+ /** Range used as a value (outside index slots and for-loop bounds).
351
+ * Emits a freshly-allocated `1×N` row tensor at runtime via
352
+ * `mtoc2_tensor_make_range`. Owned producer; ANFs. The `step` may
353
+ * be any scalar real IR expression — unlike index-slot ranges,
354
+ * codegen routes through the runtime helper which takes the step
355
+ * at runtime. */
356
+ export interface MakeRange {
357
+ kind: "MakeRange";
358
+ start: IRExpr;
359
+ step: IRExpr;
360
+ end: IRExpr;
361
+ ty: Type;
362
+ span: Span;
363
+ }
364
+ export type IRExpr = NumLit | ImagLit | StringLit | TensorBuild | TensorConcat | CellLit | CellEmpty | CellIndexLoad | Var | Binary | Unary | Call | HandleLit | HandleCaptureLoad | StructLit | MemberLoad | IndexLoad | IndexSlice | EndRef | MakeRange;
365
+ export interface ExprStmt {
366
+ kind: "ExprStmt";
367
+ expr: IRExpr;
368
+ span: Span;
369
+ }
370
+ export interface Assign {
371
+ kind: "Assign";
372
+ /** Source name. */
373
+ name: string;
374
+ /** Fresh C name allocated for this assignment. */
375
+ cName: string;
376
+ ty: Type;
377
+ expr: IRExpr;
378
+ span: Span;
379
+ }
380
+ export interface If {
381
+ kind: "If";
382
+ cond: IRExpr;
383
+ thenBody: IRStmt[];
384
+ elseBody: IRStmt[];
385
+ span: Span;
386
+ }
387
+ export interface While {
388
+ kind: "While";
389
+ cond: IRExpr;
390
+ body: IRStmt[];
391
+ span: Span;
392
+ }
393
+ export interface For {
394
+ kind: "For";
395
+ /** Source name of loop variable. */
396
+ varName: string;
397
+ /** Allocated C name for the loop variable. */
398
+ cVar: string;
399
+ start: IRExpr;
400
+ /** Literal numeric step. */
401
+ step: number;
402
+ end: IRExpr;
403
+ body: IRStmt[];
404
+ span: Span;
405
+ }
406
+ export interface ReturnFromFunction {
407
+ kind: "ReturnFromFunction";
408
+ span: Span;
409
+ }
410
+ export interface Break {
411
+ kind: "Break";
412
+ span: Span;
413
+ }
414
+ export interface Continue {
415
+ kind: "Continue";
416
+ span: Span;
417
+ }
418
+ /** Field/property write: `s.f = rhs` or chained `s.inner.f = rhs`.
419
+ * The `base` is always the root variable (a `Var`); `fieldPath`
420
+ * walks from the outermost field inward (e.g. `["inner", "f"]`).
421
+ * `leafTy` is the type of the leaf slot (the field actually being
422
+ * written). For scalar leaves codegen emits a plain
423
+ * `<base.cName>.<f1>...<fn> = <rhs>;`; for owned leaves it emits
424
+ * `<typedef>_assign(&<base.cName>.<f1>...<fn>, <rhs>);` where the
425
+ * typedef matches the leaf's owned-kind. */
426
+ export interface MemberStore {
427
+ kind: "MemberStore";
428
+ base: Var;
429
+ fieldPath: ReadonlyArray<string>;
430
+ leafTy: Type;
431
+ rhs: IRExpr;
432
+ span: Span;
433
+ }
434
+ /** Pure annotation node produced by the `%!numbl:showtype` directive.
435
+ * Carries a snapshot of `{name, cName, ty}` for each named variable
436
+ * at the directive's source position. Walk / liveness / dataflow
437
+ * treat it as a no-op; codegen renders one `/_ type ... _/` line
438
+ * per entry (using real C comment delimiters). No runtime effect. */
439
+ export interface TypeComment {
440
+ kind: "TypeComment";
441
+ entries: ReadonlyArray<{
442
+ name: string;
443
+ cName: string;
444
+ ty: Type;
445
+ }>;
446
+ span: Span;
447
+ }
448
+ /** Multi-output / drop-all user-function call statement. Drives:
449
+ * `[a, b] = foo(x);` (N≥2 outputs, mix of named lvalues
450
+ * and ignored `~` slots; trailing
451
+ * outputs may be omitted)
452
+ * `foo(x);` (N≥2-output bare statement; every
453
+ * output dropped via a discard temp)
454
+ *
455
+ * 1-output and 0-output user-function calls do NOT use this node —
456
+ * they keep the simpler return-by-value (`Assign` / `ExprStmt`) and
457
+ * `void`-returning (`ExprStmt(Call)`) shapes respectively, because
458
+ * their existing C ABI doesn't need out-pointers.
459
+ *
460
+ * Each entry of `outputs` is either a real binding (the slot's typed
461
+ * destination — driven through `recordAssignment` like any other
462
+ * Assign) or `null` for an ignored slot. Codegen wraps the call in a
463
+ * `{ … }` block and declares one inline `_mtoc2_discard_<callIdx>_<i>`
464
+ * per `null` slot so those temporaries stay scoped to the call. */
465
+ export interface MultiAssignCall {
466
+ kind: "MultiAssignCall";
467
+ /** Resolved C identifier of the callee. Two interpretations:
468
+ * - **User-function specialization** (`isBuiltin === false`) — the
469
+ * mangled spec name from `specializeUserFunction` (e.g.
470
+ * `apply__a1b2c3d4`); codegen emits a direct call.
471
+ * - **Multi-output builtin** (`isBuiltin === true`) — purely
472
+ * informational at this point; codegen routes through the
473
+ * builtin's `emit` hook for the full call string. */
474
+ cName: string;
475
+ /** Source-level name (for diagnostics and for builtin lookup at
476
+ * codegen when `isBuiltin === true`). */
477
+ name: string;
478
+ /** When true, `name` resolves to a registered builtin and codegen
479
+ * invokes its `emit` hook with `nargout = outputs.length` and the
480
+ * built `outArgsC` list. When false (or omitted), `cName` is a
481
+ * user-function spec and codegen emits a direct call. */
482
+ isBuiltin?: boolean;
483
+ args: IRExpr[];
484
+ /** One entry per output slot of the callee. `ty` is the slot's
485
+ * static type (always populated so codegen can declare a typed
486
+ * discard temp for ignored slots). `binding === null` → ignored
487
+ * output; codegen synthesizes a discard temp. A non-null binding
488
+ * means "store the call's i-th output into <binding.cName>"; the
489
+ * binding's declaration is hoisted to function top by the emitter
490
+ * (owned slots via `collectOwnedLocals`, scalar slots via
491
+ * `collectHoistedScalarLocals`). */
492
+ outputs: ReadonlyArray<{
493
+ ty: Type;
494
+ binding: {
495
+ name: string;
496
+ cName: string;
497
+ } | null;
498
+ }>;
499
+ span: Span;
500
+ }
501
+ /** Scalar element write into a multi-element tensor `base`. Mutates
502
+ * the existing buffer in place — NOT an owned re-assignment (the
503
+ * codegen emits `<base.cName>.real[<offset>] = <rhs>;`). The base
504
+ * is recorded as both a use and a def by liveness so its buffer
505
+ * stays live across the store.
506
+ *
507
+ * `fieldPath` carries a member-rooted LHS like `chnkr.r(i, j)`: the
508
+ * `base` Var still names the OWNING root (struct / class instance)
509
+ * for liveness purposes, and the codegen targets the slot
510
+ * `chnkr.r` by joining `base.cName` with the field path. `leafTy`
511
+ * is the field's NumericType; for the bare-Ident case (`v(i) =
512
+ * rhs`) both are absent and `base.ty` is the NumericType. */
513
+ export interface IndexStore {
514
+ kind: "IndexStore";
515
+ base: Var;
516
+ fieldPath?: ReadonlyArray<string>;
517
+ leafTy?: NumericType;
518
+ indices: IRExpr[];
519
+ rhs: IRExpr;
520
+ span: Span;
521
+ }
522
+ /** Brace-indexed cell write: `c{i} = rhs`, `c{i, j} = rhs`. The
523
+ * cell takes ownership of `rhs`; codegen wraps owned aliases in
524
+ * `_copy` per the standard owned-consume rule (ANF guarantees
525
+ * fresh producers / Var reads for the rhs).
526
+ *
527
+ * Tuple-mode + every index exact: codegen targets the specific
528
+ * `slot_<i>` field directly. Tuple-mode + non-exact index falls
529
+ * back to a runtime switch over the slot index. Uniform-mode
530
+ * writes through `base.slots[<offset>]` with a runtime bounds
531
+ * check (no auto-grow; mtoc2 rejects out-of-bounds writes —
532
+ * see docs/cells_plan.md). */
533
+ export interface CellIndexStore {
534
+ kind: "CellIndexStore";
535
+ base: Var;
536
+ indices: IRExpr[];
537
+ rhs: IRExpr;
538
+ span: Span;
539
+ }
540
+ /** Range / colon / scalar-mix slice write. Same arity rules as
541
+ * `IndexSlice`. RHS is either a scalar (broadcast into every slot)
542
+ * or a `Var` reading a named tensor (per-slot copy). Mutates the
543
+ * base buffer in place — not an owned re-assignment.
544
+ *
545
+ * See `IndexStore` for the meaning of `fieldPath` / `leafTy` —
546
+ * same convention. */
547
+ export interface IndexSliceStore {
548
+ kind: "IndexSliceStore";
549
+ base: Var;
550
+ fieldPath?: ReadonlyArray<string>;
551
+ leafTy?: NumericType;
552
+ index: ReadonlyArray<IndexSliceArg>;
553
+ rhs: IRExpr;
554
+ span: Span;
555
+ }
556
+ export type IRStmt = ExprStmt | Assign | If | While | For | ReturnFromFunction | Break | Continue | TypeComment | MemberStore | MultiAssignCall | IndexStore | IndexSliceStore | CellIndexStore;
557
+ export interface IRFunc {
558
+ /** Source-level function name. */
559
+ name: string;
560
+ /** Mangled C identifier (name__<8-hex>). */
561
+ cName: string;
562
+ /** Parameter source names. */
563
+ params: string[];
564
+ /** Parameter C names (parallel to `params`). */
565
+ cParams: string[];
566
+ /** Per-parameter type at this specialization. */
567
+ paramTypes: Type[];
568
+ /** Source output names. 0 outputs → C `void` return type; 1 output
569
+ * → classic return-by-value; N≥2 outputs → C `void` return + one
570
+ * trailing `T_i *_mtoc2_o<i>` parameter per output. */
571
+ outputs: string[];
572
+ /** C names for outputs (parallel to `outputs`). */
573
+ cOutputs: string[];
574
+ /** Output types after lowering. */
575
+ outputTypes: Type[];
576
+ body: IRStmt[];
577
+ span: Span;
578
+ }
579
+ export interface IRProgram {
580
+ /** Script-level top-level statements. */
581
+ topLevelStmts: IRStmt[];
582
+ /** All specialized function definitions, keyed by their mangled cName. */
583
+ functions: Map<string, IRFunc>;
584
+ }