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
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Single intra-repo bridge module for everything the vendored JIT
3
+ * (`src/numbl-core/jit/*`) consumes from the rest of numbl-core. Every
4
+ * `numbl-core/*` (and `graphics/*`) path the JIT depends on appears here
5
+ * exactly once, so:
6
+ *
7
+ * - a numbl rename / move surfaces as a single tsc error in this file
8
+ * rather than scattering across the vendored compiler's call sites;
9
+ * - the surface area between the JIT and the rest of numbl is visible at
10
+ * a glance.
11
+ *
12
+ * Historically this was mtoc2's cross-repo bridge (resolving the sibling
13
+ * `../../../numbl/` checkout); after vendoring it resolves the same
14
+ * symbols through local `numbl-core` relative paths. `parser/index.ts`
15
+ * re-exports through this module so the vendored files' import shapes
16
+ * stay unchanged.
17
+ */
18
+ export { parseMFile, SyntaxError, BinaryOperation, UnaryOperation, } from "../../parser/index.js";
19
+ export type { Span, Expr, Stmt, LValue, AbstractSyntaxTree, } from "../../parser/index.js";
20
+ export { LoweringContext } from "../../lowering/loweringContext.js";
21
+ export { resolveFunction } from "../../functionResolve.js";
22
+ export type { CallSite } from "../../runtime/runtimeHelpers.js";
23
+ export type { ItemType } from "../../lowering/itemTypes.js";
24
+ export type { ClassInfo } from "../../lowering/classInfo.js";
25
+ export { PLOT_ALL_NAMES } from "../../runtime/plotBuiltinDispatch.js";
26
+ export { dispatchPlotBuiltin, type PlotDispatchState, } from "../../runtime/plotBuiltinDispatch.js";
27
+ export type { PlotInstruction } from "../../../graphics/types.js";
28
+ export { allocFloat64Array } from "../../runtime/alloc.js";
29
+ export { RTV } from "../../runtime/constructors.js";
30
+ export type { RuntimeValue } from "../../runtime/types.js";
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Small AST helpers consumed by both the lowerer and the interpreter.
3
+ * Pure functions over the numbl AST shape — no dependency on the
4
+ * lowering / runtime layers.
5
+ */
6
+ import type { Expr, LValue } from "./index.js";
7
+ /** Walk a member-chain rooted in an `Ident` and return the dotted
8
+ * identifier (`pkg.fn`, `pkg.sub.fn`, `ClassName.staticMethod`).
9
+ * Returns null if the chain bottoms out at something that isn't a
10
+ * plain identifier (e.g. a function call result, a tensor literal).
11
+ *
12
+ * Used to disambiguate package calls (`pkg.foo(x)` — dotted lookup)
13
+ * from instance-method calls (`obj.method(x)` — receiver dispatch):
14
+ * the qualified name is only meaningful when every segment in the
15
+ * chain is a plain ident.
16
+ *
17
+ * This helper says nothing about whether the dotted name *resolves*
18
+ * to anything — that's the caller's job (consult the env / workspace
19
+ * / class registry). It only structurally extracts the dotted form. */
20
+ export declare function tryExtractDottedName(e: Expr): string | null;
21
+ /** Walk a `Member`-chain Expr down to its root Ident. Returns
22
+ * `{ root, fields }` (fields in outermost-to-innermost order) or
23
+ * null when the chain ends at anything other than a bare Ident.
24
+ *
25
+ * Shared by Member-rooted lvalue and index-base walkers so the
26
+ * same loop isn't repeated across the lowerer / interpreter. */
27
+ export declare function unwindMemberChain(e: Expr): {
28
+ root: Extract<Expr, {
29
+ type: "Ident";
30
+ }>;
31
+ fields: string[];
32
+ } | null;
33
+ /** LValue counterpart of `unwindMemberChain`: walk a `Member`
34
+ * LValue chain down to its root Ident, returning the root name and
35
+ * the full field path (including the outer Member's `name`). Returns
36
+ * null when the chain ends at anything other than a bare Ident.
37
+ *
38
+ * `LValue.Member` carries no span (unlike `Expr.Member`), so this
39
+ * helper takes the LValue shape directly. */
40
+ export declare function unwindMemberLvalue(lv: LValue): {
41
+ rootName: string;
42
+ fields: string[];
43
+ } | null;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Parser re-exports for mtoc2 consumers. The actual cross-import to
3
+ * the sibling numbl checkout lives in `src/numbl/index.ts` — this
4
+ * module is the historic stable path used by ~25 call sites and
5
+ * preserves their import shape unchanged.
6
+ *
7
+ * Structural AST drift is caught at `tsc` time; semantic drift is
8
+ * caught by the cross-runner. The pinned numbl SHA lives in
9
+ * `NUMBL_VERSION`, which CI checks out against.
10
+ */
11
+ export { parseMFile, SyntaxError, BinaryOperation, UnaryOperation, } from "../numbl/index.js";
12
+ export type { Span, Expr, Stmt, LValue, AbstractSyntaxTree, } from "../numbl/index.js";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Source location helpers used by the parser. Inlined from numbl's
3
+ * runtime/error.ts so the parser has no cross-module dependencies.
4
+ */
5
+ /** Compute 1-based line number from a character offset in source text. */
6
+ export declare function offsetToLine(source: string, offset: number): number;
7
+ /** Compute 1-based {line, column} from a character offset in source text.
8
+ * Column counts UTF-16 code units, which matches what Monaco expects. */
9
+ export declare function offsetToLineCol(source: string, offset: number): {
10
+ line: number;
11
+ column: number;
12
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Host bag passed to `Builtin.call` for the interpreter backend.
3
+ *
4
+ * Mirrors nexl's `RuntimeContext`. Side-effecty builtins (`disp`,
5
+ * `fprintf`, `error`, plot dispatch, …) consult `helpers.write` to
6
+ * emit text. Pure builtins ignore the bag.
7
+ *
8
+ * `write` is the JS analogue of C's `printf`. The CLI provides one
9
+ * backed by `process.stdout.write`; the browser provides one that
10
+ * pushes lines to the console panel; future test runners provide
11
+ * one that captures into a buffer for byte-for-byte comparison.
12
+ *
13
+ * As the interpreter grows, additional hooks (`time`, `plot`,
14
+ * `error`, …) will join this bag. Adding a hook here is the
15
+ * single source of truth — every host supplies it.
16
+ */
17
+ export interface RuntimeHelpers {
18
+ /** Append text to stdout. No implicit newline. */
19
+ write(s: string): void;
20
+ }
21
+ export interface RuntimeContext {
22
+ helpers: RuntimeHelpers;
23
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Map a runtime value back into a Type. Used by the interpreter to
3
+ * feed `argTypes` into a builtin's `transfer` (for validation) and
4
+ * `call` (for type-dispatched implementations) — so that the three
5
+ * hooks (`emitC`, `emitJs`, `call`) all branch on the same `argTypes`
6
+ * shape rather than reinventing dispatch per-backend.
7
+ */
8
+ import { type Type } from "../lowering/types.js";
9
+ import { type RuntimeValue } from "./value.js";
10
+ export declare function inferTypeFromValue(v: RuntimeValue): Type;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Runtime value carrier for the interpreter backend. Mirrors nexl's
3
+ * `RuntimeValue` design: a discriminated-via-typeof union for the
4
+ * common cases plus tagged-object wrappers for the kinds JS can't
5
+ * distinguish natively.
6
+ *
7
+ * MVP scope (Phase 3): real-double scalars, booleans (logical),
8
+ * strings (double-quoted), chars (single-quoted), real-double tensors.
9
+ * Complex / structs / classes / handles / void / cells follow as the
10
+ * type lattice and interpreter coverage expand.
11
+ *
12
+ * Builtin `call` implementations narrow via `typeof` / `isTensor` /
13
+ * `isChar` and dispatch through the same `argTypes` shape that
14
+ * `emitC` / `emitJs` consume — keeping the three backends parallel.
15
+ */
16
+ export type RuntimeValue = number | boolean | string | RuntimeTensor | RuntimeChar | RuntimeComplex | RuntimeStruct | RuntimeHandle;
17
+ /** Function handle. Named handles (`@foo`) keep the source name and
18
+ * dispatch via the interpreter's normal call-site resolution at the
19
+ * call point. Anonymous handles (`@(p1, ...) body`) capture every
20
+ * visible binding by value at the @-site and run `body` in a fresh
21
+ * env when invoked. */
22
+ export type RuntimeHandle = {
23
+ readonly mtoc2Handle: true;
24
+ readonly kind: "named";
25
+ readonly name: string;
26
+ } | {
27
+ readonly mtoc2Handle: true;
28
+ readonly kind: "anon";
29
+ readonly params: ReadonlyArray<string>;
30
+ readonly body: unknown;
31
+ readonly captures: Readonly<Record<string, RuntimeValue>>;
32
+ };
33
+ /** Narrow a RuntimeValue to a function handle. */
34
+ export declare function isHandleValue(v: RuntimeValue): v is RuntimeHandle;
35
+ /** Struct/object — plain JS object whose keys are field names. The
36
+ * c-aot path emits a typedef'd C struct; the JS path just uses a
37
+ * bare object. Recurses through field values that may themselves be
38
+ * any RuntimeValue (including nested structs). */
39
+ export type RuntimeStruct = {
40
+ readonly [field: string]: RuntimeValue;
41
+ };
42
+ /** Real or complex double tensor. `data` is the real lane,
43
+ * column-major to match numbl's `RuntimeTensor.data`. `imag` is the
44
+ * imaginary lane (same length and orientation as `data`); absent for
45
+ * real-only tensors. Mirrors the C representation's split-buffer
46
+ * layout — codegen / interpreter dispatch on `imag !== undefined`
47
+ * the way the C side dispatches on `imag != NULL`. The shape array
48
+ * is owned by the value; do not mutate.
49
+ *
50
+ * `isLogical` flags this tensor as the result of a logical operation
51
+ * (`~`, `<`, `==`, `&&`, …) so downstream index-slot resolution can
52
+ * treat it as a mask instead of an IndexVec — same role as numbl's
53
+ * `_isLogical` on its RuntimeTensor. The flag is one-way (once set,
54
+ * stays set across copies via the helper) and absent on numeric
55
+ * tensors; helper sites that don't care leave it undefined. */
56
+ export interface RuntimeTensor {
57
+ readonly mtoc2Tag: "tensor";
58
+ readonly shape: number[];
59
+ readonly data: Float64Array;
60
+ readonly imag?: Float64Array;
61
+ readonly isLogical?: boolean;
62
+ }
63
+ /** Single-quoted char-array (`'foo'`). Distinct from `"foo"` strings
64
+ * because numbl treats them differently: `length('foo') === 3` but
65
+ * `length("foo") === 1`. */
66
+ export interface RuntimeChar {
67
+ readonly mtoc2Tag: "char";
68
+ readonly value: string;
69
+ }
70
+ /** Scalar complex value — JS-side analogue of the `mtoc2_complex_t`
71
+ * struct in `cscalar.h`. The cscalar runtime helpers
72
+ * (`mtoc2_cmake`, `mtoc2_creal`, etc.) consume and produce this
73
+ * shape. We DON'T tag it the way tensor / char are tagged because
74
+ * emitJs literals (`{re: 0, im: 1}`) and runtime calls produce the
75
+ * bare object form — adding a tag would force every helper to
76
+ * re-wrap. Use `isComplexValue` for narrowing. */
77
+ export interface RuntimeComplex {
78
+ readonly re: number;
79
+ readonly im: number;
80
+ }
81
+ /** Narrow a RuntimeValue to a complex scalar. Matches the cscalar
82
+ * helpers' `{re, im}` shape. */
83
+ export declare function isComplexValue(v: RuntimeValue): v is RuntimeComplex;
84
+ export declare function makeTensor(shape: number[], data: Float64Array): RuntimeTensor;
85
+ /** Complex tensor with both lanes. `data` is the real lane, `imag`
86
+ * the imaginary lane; both must have the same length and match the
87
+ * product of `shape`. */
88
+ export declare function makeComplexTensor(shape: number[], data: Float64Array, imag: Float64Array): RuntimeTensor;
89
+ /** True iff this tensor carries an imaginary lane. */
90
+ export declare function isComplexTensor(v: RuntimeTensor): boolean;
91
+ export declare function makeChar(value: string): RuntimeChar;
92
+ export declare function isTensor(v: RuntimeValue): v is RuntimeTensor;
93
+ export declare function isChar(v: RuntimeValue): v is RuntimeChar;
94
+ /** Materialize a scalar value as a plain JS number. Used by builtins
95
+ * that need to treat scalar tensors and scalar numbers uniformly. */
96
+ export declare function toScalarNumber(v: RuntimeValue): number;
97
+ /** MATLAB-style truthiness — for `if` / `while` / `&&` / `||`.
98
+ * Scalar non-zero, all-elements-non-zero for tensors, nonempty
99
+ * text. The interpreter uses this; codegen relies on the matching
100
+ * C-side `__nonzero` helpers. */
101
+ export declare function isTruthy(v: RuntimeValue): boolean;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Driver-script prologue extractor.
3
+ *
4
+ * mtoc2 accepts `addpath(<literal>, ...)` only as a leading sequence
5
+ * of top-level statements in the driver script. Each call is parsed
6
+ * into a list of directory arguments (literal strings only) plus an
7
+ * optional trailing `-begin` / `-end` flag.
8
+ *
9
+ * Two call sites:
10
+ * - The CLI invokes the extractor before scanning the filesystem so
11
+ * it knows which directories to fold into the workspace search
12
+ * path.
13
+ * - `translateProject` / the interpreter run path invoke it purely
14
+ * to drop the prologue statements from the driver AST before
15
+ * lowering / execution begins. The dirs are ignored there.
16
+ *
17
+ * The two calls are idempotent: same input AST → same dirs and
18
+ * remaining body, so it doesn't matter that they parse twice.
19
+ *
20
+ * Any `addpath` left in the AST (anywhere outside the leading prefix)
21
+ * still hits the `addpath` builtin's `transfer`, which errors with a
22
+ * span-attributed message. `rmpath` / `savepath` are always rejected
23
+ * by their own `transfer` hooks; the extractor never accepts them.
24
+ *
25
+ * Function-file auto-invoke: a driver whose body (after the prologue)
26
+ * contains only function/classdef definitions and no top-level
27
+ * statements is a "function file" — running it means calling its
28
+ * first function with zero arguments. The extractor appends a
29
+ * synthesized 0-arg call so every execution path (interpreter,
30
+ * js-aot, c-aot) treats it the same way. Mirrors numbl's
31
+ * `Interpreter.run` (interpreter.ts).
32
+ */
33
+ import type { AbstractSyntaxTree, Stmt, Span } from "../parser/index.js";
34
+ export interface AddPathDir {
35
+ /** Directory string as the user wrote it. Relative paths are NOT
36
+ * resolved here; callers resolve against `process.cwd()`. */
37
+ dir: string;
38
+ /** Whether the directory inserts at the front of the addpath block
39
+ * (default / `-begin`) or after the CLI `--path` dirs at the end
40
+ * (`-end`). */
41
+ position: "begin" | "end";
42
+ /** Span of the originating `addpath(...)` call. */
43
+ span: Span;
44
+ }
45
+ export interface DriverPrologueOpts {
46
+ /** Set to `true` when a filesystem is available to resolve dirs
47
+ * against (CLI). When `false` or omitted (web IDE, in-memory
48
+ * translate, vitest), any leading `addpath` call is itself an
49
+ * `UnsupportedConstruct`. */
50
+ allowAddpath?: boolean;
51
+ }
52
+ export interface DriverPrologueResult {
53
+ addpaths: AddPathDir[];
54
+ /** Top-level statements after the prologue. Suitable for direct
55
+ * use with `Lowerer.lowerProgram` (via a shallow AST copy with
56
+ * this `body`) or `Interpreter.runProgram`. */
57
+ remainingBody: Stmt[];
58
+ }
59
+ export declare function extractDriverPrologue(ast: AbstractSyntaxTree, opts?: DriverPrologueOpts): DriverPrologueResult;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Loader for `.mtoc2.js` user functions.
3
+ *
4
+ * A `.mtoc2.js` file is plain JavaScript with no mtoc2 dependency.
5
+ * The loader evaluates it as a CommonJS-style module (`exports` and
6
+ * `module.exports` are the only injected names) and reads four
7
+ * exports to assemble a workspace-scoped `Builtin`:
8
+ *
9
+ * exports.name — string, must match the file's basename.
10
+ * exports.transfer — (argTypes, nargout) -> Type[]. Raw mtoc2 Type
11
+ * objects in, raw Type objects out. Throws
12
+ * `Error` on bad input.
13
+ * exports.emit — ({argsC, prefix, ...}) -> string. C expression
14
+ * for the call. Use `prefix` to name any private
15
+ * C helpers (kept collision-free across files).
16
+ * exports.cBody — ({prefix}) -> string. C source (helper
17
+ * function definitions) injected once per
18
+ * translation unit. Use the same `prefix` as
19
+ * `emit`.
20
+ * exports.cHeaders? — string[] of additional `#include` lines to
21
+ * activate (optional).
22
+ *
23
+ * Prefix shape: `mtoc2_user_<safe_funcname>__<8hex>__` where the hex
24
+ * is the FNV-1a hash of the workspace-relative file path. Including
25
+ * the path in the hash makes the prefix unique across all `.mtoc2.js`
26
+ * files in the workspace, even if two files happen to define
27
+ * functions with overlapping internal names.
28
+ */
29
+ import type { Builtin } from "../builtins/registry.js";
30
+ /** Resolved sibling file: the relative path (used by the build to
31
+ * pick a unique on-disk name) plus the file's text. */
32
+ export interface ResolvedCSource {
33
+ /** Path as written by the user in `exports.cSources` (e.g.
34
+ * `"impl.c"` or `"sub/helpers.h"`). */
35
+ relPath: string;
36
+ /** File text the build will write to disk. */
37
+ source: string;
38
+ }
39
+ /** Loader output: the assembled `Builtin` plus the user-supplied C
40
+ * sibling files the framework needs to thread through to the build
41
+ * pipeline. */
42
+ export interface LoadedUserFunction {
43
+ builtin: Builtin;
44
+ cSources: ResolvedCSource[];
45
+ }
46
+ /** Evaluate a `.mtoc2.js` file and return its assembled `Builtin`
47
+ * plus the user-supplied sibling C files (`cSources`).
48
+ *
49
+ * - `fileName` — the .mtoc2.js's full path (used for diagnostics and
50
+ * to resolve sibling paths).
51
+ * - `expectedName` — what numbl's workspace registered the file
52
+ * under (derived from the file's basename / package path); we
53
+ * validate the user's `exports.name` matches so a typo / rename
54
+ * surfaces here rather than at the first call site.
55
+ * - `relPath` — workspace-relative path used for the prefix hash.
56
+ * - `readSibling(p)` — given a path-key relative to the .mtoc2.js's
57
+ * directory, return the sibling file's source text. Used to pull
58
+ * `cSources` entries out of the workspace's file map (which is
59
+ * the same regardless of CLI vs web IDE). Returns `undefined` if
60
+ * the file is not in the workspace; the loader throws a clear
61
+ * error pointing at the missing path. */
62
+ export declare function loadMtoc2UserFunction(fileName: string, source: string, expectedName: string, relPath: string, readSibling: (siblingRelPath: string) => string | undefined): LoadedUserFunction;
@@ -0,0 +1,243 @@
1
+ /**
2
+ * Workspace + cross-file function dispatch.
3
+ *
4
+ * Thin adapter over numbl's vendored `LoweringContext` (see
5
+ * [../parser/index.ts](../parser/index.ts) for how mtoc2 imports
6
+ * numbl directly via sibling-relative paths). Numbl's
7
+ * `resolveFunction` is the source of truth for "which function does
8
+ * `foo(...)` refer to from this call site"; it implements MATLAB's
9
+ * precedence rules (local > workspace > builtin, plus class-method
10
+ * dispatch on `obj.method(args)` and `ClassName.method(args)`).
11
+ * mtoc2 translates the result back into its own narrow
12
+ * `ResolvedTarget` shape and fences off everything outside v1
13
+ * (private/, +pkg/ namespaces, .numbl.js, imports) with a clean
14
+ * `UnsupportedConstruct`.
15
+ *
16
+ * mtoc2's `MType → ItemType` adapter is intentionally lossy: the
17
+ * resolver inspects `kind === "ClassInstance"` (and only the
18
+ * `className` there); every other shape collapses to `Unknown`.
19
+ * That's all the resolver needs to apply class-method precedence.
20
+ */
21
+ import type { AbstractSyntaxTree, Stmt, Span } from "../parser/index.js";
22
+ import { LoweringContext, type CallSite, type ItemType } from "../numbl/index.js";
23
+ import { UnsupportedConstruct } from "../lowering/errors.js";
24
+ import type { Type } from "../lowering/types.js";
25
+ import { type ClassRegistration } from "../lowering/classDefs.js";
26
+ import type { Builtin } from "../builtins/registry.js";
27
+ type FuncStmt = Extract<Stmt, {
28
+ type: "Function";
29
+ }>;
30
+ type ClassDefStmt = Extract<Stmt, {
31
+ type: "ClassDef";
32
+ }>;
33
+ export interface WorkspaceFile {
34
+ /** Absolute (or web-IDE-flat) file name used in error attribution
35
+ * and in numbl's resolver. Numbl uses `fileToFuncName` to derive
36
+ * bare workspace-function names from this. */
37
+ name: string;
38
+ source: string;
39
+ /** Pre-parsed AST. Set by `Workspace.addFile`; callers populate
40
+ * it via `parseMFile` before registration. */
41
+ ast?: AbstractSyntaxTree;
42
+ }
43
+ /** Narrow shape mtoc2 cares about. The resolver may return additional
44
+ * kinds (private, JS user functions, ...) — those are fenced off
45
+ * here with `UnsupportedConstruct` so the diagnostic gets a span at
46
+ * the call site. */
47
+ export type ResolvedTarget = {
48
+ kind: "userFunction";
49
+ /** Source-level name (as written at the call site). */
50
+ name: string;
51
+ /** AST of the function definition. */
52
+ ast: FuncStmt;
53
+ /** Source file the function lives in. Used to salt
54
+ * specialization mangling so two files defining a subfunction
55
+ * with the same name get distinct C names. */
56
+ file: string;
57
+ } | {
58
+ /** Numbl says this name resolves to a builtin. mtoc2 still
59
+ * validates it against its own builtin registry. */
60
+ kind: "builtin";
61
+ name: string;
62
+ } | {
63
+ /** A `.mtoc2.js` user function discovered in the workspace.
64
+ * The evaluated `Builtin` lives in `Workspace.userBuiltins` —
65
+ * fetch via `getUserBuiltin(name)` for both lowering and
66
+ * codegen. The resolved-target carries the source-level name
67
+ * (which the lowerer also uses as the emitted C call name). */
68
+ kind: "mtoc2UserFunction";
69
+ name: string;
70
+ file: string;
71
+ } | {
72
+ /** `Foo(args)` — class constructor call. The class is looked
73
+ * up in `Workspace.classes`. */
74
+ kind: "classConstructor";
75
+ className: string;
76
+ } | {
77
+ /** Class method dispatch — covers `obj.method(args)`,
78
+ * `method(obj, args)`, and `ClassName.staticMethod(args)`. */
79
+ kind: "classMethod";
80
+ className: string;
81
+ methodName: string;
82
+ /** When true the receiver is NOT passed as a C arg (a static
83
+ * method called via `ClassName.method(args)` or via instance-
84
+ * style `obj.staticMethod(args)`). When false the receiver is
85
+ * the implicit first C arg. */
86
+ stripInstance: boolean;
87
+ };
88
+ export declare class Workspace {
89
+ /** File source + AST, keyed by file name. The AST cache is also
90
+ * mirrored into the vendored LoweringContext, but this side map
91
+ * keeps `source` retrievable for diagnostics
92
+ * (`offsetToLineCol`). */
93
+ readonly files: Map<string, WorkspaceFile>;
94
+ /** The entry file (active file) — bare-name calls from sibling
95
+ * files don't see its local functions. */
96
+ readonly mainFile: string;
97
+ /** Search paths used by the vendored resolver to compute relative
98
+ * paths (and hence workspace-function names). For the CLI,
99
+ * `[dirname(absoluteEntry)]`. For the web IDE (flat file names),
100
+ * empty — the resolver treats every name as already-relative. */
101
+ readonly searchPaths: ReadonlyArray<string>;
102
+ /** Numbl resolution context. Holds the workspace registry
103
+ * (`filesByFuncName`, `classesByName`, `localClassesByName`) and
104
+ * the `FunctionIndex` used by `resolveFunction`. Settable so the
105
+ * `fromExistingContext` JIT factory can replace the constructor-
106
+ * built default with a caller-owned context. */
107
+ ctx: LoweringContext;
108
+ /** Resolved class registry — populated by `finalize()` by walking
109
+ * every classdef numbl knows about (workspace + local) and
110
+ * applying mtoc2's validation/property-type inference. */
111
+ classes: Map<string, ClassRegistration>;
112
+ /** Classes that numbl knows about but mtoc2's `registerClassDef`
113
+ * rejected (e.g. inheritance, unsupported attributes). Only
114
+ * populated in `fromExistingContext` (JIT bridge) mode — the
115
+ * standalone path still fails finalize() on the first bad class.
116
+ *
117
+ * `isClass(name)` returns `true` for these so call-site dispatch
118
+ * doesn't get steered into a wrong code path (treating a class
119
+ * reference as a function call). `requireClass(name)` re-throws
120
+ * the saved `UnsupportedConstruct` at the actual use site, which
121
+ * the JIT bridge catches as a decline and falls back to the
122
+ * interpreter for that call. */
123
+ failedClassValidations: Map<string, UnsupportedConstruct>;
124
+ /** Workspace-scoped `Builtin` objects loaded from `.mtoc2.js` files.
125
+ * Keyed by source-level function name (matches numbl's
126
+ * `mtoc2UserFunctionsByName` keys). Populated lazily by `finalize`. */
127
+ private userBuiltins;
128
+ /** Sibling C/H files pulled in by `.mtoc2.js` user functions via
129
+ * `exports.cSources`. Each entry carries the originating
130
+ * `.mtoc2.js` function name (for namespacing in the build dir),
131
+ * the file's relative path (as the user wrote it), and the file
132
+ * text. Populated lazily by `finalize`; exposed via
133
+ * `getUserCSources()` for the build pipeline. */
134
+ private userCSources;
135
+ private finalized;
136
+ /** Set by `fromExistingContext` to indicate that `this.ctx` was
137
+ * populated by the caller (numbl's interpreter, in the JIT case)
138
+ * and re-registering its local functions / classes / workspace
139
+ * files in `finalize()` would duplicate work and possibly error.
140
+ * The mtoc2-side phases (class registry, `.mtoc2.js` loader) still
141
+ * run regardless — those are mtoc2-only bookkeeping. */
142
+ private skipCtxRegistration;
143
+ constructor(mainFile: string, searchPaths?: ReadonlyArray<string>);
144
+ /** Build a Workspace that wraps an existing `LoweringContext`. The
145
+ * caller's `ctx` must already have file ASTs cached, local
146
+ * functions and classes for the main file registered, workspace
147
+ * files registered, and the function index built — typically
148
+ * because a host runtime (e.g. numbl's interpreter) has been
149
+ * driving the same context. Mtoc2 still runs its own class-registry
150
+ * + `.mtoc2.js` loader bookkeeping on top.
151
+ *
152
+ * Used by the numbl JIT bridge so a single `LoweringContext` is
153
+ * shared between numbl's interpreter and mtoc2's JIT compile path
154
+ * per session. */
155
+ static fromExistingContext(ctx: LoweringContext, mainFile: string, files: Iterable<WorkspaceFile>): Workspace;
156
+ /** Register a file by name.
157
+ *
158
+ * - `.m` files require a pre-parsed `ast` (from `parseMFile`) so
159
+ * numbl's resolver and mtoc2's lowerer share one cached AST per
160
+ * file.
161
+ * - `.mtoc2.js` files carry source text only; the workspace passes
162
+ * the source to numbl's registry under the function's basename
163
+ * and (later) evaluates the JS via `loadMtoc2UserFunctions`. No
164
+ * AST is required. */
165
+ addFile(file: WorkspaceFile): void;
166
+ /** Build the function index + class registry. Call once after
167
+ * every file has been added. Subsequent calls are no-ops. */
168
+ finalize(): void;
169
+ /** Compute the workspace-relative path for `absPath`. Used to hash
170
+ * per-file C-namespace prefixes for `.mtoc2.js` user functions so
171
+ * the same hash falls out regardless of where the project lives
172
+ * on disk. Falls back to the bare basename when no search path
173
+ * contains the file (web IDE, ad-hoc absolute path outside the
174
+ * entry's directory). */
175
+ private workspaceRelativePath;
176
+ /** Look up an evaluated `.mtoc2.js` user function by source-level
177
+ * name. Returns `undefined` if no such workspace user function
178
+ * exists. Both the lowerer and codegen consult this — the former
179
+ * to call `transfer`, the latter to call `emit`. */
180
+ getUserBuiltin(name: string): Builtin | undefined;
181
+ /** Sibling C/H files supplied by `.mtoc2.js` user functions via
182
+ * `exports.cSources`. The build pipeline writes each file to a
183
+ * per-owner subdirectory under the build root and adds `-I` for
184
+ * that subdir; `.c` entries are compiled along with the main C,
185
+ * `.h` entries just sit in the include path. Each entry's
186
+ * `ownerHash` is the same FNV-1a hash that names the owner's
187
+ * C-symbol prefix, so per-user-function subdirs stay collision-
188
+ * free even if two files share a basename. */
189
+ getUserCSources(): ReadonlyArray<{
190
+ ownerFunc: string;
191
+ ownerHash: string;
192
+ relPath: string;
193
+ source: string;
194
+ }>;
195
+ /** Pull the primary Function AST from each `@ClassName/<methodName>.m`
196
+ * external method file that numbl registered for `info`. Any other
197
+ * top-level functions in the file are per-method-file local helpers
198
+ * (numbl scopes them via `withMethodScope`); mtoc2 surfaces them
199
+ * through the resolve path via `target.source.from === "classFile"`,
200
+ * so we don't need to collect them here — only the primary needs to
201
+ * join the class's method registry. Returns `undefined` when the
202
+ * class has no external methods. */
203
+ private collectExternalMethods;
204
+ private spanFromClassFile;
205
+ /** Is `name` a registered class (workspace or local)? Used by the
206
+ * lowerer to route `Foo(args)` to the constructor path and to
207
+ * detect `ClassName.staticMethod(args)` against an Ident base. */
208
+ isClass(name: string): boolean;
209
+ /** Like `classes.get(name)`, but re-throws the saved
210
+ * `UnsupportedConstruct` if the class was registered in
211
+ * `failedClassValidations` (JIT bridge mode). Use this at sites
212
+ * that would otherwise do `classes.get(name)!` and dereference
213
+ * `undefined`. */
214
+ requireClass(name: string): ClassRegistration | undefined;
215
+ /** Resolve a call site to a single target. Wraps numbl's
216
+ * `resolveFunction`, applies mtoc2-narrow validation, and routes
217
+ * classMethod verdicts (instance + static) through one shape. */
218
+ resolve(name: string, argTypes: ReadonlyArray<Type>, callSite: CallSite, span: Span): ResolvedTarget | null;
219
+ /** Look up the source text of a file by its name. Used by the
220
+ * lowerer's `printtype` directive to map a span offset to a
221
+ * line/column in the right file. */
222
+ sourceOf(file: string): string | undefined;
223
+ }
224
+ /** Pre-parse a list of source files into `WorkspaceFile`s.
225
+ *
226
+ * The `mainName` file's parse errors are propagated; for every other
227
+ * file, parse errors are reported via `onWarn` and the file is
228
+ * dropped from the result. This matches numbl, which warns and
229
+ * skips workspace siblings that fail to parse so that a single bad
230
+ * file in an `addpath`'d tree doesn't poison the whole run.
231
+ *
232
+ * Files ending in `.mtoc2.js` skip MATLAB parsing — they're plain
233
+ * JavaScript text that the workspace will hand to the mtoc2 user-
234
+ * function loader later. Their `ast` field stays undefined. */
235
+ export declare function parseFiles(files: ReadonlyArray<{
236
+ name: string;
237
+ source: string;
238
+ }>, mainName?: string, onWarn?: (msg: string) => void): WorkspaceFile[];
239
+ /** Adapter from mtoc2's `Type` to numbl's `ItemType`. The resolver
240
+ * only reads `kind === "ClassInstance"` and `className` from there;
241
+ * every other shape collapses to `Unknown`. */
242
+ export declare function mtypeToItemType(t: Type): ItemType;
243
+ export type { ClassDefStmt };