numbl 0.4.21 → 0.4.22

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 (281) hide show
  1. package/binding.gyp +12 -6
  2. package/dist-browser/browser/index.d.ts +1 -1
  3. package/dist-browser/browser/mip.d.ts +7 -0
  4. package/dist-browser/browser/protocol.d.ts +1 -1
  5. package/dist-browser/browser.js +1 -1
  6. package/dist-browser/db/operations.d.ts +0 -1
  7. package/dist-browser/gpuHelper.d.ts +29 -0
  8. package/dist-browser/hooks/projectFilesState.d.ts +37 -0
  9. package/dist-browser/numbl-core/execSession.d.ts +39 -0
  10. package/dist-browser/numbl-core/executeCode.d.ts +10 -1
  11. package/dist-browser/numbl-core/executors/classification.d.ts +2 -10
  12. package/dist-browser/numbl-core/executors/jit/backend.d.ts +65 -0
  13. package/dist-browser/numbl-core/executors/jit/cBackend.d.ts +22 -0
  14. package/dist-browser/numbl-core/executors/jit/callExecutor.d.ts +13 -44
  15. package/dist-browser/numbl-core/executors/jit/hostHelpers.d.ts +24 -0
  16. package/dist-browser/numbl-core/executors/jit/jsBackend.d.ts +15 -0
  17. package/dist-browser/numbl-core/executors/jit/loopExecutor.d.ts +13 -40
  18. package/dist-browser/numbl-core/executors/jit/session.d.ts +1 -1
  19. package/dist-browser/numbl-core/executors/jit/topLevelExecutor.d.ts +13 -33
  20. package/dist-browser/numbl-core/executors/jit/valueAdapterC.d.ts +32 -48
  21. package/dist-browser/numbl-core/executors/lowering.d.ts +38 -96
  22. package/dist-browser/numbl-core/executors/plugins.d.ts +14 -28
  23. package/dist-browser/numbl-core/executors/registry.d.ts +32 -133
  24. package/dist-browser/numbl-core/executors/types.d.ts +30 -92
  25. package/dist-browser/numbl-core/functionResolve.d.ts +3 -13
  26. package/dist-browser/numbl-core/helpers/check-helpers.d.ts +0 -5
  27. package/dist-browser/numbl-core/helpers/glob.d.ts +14 -0
  28. package/dist-browser/numbl-core/helpers/linsolve.d.ts +3 -13
  29. package/dist-browser/numbl-core/helpers/reduction-helpers.d.ts +2 -4
  30. package/dist-browser/numbl-core/helpers/shape-utils.d.ts +10 -0
  31. package/dist-browser/numbl-core/interpreter/builtins/index.d.ts +3 -1
  32. package/dist-browser/numbl-core/interpreter/builtins/time-system.d.ts +0 -1
  33. package/dist-browser/numbl-core/interpreter/builtins/types.d.ts +7 -7
  34. package/dist-browser/numbl-core/interpreter/interpreter.d.ts +6 -6
  35. package/dist-browser/numbl-core/interpreter/interpreterFunctions.d.ts +9 -1
  36. package/dist-browser/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +6 -3
  37. package/dist-browser/numbl-core/jit/builtins/defs/_shared.d.ts +1 -5
  38. package/dist-browser/numbl-core/jit/builtins/defs/arithmetic/_elemwise.d.ts +1 -2
  39. package/dist-browser/numbl-core/jit/builtins/defs/logical/_unary_pred.d.ts +3 -3
  40. package/dist-browser/numbl-core/jit/builtins/defs/logical/fieldnames.d.ts +1 -1
  41. package/dist-browser/numbl-core/jit/builtins/defs/logical/strcmp.d.ts +1 -1
  42. package/dist-browser/numbl-core/jit/builtins/defs/math/_unary_real.d.ts +5 -2
  43. package/dist-browser/numbl-core/jit/builtins/defs/math/realsqrt.d.ts +6 -0
  44. package/dist-browser/numbl-core/jit/builtins/defs/reduction/_shape.d.ts +0 -5
  45. package/dist-browser/numbl-core/jit/builtins/defs/shape/_construct.d.ts +0 -4
  46. package/dist-browser/numbl-core/jit/builtins/defs/shape/_triangular.d.ts +2 -8
  47. package/dist-browser/numbl-core/jit/builtins/defs/system/deal.d.ts +4 -5
  48. package/dist-browser/numbl-core/jit/builtins/defs/system/feval.d.ts +7 -29
  49. package/dist-browser/numbl-core/jit/builtins/registry.d.ts +15 -30
  50. package/dist-browser/numbl-core/jit/builtins/runtime/system/cdiv.d.ts +4 -0
  51. package/dist-browser/numbl-core/jit/builtins/runtime/system/cscalar.d.ts +4 -0
  52. package/dist-browser/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real_fn.d.ts +45 -15
  53. package/dist-browser/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_real.d.ts +5 -5
  54. package/dist-browser/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_real_math.d.ts +6 -0
  55. package/dist-browser/numbl-core/jit/codegen/emit.d.ts +9 -30
  56. package/dist-browser/numbl-core/jit/codegen/emitJs.d.ts +9 -27
  57. package/dist-browser/numbl-core/jit/codegen/emitStmt.d.ts +8 -31
  58. package/dist-browser/numbl-core/jit/codegen/emitTensorFused.d.ts +10 -9
  59. package/dist-browser/numbl-core/jit/codegen/inlinePass.d.ts +39 -48
  60. package/dist-browser/numbl-core/jit/codegen/prettyIR.d.ts +1 -6
  61. package/dist-browser/numbl-core/jit/codegen/runtime.d.ts +7 -28
  62. package/dist-browser/numbl-core/jit/compileSpec.d.ts +3 -6
  63. package/dist-browser/numbl-core/jit/compileSpecC.d.ts +5 -0
  64. package/dist-browser/numbl-core/jit/lowering/assignedFlags.d.ts +24 -0
  65. package/dist-browser/numbl-core/jit/lowering/definiteAssign.d.ts +3 -1
  66. package/dist-browser/numbl-core/jit/lowering/errors.d.ts +3 -15
  67. package/dist-browser/numbl-core/jit/lowering/ir.d.ts +0 -2
  68. package/dist-browser/numbl-core/jit/lowering/lower.d.ts +4 -12
  69. package/dist-browser/numbl-core/jit/lowering/types.d.ts +2 -7
  70. package/dist-browser/numbl-core/jit/numbl/index.d.ts +5 -14
  71. package/dist-browser/numbl-core/jit/parser/index.d.ts +4 -9
  72. package/dist-browser/numbl-core/jit/workspace/workspace.d.ts +32 -136
  73. package/dist-browser/numbl-core/jitDeclineDiagnostics.d.ts +1 -1
  74. package/dist-browser/numbl-core/jsUserFunctions.d.ts +10 -12
  75. package/dist-browser/numbl-core/lowering/classInfo.d.ts +4 -1
  76. package/dist-browser/numbl-core/lowering/loweringContext.d.ts +15 -23
  77. package/dist-browser/numbl-core/native/lapack-bridge.d.ts +111 -130
  78. package/dist-browser/numbl-core/native/ts-lapack-bridge.d.ts +4 -5
  79. package/dist-browser/numbl-core/native/ts-lapack-complex.d.ts +23 -0
  80. package/dist-browser/numbl-core/native/ts-lapack-qr-lu.d.ts +37 -0
  81. package/dist-browser/numbl-core/native/wasm-lapack-bridge.d.ts +4 -5
  82. package/dist-browser/numbl-core/ops/dispatch.d.ts +4 -5
  83. package/dist-browser/numbl-core/parser/types.d.ts +1 -21
  84. package/{dist-lib/numbl-core/runtime → dist-browser/numbl-core/plotting}/axisCommand.d.ts +2 -2
  85. package/dist-browser/{graphics → numbl-core/plotting}/axisLimits.d.ts +14 -2
  86. package/dist-browser/numbl-core/plotting/builtins.d.ts +8 -0
  87. package/dist-browser/numbl-core/plotting/colormaps.d.ts +10 -0
  88. package/dist-browser/numbl-core/{runtime/plotBuiltinDispatch.d.ts → plotting/dispatch.d.ts} +14 -25
  89. package/dist-browser/numbl-core/plotting/imagescExtent.d.ts +19 -0
  90. package/dist-browser/numbl-core/{runtime/runtimePlot.d.ts → plotting/instructions.d.ts} +5 -17
  91. package/dist-browser/numbl-core/plotting/parseArgsChart.d.ts +94 -0
  92. package/dist-browser/numbl-core/plotting/parseArgsCommon.d.ts +64 -0
  93. package/dist-browser/numbl-core/plotting/parseArgsLine.d.ts +103 -0
  94. package/dist-browser/numbl-core/plotting/parseArgsPatch.d.ts +38 -0
  95. package/dist-browser/numbl-core/plotting/parseArgsQuiver.d.ts +32 -0
  96. package/dist-browser/numbl-core/plotting/parseArgsSurface.d.ts +75 -0
  97. package/dist-browser/numbl-core/plotting/streamline.d.ts +16 -0
  98. package/{dist-graphics/graphics → dist-browser/numbl-core/plotting}/types.d.ts +9 -7
  99. package/dist-browser/numbl-core/runtime/cow.d.ts +0 -8
  100. package/dist-browser/numbl-core/runtime/refcount.d.ts +0 -3
  101. package/dist-browser/numbl-core/runtime/registerSpecial.d.ts +15 -0
  102. package/dist-browser/numbl-core/runtime/runtime.d.ts +11 -35
  103. package/dist-browser/numbl-core/runtime/runtimeDispatch.d.ts +6 -0
  104. package/dist-browser/numbl-core/runtime/specialBuiltins.d.ts +3 -9
  105. package/dist-browser/numbl-core/runtime/uihtmlSession.d.ts +5 -13
  106. package/dist-browser/numbl-core/runtime/utils.d.ts +4 -1
  107. package/dist-browser/numbl-core/version.d.ts +1 -1
  108. package/dist-browser/numbl-core/workspace/workspace.d.ts +64 -0
  109. package/dist-browser/vfs/syncVfsChanges.d.ts +2 -2
  110. package/dist-cli/cli.js +74244 -80566
  111. package/dist-graphics/graphics/FigureView.d.ts +1 -1
  112. package/dist-graphics/graphics/SurfView.d.ts +3 -2
  113. package/dist-graphics/graphics/drawPlot.d.ts +1 -1
  114. package/dist-graphics/graphics/exportFigureHdf5.d.ts +1 -1
  115. package/dist-graphics/graphics/figureHashTransport.d.ts +1 -1
  116. package/dist-graphics/graphics/figureUpload.d.ts +1 -1
  117. package/dist-graphics/graphics/importFigureHdf5.d.ts +1 -1
  118. package/dist-graphics/graphics/openInFigureViewer.d.ts +1 -1
  119. package/dist-graphics/graphics/plotHelpers.d.ts +1 -1
  120. package/dist-graphics/graphics/plotLegend.d.ts +1 -1
  121. package/dist-graphics/graphics/plotMarkers.d.ts +1 -1
  122. package/dist-graphics/graphics/restoreNaNs.d.ts +1 -1
  123. package/dist-graphics/graphics/uihtmlRelay.d.ts +16 -0
  124. package/dist-graphics/graphics-lib.d.ts +3 -3
  125. package/dist-graphics/index.js +294 -328
  126. package/{dist-lib/graphics → dist-graphics/numbl-core/plotting}/axisLimits.d.ts +14 -2
  127. package/dist-graphics/numbl-core/plotting/colormaps.d.ts +10 -0
  128. package/dist-graphics/numbl-core/plotting/imagescExtent.d.ts +19 -0
  129. package/{dist-browser/graphics → dist-graphics/numbl-core/plotting}/types.d.ts +9 -7
  130. package/dist-lib/browser/mip.d.ts +17 -0
  131. package/dist-lib/cli-scan.d.ts +8 -1
  132. package/dist-lib/lib.d.ts +1 -1
  133. package/dist-lib/lib.js +29201 -35301
  134. package/dist-lib/node.js +22 -14
  135. package/dist-lib/numbl-core/execSession.d.ts +39 -0
  136. package/dist-lib/numbl-core/executeCode.d.ts +10 -1
  137. package/dist-lib/numbl-core/executors/classification.d.ts +2 -10
  138. package/dist-lib/numbl-core/executors/jit/backend.d.ts +65 -0
  139. package/dist-lib/numbl-core/executors/jit/cBackend.d.ts +22 -0
  140. package/dist-lib/numbl-core/executors/jit/callExecutor.d.ts +13 -44
  141. package/dist-lib/numbl-core/executors/jit/hostHelpers.d.ts +24 -0
  142. package/dist-lib/numbl-core/executors/jit/jsBackend.d.ts +15 -0
  143. package/dist-lib/numbl-core/executors/jit/loopExecutor.d.ts +13 -40
  144. package/dist-lib/numbl-core/executors/jit/session.d.ts +1 -1
  145. package/dist-lib/numbl-core/executors/jit/topLevelExecutor.d.ts +13 -33
  146. package/dist-lib/numbl-core/executors/jit/valueAdapterC.d.ts +32 -48
  147. package/dist-lib/numbl-core/executors/lowering.d.ts +38 -96
  148. package/dist-lib/numbl-core/executors/plugins.d.ts +14 -28
  149. package/dist-lib/numbl-core/executors/registry.d.ts +32 -133
  150. package/dist-lib/numbl-core/executors/types.d.ts +30 -92
  151. package/dist-lib/numbl-core/functionResolve.d.ts +3 -13
  152. package/dist-lib/numbl-core/helpers/check-helpers.d.ts +0 -5
  153. package/dist-lib/numbl-core/helpers/glob.d.ts +14 -0
  154. package/dist-lib/numbl-core/helpers/linsolve.d.ts +3 -13
  155. package/dist-lib/numbl-core/helpers/reduction-helpers.d.ts +2 -4
  156. package/dist-lib/numbl-core/helpers/shape-utils.d.ts +10 -0
  157. package/dist-lib/numbl-core/interpreter/builtins/index.d.ts +3 -1
  158. package/dist-lib/numbl-core/interpreter/builtins/time-system.d.ts +0 -1
  159. package/dist-lib/numbl-core/interpreter/builtins/types.d.ts +7 -7
  160. package/dist-lib/numbl-core/interpreter/interpreter.d.ts +6 -6
  161. package/dist-lib/numbl-core/interpreter/interpreterFunctions.d.ts +9 -1
  162. package/dist-lib/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +6 -3
  163. package/dist-lib/numbl-core/jit/builtins/defs/_shared.d.ts +1 -5
  164. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/_elemwise.d.ts +1 -2
  165. package/dist-lib/numbl-core/jit/builtins/defs/logical/_unary_pred.d.ts +3 -3
  166. package/dist-lib/numbl-core/jit/builtins/defs/logical/fieldnames.d.ts +1 -1
  167. package/dist-lib/numbl-core/jit/builtins/defs/logical/strcmp.d.ts +1 -1
  168. package/dist-lib/numbl-core/jit/builtins/defs/math/_unary_real.d.ts +5 -2
  169. package/dist-lib/numbl-core/jit/builtins/defs/math/realsqrt.d.ts +6 -0
  170. package/dist-lib/numbl-core/jit/builtins/defs/reduction/_shape.d.ts +0 -5
  171. package/dist-lib/numbl-core/jit/builtins/defs/shape/_construct.d.ts +0 -4
  172. package/dist-lib/numbl-core/jit/builtins/defs/shape/_triangular.d.ts +2 -8
  173. package/dist-lib/numbl-core/jit/builtins/defs/system/deal.d.ts +4 -5
  174. package/dist-lib/numbl-core/jit/builtins/defs/system/feval.d.ts +7 -29
  175. package/dist-lib/numbl-core/jit/builtins/registry.d.ts +15 -30
  176. package/dist-lib/numbl-core/jit/builtins/runtime/system/cdiv.d.ts +4 -0
  177. package/dist-lib/numbl-core/jit/builtins/runtime/system/cscalar.d.ts +4 -0
  178. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real_fn.d.ts +45 -15
  179. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_real.d.ts +5 -5
  180. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_real_math.d.ts +6 -0
  181. package/dist-lib/numbl-core/jit/codegen/emit.d.ts +9 -30
  182. package/dist-lib/numbl-core/jit/codegen/emitJs.d.ts +9 -27
  183. package/dist-lib/numbl-core/jit/codegen/emitStmt.d.ts +8 -31
  184. package/dist-lib/numbl-core/jit/codegen/emitTensorFused.d.ts +10 -9
  185. package/dist-lib/numbl-core/jit/codegen/inlinePass.d.ts +39 -48
  186. package/dist-lib/numbl-core/jit/codegen/prettyIR.d.ts +1 -6
  187. package/dist-lib/numbl-core/jit/codegen/runtime.d.ts +7 -28
  188. package/dist-lib/numbl-core/jit/compileSpec.d.ts +3 -6
  189. package/dist-lib/numbl-core/jit/compileSpecC.d.ts +5 -0
  190. package/dist-lib/numbl-core/jit/lowering/assignedFlags.d.ts +24 -0
  191. package/dist-lib/numbl-core/jit/lowering/definiteAssign.d.ts +3 -1
  192. package/dist-lib/numbl-core/jit/lowering/errors.d.ts +3 -15
  193. package/dist-lib/numbl-core/jit/lowering/ir.d.ts +0 -2
  194. package/dist-lib/numbl-core/jit/lowering/lower.d.ts +4 -12
  195. package/dist-lib/numbl-core/jit/lowering/types.d.ts +2 -7
  196. package/dist-lib/numbl-core/jit/numbl/index.d.ts +5 -14
  197. package/dist-lib/numbl-core/jit/parser/index.d.ts +4 -9
  198. package/dist-lib/numbl-core/jit/workspace/workspace.d.ts +32 -136
  199. package/dist-lib/numbl-core/jitDeclineDiagnostics.d.ts +1 -1
  200. package/dist-lib/numbl-core/jsUserFunctions.d.ts +10 -12
  201. package/dist-lib/numbl-core/lowering/classInfo.d.ts +4 -1
  202. package/dist-lib/numbl-core/lowering/loweringContext.d.ts +15 -23
  203. package/dist-lib/numbl-core/native/lapack-bridge.d.ts +111 -130
  204. package/dist-lib/numbl-core/native/ts-lapack-bridge.d.ts +4 -5
  205. package/dist-lib/numbl-core/native/ts-lapack-complex.d.ts +23 -0
  206. package/dist-lib/numbl-core/native/ts-lapack-qr-lu.d.ts +37 -0
  207. package/dist-lib/numbl-core/native/wasm-lapack-bridge.d.ts +4 -5
  208. package/dist-lib/numbl-core/ops/dispatch.d.ts +4 -5
  209. package/dist-lib/numbl-core/parser/types.d.ts +1 -21
  210. package/{dist-browser/numbl-core/runtime → dist-lib/numbl-core/plotting}/axisCommand.d.ts +2 -2
  211. package/{dist-graphics/graphics → dist-lib/numbl-core/plotting}/axisLimits.d.ts +14 -2
  212. package/dist-lib/numbl-core/plotting/builtins.d.ts +8 -0
  213. package/dist-lib/numbl-core/plotting/colormaps.d.ts +10 -0
  214. package/dist-lib/numbl-core/{runtime/plotBuiltinDispatch.d.ts → plotting/dispatch.d.ts} +14 -25
  215. package/dist-lib/numbl-core/plotting/imagescExtent.d.ts +19 -0
  216. package/dist-lib/numbl-core/{runtime/runtimePlot.d.ts → plotting/instructions.d.ts} +5 -17
  217. package/dist-lib/numbl-core/plotting/parseArgsChart.d.ts +94 -0
  218. package/dist-lib/numbl-core/plotting/parseArgsCommon.d.ts +64 -0
  219. package/dist-lib/numbl-core/plotting/parseArgsLine.d.ts +103 -0
  220. package/dist-lib/numbl-core/plotting/parseArgsPatch.d.ts +38 -0
  221. package/dist-lib/numbl-core/plotting/parseArgsQuiver.d.ts +32 -0
  222. package/dist-lib/numbl-core/plotting/parseArgsSurface.d.ts +75 -0
  223. package/dist-lib/numbl-core/plotting/streamline.d.ts +16 -0
  224. package/dist-lib/{graphics → numbl-core/plotting}/types.d.ts +9 -7
  225. package/dist-lib/numbl-core/runtime/cow.d.ts +0 -8
  226. package/dist-lib/numbl-core/runtime/refcount.d.ts +0 -3
  227. package/dist-lib/numbl-core/runtime/registerSpecial.d.ts +15 -0
  228. package/dist-lib/numbl-core/runtime/runtime.d.ts +11 -35
  229. package/dist-lib/numbl-core/runtime/runtimeDispatch.d.ts +6 -0
  230. package/dist-lib/numbl-core/runtime/specialBuiltins.d.ts +3 -9
  231. package/dist-lib/numbl-core/runtime/uihtmlSession.d.ts +5 -13
  232. package/dist-lib/numbl-core/runtime/utils.d.ts +4 -1
  233. package/dist-lib/numbl-core/version.d.ts +1 -1
  234. package/dist-lib/numbl-core/workspace/workspace.d.ts +64 -0
  235. package/dist-lib/vfs/unzipToFiles.d.ts +7 -0
  236. package/dist-plot-viewer/assets/index-C0fIevlp.js +4504 -0
  237. package/dist-plot-viewer/index.html +1 -1
  238. package/dist-site-viewer/assets/index-BDaviCH6.js +4832 -0
  239. package/dist-site-viewer/assets/numbl-worker-D6m4K2PP.js +5691 -0
  240. package/dist-site-viewer/index.html +2 -2
  241. package/native/numbl_addon.cpp +2 -12
  242. package/native/numbl_addon_common.h +0 -5
  243. package/package.json +6 -5
  244. package/dist-browser/hooks/useProjectFiles.d.ts +0 -45
  245. package/dist-browser/numbl-core/executors/context.d.ts +0 -76
  246. package/dist-browser/numbl-core/executors/index.d.ts +0 -14
  247. package/dist-browser/numbl-core/executors/jit/cJitCallExecutor.d.ts +0 -35
  248. package/dist-browser/numbl-core/executors/jit/cJitLoopExecutor.d.ts +0 -31
  249. package/dist-browser/numbl-core/executors/jit/cJitTopLevelExecutor.d.ts +0 -29
  250. package/dist-browser/numbl-core/helpers/dummy.d.ts +0 -5
  251. package/dist-browser/numbl-core/jit/runtime/context.d.ts +0 -23
  252. package/dist-browser/numbl-core/jit/runtime/inferType.d.ts +0 -10
  253. package/dist-browser/numbl-core/jit/runtime/value.d.ts +0 -101
  254. package/dist-browser/numbl-core/jit/workspace/driverPrologue.d.ts +0 -59
  255. package/dist-browser/numbl-core/jit/workspace/mtoc2UserFunctionLoader.d.ts +0 -62
  256. package/dist-browser/numbl-core/native/bridge-resolve.d.ts +0 -14
  257. package/dist-browser/numbl-core/runtime/plotUtils.d.ts +0 -336
  258. package/dist-browser/numbl-core/runtime/specialBuiltinNames.d.ts +0 -2
  259. package/dist-graphics/graphics/surfColormap.d.ts +0 -2
  260. package/dist-lib/numbl-core/executors/context.d.ts +0 -76
  261. package/dist-lib/numbl-core/executors/index.d.ts +0 -14
  262. package/dist-lib/numbl-core/executors/jit/cJitCallExecutor.d.ts +0 -35
  263. package/dist-lib/numbl-core/executors/jit/cJitLoopExecutor.d.ts +0 -31
  264. package/dist-lib/numbl-core/executors/jit/cJitTopLevelExecutor.d.ts +0 -29
  265. package/dist-lib/numbl-core/helpers/dummy.d.ts +0 -5
  266. package/dist-lib/numbl-core/jit/runtime/context.d.ts +0 -23
  267. package/dist-lib/numbl-core/jit/runtime/inferType.d.ts +0 -10
  268. package/dist-lib/numbl-core/jit/runtime/value.d.ts +0 -101
  269. package/dist-lib/numbl-core/jit/workspace/driverPrologue.d.ts +0 -59
  270. package/dist-lib/numbl-core/jit/workspace/mtoc2UserFunctionLoader.d.ts +0 -62
  271. package/dist-lib/numbl-core/native/bridge-resolve.d.ts +0 -14
  272. package/dist-lib/numbl-core/runtime/plotUtils.d.ts +0 -336
  273. package/dist-lib/numbl-core/runtime/specialBuiltinNames.d.ts +0 -2
  274. package/dist-plot-viewer/assets/index-YeXWXIxH.js +0 -4504
  275. package/dist-site-viewer/assets/index-DrtkDG_M.js +0 -4832
  276. package/dist-site-viewer/assets/numbl-worker-Dz_Z8B9u.js +0 -5327
  277. package/native/elemwise.cpp +0 -360
  278. package/native/unary_elemwise.cpp +0 -67
  279. /package/dist-browser/{graphics → numbl-core/plotting}/figuresReducer.d.ts +0 -0
  280. /package/dist-graphics/{graphics → numbl-core/plotting}/figuresReducer.d.ts +0 -0
  281. /package/dist-lib/{graphics → numbl-core/plotting}/figuresReducer.d.ts +0 -0
