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
@@ -13,77 +13,97 @@ export function mtoc2_tensor_atan2_st(s: any, a: any): {
13
13
  shape: any;
14
14
  data: any;
15
15
  };
16
- export function mtoc2_tensor_atan2_bcast_tt(a: any, b: any): {
16
+ export function mtoc2_tensor_hypot_tt(a: any, b: any): {
17
17
  mtoc2Tag: string;
18
18
  shape: any;
19
19
  data: any;
20
20
  };
21
- export function mtoc2_tensor_hypot_tt(a: any, b: any): {
21
+ export function mtoc2_tensor_hypot_ts(a: any, s: any): {
22
22
  mtoc2Tag: string;
23
23
  shape: any;
24
24
  data: any;
25
25
  };
26
- export function mtoc2_tensor_hypot_ts(a: any, s: any): {
26
+ export function mtoc2_tensor_power_tt(a: any, b: any): {
27
27
  mtoc2Tag: string;
28
28
  shape: any;
29
29
  data: any;
30
30
  };
31
- export function mtoc2_tensor_hypot_bcast_tt(a: any, b: any): {
31
+ export function mtoc2_tensor_power_ts(a: any, s: any): {
32
32
  mtoc2Tag: string;
33
33
  shape: any;
34
34
  data: any;
35
35
  };
36
- export function mtoc2_tensor_power_tt(a: any, b: any): {
36
+ export function mtoc2_tensor_power_st(s: any, a: any): {
37
37
  mtoc2Tag: string;
38
38
  shape: any;
39
39
  data: any;
40
40
  };
41
- export function mtoc2_tensor_power_ts(a: any, s: any): {
41
+ export function mtoc2_tensor_rem_tt(a: any, b: any): {
42
42
  mtoc2Tag: string;
43
43
  shape: any;
44
44
  data: any;
45
45
  };
46
- export function mtoc2_tensor_power_st(s: any, a: any): {
46
+ export function mtoc2_tensor_rem_ts(a: any, s: any): {
47
47
  mtoc2Tag: string;
48
48
  shape: any;
49
49
  data: any;
50
50
  };
51
- export function mtoc2_tensor_power_bcast_tt(a: any, b: any): {
51
+ export function mtoc2_tensor_rem_st(s: any, a: any): {
52
52
  mtoc2Tag: string;
53
53
  shape: any;
54
54
  data: any;
55
55
  };
56
- export function mtoc2_tensor_rem_tt(a: any, b: any): {
56
+ export function mtoc2_tensor_mod_tt(a: any, b: any): {
57
57
  mtoc2Tag: string;
58
58
  shape: any;
59
59
  data: any;
60
60
  };
61
- export function mtoc2_tensor_rem_ts(a: any, s: any): {
61
+ export function mtoc2_tensor_mod_ts(a: any, s: any): {
62
62
  mtoc2Tag: string;
63
63
  shape: any;
64
64
  data: any;
65
65
  };
66
- export function mtoc2_tensor_rem_st(s: any, a: any): {
66
+ export function mtoc2_tensor_mod_st(s: any, a: any): {
67
67
  mtoc2Tag: string;
68
68
  shape: any;
69
69
  data: any;
70
70
  };
71
- export function mtoc2_tensor_rem_bcast_tt(a: any, b: any): {
71
+ export function mtoc2_tensor_max_tt(a: any, b: any): {
72
72
  mtoc2Tag: string;
73
73
  shape: any;
74
74
  data: any;
75
75
  };
76
- export function mtoc2_tensor_mod_tt(a: any, b: any): {
76
+ export function mtoc2_tensor_max_ts(a: any, s: any): {
77
77
  mtoc2Tag: string;
78
78
  shape: any;
79
79
  data: any;
80
80
  };
81
- export function mtoc2_tensor_mod_ts(a: any, s: any): {
81
+ export function mtoc2_tensor_min_tt(a: any, b: any): {
82
82
  mtoc2Tag: string;
83
83
  shape: any;
84
84
  data: any;
85
85
  };
86
- export function mtoc2_tensor_mod_st(s: any, a: any): {
86
+ export function mtoc2_tensor_min_ts(a: any, s: any): {
87
+ mtoc2Tag: string;
88
+ shape: any;
89
+ data: any;
90
+ };
91
+ export function mtoc2_tensor_atan2_bcast_tt(a: any, b: any): {
92
+ mtoc2Tag: string;
93
+ shape: any;
94
+ data: any;
95
+ };
96
+ export function mtoc2_tensor_hypot_bcast_tt(a: any, b: any): {
97
+ mtoc2Tag: string;
98
+ shape: any;
99
+ data: any;
100
+ };
101
+ export function mtoc2_tensor_power_bcast_tt(a: any, b: any): {
102
+ mtoc2Tag: string;
103
+ shape: any;
104
+ data: any;
105
+ };
106
+ export function mtoc2_tensor_rem_bcast_tt(a: any, b: any): {
87
107
  mtoc2Tag: string;
88
108
  shape: any;
89
109
  data: any;
@@ -93,3 +113,13 @@ export function mtoc2_tensor_mod_bcast_tt(a: any, b: any): {
93
113
  shape: any;
94
114
  data: any;
95
115
  };
116
+ export function mtoc2_tensor_max_bcast_tt(a: any, b: any): {
117
+ mtoc2Tag: string;
118
+ shape: any;
119
+ data: any;
120
+ };
121
+ export function mtoc2_tensor_min_bcast_tt(a: any, b: any): {
122
+ mtoc2Tag: string;
123
+ shape: any;
124
+ data: any;
125
+ };
@@ -1,28 +1,28 @@
1
- export function mtoc2_sum_all(t: any): any;
1
+ export function mtoc2_sum_all(t: any): number;
2
2
  export function mtoc2_sum_dim(t: any, d: any): {
3
3
  mtoc2Tag: string;
4
4
  shape: any;
5
5
  data: any;
6
6
  };
7
- export function mtoc2_prod_all(t: any): any;
7
+ export function mtoc2_prod_all(t: any): number;
8
8
  export function mtoc2_prod_dim(t: any, d: any): {
9
9
  mtoc2Tag: string;
10
10
  shape: any;
11
11
  data: any;
12
12
  };
13
- export function mtoc2_mean_all(t: any): any;
13
+ export function mtoc2_mean_all(t: any): number;
14
14
  export function mtoc2_mean_dim(t: any, d: any): {
15
15
  mtoc2Tag: string;
16
16
  shape: any;
17
17
  data: any;
18
18
  };
19
- export function mtoc2_min_all(t: any): number;
19
+ export function mtoc2_min_all(t: any): any;
20
20
  export function mtoc2_min_dim(t: any, d: any): {
21
21
  mtoc2Tag: string;
22
22
  shape: any;
23
23
  data: any;
24
24
  };
25
- export function mtoc2_max_all(t: any): number;
25
+ export function mtoc2_max_all(t: any): any;
26
26
  export function mtoc2_max_dim(t: any, d: any): {
27
27
  mtoc2Tag: string;
28
28
  shape: any;
@@ -1,3 +1,4 @@
1
+ export function mtoc2_realsqrt(x: any): number;
1
2
  export function mtoc2_tensor_cos(a: any): {
2
3
  mtoc2Tag: string;
3
4
  shape: any;
@@ -63,6 +64,11 @@ export function mtoc2_tensor_sqrt(a: any): {
63
64
  shape: any;
64
65
  data: any;
65
66
  };
67
+ export function mtoc2_tensor_realsqrt(a: any): {
68
+ mtoc2Tag: string;
69
+ shape: any;
70
+ data: any;
71
+ };
66
72
  export function mtoc2_tensor_abs(a: any): {
67
73
  mtoc2Tag: string;
68
74
  shape: any;
@@ -1,9 +1,9 @@
1
1
  /**
2
- * Single-file C codegen for mtoc2 IR. Emits:
2
+ * Single-file C codegen for JIT IR. Emits a shared-library module:
3
3
  * 1. Standard headers + activated runtime snippets (in dep order).
4
4
  * 2. Forward declarations for user-function specializations.
5
- * 3. Function specialization bodies.
6
- * 4. `main()` containing top-level statements.
5
+ * 3. Function specialization bodies; the entry spec gets extern
6
+ * linkage so the host can `dlsym` it.
7
7
  *
8
8
  * Scalars compile to bare `double`. Multi-element tensors compile to
9
9
  * `mtoc2_tensor_t` — no refcount, no COW. The codegen invariant
@@ -14,39 +14,18 @@
14
14
  * later distinction uniform (the assign helper releases the prior
15
15
  * buffer, which is NULL on first call). Scope-exit emits a
16
16
  * `mtoc2_tensor_free` for every owned local.
17
- *
18
- * `includeRuntime` (default true): when false, the activated runtime
19
- * helpers are omitted from the output (a placeholder comment is shown
20
- * instead) so the IDE's "runtime helpers" toggle can show user-level
21
- * code in isolation. The emitted C is not compilable in that mode —
22
- * it's a viewing aid.
23
17
  */
24
18
  import type { IRProgram } from "../lowering/ir.js";
25
19
  import { type Type } from "../lowering/types.js";
26
20
  import { type RuntimeState } from "./runtime.js";
27
21
  export interface EmitOptions {
28
- /** Include the activated runtime helper bodies in the output.
29
- * Default true. When false, headers + a placeholder stub replace
30
- * them so the user sees only their generated code. */
31
- includeRuntime?: boolean;
32
- /** Max-threads OpenMP setting. See `TranslateOptions.threads`. */
33
- threads?: number | "auto";
34
- /** Workspace context. Threaded through `RuntimeState` so emit-time
35
- * builtin lookups consult `.mtoc2.js` user builtins via
36
- * `getUserBuiltin`. Optional — vitest unit tests that don't drive
37
- * through a workspace can omit it. */
38
- workspace?: import("./runtime.js").WorkspaceLike;
39
- /** JIT-mode emit. When set, the cName of a single user-function spec
40
- * to expose at module scope (no `static` qualifier so `dlsym` /
41
- * koffi can resolve it after `dlopen`). Disables the `int main()`
42
- * emission — the module becomes a `.so` consumers load and call
43
- * into directly. Requires `prog.topLevelStmts` to be empty and
44
- * `prog.functions` to contain the named spec; every spec
45
- * transitively called by the entry must also be in
46
- * `prog.functions` so internal calls resolve. */
47
- exposeSpec?: string;
22
+ /** cName of the entry spec to expose at module scope (no `static`
23
+ * qualifier so `dlsym` / koffi can resolve it after `dlopen`).
24
+ * `prog.functions` must contain it and every spec it transitively
25
+ * calls. */
26
+ exposeSpec: string;
48
27
  }
49
- export declare function emitProgram(prog: IRProgram, opts?: EmitOptions): string;
28
+ export declare function emitProgram(prog: IRProgram, opts: EmitOptions): string;
50
29
  export declare function activateOwnedRuntime(t: Type, state: RuntimeState): void;
51
30
  /** Activate the runtime snippets needed for an owned type AND return
52
31
  * its OwnedHelpers descriptor. Shorthand for the
@@ -22,43 +22,25 @@
22
22
  * <inlined runtime snippet bodies>
23
23
  * function <user-fn-spec-1>(...) { ... }
24
24
  * function <user-fn-spec-2>(...) { ... }
25
- * function run($h) {
26
- * globalThis.$write = $h.write;
27
- * let v1, v2, ...; // pre-declared locals
28
- * ... top-level stmts ...
29
- * }
30
- * return run;
25
+ * return function ($h) { globalThis.$write = $h.write; ...; return <entry-spec>; };
31
26
  * ```
32
27
  *
33
- * The CLI / engine evals the source via `new Function(source)(...)`
34
- * which returns `run`, then invokes `run(ctx.helpers)`.
28
+ * The host evals the source via `new Function(source)()`, then calls
29
+ * the returned factory with its helper hooks to get the entry spec.
35
30
  */
36
31
  import type { IRProgram } from "../lowering/ir.js";
37
- import { type WorkspaceLike } from "./runtime.js";
38
32
  export interface EmitJsOptions {
39
- /** Workspace context. Threaded through `RuntimeState` so emit-time
40
- * builtin lookups consult `.mtoc2.js` user builtins. Optional. */
41
- workspace?: WorkspaceLike;
42
- /** Include the activated runtime helper bodies inline at the top of
43
- * the emitted module. Default true. When false the placeholder
44
- * comment lands instead — useful for the IDE preview. */
45
- includeRuntime?: boolean;
46
- /** JIT-mode emit. When set, the cName of a single user-function spec
47
- * to expose: the outer module returns a `($h) => specFn` factory
48
- * instead of the script-style `function run($h)` wrapper. Requires
49
- * `prog.topLevelStmts` to be empty and `prog.functions` to contain
50
- * the named spec (which must be reachable along with any specs it
51
- * transitively calls). Used by the numbl JIT bridge. */
52
- exposeSpec?: string;
33
+ /** cName of the entry spec the module's factory returns.
34
+ * `prog.functions` must contain it and every spec it transitively
35
+ * calls. */
36
+ exposeSpec: string;
53
37
  }
54
38
  export interface EmitJsResult {
55
39
  /** Full module source — runtime snippets, user-function defs, and
56
- * either `function run($h)` + `return run;` (script mode) or
57
- * `return ($h) => specFn;` (when `opts.exposeSpec` is set). Ready
58
- * for `new Function(...)`. */
40
+ * `return ($h) => specFn;`. Ready for `new Function(...)`. */
59
41
  source: string;
60
42
  /** Names of every runtime snippet activated during emit (debug aid;
61
43
  * also useful to gate dependency wiring in tests). */
62
44
  activatedSnippets: ReadonlyArray<string>;
63
45
  }
64
- export declare function emitJsProgram(prog: IRProgram, opts?: EmitJsOptions): EmitJsResult;
46
+ export declare function emitJsProgram(prog: IRProgram, opts: EmitJsOptions): EmitJsResult;
@@ -11,47 +11,23 @@ import type { IRExpr, IRFunc, IRStmt } from "../lowering/ir.js";
11
11
  import { type Type } from "../lowering/types.js";
12
12
  import { type RuntimeState } from "./runtime.js";
13
13
  import { type FutureTouchMap } from "./liveness.js";
14
- /** Default initializer for a freshly-declared non-owned local. Owned
15
- * types (tensors, structs, classes, handles) route through their
16
- * `_empty()` helper instead and never hit this path; everything
17
- * reaching here is scalar real numeric, so `0.0` always fits. */
18
- export declare function defaultInitFor(): string;
19
14
  export declare function fnRetType(fn: IRFunc): string;
20
15
  export declare function fnParamList(fn: IRFunc): string;
21
- /** Walk `stmts` once and split the result into owned vs non-owned
22
- * locals. Every local is pre-declared at function top — owned with
23
- * the per-type `_empty()` helper, scalars with the default init
24
- * (`0.0` / `0`). The non-owned half also picks up For loop vars and
25
- * multi-assign slot bindings so that a later read of a variable
26
- * first written inside an If / While / For body (reachable via
27
- * `mergeBranchEnvs` keeping partial-branch keys) doesn't reference
28
- * an out-of-scope C local. */
29
- export declare function collectLocals(stmts: IRStmt[]): {
30
- owned: {
31
- cName: string;
32
- ty: Type;
33
- }[];
34
- scalars: {
35
- cName: string;
36
- ty: Type;
37
- }[];
38
- };
39
16
  /** Emits the function/scope's exit cleanup + return statements at a
40
17
  * given indent. Called from two places: at every `ReturnFromFunction`
41
18
  * site (inline cleanup — no goto), and at the fall-through bottom of
42
19
  * the function. Single source of truth so the two callers can't
43
20
  * drift on which locals get freed in what order.
44
21
  *
45
- * Why inline rather than goto-to-a-shared-tail: c2js can't translate
46
- * C `goto`, and we want a single C emit that works for both targets.
47
- * Inlining produces some duplication when a function has many early
48
- * returns and many owned locals, but typical mtoc2 functions are
49
- * small and the C compiler dedupes-by-tail-merge anyway. */
50
- export type EmitReturnTail = (indent: string) => string;
22
+ * Inlined rather than goto-to-a-shared-tail, which keeps the C emit
23
+ * parallel to the JS one. Inlining produces some duplication when a
24
+ * function has many early returns and many owned locals, but typical
25
+ * functions are small and the C compiler dedupes-by-tail-merge
26
+ * anyway. */
27
+ type EmitReturnTail = (indent: string) => string;
51
28
  export declare function emitFunction(fn: IRFunc, state: RuntimeState,
52
29
  /** Storage-class qualifier on the function definition. Default is
53
- * `static` (file-scope, the C-AOT whole-program convention). Pass
54
- * `""` to omit the qualifier — the function then gets external
30
+ * `static` (file-scope). Pass `""` to omit the qualifier — the function then gets external
55
31
  * linkage so a JIT host can resolve it via `dlsym` / koffi after
56
32
  * `dlopen`'ing the compiled `.so`. */
57
33
  storageClass?: "static" | ""): string;
@@ -74,3 +50,4 @@ export declare function cellLinearOffsetExpr(indices: ReadonlyArray<IRExpr>, bas
74
50
  export declare function tryStaticCellOffset(indices: ReadonlyArray<IRExpr>, baseTy: Extract<Type, {
75
51
  kind: "Cell";
76
52
  }>): number | null;
53
+ export {};
@@ -23,15 +23,16 @@
23
23
  * For a single-Binary RHS this is equivalent (post-`-O3`) to the
24
24
  * existing `mtoc2_tensor_assign(&c, mtoc2_tensor_plus_tt(a, b))`
25
25
  * path — the helper's body is literally the same loop. The point of
26
- * doing the inlining at the IR level is that the `--inline-temps`
27
- * pass (phase 2) can fold a chain like `_t1 = a * b; c = _t1 + d`
28
- * into `c = (a * b) + d`, which the fused emitter then renders as
29
- * one loop with no intermediate tensor allocation.
26
+ * doing the inlining at the IR level is that an IR-to-IR pass
27
+ * (`inlinePass.ts`, run by `compileSpecC` before emit)
28
+ * can fold a chain like `_t1 = a * b; c = _t1 + d` into
29
+ * `c = (a * b) + d`, which the fused emitter then renders as one loop
30
+ * with no intermediate tensor allocation.
30
31
  *
31
- * Phase 1 (this file) only handles the *same-static-shape* case. If
32
- * any multi-element operand has a statically-different shape from
33
- * the target, the Assign falls back to the runtime-helper path
34
- * (`mtoc2_tensor_<op>_bcast_tt(...)`). Broadcast fusion is phase 3.
32
+ * Only the *same-static-shape* case is handled. If any multi-element
33
+ * operand has a statically-different shape from the target, the
34
+ * Assign falls back to the runtime-helper path
35
+ * (`mtoc2_tensor_<op>_bcast_tt(...)`).
35
36
  */
36
37
  import type { Assign, IRExpr } from "../lowering/ir.js";
37
38
  import { type RuntimeState } from "./runtime.js";
@@ -72,6 +73,6 @@ export declare function fusedAssignNeedsShapeGuard(s: Assign): boolean;
72
73
  * operand must match the shape source's runtime shape, else the assign
73
74
  * defers to `fallbackStmt` — the bcast-aware helper path, which
74
75
  * broadcasts compatible shapes and raises "Matrix dimensions must
75
- * agree" on incompatible ones. Mirrors the JS `tt_kernel` deferring to
76
+ * agree" on incompatible ones. Mirrors the JS `_tt` helpers deferring to
76
77
  * `bcast_kernel`. */
77
78
  export declare function emitTensorAssignFused(s: Assign, indent: string, state: RuntimeState, fallbackStmt?: string): string;
@@ -1,6 +1,6 @@
1
1
  /**
2
- * `--inline-temps` IR-to-IR rewrite: substitutes a single-use
3
- * producer Assign's RHS into its consumer's RHS and removes the
2
+ * IR-to-IR rewrite for the C backend: substitutes a single-use
3
+ * producer Assign's RHS into its consumer's RHS and drops the
4
4
  * producer.
5
5
  *
6
6
  * After ANF normalization every owned-producing tensor expression
@@ -13,54 +13,45 @@
13
13
  * r2 = _t10 + 0.01
14
14
  *
15
15
  * emits four separate fused loops with three intermediate allocs.
16
- * After inlining (this pass), the chain collapses to
16
+ * After inlining, the chain collapses to
17
17
  *
18
18
  * r2 = (rx .^ 2 + ry .^ 2 + 0.01)
19
19
  *
20
20
  * which the elementwise-fused emitter (`emitTensorFused.ts`) renders
21
- * as a single iter loop. No intermediate tensors, no extra passes
22
- * through memory.
23
- *
24
- * Gates (must all hold to inline producer P into consumer C):
25
- *
26
- * 1. P is an Assign producing a real-double multi-element tensor.
27
- * 2. P's RHS is pure elementwise — only NumLit / Var / Binary /
28
- * Unary / Call to a builtin that has `perSlotC`. No
29
- * TensorBuild / TensorConcat / IndexLoad / IndexSlice /
30
- * MemberLoad / HandleLit / etc.
31
- * 3. P's LHS cName is used exactly once in the body. Function
32
- * output cNames get a `+1` protective bump so the returned
33
- * value is never elided.
34
- * 4. The single use is in another Assign's RHS, in a slot
35
- * position (subexpression of Binary / Unary / Call args). NOT
36
- * as the base of an IndexLoad / IndexSlice / MemberLoad, NOT
37
- * inside a TensorBuild / TensorConcat / StructLit / HandleLit.
38
- * 5. C is also fusable (same predicate as `isFusableAssign`).
39
- * 6. P and C are at the same body level (no inlining across
40
- * If / While / For — nested bodies are inlined separately).
41
- * 7. No statement between P and C writes to P's LHS or to any
42
- * free Var in P's RHS, and no statement reads P's LHS except
43
- * C. Control flow (If / While / For / Break / Continue /
44
- * ReturnFromFunction) ends the safe window.
45
- *
46
- * Algorithm: per body, iterate `inlineOnePass` to fixed point.
47
- * Each pass scans producers in source order, finds the first
48
- * inlinable pair, substitutes, and returns the new body. Chained
49
- * inlining (`a → b → c`) needs multiple iterations because each
50
- * substitution can flip a previously-multi-use cName to single-use;
51
- * we cap at 32 iterations defensively.
52
- *
53
- * Preserves: post-inlining the IR is still well-typed (each node's
54
- * `.ty` is unchanged — the substitution copies the producer's RHS
55
- * subtree verbatim); the ANF invariant for owned producers still
56
- * holds because we only inline producers whose RHS is NOT itself
57
- * an owned producer (no TensorBuild / Call-to-direct-owned-builtin
58
- * / etc.); and the `isFusableAssign` predicate that gates the
59
- * emit-path routing still accepts the consumer after substitution
60
- * (shape checks compose under inlining — see the design notes in
61
- * `emitTensorFused.ts`).
21
+ * as a single loop.
22
+ *
23
+ * Gates (all must hold to inline producer P into consumer C):
24
+ *
25
+ * 1. P is a fusable Assign (`isFusableAssign`): real multi-element
26
+ * tensor target, pure-elementwise RHS, operand shapes matching
27
+ * the target.
28
+ * 2. P's LHS cName is read exactly once in the whole function
29
+ * (nested bodies included). Function outputs get a +1 bump so
30
+ * they are never dropped. Counting function-wide, not per body,
31
+ * is what makes inlining inside loop / if bodies safe: a
32
+ * body-local count misses reads after the loop.
33
+ * 3. C is the first statement after P in the same body that reads
34
+ * P's LHS, and it is an Assign. Statements in between must not
35
+ * write P's LHS or any Var P's RHS reads, and must not be
36
+ * control flow. C itself may write such a Var: an Assign
37
+ * evaluates its whole RHS before storing.
38
+ * 4. The read in C is in a slot position (Binary / Unary / Call
39
+ * operand), and C is still fusable after substitution. The
40
+ * latter is an ownership rule: a non-fused consumer would get a
41
+ * nested owned operand that nothing frees.
42
+ *
43
+ * Use counts are stable under substitution (a single-use producer's
44
+ * reads move into its consumer; none is duplicated or dropped), so
45
+ * one forward sweep per body suffices: a consumer rewritten at index
46
+ * j is itself considered as a producer when the sweep reaches j,
47
+ * which collapses chains of any depth.
48
+ *
49
+ * The pass never mutates its input. The Lowerer's specialization
50
+ * cache is shared by the JS and C backends, so changed functions and
51
+ * statements are fresh objects; untouched ones are shared.
62
52
  */
63
- import type { IRProgram } from "../lowering/ir.js";
64
- /** Top-level entry. Mutates `prog.topLevelStmts` and each function's
65
- * `body` in place when inlining fires. */
66
- export declare function inlinePass(prog: IRProgram): void;
53
+ import type { IRFunc, IRProgram } from "../lowering/ir.js";
54
+ /** Returns a new program with every function inlined. */
55
+ export declare function inlinePass(prog: IRProgram): IRProgram;
56
+ /** Returns `fn` itself when nothing was inlined. */
57
+ export declare function inlineFunc(fn: IRFunc): IRFunc;
@@ -9,7 +9,7 @@
9
9
  * are visible). It IS a faithful render of what the IR actually says
10
10
  * after lowering — useful when debugging the translator.
11
11
  */
12
- import type { IRStmt, IRFunc, IRProgram } from "../lowering/ir.js";
12
+ import type { IRStmt, IRFunc } from "../lowering/ir.js";
13
13
  /** One-line summary of a statement (no trailing newline). Returns null
14
14
  * for stmts the emitter handles structurally (compound-block bodies
15
15
  * get their own per-stmt comments inside). */
@@ -17,8 +17,3 @@ export declare function irStmtHeader(s: IRStmt): string | null;
17
17
  /** Multi-line C block comment for a function specialization, listing
18
18
  * name, mangled C identifier, per-parameter types, and output types. */
19
19
  export declare function irFuncDocComment(fn: IRFunc): string;
20
- /** Render the whole lowered IR as a numbl-like script with one block
21
- * per function specialization plus a trailing top-level body. Used by
22
- * the IDE's Internals tab in interpreter mode, where no codegen
23
- * artifact exists. */
24
- export declare function prettyIRProgram(prog: IRProgram): string;
@@ -13,15 +13,8 @@
13
13
  * Snippets can declare other snippets they depend on; the activator
14
14
  * pulls dependencies in first.
15
15
  */
16
- import type { Builtin } from "../builtins/registry.js";
17
16
  /** Register the C runtime-snippet table. Called once at Node bootstrap. */
18
17
  export declare function setCSnippets(snippets: Record<string, string>): void;
19
- /** Minimal Workspace shape consulted at emit time. Importing the
20
- * concrete Workspace class would create a cycle (workspace ↔ codegen);
21
- * the structural type below captures exactly what codegen needs. */
22
- export interface WorkspaceLike {
23
- getUserBuiltin(name: string): Builtin | undefined;
24
- }
25
18
  export interface RuntimeSnippet {
26
19
  /** Standard-library headers parsed out of the source file. */
27
20
  headers: ReadonlyArray<string>;
@@ -57,13 +50,9 @@ export declare function parseSnippetSource(raw: string): {
57
50
  headers: string[];
58
51
  code: string;
59
52
  };
60
- /** Public re-export for callers that don't have a `RuntimeState` (the
61
- * build-snippets script). Resolves against the global registry only. */
62
- export declare function getRuntimeSnippet(name: string): RuntimeSnippet;
63
- /** Inline snippet definition supplied by a user `.mtoc2.js` builtin's
64
- * `emitC` / `emitJs` via `useRuntime({...})`. Once registered on a
65
- * `RuntimeState`, subsequent activations of the same `name` are
66
- * deduplicated.
53
+ /** Inline snippet definition supplied by an emitter via
54
+ * `useRuntime({...})`. Once registered on a `RuntimeState`, subsequent
55
+ * activations of the same `name` are deduplicated.
67
56
  *
68
57
  * `code` is the C body (required for `emitC` consumers); `jsCode`
69
58
  * is the optional JS body (required for `emitJs` consumers but
@@ -83,14 +72,9 @@ export interface RuntimeState {
83
72
  * multi-output call sites don't collide on `_mtoc2_discard_<N>_<i>`
84
73
  * names. Incremented each time a multi-output call is emitted. */
85
74
  multiAssignCallCounter: number;
86
- /** Workspace-scoped snippets registered via the user `useRuntime`
87
- * callback. Looked up by name alongside the global registry. */
75
+ /** Inline snippets registered via `useRuntime({...})`. Looked up
76
+ * by name alongside the global registry. */
88
77
  extraSnippets: Map<string, RuntimeSnippet>;
89
- /** Workspace reference for resolving names to `.mtoc2.js` user
90
- * builtins during emit. Undefined for non-workspace-driven codegen
91
- * (the snippet-build script, vitest unit tests that bypass the
92
- * workspace). */
93
- workspace?: WorkspaceLike;
94
78
  /** JS-side helper: cName list of the currently-emitting user
95
79
  * function's outputs. Set by `emitFunction` before walking the
96
80
  * body and cleared after so `ReturnFromFunction` can emit a
@@ -106,12 +90,7 @@ export interface RuntimeState {
106
90
  * `emit.ts` so it's set regardless of function emission order. */
107
91
  usedGrowBail?: boolean;
108
92
  }
109
- export declare function newRuntimeState(workspace?: WorkspaceLike): RuntimeState;
110
- /** Look up a `Builtin` for an emit-time call. Consults the workspace's
111
- * `.mtoc2.js` user builtins first (so a `foo.mtoc2.js` overrides any
112
- * identically-named built-in for callers in this workspace), then
113
- * falls back to the global registry. */
114
- export declare function lookupBuiltin(state: RuntimeState, name: string): Builtin | undefined;
93
+ export declare function newRuntimeState(): RuntimeState;
115
94
  /** Activate a snippet by its registered name. Pulls its `deps` in first
116
95
  * so they appear before it in the final emission order. Also pulls in
117
96
  * JS-import deps inferred from the snippet's paired `.js` sibling
@@ -119,7 +98,7 @@ export declare function lookupBuiltin(state: RuntimeState, name: string): Builti
119
98
  * so cross-snippet JS calls resolve at runtime even when the C deps
120
99
  * field doesn't enumerate them. Idempotent. */
121
100
  export declare function useRuntimeByName(state: RuntimeState, name: string): void;
122
- /** Register-and-activate an inline snippet supplied by a user builtin.
101
+ /** Register-and-activate an inline snippet.
123
102
  * First call registers the snippet on the state; subsequent calls
124
103
  * (with the same name) are no-ops at the registration step and just
125
104
  * re-activate through the global pathway. */
@@ -1,11 +1,8 @@
1
1
  /**
2
- * JIT entry point for sibling consumers (e.g. numbl's executor
3
- * registry) that want to compile a single user-function
4
- * specialization on demand instead of running mtoc2 as a whole-program
5
- * AOT translator.
2
+ * JS-JIT entry point for numbl's executor registry: compiles a single
3
+ * user-function specialization on demand.
6
4
  *
7
- * Bypasses the script-level driver (`translate.ts` / `lowerProject`)
8
- * and produces an emitted JS module that returns a factory
5
+ * Produces an emitted JS module that returns a factory
9
6
  * `($h) => specFn`. The caller evaluates the source with
10
7
  * `new Function(source)()`, invokes the factory once per spec to bind
11
8
  * its I/O hooks, then calls `specFn(...args)` per dispatch. Per-call
@@ -27,6 +27,7 @@ import type { Stmt } from "./parser/index.js";
27
27
  import type { Lowerer } from "./lowering/lower.js";
28
28
  import type { Workspace } from "./workspace/workspace.js";
29
29
  import { type Type } from "./lowering/types.js";
30
+ import { type AssignedFlag } from "./lowering/assignedFlags.js";
30
31
  type FuncStmt = Extract<Stmt, {
31
32
  type: "Function";
32
33
  }>;
@@ -95,6 +96,10 @@ export interface CompileSpecCResult {
95
96
  activatedSnippets: ReadonlyArray<string>;
96
97
  /** Signature description so the host can build the koffi prototype. */
97
98
  signature: SpecCSignature;
99
+ /** Synthetic entries only: outputs that may be left unassigned, each
100
+ * paired with a trailing flag output that is 0 when it was. The host
101
+ * skips writing such an output back. */
102
+ assignedFlags: ReadonlyArray<AssignedFlag>;
98
103
  }
99
104
  export declare function compileSpecC(args: CompileSpecCArgs): CompileSpecCResult;
100
105
  export {};
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Assigned flags for the C backend's synthetic loop / top-level entries.
3
+ *
4
+ * A synthetic wrapper's outputs include names the body assigns only on a
5
+ * path that may not run (the loop variable and body locals of a zero-trip
6
+ * `for`). C predeclares every output to 0, so writing such an output back
7
+ * would bind a value the interpreter and JS-JIT leave undefined. For each
8
+ * output that is neither a param nor definitely assigned, this pass adds a
9
+ * scalar flag output set to 1 right after every assignment to it; the host
10
+ * skips the writeback when the flag is still 0.
11
+ */
12
+ import type { IRFunc } from "./ir.js";
13
+ export interface AssignedFlag {
14
+ /** Index of the guarded output in `fn.outputs`. */
15
+ readonly output: number;
16
+ /** Index of its flag output in `fn.outputs`. */
17
+ readonly flag: number;
18
+ }
19
+ /** Return a copy of `fn` with a flag output per output in `maybeUnassigned`
20
+ * (or `fn` itself when there is none), plus the output/flag pairing. */
21
+ export declare function addAssignedFlags(fn: IRFunc, maybeUnassigned: ReadonlySet<string>): {
22
+ fn: IRFunc;
23
+ flags: AssignedFlag[];
24
+ };