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,103 @@
1
+ /**
2
+ * Executor registry — core types.
3
+ *
4
+ * See docs/developer_reference/executors.md for the design overview.
5
+ *
6
+ * The interpreter delegates each statement (or run of statements) — and
7
+ * each user-function call — to a registry of Executors. Each executor
8
+ * implements one strategy (interpreter, JS-JIT, C-kernel, ...). On each
9
+ * dispatch, every executor may submit a Proposal; the dispatcher picks
10
+ * the lowest-cost. Stmt-shape and call-shape work share the same
11
+ * Executor interface — they're discriminated via the lowered statement
12
+ * passed to propose().
13
+ */
14
+ import type { DispatchContext } from "./context.js";
15
+ import type { LoweredStmt } from "./lowering.js";
16
+ /** Estimated cost of using this executor for the proposed work.
17
+ * Numbers can be very rough at first; the dispatcher's policy is
18
+ * refined separately from executors. */
19
+ export interface CostEstimate {
20
+ /** One-time compile cost on cache miss. */
21
+ compileMs: number;
22
+ /** Per-call dispatch overhead (marshaling, frame setup, ...). */
23
+ perCallNs: number;
24
+ /** Estimated work done by the compiled artifact for the proposed
25
+ * input sizes. */
26
+ runNs: number;
27
+ }
28
+ /** Reason a `run` invocation could not complete. The dispatcher
29
+ * invalidates the cache entry and tries the next-best candidate. */
30
+ export interface BailReason {
31
+ message: string;
32
+ cause?: unknown;
33
+ }
34
+ export type RunResult =
35
+ /** Stmt-shape success — handled the head stmt. Registered executors
36
+ * don't produce control signals (break/continue/return); only the
37
+ * hardcoded interpreter fallback in `Registry.dispatch` does.
38
+ * The dispatcher always advances by exactly one stmt on success. */
39
+ {
40
+ ok: true;
41
+ }
42
+ /** Call-shape success — used by executors that handle a
43
+ * CallLoweredStmt. The dispatcher's call entry point
44
+ * (`dispatchCall`) returns this `result` to the caller. */
45
+ | {
46
+ result: unknown;
47
+ } | {
48
+ bail: BailReason;
49
+ /** When true, the bail is not cached: future dispatches re-enter
50
+ * the executor as if cache had never been touched. Use for
51
+ * shim/wrapper executors whose internal classify logic must
52
+ * re-run on every call (e.g., because the wrapped layer caches
53
+ * on its own keying scheme). Default false. */
54
+ transient?: boolean;
55
+ };
56
+ /** An executor's bid to handle the current dispatch. The dispatcher
57
+ * picks the lowest-cost proposal; the executor's own `data` flows
58
+ * through to compile() and run() unchanged. */
59
+ export interface Proposal<D> {
60
+ /** Opaque per-executor data; passed to compile() and run(). */
61
+ data: D;
62
+ cost: CostEstimate;
63
+ /** Whether this specific proposal's compiled artifact may fail an
64
+ * invariant mid-execution (and thus need re-running by a fallback).
65
+ * The dispatcher filters bail-risk proposals out of contexts marked
66
+ * `requireNoBail`. Per-proposal because a single executor may
67
+ * produce both bail-risky and bail-safe proposals depending on the
68
+ * inputs it sees. */
69
+ bailRisk: boolean;
70
+ }
71
+ export interface Executor<D = unknown, C = unknown> {
72
+ /** Stable identifier for logging, cache keys, and test selection. */
73
+ readonly name: string;
74
+ /** Submit a bid to handle this stmt. Runs on every dispatch — must
75
+ * be cheap.
76
+ *
77
+ * Receives the lowered statement produced by the dispatcher's
78
+ * pre-propose lowering pass. The `kind` field discriminates: a
79
+ * specialized shape (e.g. `"top-level"`) carries a lowered IR
80
+ * plus pre-computed feasibility flags; the fallback `"stmt"` kind
81
+ * carries the raw AST stmt for executors that classify from the
82
+ * AST directly.
83
+ *
84
+ * Codegen-feasibility decisions (display mode, IO+bail-risk, etc.)
85
+ * belong here — the lowering pipeline produces an IR; the
86
+ * executor decides whether to commit. For lookahead across
87
+ * multiple stmts, use `ctx.peekSibling(offset)` or `ctx.siblings`.
88
+ *
89
+ * Returns null to decline. */
90
+ propose(lowered: LoweredStmt, ctx: DispatchContext): Proposal<D> | null;
91
+ /** Stable cache key projected from the proposal data. Drops
92
+ * volatile bits (e.g., exact scalar values; tensor shape if
93
+ * codegen is shape-agnostic) so unrelated runs of the same code
94
+ * reuse compiled artifacts. */
95
+ cacheKey(data: D): string;
96
+ /** Compile to a runnable artifact. Called only on cache miss.
97
+ * Cached under (executor, headStmt, cacheKey). */
98
+ compile(data: D, ctx: DispatchContext): C;
99
+ /** Execute. Returns the number of consumed sibling stmts on success,
100
+ * or a Bail signalling the cache entry should be invalidated and
101
+ * the next-best candidate tried. */
102
+ run(compiled: C, data: D, ctx: DispatchContext): RunResult;
103
+ }
@@ -43,6 +43,13 @@ export type ResolvedTarget = {
43
43
  kind: "jsUserFunction";
44
44
  name: string;
45
45
  argTypes: ItemType[];
46
+ } | {
47
+ /** mtoc2-only user function (.mtoc2.js). Numbl's interpreter
48
+ * rejects calls to this kind; mtoc2's loader picks up the source
49
+ * from the workspace registry and evaluates it. */
50
+ kind: "mtoc2UserFunction";
51
+ name: string;
52
+ argTypes: ItemType[];
46
53
  } | {
47
54
  kind: "workspaceClassConstructor";
48
55
  className: string;
@@ -2,10 +2,9 @@
2
2
  * Helpers for writing builtin check functions.
3
3
  * These make check implementations shorter and easier to read.
4
4
  */
5
- import { type FloatXArrayType } from "../runtime/types.js";
6
5
  import { RTV, RuntimeValue } from "../runtime/index.js";
7
6
  /** Ensure data is Float64Array (needed by LAPACK bridges). */
8
- export declare function toF64(data: FloatXArrayType): Float64Array;
7
+ export declare function toF64(data: Float64Array): Float64Array;
9
8
  /**
10
9
  * Extract and normalize a string argument at runtime.
11
10
  * Strips surrounding quotes and lowercases the result.
@@ -31,18 +30,18 @@ export declare function buildEigenvectorMatrix(packedV: Float64Array, wi: Float6
31
30
  * Build a tensor, attaching the imaginary part only when it contains non-zero values.
32
31
  * Replaces the repeated `hasComplex ? RTV.tensor(re, shape, im) : RTV.tensor(re, shape)` pattern.
33
32
  */
34
- export declare function maybeComplexTensor(re: FloatXArrayType | Float64Array, shape: number[], im: FloatXArrayType | Float64Array | undefined): ReturnType<typeof RTV.tensor>;
33
+ export declare function maybeComplexTensor(re: Float64Array | Float64Array, shape: number[], im: Float64Array | Float64Array | undefined): ReturnType<typeof RTV.tensor>;
35
34
  /**
36
35
  * Build a diagonal matrix from a vector of values (column-major).
37
36
  * For square matrices pass just n; for rectangular pass [rows, cols].
38
37
  * Optionally includes an imaginary diagonal.
39
38
  */
40
- export declare function buildDiagMatrix(realVals: Float64Array | FloatXArrayType, imagVals: Float64Array | FloatXArrayType | undefined, size: number | [number, number]): ReturnType<typeof RTV.tensor>;
39
+ export declare function buildDiagMatrix(realVals: Float64Array | Float64Array, imagVals: Float64Array | Float64Array | undefined, size: number | [number, number]): ReturnType<typeof RTV.tensor>;
41
40
  /**
42
41
  * In-place Gauss-Jordan elimination with partial pivoting on a column-major
43
42
  * augmented matrix [A | B] of size `rows × totalCols`.
44
43
  */
45
- export declare function gaussJordanEliminate(aug: FloatXArrayType, rows: number, totalCols: number): void;
44
+ export declare function gaussJordanEliminate(aug: Float64Array, rows: number, totalCols: number): void;
46
45
  /**
47
46
  * Call a registered builtin from within another builtin's apply().
48
47
  * Convenience wrapper that includes the caller name in error messages.
@@ -9,18 +9,17 @@
9
9
  * Both the native LAPACK addon and the ts-lapack TypeScript fallback are
10
10
  * supported; the native addon is preferred when available.
11
11
  */
12
- import { FloatXArrayType } from "../runtime/types.js";
13
12
  /**
14
13
  * Dispatch linsolve to the native addon (preferred) or ts-lapack fallback.
15
14
  * Returns null only when neither bridge exposes `linsolve` (should not happen
16
15
  * in practice since ts-lapack always has it).
17
16
  */
18
- export declare function linsolveLapack(A: FloatXArrayType, m: number, n: number, B: FloatXArrayType, nrhs: number): Float64Array | null;
17
+ export declare function linsolveLapack(A: Float64Array, m: number, n: number, B: Float64Array, nrhs: number): Float64Array | null;
19
18
  /**
20
19
  * Dispatch complex linsolve to the native addon (preferred) or ts-lapack fallback.
21
20
  * The ts-lapack fallback throws — native addon is required for complex linsolve.
22
21
  */
23
- export declare function linsolveComplexLapack(ARe: FloatXArrayType, AIm: FloatXArrayType, m: number, n: number, BRe: FloatXArrayType, BIm: FloatXArrayType, nrhs: number): {
22
+ export declare function linsolveComplexLapack(ARe: Float64Array, AIm: Float64Array, m: number, n: number, BRe: Float64Array, BIm: Float64Array, nrhs: number): {
24
23
  re: Float64Array;
25
24
  im: Float64Array;
26
25
  };
@@ -2,7 +2,6 @@
2
2
  * Seedable PRNG (xoshiro128**) for random number generation
3
3
  */
4
4
  import { RuntimeValue } from "../runtime/index.js";
5
- import { type FloatXArrayType } from "../runtime/types.js";
6
5
  export declare function setRngShuffle(): void;
7
6
  export declare function setRngSeed(seed: number): void;
8
7
  export declare function seedRng(seed: number): void;
@@ -10,7 +9,7 @@ export declare function seedRng(seed: number): void;
10
9
  export declare function rngRandom(): number;
11
10
  export declare function boxMullerRandom(): number;
12
11
  /** Fill a typed array with normal random values (bulk polar method) */
13
- export declare function fillRandn(data: FloatXArrayType): void;
12
+ export declare function fillRandn(data: Float64Array): void;
14
13
  /** Return the current RNG state as a struct {Type, Seed, State} */
15
14
  export declare function getRngStateStruct(): RuntimeValue;
16
15
  /** Restore RNG state from a struct previously returned by rng() */
@@ -13,7 +13,10 @@ export declare function forEachSlice(shape: number[], dim: number, callback: (ou
13
13
  resultShape: number[];
14
14
  totalElems: number;
15
15
  } | null;
16
- /** Return 1-based dim to reduce along (first non-singleton), or 0 for "reduce to scalar". */
16
+ /** Return 1-based dim to reduce along (first dim whose size != 1), or 0 for
17
+ * "reduce to scalar". A size-0 dimension counts as non-singleton (MATLAB
18
+ * reduces along it), so `sum(zeros(0,3))` is `[0 0 0]` not a scalar — the
19
+ * previous `d > 1` test wrongly treated a size-0 dim as singleton. */
17
20
  export declare function firstReduceDim(shape: number[]): number;
18
21
  /** Return a deep copy of a tensor (data + shape + optional imag). */
19
22
  export declare function copyTensor(v: RuntimeTensor): RuntimeValue;
@@ -27,7 +27,8 @@
27
27
  * `seconds(d)` returns the numeric seconds of a duration, or wraps a
28
28
  * number as a duration.
29
29
  */
30
- import type { RuntimeValue, RuntimeClassInstance } from "../../runtime/types.js";
30
+ import type { RuntimeValue } from "../../runtime/types.js";
31
+ import { RuntimeClassInstance } from "../../runtime/types.js";
31
32
  export declare function makeDatetime(year: number, month: number, day: number, hour: number, minute: number, second: number): RuntimeClassInstance;
32
33
  export declare function makeDuration(totalSeconds: number): RuntimeClassInstance;
33
34
  /**
@@ -31,6 +31,6 @@ import "./special-math.js";
31
31
  import "./misc.js";
32
32
  import "./dictionary.js";
33
33
  import "./help-text.js";
34
- export { getIBuiltin, getIBuiltinHelp, getIBuiltinNargin, getAllIBuiltinNames, buildIBuiltinHelpers, setDynamicRegisterHook, registerBuiltinHelp, inferJitType, } from "./types.js";
34
+ export { getIBuiltin, getIBuiltinHelp, getIBuiltinNargin, getAllIBuiltinNames, registerBuiltinHelp, inferJitType, } from "./types.js";
35
35
  export type { IBuiltin, IBuiltinResolution, BuiltinHelp } from "./types.js";
36
36
  export { resetAppdataStore, convertJsonValue } from "./misc.js";
@@ -1,4 +1,7 @@
1
1
  import type { RuntimeValue } from "../../runtime/types.js";
2
- /** Clear all appdata — called at the start of each executeCode to isolate runs. */
2
+ /** Clear all appdata — called at the start of each executeCode to isolate
3
+ * runs. Decrefs every stored value so the previous run's containers can
4
+ * hit rc=0 cleanly; if the previous runtime is gone (test harness), we
5
+ * just drop the JS references and let GC reclaim them. */
3
6
  export declare function resetAppdataStore(): void;
4
7
  export declare function convertJsonValue(val: unknown): RuntimeValue;
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * IBuiltin interface, registry, and shared helpers for interpreter builtins.
3
3
  */
4
- import type { RuntimeValue, RuntimeTensor, RuntimeComplexNumber } from "../../runtime/types.js";
5
- import { FloatXArray } from "../../runtime/types.js";
6
- import { type JitType } from "../../jit/jitTypes.js";
4
+ import type { RuntimeValue } from "../../runtime/types.js";
5
+ import { RuntimeTensor, RuntimeComplexNumber } from "../../runtime/types.js";
6
+ import { type JitType } from "../../jitTypes.js";
7
7
  export interface IBuiltinResolution {
8
8
  outputTypes: JitType[];
9
9
  apply: (args: RuntimeValue[], nargout: number) => RuntimeValue | RuntimeValue[];
@@ -17,56 +17,9 @@ export interface IBuiltin {
17
17
  help?: BuiltinHelp;
18
18
  /** Given input JIT types + nargout, return output types and a specialized apply, or null. */
19
19
  resolve: (argTypes: JitType[], nargout: number) => IBuiltinResolution | null;
20
- /** Optional fast-path JS code emission for JIT. Return null to fall back to $h.ib_<name>. */
21
- jitEmit?: (argCode: string[], argTypes: JitType[], getDest?: () => string) => string | null;
22
- /**
23
- * Optional fast-path C code emission for the C-JIT. Return null if the
24
- * builtin can't be emitted as a C expression for the given arg types
25
- * — the C-JIT will bail to JS-JIT for this call site. Covers the
26
- * scalar-argument case only (tensor-argument emission is handled by
27
- * separate tensor-op dispatch in assemble.ts / emit/fused.ts).
28
- */
29
- jitEmitC?: (argCode: string[], argTypes: JitType[]) => string | null;
30
- /**
31
- * Optional C-JIT tensor-op dispatch metadata. When a field is present,
32
- * both the C feasibility check and C codegen read it directly —
33
- * adding a new tensor-unary / tensor-binary / tensor-reduction builtin
34
- * is one edit here (plus the matching native-side enum or C function).
35
- * Previously these were three parallel hardcoded tables (one in
36
- * feasibility.ts, two in context.ts) that could silently drift
37
- * from the native-side opcode enums. Centralizing on the IBuiltin
38
- * registration removes that drift risk.
39
- */
40
- jitCapabilities?: JitCapabilities;
41
- }
42
- /** Per-builtin C-JIT tensor-op dispatch metadata. See IBuiltin.jitCapabilities. */
43
- export interface JitCapabilities {
44
- /**
45
- * libnumbl_ops opcode enum name (e.g. "NUMBL_UNARY_EXP") for
46
- * element-wise unary tensor builtins routed through
47
- * `numbl_realUnaryElemwise`. Set this on element-wise unary functions
48
- * that have a libnumbl_ops opcode and are safe to invoke on any real
49
- * input (domain-restricted ones like log/sqrt stay excluded).
50
- */
51
- tensorUnaryOp?: string;
52
- /**
53
- * C function name (e.g. "fmax", "atan2", "numbl_mod") for 2-arg
54
- * element-wise tensor builtins. The C-JIT emits an inline per-element
55
- * loop calling this function; it must match the interpreter's
56
- * scalar-apply semantics exactly.
57
- */
58
- tensorBinaryFn?: string;
59
- /**
60
- * libnumbl_ops opcode enum name (e.g. "NUMBL_REDUCE_SUM") for
61
- * tensor→scalar reductions routed through `numbl_tensor_reduce_op`.
62
- * Set on reduction builtins (sum / prod / max / min / any / all / mean).
63
- */
64
- tensorReductionOp?: string;
65
20
  }
66
21
  export declare function getIBuiltin(name: string): IBuiltin | undefined;
67
22
  export declare function registerIBuiltin(b: IBuiltin): void;
68
- /** Set a callback for dynamic IBuiltin registration (called by jitHelpers setup). */
69
- export declare function setDynamicRegisterHook(hook: ((b: IBuiltin) => void) | null): void;
70
23
  /** Register a dynamic IBuiltin (e.g. .js user functions), replacing any
71
24
  * existing entry with the same name without error. */
72
25
  export declare function registerDynamicIBuiltin(b: IBuiltin): void;
@@ -78,12 +31,8 @@ export declare function registerBuiltinHelp(name: string, help: BuiltinHelp): vo
78
31
  * Tries resolve with 1, 2, 3 number-type args to find the accepted count. */
79
32
  export declare function getIBuiltinNargin(name: string): number | undefined;
80
33
  export declare function inferJitType(value: unknown): JitType;
81
- /** Build the ib_* entries for the jitHelpers object.
82
- * The returned object also has _profileEnter/_profileLeave hooks (no-ops by default)
83
- * that the runtime replaces when profiling is enabled. */
84
- export declare function buildIBuiltinHelpers(): Record<string, any>;
85
34
  export declare function mkc(re: number, im: number): number | RuntimeComplexNumber;
86
- export declare function makeTensor(data: InstanceType<typeof FloatXArray>, imag: InstanceType<typeof FloatXArray> | undefined, shape: number[]): RuntimeTensor;
35
+ export declare function makeTensor(data: Float64Array, imag: Float64Array | undefined, shape: number[]): RuntimeTensor;
87
36
  /** Type rule requiring two scalar numbers */
88
37
  export declare function binaryNumberOnly(argTypes: JitType[]): JitType[] | null;
89
38
  export declare function applyUnaryElemwise(v: RuntimeValue, realFn: (x: number) => number, complexFn: (re: number, im: number) => {
@@ -109,9 +58,6 @@ export declare function defineBuiltin(opts: {
109
58
  name: string;
110
59
  help?: BuiltinHelp;
111
60
  cases: BuiltinCase[];
112
- jitEmit?: (argCode: string[], argTypes: JitType[], getDest?: () => string) => string | null;
113
- jitEmitC?: (argCode: string[], argTypes: JitType[]) => string | null;
114
- jitCapabilities?: JitCapabilities;
115
61
  }): void;
116
62
  type NumberJitType = Extract<JitType, {
117
63
  kind: "number";
@@ -149,55 +95,4 @@ export declare function unaryElemwiseCases(spec: UnaryElemwiseSpec, name: string
149
95
  export declare function unaryRealResultCases(realFn: (x: number) => number, complexFn: (re: number, im: number) => number, name: string): BuiltinCase[];
150
96
  /** Build cases for numeric predicates (isnan, isinf, isfinite) that return logical. */
151
97
  export declare function predicateCases(scalarTest: (x: number) => boolean, complexTest: (re: number, im: number) => boolean, tensorTest: (x: number) => boolean, tensorComplexTest: (re: number, im: number) => boolean, name: string): BuiltinCase[];
152
- /** Fast-path emitter for unary Math.* functions.
153
- * Emits Math.fn(x) for scalar numbers, $h.tHelper(dest, x) for real
154
- * tensors. `getDest` is a lazy callback returning the dest local: either
155
- * a mangled LHS (top-level Assign) or a fresh scratch (inner tensor
156
- * sub-expression). It's only invoked when the tensor fast path is
157
- * actually taken, so scalar / rejected paths don't burn a scratch. */
158
- export declare function unaryMathJitEmit(mathFn: string, tensorHelper: string, requireNonneg?: boolean): (argCode: string[], argTypes: JitType[], getDest?: () => string) => string | null;
159
- /** Fast-path emitter for binary Math.* functions on two scalar numbers. */
160
- export declare function binaryMathJitEmit(mathFn: string): (argCode: string[], argTypes: JitType[]) => string | null;
161
- /** Fast-path C emitter for unary math functions on a scalar.
162
- * Emits `cFn(x)` for scalar number/boolean; returns null otherwise
163
- * (tensor emission is handled separately by emit/tensor.ts).
164
- * If `requireNonneg` is set, rejects values whose sign isn't known
165
- * to be nonneg — matches the JS guard for domain-restricted functions. */
166
- export declare function unaryMathJitEmitC(cFn: string, requireNonneg?: boolean): (argCode: string[], argTypes: JitType[]) => string | null;
167
- /** Fast-path C emitter for binary math functions on two scalar numbers. */
168
- export declare function binaryMathJitEmitC(cFn: string): (argCode: string[], argTypes: JitType[]) => string | null;
169
- /**
170
- * Fast-path C emitter for 1-arg scalar builtins that collapse to a
171
- * compile-time constant given the arg's kind. Common for shape/type
172
- * predicates where the answer is fully determined by the type
173
- * (e.g. `isnumeric(number) -> 1.0`, `isscalar(number) -> 1.0`,
174
- * `ndims(number) -> 2.0`, `numel(number) -> 1.0`).
175
- *
176
- * `valueByKind` maps each supported JitType kind to its C constant.
177
- * Arg kinds not in the map return null, which bails the C-JIT to
178
- * JS-JIT for that call site. All values must be valid C double
179
- * literals (`"1.0"`, `"0.0"`, `"2.0"`, ...).
180
- */
181
- export declare function scalarConstantJitEmitC(valueByKind: Partial<Record<JitType["kind"], string>>): (argCode: string[], argTypes: JitType[]) => string | null;
182
- /**
183
- * Fast-path C emitter for 1-arg scalar predicates backed by a runtime
184
- * helper whose return value is int (e.g. `numbl_is_nan`,
185
- * `numbl_is_inf`, `numbl_is_finite`). The int is cast to double for
186
- * the C-JIT's uniform boolean-as-double representation. Returns null
187
- * for non-scalar args.
188
- *
189
- * Note: `isnan` / `isinf` / `isfinite` from `<math.h>` can't be used
190
- * directly because the JIT compiles with `-ffast-math`, which implies
191
- * `-ffinite-math-only` and constant-folds those macros to false/true.
192
- * The `numbl_is_nan` / `_is_inf` / `_is_finite` helpers in
193
- * `jit_runtime` use bit-pattern inspection and live in a separately
194
- * compiled archive, so the caller's `-ffast-math` can't defeat them.
195
- */
196
- export declare function unaryPredicateJitEmitC(cFn: string): (argCode: string[], argTypes: JitType[]) => string | null;
197
- /**
198
- * Fast-path C emitter for 1-arg scalar builtins that are the identity
199
- * on real scalars (e.g. `double(x)`, `real(x)`, `conj(x)`). Returns
200
- * `(x)` for `number`/`boolean`, null otherwise.
201
- */
202
- export declare function scalarIdentityJitEmitC(): (argCode: string[], argTypes: JitType[]) => string | null;
203
98
  export {};
@@ -40,6 +40,23 @@ export declare class Interpreter {
40
40
  dimIndex: number;
41
41
  numIndices: number;
42
42
  }>;
43
+ /** @internal Number of enclosing `for` / `while` loop bodies the
44
+ * interpreter is currently inside. Bumped on body entry, decremented
45
+ * on exit. Read by the executor registry's `propose()` to gate JIT
46
+ * attempts: when `loopDepth > 0`, the interpreter is iterating a
47
+ * hot loop and per-call JIT lookup overhead / spec-cache thrashing
48
+ * is a net loss. Once mtoc2 successfully JITs an outer call, the
49
+ * nested loops execute inside the compiled artifact and the
50
+ * interpreter never sees them, so this gate only fires on calls
51
+ * that genuinely happen at the interpreter level inside a loop. */
52
+ loopDepth: number;
53
+ /** @internal Number of enclosing conditional blocks (`if` / `switch` /
54
+ * `try`) whose bodies the interpreter is currently executing. Used by
55
+ * the loop classifier: when a loop is dispatched with `condBlockDepth >
56
+ * 0` (or `loopDepth > 0`), its sibling list is a nested block, so the
57
+ * post-loop liveness scan can't see reads after the enclosing block —
58
+ * the classifier must then keep every loop-assigned name live-out. */
59
+ condBlockDepth: number;
43
60
  /** @internal */
44
61
  functionDefCache: Map<string, FunctionDef>;
45
62
  /** @internal Pre-built line break tables for offset→line lookup per file. */
@@ -48,59 +65,43 @@ export declare class Interpreter {
48
65
  fileSources: Map<string, string>;
49
66
  /** @internal Guard against infinite recursion in compileSpecialized */
50
67
  compileInProgress: Set<string>;
51
- /** @internal Per-instance cache for JIT-compiled loops (avoids cross-execution collisions). */
52
- loopJitCache: Map<string, {
53
- fn: (...args: unknown[]) => unknown;
54
- source: string;
55
- } | null>;
56
- /** @internal Progressive type widening for loop JIT: location -> last unified input types. */
57
- loopLastInputTypes: Map<string, import("../jit/jitTypes.js").JitType[]>;
58
- /** @internal Sibling stmts of the currently-executing stmt (set by execStmts). */
59
- _postSiblings: import("../parser/types.js").Stmt[] | null;
60
- /** @internal Index in _postSiblings of the next stmt after the current one. */
61
- _postSiblingsIdx: number;
62
- /** @internal Number of EXTRA sibling stmts that the current execStmt
63
- * consumed beyond the one passed in. The surrounding sibling loop
64
- * reads this after each execStmt and advances its index by this
65
- * many. Used by `--opt e2` chain fusion to atomically execute a run
66
- * of consecutive Assigns as one C kernel. The interpreter must
67
- * reset this to 0 before each execStmt call. */
68
- _e2ChainAdvance: number;
69
- /** @internal The stmt list of the innermost enclosing function body
70
- * (or top-level script body). Used by `--opt e2` chain liveness
71
- * analysis to decide whether a chain LHS is actually referenced
72
- * outside the chain — if not, the LHS becomes a per-element stack-
73
- * local rather than a materialized output buffer. Pushed on call
74
- * frame entry, popped on exit. */
75
- _currentScopeBody: import("../parser/types.js").Stmt[] | null;
76
- /** @internal Names that "escape" the current scope regardless of
77
- * textual usage. For functions: the declared output names (plus
78
- * `varargout`). For top-level scripts: `null`, meaning every name
79
- * escapes (the surrounding caller can read all script-level vars
80
- * via `result.variableValues`). Pushed/popped alongside
81
- * `_currentScopeBody`. */
82
- _currentScopeExports: Set<string> | null;
83
68
  /**
84
- * Optimization level:
85
- * 0 — pure AST interpreter, no JIT.
86
- * 1 — JS-JIT (default): type-specialize hot functions/loops to JS via `new Function()`.
69
+ * Optimization mode:
70
+ * "0" — pure AST interpreter, no JIT.
71
+ * "1" — JS-JIT (default): top-level + call shapes get
72
+ * type-specialized JS via the JIT's `compileSpec`.
73
+ * "2" — C-JIT: scalar/tensor kernels via `compileSpecC` + koffi.
87
74
  */
88
- optimization: number;
89
- /**
90
- * Experimental opt variant selector e.g. `"e1"` for the mode that
91
- * keeps JS-JIT as the outer and emits on-demand C kernels for fusible
92
- * tensor chains and pure-scalar user functions. Undefined for the
93
- * standard `--opt <n>` path.
94
- */
95
- experimental?: string;
96
- /** Parallelize fused loops with OpenMP threads (--par flag). */
97
- par: boolean;
98
- /** Callback for JIT compilation logging (JS codegen). */
99
- onJitCompile?: (description: string, jsCode: string) => void;
100
- /** Callback for C-kernel compilation logging (--opt e2 / --dump-c). */
101
- onCCompile?: (description: string, cCode: string) => void;
75
+ optimization: import("../executors/plugins.js").OptLevel;
76
+ /** Callback for JIT compilation logging. `lang` distinguishes the
77
+ * emitted source: `"js"` for the JS-JIT backend, `"c"` for the
78
+ * C-JIT backend (both can fire in a single `--opt 2` run). */
79
+ onJitCompile?: (description: string, code: string, lang: "js" | "c") => void;
80
+ /** Called when a JIT-compiled unit bails back to the interpreter at
81
+ * RUNTIME (as opposed to declining at compile time). Today the sole
82
+ * trigger is an indexed-store array growth that's only detectable at
83
+ * runtime the JIT can't model the grown shape, so it bails and the
84
+ * interpreter re-runs the whole scope with full MATLAB semantics.
85
+ * Surfaced as a warning (the CLI routes it to stderr); a compile-time
86
+ * decline stays silent (it's the normal "not JIT-able" path). */
87
+ onJitBail?: (message: string) => void;
88
+ /** Bridge for loading native shared libraries. Undefined in browser
89
+ * contexts. */
90
+ nativeBridge?: import("../workspace/types.js").NativeBridge;
91
+ /** Telemetry: invoked after a registered executor's `run()` succeeds.
92
+ * Used to track which optimizers fire in a session. The kind is the
93
+ * LoweredStmt kind the executor handled ("top-level", "loop", "call",
94
+ * ...). Hot path — keep the callback cheap. */
95
+ onExecutorFired?: (name: string, kind: string) => void;
102
96
  /** Verbose log sink (plumbed from ExecOptions.log). */
103
97
  log?: (message: string) => void;
98
+ /** Executor registry. Holds the strategies (JS-JIT, C-kernel, ...)
99
+ * the dispatcher selects among at runtime. The AST interpreter is
100
+ * the dispatcher's hardcoded fallback (not a registered executor).
101
+ * Mode-driven plugins (`--opt 1`, `--opt 2`, ...) register
102
+ * executors during `executeCode` setup. See
103
+ * docs/developer_reference/executors.md. */
104
+ readonly registry: import("../executors/registry.js").Registry;
104
105
  constructor(rt: Runtime, ctx: LoweringContext, functionIndex: FunctionIndex, mainFileName: string, initialVariableValues?: Record<string, RuntimeValue>);
105
106
  /** Clear all JIT and function resolution caches. Called after addpath/rmpath. */
106
107
  clearAllCaches(): void;
@@ -112,6 +113,7 @@ export declare class Interpreter {
112
113
  getVariableValues(): Record<string, RuntimeValue>;
113
114
  execStmt: (stmt: Stmt) => ControlSignal | null;
114
115
  execStmts: (stmts: Stmt[]) => ControlSignal | null;
116
+ execBlockStmts: (stmts: Stmt[]) => ControlSignal | null;
115
117
  evalExpr: (expr: Expr) => unknown;
116
118
  evalExprNargout: (expr: Expr, nargout: number) => unknown;
117
119
  evalBinary: (expr: Extract<Expr, {
@@ -8,6 +8,12 @@ import { type ControlSignal } from "./types.js";
8
8
  import type { Interpreter } from "./interpreter.js";
9
9
  export declare function execStmt(this: Interpreter, stmt: Stmt): ControlSignal | null;
10
10
  export declare function execStmts(this: Interpreter, stmts: Stmt[]): ControlSignal | null;
11
+ /** Execute a conditional-block body (`if` / `switch` / `try`), tracking
12
+ * `condBlockDepth` so a loop dispatched inside knows its sibling list is
13
+ * a nested block — the loop classifier then keeps every loop-assigned
14
+ * name live-out (the post-loop liveness scan can't see reads after the
15
+ * enclosing block). */
16
+ export declare function execBlockStmts(this: Interpreter, stmts: Stmt[]): ControlSignal | null;
11
17
  export declare function evalExpr(this: Interpreter, expr: Expr): unknown;
12
18
  export declare function evalExprNargout(this: Interpreter, expr: Expr, nargout: number): unknown;
13
19
  export declare function evalArgs(this: Interpreter, argExprs: Expr[]): unknown[];
@@ -12,15 +12,18 @@ export interface InterpreterContext {
12
12
  evalInLocalScope: (codeArg: unknown, fileName?: string) => unknown;
13
13
  callFunction: (name: string, args: unknown[], nargout: number) => unknown;
14
14
  rt: Runtime;
15
- /** Optimization level (0 = JIT disabled, 1 = JIT scalar functions). */
16
- optimization: number;
15
+ /** Optimization mode: "0" = no JIT, "1" = JS-JIT, "2" = C-JIT. */
16
+ optimization: import("../executors/plugins.js").OptLevel;
17
17
  /** Resolve a workspace function or class name to its source file,
18
18
  * or undefined if no workspace file provides that name.
19
19
  * `kind` distinguishes a regular .m function from a .numbl.js
20
- * user function (treated as a MEX-equivalent) or a class file. */
20
+ * user function (treated as a MEX-equivalent) or a class file.
21
+ * `source` is the raw .m source for "function"/"class" kinds, or empty
22
+ * for "jsfunction" (where the implementation is JS, not .m text). */
21
23
  lookupWorkspaceFile: (name: string) => {
22
24
  path: string;
23
25
  kind: "function" | "jsfunction" | "class";
26
+ source: string;
24
27
  } | undefined;
25
28
  }
26
29
  export declare const FALL_THROUGH: unique symbol;
@@ -4,7 +4,6 @@
4
4
  import type { Stmt, ArgumentsBlock } from "../parser/types.js";
5
5
  import type { Runtime } from "../runtime/runtime.js";
6
6
  import type { RuntimeValue } from "../runtime/types.js";
7
- import type { JitType } from "../jit/jitTypes.js";
8
7
  export declare class BreakSignal {
9
8
  readonly _tag = "break";
10
9
  }
@@ -18,8 +17,8 @@ export declare class ReturnSignal {
18
17
  }
19
18
  export type ControlSignal = BreakSignal | ContinueSignal | ReturnSignal;
20
19
  export declare class Environment {
21
- private parent?;
22
- private vars;
20
+ parent?: Environment | undefined;
21
+ vars: Map<string, RuntimeValue>;
23
22
  /** When true, writes to variables found in parent go to the parent (nested function semantics). */
24
23
  isNested: boolean;
25
24
  /** Nested function definitions registered during execution. Lazy-initialized. */
@@ -44,12 +43,27 @@ export declare class Environment {
44
43
  persistentFuncId: string | undefined;
45
44
  /** Back-reference to the runtime (needed for global/persistent access) */
46
45
  rt: Runtime | null;
46
+ /** Set when a `@nestedFn` handle has been created that captures this env
47
+ * (or an ancestor). Tells the function-exit cleanup that clearing this
48
+ * env would strand the handle's closure, so locals must be left alive. */
49
+ nestedHandleCreated: boolean;
47
50
  constructor(parent?: Environment | undefined);
48
51
  get(name: string): RuntimeValue | undefined;
49
- /** Set variable — for nested scopes, writes to parent if variable exists there. */
52
+ /** Set variable — for nested scopes, writes to parent if variable
53
+ * exists there. Maintains refcounts: increfs the new value, decrefs
54
+ * the slot's prior occupant (in that order so self-rebind is safe). */
50
55
  set(name: string, value: RuntimeValue): void;
51
56
  /** Always writes to this scope (for parameter binding). */
52
57
  setLocal(name: string, value: RuntimeValue): void;
58
+ /** Remove a variable from this scope's local map.
59
+ * Returns true if the name was present locally. Does not touch
60
+ * the parent scope, globals, or persistent registrations — those
61
+ * are removed via `clear global` / `clear functions` (not yet
62
+ * implemented). */
63
+ delete(name: string): boolean;
64
+ /** Remove all local variables from this scope. Globals,
65
+ * persistents, and nested function defs are preserved. */
66
+ clearLocals(): void;
53
67
  has(name: string): boolean;
54
68
  /** Check if this scope directly owns a variable (not parent). */
55
69
  hasLocal(name: string): boolean;
@@ -60,9 +74,17 @@ export declare class Environment {
60
74
  fn: FunctionDef;
61
75
  env: Environment;
62
76
  } | undefined;
77
+ /** Mark this env and every ancestor up to (and including) the env that
78
+ * defines `name` as having had a nested-function handle created. The
79
+ * handle's closure references this env, so any of those scopes' locals
80
+ * must stay alive after the function exits. Returns true if `name`
81
+ * was found as a nested-function definition somewhere in the chain. */
82
+ markChainForNestedHandle(name: string): boolean;
63
83
  localNames(): string[];
64
84
  /** Create a snapshot of this environment (copies all variables by value).
65
- * Used for anonymous functions which capture values at definition time. */
85
+ * Used for anonymous functions which capture values at definition time.
86
+ * Each captured value is incref'd so it survives the source env's
87
+ * clearLocals when the original frame returns. */
66
88
  snapshot(): Environment;
67
89
  toRecord(): Record<string, RuntimeValue>;
68
90
  }
@@ -72,13 +94,6 @@ export interface FunctionDef {
72
94
  outputs: string[];
73
95
  body: Stmt[];
74
96
  argumentsBlocks?: ArgumentsBlock[];
75
- /** JIT compilation cache: maps signature key -> compiled entry or null (failed). */
76
- _jitCache?: Map<string, {
77
- fn: (...args: unknown[]) => unknown;
78
- source: string;
79
- } | null>;
80
- /** Progressive type widening: last unified arg types, keyed by nargout. */
81
- _lastJitArgTypes?: Map<number, JitType[]>;
82
97
  }
83
98
  /** Create a FunctionDef from an AST Function statement. */
84
99
  export declare function funcDefFromStmt(stmt: Stmt & {