@@ -1,120 +1,62 @@
1
1
  /**
2
2
  * Shared lowering pipeline.
3
3
  *
4
- * The dispatcher calls `tryLower` once per stmt-dispatch and
5
- * `tryLowerCall` per function-call dispatch, before any executor is
6
- * asked to propose. The result — a `LoweredStmt` — is passed to every
7
- * executor's `propose()` as the first argument. `tryLower` returns
8
- * `null` for stmts with no specialized lowering shape; the dispatcher
9
- * falls through to its hardcoded `interp.execStmt` path in that case.
4
+ * The registry lowers each unit once, before any executor is asked to
5
+ * propose, and passes the resulting `LoweredStmt` to every executor
6
+ * registered for that shape:
10
7
  *
11
- * Lowering here is *classification only*: it analyses inputs/outputs,
12
- * infers types, and synthesizes a cacheKey. It does NOT make
13
- * codegen-feasibility decisions — those live in the codegen executor's
14
- * `propose`. This keeps the dispatcher free of dependencies on the
15
- * JIT backend's internals (the in-tree compiler under
16
- * `src/numbl-core/jit`).
17
- *
18
- * Shapes today:
19
- * - `top-level` — script body (top-level scope). Whole script
20
- * analysed as a synthetic FunctionDef.
21
- * - `call` — user-function call. Produced by `tryLowerCall`
22
- * from `dispatchCall`.
23
- * - `synth` — a `Synth` AST stmt produced by a registered AST
24
- * transformer (no further analysis here).
8
+ * - `top-level` — a script body (`tryLowerTopLevel`), analysed as a
9
+ * synthetic FunctionDef.
10
+ * - `loop` — a For/While stmt (`tryLowerLoop`).
11
+ * - `call` — a user-function call (`tryLowerCall`).
25
12
  *
26
- * Lowerings are cached by (head Stmt or FunctionDef, classification
27
- * cacheKey).
13
+ * Lowering here is *classification only*: it analyses inputs/outputs,
14
+ * infers types, and synthesizes a cacheKey. Codegen-feasibility decisions
15
+ * live in each executor's `propose`, which keeps this layer free of
16
+ * dependencies on the JIT compiler (`src/numbl-core/jit`).
28
17
  */
