numbl 0.3.3 → 0.4.1

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 (349) hide show
  1. package/binding.gyp +6 -5
  2. package/dist-cli/cli.js +63077 -42047
  3. package/dist-lib/graphics/types.d.ts +40 -1
  4. package/dist-lib/lib.d.ts +0 -1
  5. package/dist-lib/lib.js +78446 -57671
  6. package/dist-lib/numbl-core/executeCode.d.ts +10 -12
  7. package/dist-lib/numbl-core/executors/classification.d.ts +134 -0
  8. package/dist-lib/numbl-core/executors/handleInline.d.ts +42 -0
  9. package/dist-lib/numbl-core/executors/index.d.ts +0 -3
  10. package/dist-lib/numbl-core/executors/jit/cJitCallExecutor.d.ts +35 -0
  11. package/dist-lib/numbl-core/executors/jit/cJitLoopExecutor.d.ts +31 -0
  12. package/dist-lib/numbl-core/executors/jit/cJitTopLevelExecutor.d.ts +29 -0
  13. package/dist-lib/numbl-core/executors/jit/callExecutor.d.ts +45 -0
  14. package/dist-lib/numbl-core/executors/jit/compileC.d.ts +51 -0
  15. package/dist-lib/numbl-core/executors/jit/compileC.node.d.ts +25 -0
  16. package/dist-lib/numbl-core/executors/jit/hostHelpers.d.ts +27 -0
  17. package/dist-lib/numbl-core/executors/jit/loopExecutor.d.ts +41 -0
  18. package/dist-lib/numbl-core/executors/jit/session.d.ts +17 -0
  19. package/dist-lib/numbl-core/executors/jit/topLevelExecutor.d.ts +36 -0
  20. package/dist-lib/numbl-core/executors/jit/typeAdapter.d.ts +28 -0
  21. package/dist-lib/numbl-core/executors/jit/typeAdapterC.d.ts +73 -0
  22. package/dist-lib/numbl-core/executors/jit/valueAdapter.d.ts +48 -0
  23. package/dist-lib/numbl-core/executors/jit/valueAdapterC.d.ts +108 -0
  24. package/dist-lib/numbl-core/executors/lowering.d.ts +31 -77
  25. package/dist-lib/numbl-core/executors/plugins.d.ts +14 -21
  26. package/dist-lib/numbl-core/helpers/reduction-helpers.d.ts +4 -1
  27. package/dist-lib/numbl-core/interpreter/builtins/index.d.ts +1 -1
  28. package/dist-lib/numbl-core/interpreter/builtins/types.d.ts +0 -18
  29. package/dist-lib/numbl-core/interpreter/interpreter.d.ts +37 -21
  30. package/dist-lib/numbl-core/interpreter/interpreterExec.d.ts +6 -0
  31. package/dist-lib/numbl-core/interpreter/interpreterFunctions.d.ts +13 -1
  32. package/dist-lib/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +1 -1
  33. package/dist-lib/numbl-core/jit/builtins/defs/_shared.d.ts +43 -0
  34. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/_elemwise.d.ts +123 -0
  35. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/minus.d.ts +2 -0
  36. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/mpower.d.ts +12 -0
  37. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/mrdivide.d.ts +5 -0
  38. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/mtimes.d.ts +2 -0
  39. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/plus.d.ts +2 -0
  40. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/power.d.ts +30 -0
  41. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/rdivide.d.ts +2 -0
  42. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/times.d.ts +2 -0
  43. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/uminus.d.ts +2 -0
  44. package/dist-lib/numbl-core/jit/builtins/defs/compare/_compare.d.ts +12 -0
  45. package/dist-lib/numbl-core/jit/builtins/defs/compare/eq.d.ts +2 -0
  46. package/dist-lib/numbl-core/jit/builtins/defs/compare/ge.d.ts +2 -0
  47. package/dist-lib/numbl-core/jit/builtins/defs/compare/gt.d.ts +2 -0
  48. package/dist-lib/numbl-core/jit/builtins/defs/compare/le.d.ts +2 -0
  49. package/dist-lib/numbl-core/jit/builtins/defs/compare/lt.d.ts +2 -0
  50. package/dist-lib/numbl-core/jit/builtins/defs/compare/ne.d.ts +2 -0
  51. package/dist-lib/numbl-core/jit/builtins/defs/diag/assert.d.ts +6 -0
  52. package/dist-lib/numbl-core/jit/builtins/defs/io/_format_args.d.ts +17 -0
  53. package/dist-lib/numbl-core/jit/builtins/defs/io/disp.d.ts +2 -0
  54. package/dist-lib/numbl-core/jit/builtins/defs/io/error.d.ts +2 -0
  55. package/dist-lib/numbl-core/jit/builtins/defs/io/fprintf.d.ts +2 -0
  56. package/dist-lib/numbl-core/jit/builtins/defs/io/sprintf.d.ts +2 -0
  57. package/dist-lib/numbl-core/jit/builtins/defs/io/warning.d.ts +15 -0
  58. package/dist-lib/numbl-core/jit/builtins/defs/logical/_shortcircuit.d.ts +30 -0
  59. package/dist-lib/numbl-core/jit/builtins/defs/logical/_unary_pred.d.ts +30 -0
  60. package/dist-lib/numbl-core/jit/builtins/defs/logical/and.d.ts +5 -0
  61. package/dist-lib/numbl-core/jit/builtins/defs/logical/andand.d.ts +1 -0
  62. package/dist-lib/numbl-core/jit/builtins/defs/logical/boolconst.d.ts +3 -0
  63. package/dist-lib/numbl-core/jit/builtins/defs/logical/classBuiltin.d.ts +21 -0
  64. package/dist-lib/numbl-core/jit/builtins/defs/logical/fieldnames.d.ts +15 -0
  65. package/dist-lib/numbl-core/jit/builtins/defs/logical/isa.d.ts +13 -0
  66. package/dist-lib/numbl-core/jit/builtins/defs/logical/iscell.d.ts +8 -0
  67. package/dist-lib/numbl-core/jit/builtins/defs/logical/isempty.d.ts +2 -0
  68. package/dist-lib/numbl-core/jit/builtins/defs/logical/isequal.d.ts +2 -0
  69. package/dist-lib/numbl-core/jit/builtins/defs/logical/isfield.d.ts +20 -0
  70. package/dist-lib/numbl-core/jit/builtins/defs/logical/isinf.d.ts +2 -0
  71. package/dist-lib/numbl-core/jit/builtins/defs/logical/isnan.d.ts +1 -0
  72. package/dist-lib/numbl-core/jit/builtins/defs/logical/isnumeric.d.ts +7 -0
  73. package/dist-lib/numbl-core/jit/builtins/defs/logical/isreal.d.ts +2 -0
  74. package/dist-lib/numbl-core/jit/builtins/defs/logical/isscalar.d.ts +20 -0
  75. package/dist-lib/numbl-core/jit/builtins/defs/logical/isstruct.d.ts +7 -0
  76. package/dist-lib/numbl-core/jit/builtins/defs/logical/logical.d.ts +1 -0
  77. package/dist-lib/numbl-core/jit/builtins/defs/logical/not.d.ts +15 -0
  78. package/dist-lib/numbl-core/jit/builtins/defs/logical/or.d.ts +11 -0
  79. package/dist-lib/numbl-core/jit/builtins/defs/logical/oror.d.ts +1 -0
  80. package/dist-lib/numbl-core/jit/builtins/defs/logical/strcmp.d.ts +21 -0
  81. package/dist-lib/numbl-core/jit/builtins/defs/logical/typequery.d.ts +10 -0
  82. package/dist-lib/numbl-core/jit/builtins/defs/logical/xor.d.ts +12 -0
  83. package/dist-lib/numbl-core/jit/builtins/defs/math/_complex_fold.d.ts +34 -0
  84. package/dist-lib/numbl-core/jit/builtins/defs/math/_unary_real.d.ts +51 -0
  85. package/dist-lib/numbl-core/jit/builtins/defs/math/abs.d.ts +7 -0
  86. package/dist-lib/numbl-core/jit/builtins/defs/math/angle.d.ts +7 -0
  87. package/dist-lib/numbl-core/jit/builtins/defs/math/asinh.d.ts +1 -0
  88. package/dist-lib/numbl-core/jit/builtins/defs/math/atan.d.ts +1 -0
  89. package/dist-lib/numbl-core/jit/builtins/defs/math/atan2.d.ts +3 -0
  90. package/dist-lib/numbl-core/jit/builtins/defs/math/besselh.d.ts +2 -0
  91. package/dist-lib/numbl-core/jit/builtins/defs/math/ceil.d.ts +4 -0
  92. package/dist-lib/numbl-core/jit/builtins/defs/math/conj.d.ts +7 -0
  93. package/dist-lib/numbl-core/jit/builtins/defs/math/constants.d.ts +7 -0
  94. package/dist-lib/numbl-core/jit/builtins/defs/math/cos.d.ts +1 -0
  95. package/dist-lib/numbl-core/jit/builtins/defs/math/cosh.d.ts +1 -0
  96. package/dist-lib/numbl-core/jit/builtins/defs/math/dot.d.ts +20 -0
  97. package/dist-lib/numbl-core/jit/builtins/defs/math/double.d.ts +28 -0
  98. package/dist-lib/numbl-core/jit/builtins/defs/math/exp.d.ts +1 -0
  99. package/dist-lib/numbl-core/jit/builtins/defs/math/fix.d.ts +4 -0
  100. package/dist-lib/numbl-core/jit/builtins/defs/math/floor.d.ts +4 -0
  101. package/dist-lib/numbl-core/jit/builtins/defs/math/hypot.d.ts +3 -0
  102. package/dist-lib/numbl-core/jit/builtins/defs/math/imag.d.ts +7 -0
  103. package/dist-lib/numbl-core/jit/builtins/defs/math/linspace.d.ts +6 -0
  104. package/dist-lib/numbl-core/jit/builtins/defs/math/log.d.ts +4 -0
  105. package/dist-lib/numbl-core/jit/builtins/defs/math/log10.d.ts +3 -0
  106. package/dist-lib/numbl-core/jit/builtins/defs/math/log2.d.ts +5 -0
  107. package/dist-lib/numbl-core/jit/builtins/defs/math/logspace.d.ts +8 -0
  108. package/dist-lib/numbl-core/jit/builtins/defs/math/mod.d.ts +1 -0
  109. package/dist-lib/numbl-core/jit/builtins/defs/math/norm.d.ts +2 -0
  110. package/dist-lib/numbl-core/jit/builtins/defs/math/real.d.ts +7 -0
  111. package/dist-lib/numbl-core/jit/builtins/defs/math/rem.d.ts +3 -0
  112. package/dist-lib/numbl-core/jit/builtins/defs/math/round.d.ts +1 -0
  113. package/dist-lib/numbl-core/jit/builtins/defs/math/sign.d.ts +5 -0
  114. package/dist-lib/numbl-core/jit/builtins/defs/math/sin.d.ts +1 -0
  115. package/dist-lib/numbl-core/jit/builtins/defs/math/sinh.d.ts +1 -0
  116. package/dist-lib/numbl-core/jit/builtins/defs/math/sqrt.d.ts +11 -0
  117. package/dist-lib/numbl-core/jit/builtins/defs/math/tan.d.ts +1 -0
  118. package/dist-lib/numbl-core/jit/builtins/defs/math/tanh.d.ts +1 -0
  119. package/dist-lib/numbl-core/jit/builtins/defs/math/uniquetol.d.ts +22 -0
  120. package/dist-lib/numbl-core/jit/builtins/defs/plot/dispatch.d.ts +6 -0
  121. package/dist-lib/numbl-core/jit/builtins/defs/reduction/_cumulative.d.ts +49 -0
  122. package/dist-lib/numbl-core/jit/builtins/defs/reduction/_shape.d.ts +126 -0
  123. package/dist-lib/numbl-core/jit/builtins/defs/reduction/_variance.d.ts +17 -0
  124. package/dist-lib/numbl-core/jit/builtins/defs/reduction/all.d.ts +1 -0
  125. package/dist-lib/numbl-core/jit/builtins/defs/reduction/any.d.ts +1 -0
  126. package/dist-lib/numbl-core/jit/builtins/defs/reduction/cummax.d.ts +1 -0
  127. package/dist-lib/numbl-core/jit/builtins/defs/reduction/cummin.d.ts +1 -0
  128. package/dist-lib/numbl-core/jit/builtins/defs/reduction/cumprod.d.ts +1 -0
  129. package/dist-lib/numbl-core/jit/builtins/defs/reduction/cumsum.d.ts +1 -0
  130. package/dist-lib/numbl-core/jit/builtins/defs/reduction/diff.d.ts +16 -0
  131. package/dist-lib/numbl-core/jit/builtins/defs/reduction/length.d.ts +2 -0
  132. package/dist-lib/numbl-core/jit/builtins/defs/reduction/max.d.ts +1 -0
  133. package/dist-lib/numbl-core/jit/builtins/defs/reduction/mean.d.ts +1 -0
  134. package/dist-lib/numbl-core/jit/builtins/defs/reduction/min.d.ts +1 -0
  135. package/dist-lib/numbl-core/jit/builtins/defs/reduction/numel.d.ts +2 -0
  136. package/dist-lib/numbl-core/jit/builtins/defs/reduction/prod.d.ts +1 -0
  137. package/dist-lib/numbl-core/jit/builtins/defs/reduction/std.d.ts +1 -0
  138. package/dist-lib/numbl-core/jit/builtins/defs/reduction/sum.d.ts +1 -0
  139. package/dist-lib/numbl-core/jit/builtins/defs/reduction/var.d.ts +1 -0
  140. package/dist-lib/numbl-core/jit/builtins/defs/shape/_construct.d.ts +67 -0
  141. package/dist-lib/numbl-core/jit/builtins/defs/shape/_triangular.d.ts +34 -0
  142. package/dist-lib/numbl-core/jit/builtins/defs/shape/cat.d.ts +33 -0
  143. package/dist-lib/numbl-core/jit/builtins/defs/shape/diag.d.ts +29 -0
  144. package/dist-lib/numbl-core/jit/builtins/defs/shape/eye.d.ts +5 -0
  145. package/dist-lib/numbl-core/jit/builtins/defs/shape/flip.d.ts +7 -0
  146. package/dist-lib/numbl-core/jit/builtins/defs/shape/meshgrid.d.ts +12 -0
  147. package/dist-lib/numbl-core/jit/builtins/defs/shape/ones.d.ts +1 -0
  148. package/dist-lib/numbl-core/jit/builtins/defs/shape/repmat.d.ts +37 -0
  149. package/dist-lib/numbl-core/jit/builtins/defs/shape/reshape.d.ts +39 -0
  150. package/dist-lib/numbl-core/jit/builtins/defs/shape/size.d.ts +20 -0
  151. package/dist-lib/numbl-core/jit/builtins/defs/shape/sort.d.ts +19 -0
  152. package/dist-lib/numbl-core/jit/builtins/defs/shape/transpose.d.ts +6 -0
  153. package/dist-lib/numbl-core/jit/builtins/defs/shape/tril.d.ts +16 -0
  154. package/dist-lib/numbl-core/jit/builtins/defs/shape/triu.d.ts +16 -0
  155. package/dist-lib/numbl-core/jit/builtins/defs/shape/zeros.d.ts +1 -0
  156. package/dist-lib/numbl-core/jit/builtins/defs/system/deal.d.ts +20 -0
  157. package/dist-lib/numbl-core/jit/builtins/defs/system/feval.d.ts +36 -0
  158. package/dist-lib/numbl-core/jit/builtins/defs/system/pathBuiltins.d.ts +4 -0
  159. package/dist-lib/numbl-core/jit/builtins/defs/system/tic.d.ts +8 -0
  160. package/dist-lib/numbl-core/jit/builtins/defs/system/toc.d.ts +5 -0
  161. package/dist-lib/numbl-core/jit/builtins/index.d.ts +16 -0
  162. package/dist-lib/numbl-core/jit/builtins/registry.d.ts +138 -0
  163. package/dist-lib/numbl-core/jit/builtins/runtime/cell/cell.d.ts +24 -0
  164. package/dist-lib/numbl-core/jit/builtins/runtime/indexing/loop_count.d.ts +1 -0
  165. package/dist-lib/numbl-core/jit/builtins/runtime/indexing/range_value.d.ts +1 -0
  166. package/dist-lib/numbl-core/jit/builtins/runtime/indexing/scalar_index.d.ts +11 -0
  167. package/dist-lib/numbl-core/jit/builtins/runtime/indexing/tensor_make_range.d.ts +5 -0
  168. package/dist-lib/numbl-core/jit/builtins/runtime/io/assert_fmt.d.ts +1 -0
  169. package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_complex.d.ts +1 -0
  170. package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_double.d.ts +1 -0
  171. package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_struct.d.ts +1 -0
  172. package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_tensor.d.ts +1 -0
  173. package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_tensor_complex.d.ts +1 -0
  174. package/dist-lib/numbl-core/jit/builtins/runtime/io/error_fmt.d.ts +2 -0
  175. package/dist-lib/numbl-core/jit/builtins/runtime/io/format_complex.d.ts +1 -0
  176. package/dist-lib/numbl-core/jit/builtins/runtime/io/format_double.d.ts +1 -0
  177. package/dist-lib/numbl-core/jit/builtins/runtime/io/format_engine.d.ts +1 -0
  178. package/dist-lib/numbl-core/jit/builtins/runtime/io/fprintf.d.ts +1 -0
  179. package/dist-lib/numbl-core/jit/builtins/runtime/io/sprintf.d.ts +5 -0
  180. package/dist-lib/numbl-core/jit/builtins/runtime/io/warning_fmt.d.ts +2 -0
  181. package/dist-lib/numbl-core/jit/builtins/runtime/plot/plot_dispatch.d.ts +1 -0
  182. package/dist-lib/numbl-core/jit/builtins/runtime/snippets.gen.d.ts +86 -0
  183. package/dist-lib/numbl-core/jit/builtins/runtime/system/cdiv.d.ts +4 -0
  184. package/dist-lib/numbl-core/jit/builtins/runtime/system/cscalar.d.ts +103 -0
  185. package/dist-lib/numbl-core/jit/builtins/runtime/system/deep_clone.d.ts +1 -0
  186. package/dist-lib/numbl-core/jit/builtins/runtime/system/isequal.d.ts +2 -0
  187. package/dist-lib/numbl-core/jit/builtins/runtime/system/tictoc.d.ts +5 -0
  188. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor.d.ts +6 -0
  189. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc.d.ts +5 -0
  190. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc_complex.d.ts +6 -0
  191. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc_nd.d.ts +5 -0
  192. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc_nd_complex.d.ts +6 -0
  193. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_copy_complex.d.ts +6 -0
  194. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_matrix.d.ts +5 -0
  195. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_matrix_complex.d.ts +6 -0
  196. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_row.d.ts +5 -0
  197. package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_row_complex.d.ts +6 -0
  198. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_cat.d.ts +11 -0
  199. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_cumulative.d.ts +32 -0
  200. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_diag.d.ts +33 -0
  201. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_diff.d.ts +5 -0
  202. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_dot.d.ts +16 -0
  203. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_complex.d.ts +90 -0
  204. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real.d.ts +75 -0
  205. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real_fn.d.ts +95 -0
  206. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_eye.d.ts +10 -0
  207. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_fill_nd.d.ts +11 -0
  208. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_fill_square.d.ts +5 -0
  209. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_flip.d.ts +11 -0
  210. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_linspace.d.ts +5 -0
  211. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_logical_real.d.ts +10 -0
  212. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_logspace.d.ts +5 -0
  213. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_meshgrid.d.ts +29 -0
  214. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_mtimes_complex.d.ts +10 -0
  215. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_mtimes_real.d.ts +6 -0
  216. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_norm.d.ts +4 -0
  217. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_ones_nd.d.ts +5 -0
  218. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_ones_square.d.ts +5 -0
  219. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_predicate.d.ts +42 -0
  220. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_complex.d.ts +53 -0
  221. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_real.d.ts +42 -0
  222. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_repmat.d.ts +11 -0
  223. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reshape_nd.d.ts +5 -0
  224. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reshape_nd_complex.d.ts +6 -0
  225. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_size.d.ts +5 -0
  226. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_sort_real.d.ts +36 -0
  227. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_transpose.d.ts +5 -0
  228. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_transpose_complex.d.ts +6 -0
  229. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_triangular.d.ts +22 -0
  230. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_complex_math.d.ts +128 -0
  231. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_real_math.d.ts +95 -0
  232. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_uniquetol.d.ts +5 -0
  233. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_var.d.ts +12 -0
  234. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_zeros_nd.d.ts +5 -0
  235. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_zeros_square.d.ts +5 -0
  236. package/dist-lib/numbl-core/jit/builtins/runtime/text/strcmp.d.ts +2 -0
  237. package/dist-lib/numbl-core/jit/codegen/cFormat.d.ts +36 -0
  238. package/dist-lib/numbl-core/jit/codegen/cHelpers.d.ts +48 -0
  239. package/dist-lib/numbl-core/jit/codegen/emit.d.ts +55 -0
  240. package/dist-lib/numbl-core/jit/codegen/emitCellTypedef.d.ts +23 -0
  241. package/dist-lib/numbl-core/jit/codegen/emitExpr.d.ts +33 -0
  242. package/dist-lib/numbl-core/jit/codegen/emitIndex.d.ts +56 -0
  243. package/dist-lib/numbl-core/jit/codegen/emitJs.d.ts +64 -0
  244. package/dist-lib/numbl-core/jit/codegen/emitNamedTypedef.d.ts +58 -0
  245. package/dist-lib/numbl-core/jit/codegen/emitStmt.d.ts +76 -0
  246. package/dist-lib/numbl-core/jit/codegen/emitTensorConcat.d.ts +23 -0
  247. package/dist-lib/numbl-core/jit/codegen/emitTensorConcatJs.d.ts +16 -0
  248. package/dist-lib/numbl-core/jit/codegen/emitTensorFused.d.ts +77 -0
  249. package/dist-lib/numbl-core/jit/codegen/inlinePass.d.ts +66 -0
  250. package/dist-lib/numbl-core/jit/codegen/liveness.d.ts +58 -0
  251. package/dist-lib/numbl-core/jit/codegen/prettyIR.d.ts +24 -0
  252. package/dist-lib/numbl-core/jit/codegen/runtime.d.ts +150 -0
  253. package/dist-lib/numbl-core/jit/compileSpec.d.ts +84 -0
  254. package/dist-lib/numbl-core/jit/compileSpecC.d.ts +93 -0
  255. package/dist-lib/numbl-core/jit/index.d.ts +15 -0
  256. package/dist-lib/numbl-core/jit/lowering/classDefs.d.ts +109 -0
  257. package/dist-lib/numbl-core/jit/lowering/errors.d.ts +35 -0
  258. package/dist-lib/numbl-core/jit/lowering/indexFold.d.ts +31 -0
  259. package/dist-lib/numbl-core/jit/lowering/indexResolve.d.ts +100 -0
  260. package/dist-lib/numbl-core/jit/lowering/ir.d.ts +584 -0
  261. package/dist-lib/numbl-core/jit/lowering/lower.d.ts +271 -0
  262. package/dist-lib/numbl-core/jit/lowering/lowerCellIndex.d.ts +41 -0
  263. package/dist-lib/numbl-core/jit/lowering/lowerCellLit.d.ts +19 -0
  264. package/dist-lib/numbl-core/jit/lowering/lowerClassConstructor.d.ts +55 -0
  265. package/dist-lib/numbl-core/jit/lowering/lowerFuncCall.d.ts +34 -0
  266. package/dist-lib/numbl-core/jit/lowering/lowerHandle.d.ts +57 -0
  267. package/dist-lib/numbl-core/jit/lowering/lowerIndexLoad.d.ts +16 -0
  268. package/dist-lib/numbl-core/jit/lowering/lowerIndexSlice.d.ts +29 -0
  269. package/dist-lib/numbl-core/jit/lowering/lowerIndexSliceStore.d.ts +19 -0
  270. package/dist-lib/numbl-core/jit/lowering/lowerIndexStore.d.ts +14 -0
  271. package/dist-lib/numbl-core/jit/lowering/lowerMethodCall.d.ts +45 -0
  272. package/dist-lib/numbl-core/jit/lowering/lowerMultiAssign.d.ts +36 -0
  273. package/dist-lib/numbl-core/jit/lowering/lowerTensorLit.d.ts +25 -0
  274. package/dist-lib/numbl-core/jit/lowering/rangeCount.d.ts +19 -0
  275. package/dist-lib/numbl-core/jit/lowering/specialize.d.ts +93 -0
  276. package/dist-lib/numbl-core/jit/lowering/types.d.ts +503 -0
  277. package/dist-lib/numbl-core/jit/lowering/walk.d.ts +17 -0
  278. package/dist-lib/numbl-core/jit/numbl/index.d.ts +30 -0
  279. package/dist-lib/numbl-core/jit/parser/astUtils.d.ts +43 -0
  280. package/dist-lib/numbl-core/jit/parser/index.d.ts +12 -0
  281. package/dist-lib/numbl-core/jit/parser/sourceLoc.d.ts +12 -0
  282. package/dist-lib/numbl-core/jit/runtime/context.d.ts +23 -0
  283. package/dist-lib/numbl-core/jit/runtime/inferType.d.ts +10 -0
  284. package/dist-lib/numbl-core/jit/runtime/value.d.ts +101 -0
  285. package/dist-lib/numbl-core/jit/workspace/driverPrologue.d.ts +59 -0
  286. package/dist-lib/numbl-core/jit/workspace/mtoc2UserFunctionLoader.d.ts +62 -0
  287. package/dist-lib/numbl-core/jit/workspace/workspace.d.ts +243 -0
  288. package/dist-lib/numbl-core/jitTypes.d.ts +7 -321
  289. package/dist-lib/numbl-core/jsUserFunctions.d.ts +2 -2
  290. package/dist-lib/numbl-core/parser/ClassParser.d.ts +3 -0
  291. package/dist-lib/numbl-core/runtime/index.d.ts +1 -1
  292. package/dist-lib/numbl-core/runtime/indexing.d.ts +11 -1
  293. package/dist-lib/numbl-core/runtime/plotUtils.d.ts +28 -2
  294. package/dist-lib/numbl-core/runtime/runtime.d.ts +16 -1
  295. package/dist-lib/numbl-core/runtime/runtimePlot.d.ts +5 -0
  296. package/dist-lib/numbl-core/runtime/types.d.ts +19 -3
  297. package/dist-lib/numbl-core/version.d.ts +1 -1
  298. package/dist-lib/numbl-core/workspace/types.d.ts +8 -0
  299. package/dist-plot-viewer/assets/index-DfxsWeyf.js +4426 -0
  300. package/dist-plot-viewer/index.html +1 -1
  301. package/dist-site-viewer/404.html +33 -0
  302. package/dist-site-viewer/assets/index-C5c2lKAx.js +4748 -0
  303. package/dist-site-viewer/assets/index-D5YY8PKx.css +1 -0
  304. package/dist-site-viewer/assets/numbl-worker-CkoM4MUa.js +11836 -0
  305. package/dist-site-viewer/coi-serviceworker.js +70 -0
  306. package/dist-site-viewer/favicon.svg +23 -0
  307. package/dist-site-viewer/index.html +16 -0
  308. package/dist-site-viewer/logo.svg +26 -0
  309. package/dist-site-viewer/numbl-embed.js +111 -0
  310. package/dist-site-viewer/vite.svg +1 -0
  311. package/native/ops/real_unary_elemwise.c +3 -1
  312. package/package.json +15 -9
  313. package/dist-lib/numbl-core/executors/cJit/builtins.d.ts +0 -30
  314. package/dist-lib/numbl-core/executors/cJit/chainCodegen.d.ts +0 -59
  315. package/dist-lib/numbl-core/executors/cJit/chainExecutor.d.ts +0 -27
  316. package/dist-lib/numbl-core/executors/cJit/chainPass.d.ts +0 -42
  317. package/dist-lib/numbl-core/executors/cJit/codegen.d.ts +0 -44
  318. package/dist-lib/numbl-core/executors/cJit/compile.d.ts +0 -45
  319. package/dist-lib/numbl-core/executors/cJit/elemwiseCodegen.d.ts +0 -23
  320. package/dist-lib/numbl-core/executors/cJit/elemwiseStructural.d.ts +0 -33
  321. package/dist-lib/numbl-core/executors/cJit/fuseAnalyze.d.ts +0 -39
  322. package/dist-lib/numbl-core/executors/cJit/fuseCodegen.d.ts +0 -16
  323. package/dist-lib/numbl-core/executors/cJit/fuseExecutor.d.ts +0 -28
  324. package/dist-lib/numbl-core/executors/cJit/loopExecutor.d.ts +0 -32
  325. package/dist-lib/numbl-core/executors/cJit/register.d.ts +0 -10
  326. package/dist-lib/numbl-core/executors/cJit/whitelist.d.ts +0 -15
  327. package/dist-lib/numbl-core/executors/jsJit/callExecutor.d.ts +0 -25
  328. package/dist-lib/numbl-core/executors/jsJit/codegen/jitCodegen.d.ts +0 -7
  329. package/dist-lib/numbl-core/executors/jsJit/codegen/jitCodegenHoist.d.ts +0 -70
  330. package/dist-lib/numbl-core/executors/jsJit/codegen/jsMultiReduction.d.ts +0 -67
  331. package/dist-lib/numbl-core/executors/jsJit/helpers/jitHelpers.d.ts +0 -34
  332. package/dist-lib/numbl-core/executors/jsJit/helpers/jitHelpersComplex.d.ts +0 -21
  333. package/dist-lib/numbl-core/executors/jsJit/helpers/jitHelpersIndex.d.ts +0 -33
  334. package/dist-lib/numbl-core/executors/jsJit/helpers/jitHelpersTensor.d.ts +0 -34
  335. package/dist-lib/numbl-core/executors/jsJit/jitCall.d.ts +0 -59
  336. package/dist-lib/numbl-core/executors/jsJit/jitLoop.d.ts +0 -53
  337. package/dist-lib/numbl-core/executors/jsJit/jitTopLevel.d.ts +0 -44
  338. package/dist-lib/numbl-core/executors/jsJit/loopExecutor.d.ts +0 -15
  339. package/dist-lib/numbl-core/executors/jsJit/lower/blockAnalysis.d.ts +0 -37
  340. package/dist-lib/numbl-core/executors/jsJit/lower/jitBailSafety.d.ts +0 -41
  341. package/dist-lib/numbl-core/executors/jsJit/lower/jitLower.d.ts +0 -136
  342. package/dist-lib/numbl-core/executors/jsJit/lower/jitLowerExpr.d.ts +0 -36
  343. package/dist-lib/numbl-core/executors/jsJit/lower/jitLowerStmt.d.ts +0 -9
  344. package/dist-lib/numbl-core/executors/jsJit/lower/jitLowerTypes.d.ts +0 -29
  345. package/dist-lib/numbl-core/executors/jsJit/lower/scalarEmit.d.ts +0 -58
  346. package/dist-lib/numbl-core/executors/jsJit/shared.d.ts +0 -120
  347. package/dist-lib/numbl-core/executors/jsJit/topLevelExecutor.d.ts +0 -17
  348. package/dist-plot-viewer/assets/index-COAM8o1E.js +0 -4426
  349. /package/dist-lib/numbl-core/{executors/jsJit/helpers → runtime}/alloc.d.ts +0 -0