29
18
  import type { Stmt } from "../parser/types.js";
30
19
  import type { FunctionDef } from "../interpreter/types.js";
31
20
  import type { Interpreter } from "../interpreter/interpreter.js";
21
+ import type { JitType } from "../jitTypes.js";
32
22
  import { type TopLevelClassification, type CallClassification, type LoopClassification } from "./classification.js";
33
- /** What `propose()` receives — a discriminated union of the
34
- * specialized shapes the dispatcher knows how to lower. Stmts with
35
- * no specialized shape don't reach `propose()` at all; the dispatcher
36
- * falls through to its hardcoded interpreter path. */
37
- export type LoweredStmt = TopLevelLoweredStmt | LoopLoweredStmt | CallLoweredStmt | SynthLoweredStmt;
38
- /** Top-level shape: script body analysed for whole-scope codegen. */
23
+ /** What `propose()` receives — a discriminated union of the shapes the
24
+ * registry knows how to lower. */
25
+ export type LoweredStmt = TopLevelLoweredStmt | LoopLoweredStmt | CallLoweredStmt;
39
26
  export interface TopLevelLoweredStmt {
40
27
  readonly kind: "top-level";
41
28
  readonly classification: TopLevelClassification;
42
29
  }
43
- /** Loop shape: a single For/While stmt analysed for loop codegen.
44
- * Produced by `tryLower` when the head stmt is a For/While. */
45
30
  export interface LoopLoweredStmt {
46
31
  readonly kind: "loop";
47
32
  readonly classification: LoopClassification;
48
33
  }