@@ -20,10 +20,13 @@ export interface ExecOptions {
20
20
  log?: (message: string) => void;
21
21
  /** Enable profiling of builtin function calls. */
22
22
  profile?: boolean;
23
- /** Called each time a JIT function is compiled, with a description and the generated JS. */
24
- onJitCompile?: (description: string, jsCode: string) => void;
25
- /** Called each time a C-JIT artifact is compiled, with a description and the generated C source. */
26
- onCJitCompile?: (description: string, cCode: string) => void;
23
+ /** Called each time a JIT function is compiled, with a description, the
24
+ * generated source, and the backend language (`"js"` or `"c"`). */
25
+ onJitCompile?: (description: string, code: string, lang: "js" | "c") => void;
26
+ /** Called when a JIT-compiled unit bails to the interpreter at runtime
27
+ * (e.g. an indexed-store array growth the JIT can't model). Surfaced
28
+ * as a warning; the CLI routes it to stderr. */
29
+ onJitBail?: (message: string) => void;
27
30
  /** Initial hold state for plotting (persisted across REPL executions). */
28
31
  initialHoldState?: boolean;
29
32
  /** Override or add builtins for this execution only. */
@@ -34,13 +37,8 @@ export interface ExecOptions {
34
37
  system?: SystemAdapter;
35
38
  /** Synchronous callback for the `input()` builtin. Displays prompt, returns user's line. */
36
39
  onInput?: (prompt: string) => string;
37
- /** Optimization mode: `"0"` interpreter, `"1"` JS-JIT, `"e3"` C-JIT
38
- * scalar-loop only. */
40
+ /** Optimization mode: `"0"` interpreter, `"1"` JS-JIT, `"2"` C-JIT. */
39
41
  optimization?: import("./executors/plugins.js").OptLevel;
40
- /** Compile C-JIT kernels with `-ffast-math` (libmvec-vectorized
41
- * transcendentals; reductions are reorder-allowed). Default true;
42
- * opt out via the CLI's `--no-fast-math` flag. */
43
- fastMath?: boolean;
44
42
  /**
45
43
  * Initial implicit cwd path for the MATLAB-style "cwd is the first search path" feature.
46
44
  * - undefined → auto-detect from `system.cwd()` and scan its files.
@@ -81,8 +79,8 @@ export interface ProfileData {
81
79
  export interface ExecResult {
82
80
  output: string[];
83
81
  generatedJS: string;
84
- /** Collected C source from C-JIT compilations during this run, or
85
- * empty when no C-JIT artifact was produced. */
82
+ /** C source emitted by the C-JIT backend (`--opt 2`). Empty placeholder
83
+ * when no C was generated (e.g. `--opt 0`/`1`). */
86
84
  generatedC: string;
87
85
  plotInstructions: PlotInstruction[];
88
86
  returnValue: RuntimeValue;
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Classification (JS-JIT-independent).
3
+ *
4
+ * Two classification phases — top-level (whole-script) and call
5
+ * (user-function-call) — produce the analysis records that codegen
6
+ * executors consume to decide whether they can lower a stmt list /
7
+ * call and to key their caches.
8
+ *
9
+ * The analysis is purely AST + type inference and is consumed by the
10
+ * JIT executors (`executors/jit/`) — no backend-specific IR involved.
11
+ */
12
+ import type { Interpreter } from "../interpreter/interpreter.js";
13
+ import type { FunctionDef } from "../interpreter/types.js";
14
+ import type { Stmt, Expr } from "../parser/types.js";
15
+ import { type JitType } from "../jitTypes.js";
16
+ /** A capture-free function handle the JIT inlines into the spec body as
17
+ * an in-scope `@...` constant instead of taking it as a runtime input.
18
+ * `identity` keys the spec cache (distinct handles → distinct specs). */
19
+ export interface ConstHandle {
20
+ readonly name: string;
21
+ readonly expr: Expr;
22
+ readonly identity: string;
23
+ }
24
+ /** Names that look like variables but never resolve to env values
25
+ * (constants, the special `end` slot, the imaginary unit). Skipped
26
+ * when collecting env inputs. */
27
+ export declare const KNOWN_CONSTANTS: ReadonlySet<string>;
28
+ /**
29
+ * Drop `exact` from a numeric scalar `JitType`. Numeric `exact` only
30
+ * survives unification when two consecutive specializations see the
31
+ * *same* literal — almost never the case for variables — so stripping
32
+ * up front means the first specialization's cacheKey already matches
33
+ * later calls.
34
+ */
35
+ export declare function pruneArgType(t: JitType): JitType;
36
+ /**
37
+ * Progressive type widening: in-place unify each entry of `types`
38
+ * with the corresponding entry of `prev`. No-op when shapes don't
39
+ * match (different arity → different specialization, no widening).
40
+ *
41
+ * Widening that would collapse a known type to `unknown` is rejected
42
+ * — keep this call's concrete type so a fresh, specific spec gets
43
+ * built. Without this, a 1st call with (number, …) followed by a 2nd
44
+ * call with (tensor, …) would unify the first arg to `unknown` and
45
+ * poison every subsequent specialization with the same arg shape.
46
+ */
47
+ export declare function widenAgainst(types: JitType[], prev: readonly JitType[] | undefined): void;
48
+ /**
49
+ * Gather env inputs for the synthetic FunctionDef of a top-level
50
+ * block. For each candidate name: skip known constants, skip names
51
+ * not in env (likely fn names), infer the JIT type, prune `exact`.
52
+ * Returns null if any candidate has an unknown type — that's a
53
+ * structural blocker for lowering.
54
+ */
55
+ export declare function gatherTypedEnvInputs(interp: Interpreter, candidates: readonly string[]): {
56
+ inputs: string[];
57
+ inputTypes: JitType[];
58
+ } | null;
59
+ export interface TopLevelClassification {
60
+ readonly stmts: readonly Stmt[];
61
+ readonly inputs: readonly string[];
62
+ readonly inputTypes: readonly JitType[];
63
+ readonly outputs: readonly string[];
64
+ readonly currentFile: string;
65
+ readonly hasReturn: boolean;
66
+ /** Body contains a `%!numbl:assert_jit c` directive (the C-JIT
67
+ * variant) — see `containsAssertJitC`. Makes the JS-JIT executors
68
+ * decline at `--opt 2` so the unit must C-JIT (or fall to the
69
+ * interpreter, which raises). */
70
+ readonly assertsCJit: boolean;
71
+ readonly cacheKey: string;
72
+ }
73
+ export declare function classifyTopLevel(interp: Interpreter, stmts: readonly Stmt[], prevInputTypes: readonly JitType[] | undefined): TopLevelClassification | null;
74
+ export interface LoopClassification {
75
+ /** The single For/While stmt this classification describes. */
76
+ readonly stmt: Stmt & {
77
+ type: "For" | "While";
78
+ };
79
+ readonly inputs: readonly string[];
80
+ readonly inputTypes: readonly JitType[];
81
+ /** Loop-local writes that are read by code AFTER the loop in the
82
+ * same sibling list. Loop-internal-only temporaries are filtered
83
+ * out so a JIT artifact doesn't need to write them back to env. */
84
+ readonly outputs: readonly string[];
85
+ readonly currentFile: string;
86
+ readonly hasReturn: boolean;
87
+ /** Loop body contains a `%!numbl:assert_jit c` directive (C-JIT variant). */
88
+ readonly assertsCJit: boolean;
89
+ /** Capture-free handle inputs to inline as in-scope `@...` constants
90
+ * in the synthesized spec body (instead of runtime inputs). */
91
+ readonly constHandles: readonly ConstHandle[];
92
+ readonly cacheKey: string;
93
+ }
94
+ /**
95
+ * Classify a single For/While loop at `siblings[siblingIndex]`. The
96
+ * post-loop tail of the sibling list is scanned to filter the
97
+ * loop's assigned-set down to names that are actually live-out
98
+ * (read after the loop) — purely loop-internal scratch never makes
99
+ * it into the synthetic function's outputs.
100
+ */
101
+ export declare function classifyLoop(interp: Interpreter, stmt: Stmt & {
102
+ type: "For" | "While";
103
+ }, siblings: readonly Stmt[], siblingIndex: number, prevInputTypes: readonly JitType[] | undefined): LoopClassification | null;
104
+ export interface CallClassification {
105
+ readonly fn: FunctionDef;
106
+ readonly nargout: number;
107
+ readonly argTypes: readonly JitType[];
108
+ readonly cacheKey: string;
109
+ /**
110
+ * Effective parameter names for this specialization. Mirrors
111
+ * `fn.params` for non-varargin functions. For varargin functions,
112
+ * the trailing `varargin` is replaced with one synthetic name per
113
+ * variadic arg (`$va_0`, `$va_1`, …). argTypes is one-to-one with
114
+ * effectiveParams.
115
+ */
116
+ readonly effectiveParams: readonly string[];
117
+ /** Number of variadic args (0 when fn has no varargin). */
118
+ readonly nVarargin: number;
119
+ /** Function body contains a `%!numbl:assert_jit c` directive (C-JIT variant). */
120
+ readonly assertsCJit: boolean;
121
+ }
122
+ export declare function classifyCall(fn: FunctionDef, args: unknown[], nargout: number, prevArgTypes: readonly JitType[] | undefined): CallClassification | null;
123
+ /** True if any statement in `stmts` is a `%!numbl:assert_jit c` directive
124
+ * (the C-JIT variant), recursing into control-flow bodies (if / for /
125
+ * while / switch / try) but NOT into nested function definitions — a
126
+ * directive inside a nested function belongs to that function's own unit.
127
+ *
128
+ * Only the `c` variant matters here: it requires C-JIT at `--opt 2`, so
129
+ * the JS-JIT executors decline such a unit at `--opt 2` to force either
130
+ * C-JIT or an interpreter fallthrough (which then raises). The plain
131
+ * `%!numbl:assert_jit` (require JS-JIT at `--opt 1` only) needs no
132
+ * executor change — the interpreter's `Directive` handler raises if it
133
+ * reaches the directive at `--opt 1`. */
134
+ export declare function containsAssertJitC(stmts: readonly Stmt[]): boolean;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Function-handle inlining for the JIT.
3
+ *
4
+ * A function handle that crosses a compile boundary — a loop input
5
+ * (`f = @...; for ...; f(x); end`) or a call argument
6
+ * (`applyfn(@sq, x)`) — arrives at the executor as an opaque
7
+ * `function_handle` value the JIT can't type. But a *capture-free*
8
+ * handle is fully described by its source AST, so instead of marshaling
9
+ * it across the boundary we inline its `@...` definition as an in-scope
10
+ * handle constant inside the synthesized spec. That reduces the boundary
11
+ * case to the already-supported in-scope case (`lowerAnonFunc` /
12
+ * `lowerFuncHandle` + `dispatchHandleCall`), which lowers identically on
13
+ * the JS and C backends — no value-adapter or ABI work.
14
+ *
15
+ * "Capture-free" is the key constraint: a handle that closes over an
16
+ * outer variable can't be inlined, because the inlined copy would
17
+ * re-resolve that name in the spec's scope (a different value, or
18
+ * unresolved) rather than the by-value snapshot the handle took. We
19
+ * detect captures against the handle's own recorded definition
20
+ * environment, so the test reflects what the handle actually closed
21
+ * over, not a syntactic guess.
22
+ */
23
+ import type { Expr } from "../parser/index.js";
24
+ /**
25
+ * If `val` is a function handle the JIT can inline as a compile-time
26
+ * constant in a spec compiled for `compileFile`, return its `@...`
27
+ * defining Expr; otherwise return null.
28
+ *
29
+ * Inlinable iff:
30
+ * - it's a `RuntimeFunction` carrying a recorded `handleAst`, AND
31
+ * - it was defined in `compileFile` (so a `@name` target resolves to
32
+ * the same function it did at definition — file-local functions can
33
+ * shadow across files), AND
34
+ * - for an anonymous handle, it is capture-free: no name its body
35
+ * references (other than its own params) exists as a variable in the
36
+ * handle's recorded definition environment.
37
+ *
38
+ * Named (`@name`) handles are always capture-free. Anything the lowerer
39
+ * ultimately can't compile (e.g. a builtin target) simply makes the
40
+ * enclosing unit decline to the interpreter — still correct.
41
+ */
42
+ export declare function inlinableHandleExpr(val: unknown, compileFile: string): Expr | null;
@@ -11,7 +11,4 @@ export { ExecutorCache } from "./cache.js";
11
11
  export type { JitType, SignCategory } from "../jitTypes.js";
12
12
  export { jitTypeKey, unifyJitTypes, isScalarType, isTensorType, isComplexType, isKnownInteger, } from "../jitTypes.js";
13
13
  export { inferJitType } from "../interpreter/builtins/types.js";
14
- export { jsJitTopLevelExecutor } from "./jsJit/topLevelExecutor.js";
15
- export { jsJitLoopExecutor } from "./jsJit/loopExecutor.js";
16
- export { jsJitCallExecutor } from "./jsJit/callExecutor.js";
17
14
  export { registerExecutorsForOpt } from "./plugins.js";
@@ -0,0 +1,35 @@
1
+ /**
2
+ * cjit-call — C-backed JIT executor for user-function calls.
3
+ *
4
+ * Mirrors `callExecutor.ts` (the JS-emit sibling) but routes the
5
+ * specialization's emitted code through `compileSpecC` →
6
+ * `cc -shared -fPIC -O3` → `dlopen` via koffi instead of
7
+ * `new Function(source)`. The dispatch, gating, and caching
8
+ * conventions are otherwise identical, so a sibling executor can
9
+ * register alongside the JS path at the same opt level without any
10
+ * arbitration in the dispatcher beyond cost-based selection.
11
+ *
12
+ * Declines when:
13
+ * - `nativeBridge` / `koffi` are not available (browser).
14
+ * - Any param or output type fails the C-FFI feasibility check
15
+ * (`compilerTypeToCDecl` returns null).
16
+ * - mtoc2 throws `UnsupportedConstruct` / `JitTypeError` at lowering.
17
+ */
18
+ import type { Executor } from "../types.js";
19
+ import { type JitType } from "../../jitTypes.js";
20
+ import type { FunctionDef } from "../../interpreter/types.js";
21
+ import { type Type as CompilerType, type SpecCSignature } from "../../jit/index.js";
22
+ import { type CompiledC } from "./compileC.js";
23
+ interface CJitCallData {
24
+ readonly fn: FunctionDef;
25
+ readonly nargout: number;
26
+ readonly argTypes: readonly JitType[];
27
+ readonly compilerArgTypes: readonly CompilerType[];
28
+ readonly args: readonly unknown[];
29
+ }
30
+ interface CompiledArtifact {
31
+ readonly compiled: CompiledC;
32
+ readonly signature: SpecCSignature;
33
+ }
34
+ export declare const cJitCallExecutor: Executor<CJitCallData, CompiledArtifact | null>;
35
+ export {};
@@ -0,0 +1,31 @@
1
+ /**
2
+ * cjit-loop — C-backed JIT executor for outermost For/While
3
+ * loops. Mirrors `loopExecutor.ts` (JS-emit sibling) but routes
4
+ * through `compileSpecC` → `cc -shared` → `koffi`. See
5
+ * `cJitCallExecutor.ts` for the marshaling protocol; this file just
6
+ * adapts the loop-shape `data` to the same C-side pipeline.
7
+ */
8
+ import type { Executor } from "../types.js";
9
+ import { type JitType } from "../../jitTypes.js";
10
+ import type { Stmt } from "../../parser/index.js";
11
+ import type { ConstHandle } from "../classification.js";
12
+ import { type Type as CompilerType, type SpecCSignature } from "../../jit/index.js";
13
+ import { type CompiledC } from "./compileC.js";
14
+ interface CJitLoopData {
15
+ readonly loopStmt: Stmt & {
16
+ type: "For" | "While";
17
+ };
18
+ readonly inputs: readonly string[];
19
+ readonly outputs: readonly string[];
20
+ readonly inputTypes: readonly JitType[];
21
+ readonly compilerInputTypes: readonly CompilerType[];
22
+ readonly constHandles: readonly ConstHandle[];
23
+ readonly currentFile: string;
24
+ readonly cacheKey: string;
25
+ }
26
+ interface CompiledArtifact {
27
+ readonly compiled: CompiledC;
28
+ readonly signature: SpecCSignature;
29
+ }
30
+ export declare const cJitLoopExecutor: Executor<CJitLoopData, CompiledArtifact | null>;
31
+ export {};
@@ -0,0 +1,29 @@
1
+ /**
2
+ * cjit-top-level — C-backed JIT executor for whole-script bodies.
3
+ *
4
+ * Mirrors `topLevelExecutor.ts` (JS-emit sibling) but routes through
5
+ * `compileSpecC` → `cc -shared` → `koffi`. See `cJitCallExecutor.ts`
6
+ * for the marshaling protocol. Same `isAllSuppressed` gate as the JS
7
+ * sibling so `displayAssign`/`displayResult` semantics stay on the
8
+ * interpreter path.
9
+ */
10
+ import type { Executor } from "../types.js";
11
+ import { type JitType } from "../../jitTypes.js";
12
+ import type { Stmt } from "../../parser/index.js";
13
+ import { type Type as CompilerType, type SpecCSignature } from "../../jit/index.js";
14
+ import { type CompiledC } from "./compileC.js";
15
+ interface CJitTopLevelData {
16
+ readonly stmts: readonly Stmt[];
17
+ readonly inputs: readonly string[];
18
+ readonly outputs: readonly string[];
19
+ readonly inputTypes: readonly JitType[];
20
+ readonly compilerInputTypes: readonly CompilerType[];
21
+ readonly currentFile: string;
22
+ readonly cacheKey: string;
23
+ }
24
+ interface CompiledArtifact {
25
+ readonly compiled: CompiledC;
26
+ readonly signature: SpecCSignature;
27
+ }
28
+ export declare const cJitTopLevelExecutor: Executor<CJitTopLevelData, CompiledArtifact | null>;
29
+ export {};
@@ -0,0 +1,45 @@
1
+ /**
2
+ * jit-call — executor that compiles user-function calls via mtoc2's
3
+ * `compileSpec` JIT entry point and runs the emitted JS in-process.
4
+ *
5
+ * Replaces the JS-JIT call executor at `--opt 1`. The shape of the
6
+ * fallback path is the same: on rejection (mtoc2's
7
+ * `UnsupportedConstruct` / `TypeError` during lowering, or a JitType
8
+ * the type adapter can't translate), `propose()` declines and the
9
+ * dispatcher falls through to the next executor / interpreter.
10
+ *
11
+ * Key differences from JS-JIT:
12
+ *
13
+ * - **No mid-run bailouts.** mtoc2 either lowers cleanly or rejects
14
+ * statically. When `compile()` returns, the artifact will run to
15
+ * completion. `bailRisk` is `false`.
16
+ * - **Shared `Lowerer.specializations` is the cache.** One Workspace
17
+ * + Lowerer pair per LoweringContext (i.e. per execution session);
18
+ * accumulating specs persist across calls so a function called
19
+ * repeatedly with the same arg signature reuses the prior compile.
20
+ * - **Output-count support.** `nargout >= 1` (single-output and
21
+ * multi-output `[a, b, ...] = f(x)`). `nargout === 0` (bare-stmt
22
+ * `f();`) is declined because mtoc2's nargout=0 spec emits a no-
23
+ * return body, but numbl's interpreter still uses the first
24
+ * declared output for `ans` binding — let the interpreter handle.
25
+ * - **Loop-depth gate.** Declines when `interp.loopDepth > 0` so a
26
+ * hot loop iterating function calls doesn't pay per-call JIT
27
+ * propose / spec-cache overhead. Once an outer call is JIT'd, its
28
+ * loops run inside mtoc2's compiled code anyway.
29
+ */
30
+ import type { Executor } from "../types.js";
31
+ import { type JitType } from "../../jitTypes.js";
32
+ import type { FunctionDef } from "../../interpreter/types.js";
33
+ import { type Type as CompilerType } from "../../jit/index.js";
34
+ interface JitCallData {
35
+ readonly fn: FunctionDef;
36
+ readonly nargout: number;
37
+ readonly argTypes: readonly JitType[];
38
+ readonly compilerArgTypes: readonly CompilerType[];
39
+ readonly args: readonly unknown[];
40
+ }
41
+ interface CompiledArtifact {
42
+ readonly specFn: (...args: unknown[]) => unknown;
43
+ }
44
+ export declare const jitCallExecutor: Executor<JitCallData, CompiledArtifact | null>;
45
+ export {};
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Browser-safe surface for the koffi C-JIT pipeline.
3
+ *
4
+ * The real implementation (`compileAndLoadCImpl`) lives in
5
+ * `compileC.node.ts` because it imports Node-only modules (`node:fs`,
6
+ * `node:child_process`, `node:os`, `node:crypto`) that vite/rollup
7
+ * cannot bundle for the browser. The CLI's bootstrap registers the
8
+ * Node implementation here at startup via `setCompileAndLoadCImpl()`;
9
+ * any browser bundle leaves it unregistered, so the koffi-backed
10
+ * executors decline (their proposals already gate on
11
+ * `bridge.koffi !== undefined`).
12
+ *
13
+ * Types stay in this file so the koffi executors can import them
14
+ * without dragging Node-only deps into the static dep graph.
15
+ */
16
+ import type { NativeBridge } from "../../workspace/types.js";
17
+ /** The koffi function reference returned by `lib.func(decl)`. The
18
+ * actual call signature is controlled by the caller's declaration —
19
+ * type as variadic and let the caller cast. */
20
+ export type CFn = (...args: unknown[]) => unknown;
21
+ export interface CompiledC {
22
+ readonly fn: CFn;
23
+ /** koffi `Lib` instance — useful for binding auxiliary symbols
24
+ * (`free` from libc, allocator helpers, etc.) without re-opening
25
+ * the .so. */
26
+ readonly lib: KoffiLib;
27
+ /** Path to the .so on disk — diagnostics only. */
28
+ readonly libPath: string;
29
+ /** Cache hit (true) vs. fresh cc invocation (false). */
30
+ readonly cacheHit: boolean;
31
+ }
32
+ /** koffi's runtime-shaped lib object. Loosely typed because koffi
33
+ * doesn't ship TS types for its declaration-string API. */
34
+ export interface KoffiLib {
35
+ func(declaration: string): CFn;
36
+ }
37
+ /** Signature of the real compile-and-load. The CLI registers an
38
+ * implementation that shells out to `cc` and `dlopen`s the result
39
+ * via koffi. */
40
+ export type CompileAndLoadCImpl = (source: string, declaration: string, bridge: NativeBridge) => CompiledC;
41
+ /** Install the Node-side C-JIT implementation. Called by `cli.ts`
42
+ * during CLI bootstrap; browser bundles never call this, so `impl`
43
+ * stays null and the koffi executors decline. */
44
+ export declare function setCompileAndLoadCImpl(fn: CompileAndLoadCImpl): void;
45
+ /** Compile (or look up cached) and load. Delegates to whatever was
46
+ * registered via `setCompileAndLoadCImpl()`; throws if no
47
+ * implementation is available (= running in a browser host that
48
+ * somehow got past the koffi executor's `bridge.koffi` gate). */
49
+ export declare function compileAndLoadC(source: string, declaration: string, bridge: NativeBridge): CompiledC;
50
+ export declare function setReadCachedCSourceImpl(fn: (hash: string) => string | null): void;
51
+ export declare function readCachedCSource(hash: string): string | null;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Node-only implementation of the koffi C-JIT pipeline.
3
+ *
4
+ * Cache layout: `~/.cache/numbl/mtoc2-c-jit/<sha>.so` (one per unique
5
+ * `(declaration, source, flags)` triple). On hit, `dlopen` and reuse —
6
+ * no `cc` invocation. On miss, write `<sha>.c`, exec `cc`, then
7
+ * `dlopen`.
8
+ *
9
+ * This file is split out of `compileC.ts` so the browser bundle stays
10
+ * free of `node:fs` / `node:child_process` imports — vite/rollup
11
+ * cannot resolve them for the browser target. Browser bundles import
12
+ * only `compileC.ts` (types + a runtime-injected stub); the CLI
13
+ * imports this file at bootstrap and calls `setCompileAndLoadCImpl()`.
14
+ */
15
+ import type { NativeBridge } from "../../workspace/types.js";
16
+ import { type CompiledC } from "./compileC.js";
17
+ /** Compile (or look up cached) and load. The cache key is the SHA of
18
+ * `(flags, declaration, source)` so two different signatures or
19
+ * compile-flag sets against the same source get distinct artifacts. */
20
+ export declare function compileAndLoadC(source: string, declaration: string, bridge: NativeBridge): CompiledC;
21
+ /** Read a previously-compiled C source from disk. Diagnostic helper. */
22
+ export declare function readCachedCSource(hash: string): string | null;
23
+ /** Register both implementations with the browser-safe surface. The
24
+ * CLI imports this module at bootstrap to wire them in. */
25
+ export declare function registerNodeCompileC(): void;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Build the `$h` helpers object that mtoc2's emitted spec receives
3
+ * when invoked via the numbl JIT bridge.
4
+ *
5
+ * - `write(s)` — output sink. Routed to `rt.output(...)` so `disp` /
6
+ * `fprintf` / `warning` etc. land in numbl's output stream.
7
+ * - `plotDispatch(name, args)` — host hook for plot builtins.
8
+ * mtoc2's emitted `mtoc2_plot_dispatch(...)` calls this in
9
+ * preference to the standalone-mode JSON-on-stdout wire format.
10
+ * We translate args from mtoc2's emit shape into `RuntimeValue`
11
+ * via `jitToNumbl` and call numbl's `dispatchPlotBuiltin`,
12
+ * pushing the resulting instruction onto `rt.plotInstructions` —
13
+ * so `colorbar('off')` / `pcolor(...)` / etc. produce the same
14
+ * plot-instruction stream as the interpreter would.
15
+ *
16
+ * The unknown-name fallthrough (when `dispatchPlotBuiltin` returns
17
+ * false) is a programmer error: every name mtoc2's plot builtin
18
+ * registration covers is in `PLOT_ALL_NAMES`, which is sourced from
19
+ * the same list `dispatchPlotBuiltin` switches on. Throw so the
20
+ * mismatch is loud rather than silently dropping a side effect.
21
+ */
22
+ import type { Runtime } from "../../runtime/runtime.js";
23
+ export interface JitHostHelpers {
24
+ write: (s: string) => void;
25
+ plotDispatch: (name: string, args: unknown[]) => void;
26
+ }
27
+ export declare function buildHostHelpers(rt: Runtime): JitHostHelpers;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * jit-loop — compiles a single For/While stmt via mtoc2's
3
+ * `compileSpec` with the loop wrapped as a synthetic user function
4
+ * whose params are the variables the loop reads (env inputs) and
5
+ * whose outputs are the variables it assigns that are live after the
6
+ * loop (filtered in classification).
7
+ *
8
+ * Mirrors `topLevelExecutor.ts` — the only structural difference is
9
+ * that the synthetic body is a single-element `[loopStmt]` instead of
10
+ * a whole script body.
11
+ *
12
+ * Loop-depth gate: only fires when `interp.loopDepth === 0`. A loop
13
+ * dispatched while the interpreter is iterating an enclosing
14
+ * loop-body would pay per-iter propose/cache overhead with no
15
+ * speedup, because the *outer* loop is the natural JIT entry point
16
+ * (it captures the inner loop's body and runs it natively in mtoc2-
17
+ * emitted code). When the outer loop fires its own JIT, the inner
18
+ * loop never reaches the interpreter dispatcher at all.
19
+ */
20
+ import type { Executor } from "../types.js";
21
+ import { type JitType } from "../../jitTypes.js";
22
+ import type { Stmt } from "../../parser/index.js";
23
+ import { type Type as CompilerType } from "../../jit/index.js";
24
+ import type { ConstHandle } from "../classification.js";
25
+ interface JitLoopData {
26
+ readonly loopStmt: Stmt & {
27
+ type: "For" | "While";
28
+ };
29
+ readonly inputs: readonly string[];
30
+ readonly outputs: readonly string[];
31
+ readonly inputTypes: readonly JitType[];
32
+ readonly compilerInputTypes: readonly CompilerType[];
33
+ readonly constHandles: readonly ConstHandle[];
34
+ readonly currentFile: string;
35
+ readonly cacheKey: string;
36
+ }
37
+ interface CompiledArtifact {
38
+ readonly specFn: (...args: unknown[]) => unknown;
39
+ }
40
+ export declare const jitLoopExecutor: Executor<JitLoopData, CompiledArtifact | null>;
41
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Per-LoweringContext mtoc2 session state shared between
3
+ * `jitCallExecutor` and `jitTopLevelExecutor`. One `Workspace`
4
+ * (built from numbl's existing `LoweringContext`) and one `Lowerer`
5
+ * per execution session, so the `Lowerer.specializations` cache
6
+ * persists across whole-scope + per-call dispatches.
7
+ *
8
+ * The session is keyed on the LoweringContext object — WeakMap-cleared
9
+ * automatically when the context goes out of scope.
10
+ */
11
+ import type { Interpreter } from "../../interpreter/interpreter.js";
12
+ import { Workspace, Lowerer } from "../../jit/index.js";
13
+ export interface SessionState {
14
+ workspace: Workspace;
15
+ lowerer: Lowerer;
16
+ }
17
+ export declare function getOrCreateSession(interp: Interpreter): SessionState;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * jit-top-level — compiles a script body via mtoc2's `compileSpec`
3
+ * with the body wrapped as a synthetic user function whose params are
4
+ * the variables the body reads (env inputs) and whose outputs are the
5
+ * variables it assigns (env outputs).
6
+ *
7
+ * The interpreter calls `Registry.tryRunWholeScope` once at script
8
+ * start; we register this via `registerWholeScope`. On compile
9
+ * success the entire script runs in mtoc2-emitted JS; on
10
+ * `UnsupportedConstruct` / `TypeError` we decline and the dispatcher
11
+ * falls through to per-stmt dispatch (where jit-call still handles
12
+ * individual user-function calls).
13
+ *
14
+ * Top-level loops *inside* the script execute as part of the
15
+ * compiled artifact, so `loopDepth` only gates dispatch-level calls,
16
+ * not this whole-scope attempt.
17
+ */
18
+ import type { Executor } from "../types.js";
19
+ import { type JitType } from "../../jitTypes.js";
20
+ import type { Stmt } from "../../parser/index.js";
21
+ import { type Type as CompilerType } from "../../jit/index.js";
22
+ interface JitTopLevelData {
23
+ readonly stmts: readonly Stmt[];
24
+ readonly inputs: readonly string[];
25
+ readonly outputs: readonly string[];
26
+ readonly inputTypes: readonly JitType[];
27
+ readonly compilerInputTypes: readonly CompilerType[];
28
+ readonly currentFile: string;
29
+ readonly cacheKey: string;
30
+ }
31
+ interface CompiledArtifact {
32
+ readonly specFn: (...args: unknown[]) => unknown;
33
+ readonly nargout: number;
34
+ }
35
+ export declare const jitTopLevelExecutor: Executor<JitTopLevelData, CompiledArtifact | null>;
36
+ export {};
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Adapter: numbl `JitType` → mtoc2 `Type`.
3
+ *
4
+ * Called by the mtoc2 JIT executor at `propose()` time. Numbl observes
5
+ * each argument's `JitType` from the live runtime value (via
6
+ * `inferJitType`); the adapter translates it into the matching mtoc2
7
+ * Type so `compileSpec` can specialize on the same shape information.
8
+ *
9
+ * Two design rules:
10
+ *
11
+ * 1. **Always strip exact.** Runtime-observed scalars must NOT shard
12
+ * mtoc2's spec cache by value. We never propagate `exact` through
13
+ * the adapter — `compileSpec` calls `withoutExact` again
14
+ * defensively, but doing it here makes the spec key wider one step
15
+ * earlier.
16
+ * 2. **Reject unsupported kinds via `null`.** The executor's
17
+ * `propose()` treats `null` from this adapter as "decline this
18
+ * JIT proposal" — the dispatcher falls through to the next
19
+ * executor (eventually the interpreter). First-cut coverage is
20
+ * scalars + dense real/complex tensors + strings + chars. Structs,
21
+ * cells, class instances, struct arrays, sparse, dictionaries, and
22
+ * function handles return `null`; they can be added later.
23
+ */
24
+ import type { JitType } from "../../jitTypes.js";
25
+ import { type Type } from "../../jit/index.js";
26
+ /** Translate a numbl `JitType` to the matching mtoc2 `Type`.
27
+ * Returns `null` for kinds the mtoc2 JIT path doesn't accept (yet). */
28
+ export declare function jitTypeToCompilerType(jt: JitType): Type | null;