49
- /** Call shape: a user-function call analysed for call codegen.
50
- * Produced by `tryLowerCall`, not `tryLower` — function calls fire
51
- * from expression evaluation, not from the stmt loop. */
52
34
  export interface CallLoweredStmt {
53
35
  readonly kind: "call";
54
36
  readonly classification: CallClassification;
55
- /** Runtime arg values. Carried alongside the classification
56
- * because the executor needs them at runCall time; unlike
57
- * stmt-shape executors, the call executor can't re-fetch them
58
- * from env. */
37
+ /** Runtime arg values. Unlike the env-reading shapes, a call executor
38
+ * cannot re-fetch its inputs from the env. */
59
39
  readonly args: readonly unknown[];
60
40
  }
61
- /** Synth shape: a `Synth` AST stmt produced by a registered AST
62
- * transformer. The matching executor reads `data` (analysis the
63
- * transformer pre-computed) and the `tag` discriminates among
64
- * multiple registered transformers. */
65
- export interface SynthLoweredStmt {
66
- readonly kind: "synth";
67
- readonly tag: string;
68
- readonly data: unknown;
41
+ /** Per-owner type-widening state: the most recent input type signature
42
+ * seen for (owner, slot), where owner is the head Stmt (top-level, loop)
43
+ * or the FunctionDef (call). Classification widens against it so a unit
44
+ * invoked with shifting input types converges to a single specialization
45
+ * rather than thrashing the compile cache. The slot lets one owner host
46
+ * several trackers (one per nargout for calls). WeakMap-scoped so entries
47
+ * are reclaimed when the AST is dropped. */
48
+ export declare class WideningState {
49
+ private readonly last;
50
+ get(owner: object, slot: string): JitType[] | undefined;
51
+ set(owner: object, slot: string, types: readonly JitType[]): void;
69
52
  }
70
- declare const BAILED: unique symbol;
71
- type Bailed = typeof BAILED;
72
- /** Per-owner lowering cache. Owner is either the head Stmt
73
- * (stmt-shape lowerings) or the FunctionDef (call-shape lowerings).
74
- * WeakMap-scoped so entries are reclaimed when the AST is dropped.
75
- *
76
- * Also tracks per-owner type-widening state: the most recent input
77
- * type signature seen for a given (owner, slot). Classify phases
78
- * consult this so a callee invoked with shifting input types
79
- * converges to a single specialization rather than thrashing the
80
- * cache. The slot string lets one owner host multiple widening
81
- * trackers (e.g. one per nargout for call-shape). */
82
- export declare class LoweringCache {
83
- private readonly slots;
84
- private readonly widening;
85
- get(owner: object, cacheKey: string): LoweredStmt | Bailed | undefined;
86
- set(owner: object, cacheKey: string, value: LoweredStmt): void;
87
- markBailed(owner: object, cacheKey: string): void;
88
- isBailed(value: unknown): value is Bailed;
89
- /** Most recent input-type signature recorded for (owner, slot), or
90
- * undefined when nothing has been recorded yet. */
91
- getLastInputTypes(owner: object, slot: string): import("../jitTypes.js").JitType[] | undefined;
92
- /** Record the latest unified input-type signature for (owner, slot). */
93
- setLastInputTypes(owner: object, slot: string, types: readonly import("../jitTypes.js").JitType[]): void;
94
- }
95
- /**
96
- * Try to lower the stmt at `siblings[i]`. Returns a `LoweredStmt` for
97
- * stmts that match a specialized shape, or `null` for stmts with no
98
- * shape — the dispatcher falls through to its hardcoded interpreter
99
- * path in that case.
100
- *
101
- * Whole-scope shapes (`top-level`) are NOT produced here — they're
102
- * lowered separately via `tryLowerTopLevel` and dispatched through
103
- * `Registry.tryRunWholeScope` before the per-stmt loop runs.
104
- */
105
- export declare function tryLower(siblings: readonly Stmt[], i: number, interp: Interpreter, cache: LoweringCache): LoweredStmt | null;
106
- /**
107
- * Lower a script body as a whole-scope unit. Called by the registry
108
- * before the per-stmt dispatch loop runs; returns a TopLevelLoweredStmt
109
- * for whole-scope executors to consider, or null when the classification
110
- * declines.
111
- */
112
- export declare function tryLowerTopLevel(interp: Interpreter, siblings: readonly Stmt[], cache: LoweringCache): TopLevelLoweredStmt | null;
113
- /**
114
- * Try to lower a user-function call. Always returns a
115
- * `CallLoweredStmt` when classification succeeds; null when the
116
- * classify declines (`~` params, type-unknown args, varargin
117
- * arity mismatch).
118
- */
119
- export declare function tryLowerCall(fn: FunctionDef, args: unknown[], nargout: number, cache: LoweringCache): CallLoweredStmt | null;
120
- export {};
53
+ /** Lower a For/While stmt at `siblings[i]`. Classification needs the
54
+ * post-loop tail of the sibling list (to filter outputs) and the env
55
+ * (for input types). Null when classification declines. */
56
+ export declare function tryLowerLoop(interp: Interpreter, siblings: readonly Stmt[], i: number, widening: WideningState): LoopLoweredStmt | null;
57
+ /** Lower a script body as a whole-scope unit. Null when classification
58
+ * declines. */
59
+ export declare function tryLowerTopLevel(interp: Interpreter, siblings: readonly Stmt[], widening: WideningState): TopLevelLoweredStmt | null;
60
+ /** Lower a user-function call. Null when classification declines (`~`
61
+ * params, type-unknown args, varargin arity mismatch). */
62
+ export declare function tryLowerCall(fn: FunctionDef, args: unknown[], nargout: number, widening: WideningState): CallLoweredStmt | null;
@@ -1,39 +1,25 @@
1
1
  /**
2
2
  * Mode-driven executor registration.
3
3
  *
4
- * `registerExecutorsForOpt(registry, opt)` is the single switch from
5
- * an `--opt` value to a set of registered executors. Adding a new
6
- * mode means extending the switch here — no other call-site changes.
7
- *
8
- * The AST interpreter is the dispatcher's hardcoded last-resort
9
- * fallback (see `Registry.dispatch`); it doesn't need to be a
10
- * registered executor.
4
+ * `registerExecutorsForOpt(registry, opt)` is the single switch from an
5
+ * `--opt` value to a set of registered executors. Each JIT backend
6
+ * contributes one executor per shape (top-level, loop, call); the
7
+ * registry tries them in registration order. The AST interpreter is the
8
+ * registry's last-resort fallback and isn't registered.
11
9
  */
12
10
  import type { Registry } from "./registry.js";
13
- import type { Executor } from "./types.js";
14
- /** The three C-JIT executors, registered at Node bootstrap. */
15
- export interface CJitExecutors {
16
- topLevel: Executor;
17
- loop: Executor;
18
- call: Executor;
19
- }
20
- /** Register the C-JIT executors. Called once at Node bootstrap. */
21
- export declare function registerCJitExecutors(execs: CJitExecutors): void;
11
+ import type { JitBackend } from "./jit/backend.js";
12
+ /** Register the C backend. Called once at Node bootstrap. */
13
+ export declare function registerCJitBackend(backend: JitBackend): void;
22
14
  /** Optimization mode label.
23
15
  *
24
16
  * - `"0"` — pure AST interpreter, no executors registered.
25
- * - `"1"` — JS-JIT: all three shapes (top-level, loop,
26
- * call) emit JS via `compileSpec`. JIT declines
27
- * (`UnsupportedConstruct` / `JitTypeError`) fall back to the
28
- * interpreter cleanly.
29
- * - `"2"` — C-JIT-first with JS-JIT fallback. Both backends
30
- * register their executors; the dispatcher picks based on cost,
31
- * so the C path wins where it applies (scalar / tensor numeric
32
- * types with a wired `nativeBridge`) and the JS path picks up
33
- * the slack (struct / class / handle / no-cc-available).
34
- * Requires `cc` on the PATH and `koffi` installed; without
35
- * either, the C executors decline and `"2"` collapses to the
36
- * same behaviour as `"1"`. */
17
+ * - `"1"` — JS-JIT for all three shapes.
18
+ * - `"2"` — C-JIT first, JS-JIT as fallback, per shape. C-JIT takes
19
+ * what it can marshal (scalar / tensor numeric types with a wired
20
+ * `nativeBridge`); JS-JIT picks up the rest (struct / class / handle).
21
+ * Without `cc` + `koffi` the C executors decline and `"2"` behaves
22
+ * like `"1"`. */
37
23
  export type OptLevel = "0" | "1" | "2";
38
24
  export declare const OPT_LEVELS: readonly OptLevel[];
39
25
  export declare function isOptLevel(s: string): s is OptLevel;
@@ -1,115 +1,41 @@
1
1
  /**
2
2
  * Executor registry and dispatch.
3
3
  *
4
- * Three entry points, three concerns:
5
- * - `dispatch(siblings, i, ctx)` — per-stmt dispatch. Each executor
6
- * handles exactly one stmt (no consumed-N).
4
+ * Three entry points, one per lowered shape:
5
+ * - `tryRunWholeScope(siblings, interp)` — whole-script attempt, called
6
+ * once before the per-stmt loop runs.
7
+ * - `dispatch(siblings, i, interp)` — per-stmt dispatch; loops are
8
+ * offered to the loop executors, everything else is interpreted.
7
9
  * - `dispatchCall(fn, args, nargout, interp)` — user-function call.
8
- * - `tryRunWholeScope(siblings, interp)` — whole-script attempt,
9
- * called once before the per-stmt loop runs. Top-level executors
10
- * register here separately from per-stmt ones.
11
10
  *
12
- * Plugins register executors at startup; the dispatcher selects among
13
- * them at runtime based on cost estimates. The AST interpreter is the
14
- * always-matching last-resort fallback for per-stmt dispatch and isn't
15
- * a registered executor.
11
+ * Executors are tried in registration order (at `--opt 2`: C-JIT, then
12
+ * JS-JIT). The first that proposes and runs without bailing wins. The AST
13
+ * interpreter is the last-resort fallback and isn't a registered executor.
16
14
  */
17
15
  import type { Stmt } from "../parser/types.js";
18
16
  import type { ControlSignal, FunctionDef } from "../interpreter/types.js";
19
- import type { Executor } from "./types.js";
20
- import { DispatchContext } from "./context.js";
21
- /** AST stmt-list transformer. Receives a stmt list and returns a
22
- * list of the same semantics, possibly with `Synth` stmts inserted
23
- * where the transformer can collapse a contiguous run of stmts into
24
- * a unit handled by a specialized executor. The transform is
25
- * shallow — recursive descent into For/While/If bodies happens
26
- * lazily on the next call to `transformStmts`, cached separately. */
27
- export type StmtTransformer = (stmts: readonly Stmt[]) => Stmt[];
28
- export interface DispatchResult {
29
- /** Control signal from interpreter execution (break/continue/return),
30
- * if any. */
31
- signal: ControlSignal | null;
32
- }
33
- /** Result from `dispatchCall`. `null` means no executor handled the
34
- * call — the caller should fall through to its own
35
- * interpreter-execution path. */
36
- export type CallDispatchResult = {
37
- result: unknown;
38
- } | null;
39
- /** Result from `tryRunWholeScope`. `null` means no whole-scope
40
- * executor matched (or all bailed) — the caller should fall through
41
- * to the per-stmt dispatch loop. */
42
- export type WholeScopeResult = {
43
- signal: ControlSignal | null;
44
- } | null;
17
+ import type { Interpreter } from "../interpreter/interpreter.js";
18
+ import type { Executor, RunResult, ShapeKind } from "./types.js";
45
19
  export declare class Registry {
46
- /** Per-stmt executors (loop, call, fuse). */
47
20
  private readonly executors;
48
- /** Whole-scope executors (top-level). Iterated only by
49
- * `tryRunWholeScope`, separate from per-stmt dispatch. */
50
- private readonly wholeScopeExecutors;
51
- /** AST stmt-list transformers. Run lazily on each stmt list before
52
- * the per-stmt loop walks it; result cached per input list. */
53
- private readonly transformers;
54
- /** Memoize transformed lists by input list identity. WeakMap so
55
- * entries vanish when the AST is dropped. The transformed list
56
- * is also stored mapped to itself so a second call with the
57
- * result hits the cache (idempotency). */
58
- private transformCache;
59
21
  private cache;
60
- private loweringCache;
61
- /** Pre-allocated context reused for `dispatchCall`. Avoids the
62
- * per-call Map+Set allocation cost that previously motivated
63
- * bypassing ctx entirely on call-heavy workloads. Safe to reuse
64
- * because dispatchCall isn't reentrant within itself: each call's
65
- * propose/compile/run touches the context synchronously, and any
66
- * nested call dispatch goes through `Interpreter.callUserFunction`
67
- * which re-enters dispatchCall and re-resets the context. */
68
- private callCtx;
69
- register(executor: Executor): void;
70
- /** Register an executor that handles a whole stmt list as a unit
71
- * (e.g. JS-JIT top-level). Iterated only by `tryRunWholeScope`
72
- * and never seen by per-stmt dispatch. */
73
- registerWholeScope(executor: Executor): void;
74
- /** Register an AST stmt-list transformer. Transformers run on every
75
- * stmt list the interpreter is about to walk (script body, function
76
- * body, loop body, if branch, ...) before the per-stmt loop kicks
77
- * in. They typically wrap contiguous runs of stmts in `Synth`
78
- * nodes that a matching executor will recognize. Adding new
79
- * transformers is additive — they compose in registration order. */
80
- registerStmtTransformer(fn: StmtTransformer): void;
81
- /** Transform a stmt list, applying all registered transformers in
82
- * registration order. Cached per input-list identity (WeakMap).
83
- * When no transformers are registered, returns the input unchanged
84
- * without populating the cache (saves a Map lookup per dispatch). */
85
- transformStmts(stmts: readonly Stmt[]): Stmt[];
86
- /** Number of registered per-stmt executors. Mainly for tests. */
87
- get size(): number;
22
+ private widening;
23
+ /** Register an executor for its shape. Order matters: earlier
24
+ * executors are tried first. */
25
+ register<K extends ShapeKind>(executor: Executor<K>): void;
26
+ /** Whether any call executor is registered. */
27
+ get hasCallExecutors(): boolean;
88
28
  /** Drop all cached compiled artifacts. Called from
89
29
  * `Interpreter.clearAllCaches()` after addpath/rmpath etc. */
90
30
  clearCache(): void;
91
- /**
92
- * Dispatch one statement at `siblings[i]`. Each executor handles
93
- * exactly one stmt — the dispatcher always advances by one on
94
- * success.
95
- *
96
- * Hot path. Two optimizations matter for the chunkie-helmholtz-
97
- * scale workloads:
98
- *
99
- * 1. The AST interpreter is the always-applicable last-resort
100
- * fallback. It is *not* a registered executor — the dispatcher
101
- * hardcodes a direct call to `ctx.interp.execStmt(stmt)` when
102
- * no specialized executor matches or all of them bail. This
103
- * avoids per-dispatch match/Candidate/cache/result allocations
104
- * for the most common path (where only the interpreter would
105
- * fit anyway).
106
- *
107
- * 2. The reentrancy guard (`pushActive`/`popActive` /
108
- * `isActive`) is short-circuited when the active set is
109
- * empty — no sub-dispatch in flight means the bookkeeping is
110
- * pure overhead.
111
- */
112
- dispatch(siblings: readonly Stmt[], i: number, ctx: DispatchContext): DispatchResult;
31
+ /** Try to handle the entire script body as a unit. Returns false when
32
+ * no executor took it; the caller then runs the per-stmt loop. */
33
+ tryRunWholeScope(siblings: readonly Stmt[], interp: Interpreter): boolean;
34
+ /** Dispatch the stmt at `siblings[i]`. Returns its control signal. */
35
+ dispatch(siblings: readonly Stmt[], i: number, interp: Interpreter): ControlSignal | null;
36
+ /** Dispatch a user-function call. Returns `{ result }` when an executor
37
+ * handled it, or `null` so the caller runs the interpreter's call path. */
38
+ dispatchCall(fn: FunctionDef, args: unknown[], nargout: number, interp: Interpreter): RunResult;
113
39
  /** Run one stmt on the AST interpreter.
114
40
  *
115
41
  * When that stmt is a loop, the interpreter is about to walk its body,
@@ -118,39 +44,12 @@ export declare class Registry {
118
44
  * that for the duration of the body so nested loops and calls can bid for
119
45
  * themselves instead of running interpreted all the way down. */
120
46
  private interpretFallback;
121
- private runStmtCandidate;
122
- /** Cache lookup + compile-on-miss + run + bail handling. Returns
123
- * the executor's success RunResult, or null when the candidate
124
- * bailed (cache may have been marked BAILED). When `guardKey` is
125
- * non-null, the reentrancy guard pushes/pops around `run()` —
126
- * passed by the stmt path; the call path passes null because
127
- * `dispatchCall` isn't reentrant within itself. */
128
- private executeCandidate;
129
- /**
130
- * Dispatch a user-function call. Iterates the same `executors`
131
- * array as stmt dispatch — call-shape executors filter on
132
- * `lowered.kind === "call"`. Returns `{ result }` when one of them
133
- * handles the call, or `null` so the caller (callUserFunction)
134
- * falls through to the AST interpreter.
135
- *
136
- * Reuses a pre-allocated DispatchContext (`callCtx`) to avoid the
137
- * per-call Map+Set allocation that previously motivated bypassing
138
- * ctx for call dispatch entirely.
139
- */
140
- dispatchCall(fn: FunctionDef, args: unknown[], nargout: number, interp: import("../interpreter/interpreter.js").Interpreter): CallDispatchResult;
141
- private runCallCandidate;
142
- private getCallCtx;
143
- /**
144
- * Whole-scope dispatch: try to handle the entire stmt list as a
145
- * single unit (e.g. JS-JIT top-level). Called by the Interpreter
146
- * once before the per-stmt loop runs. Returns:
147
- * - `{ signal }` when a whole-scope executor handled the body.
148
- * The caller should skip the per-stmt loop entirely.
149
- * - `null` when no whole-scope executor matched (or all bailed).
150
- * The caller falls through to per-stmt dispatch.
151
- */
152
- tryRunWholeScope(siblings: readonly Stmt[], interp: import("../interpreter/interpreter.js").Interpreter): WholeScopeResult;
153
- private finishWholeScope;
47
+ /** Try `executors` in order; return the first success, or null when
48
+ * all declined or bailed. `owner` scopes the compile cache (head Stmt
49
+ * or FunctionDef). */
50
+ private runFirst;
51
+ /** Cache lookup + compile-on-miss + run. A bail (including a compile
52
+ * that declined, which the executor reports as a bail from `run`) is
53
+ * cached so the same (executor, owner, key) is not retried. */
54
+ private execute;
154
55
  }
155
- /** Build a fresh dispatch context. */
156
- export declare function makeRootContext(interp: import("../interpreter/interpreter.js").Interpreter, registry: Registry): DispatchContext;
@@ -3,101 +3,39 @@
3
3
  *
4
4
  * See docs/developer_reference/executors.md for the design overview.
5
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().
6
+ * The interpreter delegates whole-script bodies, loops, and user-function
7
+ * calls to a registry of Executors. Each executor handles one lowered shape
8
+ * (`top-level`, `loop`, or `call`). The registry tries the executors
9
+ * registered for a shape in order; the first that proposes and runs
10
+ * without bailing wins, and the AST interpreter handles the rest.
13
11
  */
14
- import type { DispatchContext } from "./context.js";
12
+ import type { Interpreter } from "../interpreter/interpreter.js";
15
13
  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
- | {
14
+ export type ShapeKind = LoweredStmt["kind"];
15
+ export type LoweredOf<K extends ShapeKind> = Extract<LoweredStmt, {
16
+ kind: K;
17
+ }>;
18
+ /** Outcome of `run`. `{ result }` on success (the call's return value
19
+ * for the `call` shape; `undefined` otherwise). `null` is a bail: the
20
+ * registry discards any captured output, caches the bail, and tries
21
+ * the next executor (or the interpreter). */
22
+ export type RunResult = {
46
23
  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. */
24
+ } | null;
25
+ export interface Executor<K extends ShapeKind = ShapeKind, D = unknown, C = unknown> {
26
+ /** Stable identifier for diagnostics and the compile cache. */
73
27
  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. */
28
+ /** The lowered shape this executor handles. */
29
+ readonly kind: K;
30
+ /** Decide whether to take this unit. Runs on every dispatch, so it
31
+ * must be cheap. Returns per-executor data passed to `compile` and
32
+ * `run`, or null to decline. */
33
+ propose(lowered: LoweredOf<K>, interp: Interpreter): D | null;
34
+ /** Stable cache key projected from the proposal data. Drops volatile
35
+ * bits (e.g. exact scalar values) so repeated runs reuse artifacts. */
95
36
  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;
37
+ /** Compile to a runnable artifact. Called only on cache miss; cached
38
+ * under (executor, owner, cacheKey). */
39
+ compile(data: D, interp: Interpreter): C;
40
+ run(compiled: C, data: D, interp: Interpreter): RunResult;
103
41
  }
@@ -11,12 +11,10 @@ export type ResolvedTarget = {
11
11
  kind: "classMethod";
12
12
  className: string;
13
13
  methodName: string;
14
- compileArgTypes: ItemType[];
15
14
  stripInstance: boolean;
16
15
  } | {
17
16
  kind: "localFunction";
18
17
  name: string;
19
- argTypes: ItemType[];
20
18
  source: {
21
19
  from: "main";
22
20
  } | {
@@ -33,31 +31,23 @@ export type ResolvedTarget = {
33
31
  } | {
34
32
  kind: "privateFunction";
35
33
  name: string;
36
- argTypes: ItemType[];
37
34
  callerFile: string;
38
35
  } | {
39
36
  kind: "workspaceFunction";
40
37
  name: string;
41
- argTypes: ItemType[];
42
38
  } | {
43
39
  kind: "jsUserFunction";
44
40
  name: string;
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[];
53
41
  } | {
54
42
  kind: "workspaceClassConstructor";
55
43
  className: string;
56
- argTypes: ItemType[];
57
44
  } | {
58
45
  kind: "builtin";
59
46
  name: string;
60
47
  };
48
+ /** The argument type that resolution needs: only an object's class affects
49
+ * which function a name resolves to. */
50
+ export declare function resolutionArgType(v: unknown): ItemType;
61
51
  /**
62
52
  * Definitively resolve a function name to a single target using the FunctionIndex.
63
53
  * Returns null only if the function is truly not found.
@@ -37,11 +37,6 @@ export declare function maybeComplexTensor(re: Float64Array | Float64Array, shap
37
37
  * Optionally includes an imaginary diagonal.
38
38
  */
39
39
  export declare function buildDiagMatrix(realVals: Float64Array | Float64Array, imagVals: Float64Array | Float64Array | undefined, size: number | [number, number]): ReturnType<typeof RTV.tensor>;
40
- /**
41
- * In-place Gauss-Jordan elimination with partial pivoting on a column-major
42
- * augmented matrix [A | B] of size `rows × totalCols`.
43
- */
44
- export declare function gaussJordanEliminate(aug: Float64Array, rows: number, totalCols: number): void;
45
40
  /**
46
41
  * Call a registered builtin from within another builtin's apply().
47
42
  * Convenience wrapper that includes the caller name in error messages.
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Compile a wildcard pattern to an anchored RegExp.
3
+ *
4
+ * Default (single name): `*` matches any run of characters and `?` any one
5
+ * character, as in `dir('*.m')`, `delete('*.txt')` or `who('a*')`.
6
+ *
7
+ * `paths: true` matches slash-separated paths: `*` and `?` stay within one
8
+ * segment, `**` matches anything, and `**` followed by `/` matches zero or
9
+ * more directory levels (so a double-star prefix before `x.m` also matches a
10
+ * top-level `x.m`).
11
+ */
12
+ export declare function globToRegExp(pattern: string, opts?: {
13
+ paths?: boolean;
14
+ }): RegExp;