numbl 0.4.19 → 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 (314) 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/helpers/sparse-direct.d.ts +107 -0
  32. package/dist-browser/numbl-core/helpers/warn.d.ts +9 -0
  33. package/dist-browser/numbl-core/interpreter/builtins/index.d.ts +4 -1
  34. package/dist-browser/numbl-core/interpreter/builtins/sparse-solvers.d.ts +16 -0
  35. package/dist-browser/numbl-core/interpreter/builtins/time-system.d.ts +0 -1
  36. package/dist-browser/numbl-core/interpreter/builtins/types.d.ts +7 -7
  37. package/dist-browser/numbl-core/interpreter/interpreter.d.ts +6 -6
  38. package/dist-browser/numbl-core/interpreter/interpreterFunctions.d.ts +9 -1
  39. package/dist-browser/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +6 -3
  40. package/dist-browser/numbl-core/jit/builtins/defs/_shared.d.ts +1 -5
  41. package/dist-browser/numbl-core/jit/builtins/defs/arithmetic/_elemwise.d.ts +1 -2
  42. package/dist-browser/numbl-core/jit/builtins/defs/logical/_unary_pred.d.ts +3 -3
  43. package/dist-browser/numbl-core/jit/builtins/defs/logical/fieldnames.d.ts +1 -1
  44. package/dist-browser/numbl-core/jit/builtins/defs/logical/strcmp.d.ts +1 -1
  45. package/dist-browser/numbl-core/jit/builtins/defs/math/_unary_real.d.ts +5 -2
  46. package/dist-browser/numbl-core/jit/builtins/defs/math/realsqrt.d.ts +6 -0
  47. package/dist-browser/numbl-core/jit/builtins/defs/reduction/_shape.d.ts +0 -5
  48. package/dist-browser/numbl-core/jit/builtins/defs/shape/_construct.d.ts +0 -4
  49. package/dist-browser/numbl-core/jit/builtins/defs/shape/_triangular.d.ts +2 -8
  50. package/dist-browser/numbl-core/jit/builtins/defs/system/deal.d.ts +4 -5
  51. package/dist-browser/numbl-core/jit/builtins/defs/system/feval.d.ts +7 -29
  52. package/dist-browser/numbl-core/jit/builtins/registry.d.ts +15 -30
  53. package/dist-browser/numbl-core/jit/builtins/runtime/system/cdiv.d.ts +4 -0
  54. package/dist-browser/numbl-core/jit/builtins/runtime/system/cscalar.d.ts +4 -0
  55. package/dist-browser/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real_fn.d.ts +45 -15
  56. package/dist-browser/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_real.d.ts +5 -5
  57. package/dist-browser/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_real_math.d.ts +6 -0
  58. package/dist-browser/numbl-core/jit/codegen/emit.d.ts +9 -30
  59. package/dist-browser/numbl-core/jit/codegen/emitJs.d.ts +9 -27
  60. package/dist-browser/numbl-core/jit/codegen/emitStmt.d.ts +8 -31
  61. package/dist-browser/numbl-core/jit/codegen/emitTensorFused.d.ts +10 -9
  62. package/dist-browser/numbl-core/jit/codegen/inlinePass.d.ts +39 -48
  63. package/dist-browser/numbl-core/jit/codegen/prettyIR.d.ts +1 -6
  64. package/dist-browser/numbl-core/jit/codegen/runtime.d.ts +7 -28
  65. package/dist-browser/numbl-core/jit/compileSpec.d.ts +3 -6
  66. package/dist-browser/numbl-core/jit/compileSpecC.d.ts +5 -0
  67. package/dist-browser/numbl-core/jit/lowering/assignedFlags.d.ts +24 -0
  68. package/dist-browser/numbl-core/jit/lowering/definiteAssign.d.ts +3 -1
  69. package/dist-browser/numbl-core/jit/lowering/errors.d.ts +3 -15
  70. package/dist-browser/numbl-core/jit/lowering/ir.d.ts +0 -2
  71. package/dist-browser/numbl-core/jit/lowering/lower.d.ts +4 -12
  72. package/dist-browser/numbl-core/jit/lowering/types.d.ts +2 -7
  73. package/dist-browser/numbl-core/jit/numbl/index.d.ts +5 -14
  74. package/dist-browser/numbl-core/jit/parser/index.d.ts +4 -9
  75. package/dist-browser/numbl-core/jit/workspace/workspace.d.ts +32 -136
  76. package/dist-browser/numbl-core/jitDeclineDiagnostics.d.ts +1 -1
  77. package/dist-browser/numbl-core/jsUserFunctions.d.ts +10 -12
  78. package/dist-browser/numbl-core/lowering/classInfo.d.ts +4 -1
  79. package/dist-browser/numbl-core/lowering/loweringContext.d.ts +15 -23
  80. package/dist-browser/numbl-core/native/lapack-bridge.d.ts +137 -128
  81. package/dist-browser/numbl-core/native/ts-lapack-bridge.d.ts +4 -5
  82. package/dist-browser/numbl-core/native/ts-lapack-complex.d.ts +23 -0
  83. package/dist-browser/numbl-core/native/ts-lapack-eig-hermitian.d.ts +33 -0
  84. package/dist-browser/numbl-core/native/ts-lapack-qr-lu.d.ts +37 -0
  85. package/dist-browser/numbl-core/native/wasm-lapack-bridge.d.ts +4 -5
  86. package/dist-browser/numbl-core/ops/dispatch.d.ts +4 -5
  87. package/dist-browser/numbl-core/parser/types.d.ts +1 -21
  88. package/{dist-lib/numbl-core/runtime → dist-browser/numbl-core/plotting}/axisCommand.d.ts +2 -2
  89. package/dist-browser/{graphics → numbl-core/plotting}/axisLimits.d.ts +14 -2
  90. package/dist-browser/numbl-core/plotting/builtins.d.ts +8 -0
  91. package/dist-browser/numbl-core/plotting/colormaps.d.ts +10 -0
  92. package/dist-browser/numbl-core/{runtime/plotBuiltinDispatch.d.ts → plotting/dispatch.d.ts} +14 -25
  93. package/dist-browser/numbl-core/plotting/imagescExtent.d.ts +19 -0
  94. package/dist-browser/numbl-core/{runtime/runtimePlot.d.ts → plotting/instructions.d.ts} +5 -17
  95. package/dist-browser/numbl-core/plotting/parseArgsChart.d.ts +94 -0
  96. package/dist-browser/numbl-core/plotting/parseArgsCommon.d.ts +64 -0
  97. package/dist-browser/numbl-core/plotting/parseArgsLine.d.ts +103 -0
  98. package/dist-browser/numbl-core/plotting/parseArgsPatch.d.ts +38 -0
  99. package/dist-browser/numbl-core/plotting/parseArgsQuiver.d.ts +32 -0
  100. package/dist-browser/numbl-core/plotting/parseArgsSurface.d.ts +75 -0
  101. package/dist-browser/numbl-core/plotting/streamline.d.ts +16 -0
  102. package/{dist-graphics/graphics → dist-browser/numbl-core/plotting}/types.d.ts +9 -7
  103. package/dist-browser/numbl-core/runtime/cow.d.ts +0 -8
  104. package/dist-browser/numbl-core/runtime/refcount.d.ts +0 -3
  105. package/dist-browser/numbl-core/runtime/registerSpecial.d.ts +15 -0
  106. package/dist-browser/numbl-core/runtime/runtime.d.ts +11 -35
  107. package/dist-browser/numbl-core/runtime/runtimeDispatch.d.ts +6 -0
  108. package/dist-browser/numbl-core/runtime/specialBuiltins.d.ts +3 -9
  109. package/dist-browser/numbl-core/runtime/types.d.ts +12 -0
  110. package/dist-browser/numbl-core/runtime/uihtmlSession.d.ts +5 -13
  111. package/dist-browser/numbl-core/runtime/utils.d.ts +4 -1
  112. package/dist-browser/numbl-core/version.d.ts +1 -1
  113. package/dist-browser/numbl-core/workspace/workspace.d.ts +64 -0
  114. package/dist-browser/ts-lapack/src/BLAS/dsymv.d.ts +1 -0
  115. package/dist-browser/ts-lapack/src/BLAS/dsyr2.d.ts +1 -0
  116. package/dist-browser/ts-lapack/src/SRC/dlae2.d.ts +4 -0
  117. package/dist-browser/ts-lapack/src/SRC/dlaev2.d.ts +6 -0
  118. package/dist-browser/ts-lapack/src/SRC/dlanst.d.ts +1 -0
  119. package/dist-browser/ts-lapack/src/SRC/dlansy.d.ts +1 -0
  120. package/dist-browser/ts-lapack/src/SRC/dlasrt.d.ts +1 -0
  121. package/dist-browser/ts-lapack/src/SRC/dorgtr.d.ts +1 -0
  122. package/dist-browser/ts-lapack/src/SRC/dsteqr.d.ts +4 -0
  123. package/dist-browser/ts-lapack/src/SRC/dsyev.d.ts +1 -0
  124. package/dist-browser/ts-lapack/src/SRC/dsytd2.d.ts +1 -0
  125. package/dist-browser/vfs/syncVfsChanges.d.ts +2 -2
  126. package/dist-cli/cli.js +74241 -77271
  127. package/dist-graphics/graphics/FigureView.d.ts +1 -1
  128. package/dist-graphics/graphics/SurfView.d.ts +3 -2
  129. package/dist-graphics/graphics/drawPlot.d.ts +1 -1
  130. package/dist-graphics/graphics/exportFigureHdf5.d.ts +1 -1
  131. package/dist-graphics/graphics/figureHashTransport.d.ts +1 -1
  132. package/dist-graphics/graphics/figureUpload.d.ts +1 -1
  133. package/dist-graphics/graphics/importFigureHdf5.d.ts +1 -1
  134. package/dist-graphics/graphics/openInFigureViewer.d.ts +1 -1
  135. package/dist-graphics/graphics/plotHelpers.d.ts +1 -1
  136. package/dist-graphics/graphics/plotLegend.d.ts +1 -1
  137. package/dist-graphics/graphics/plotMarkers.d.ts +1 -1
  138. package/dist-graphics/graphics/restoreNaNs.d.ts +1 -1
  139. package/dist-graphics/graphics/uihtmlRelay.d.ts +16 -0
  140. package/dist-graphics/graphics-lib.d.ts +3 -3
  141. package/dist-graphics/index.js +294 -328
  142. package/{dist-lib/graphics → dist-graphics/numbl-core/plotting}/axisLimits.d.ts +14 -2
  143. package/dist-graphics/numbl-core/plotting/colormaps.d.ts +10 -0
  144. package/dist-graphics/numbl-core/plotting/imagescExtent.d.ts +19 -0
  145. package/{dist-browser/graphics → dist-graphics/numbl-core/plotting}/types.d.ts +9 -7
  146. package/dist-lib/browser/mip.d.ts +17 -0
  147. package/dist-lib/cli-scan.d.ts +8 -1
  148. package/dist-lib/lib.d.ts +1 -1
  149. package/dist-lib/lib.js +37081 -39889
  150. package/dist-lib/node.js +22 -14
  151. package/dist-lib/numbl-core/execSession.d.ts +39 -0
  152. package/dist-lib/numbl-core/executeCode.d.ts +10 -1
  153. package/dist-lib/numbl-core/executors/classification.d.ts +2 -10
  154. package/dist-lib/numbl-core/executors/jit/backend.d.ts +65 -0
  155. package/dist-lib/numbl-core/executors/jit/cBackend.d.ts +22 -0
  156. package/dist-lib/numbl-core/executors/jit/callExecutor.d.ts +13 -44
  157. package/dist-lib/numbl-core/executors/jit/hostHelpers.d.ts +24 -0
  158. package/dist-lib/numbl-core/executors/jit/jsBackend.d.ts +15 -0
  159. package/dist-lib/numbl-core/executors/jit/loopExecutor.d.ts +13 -40
  160. package/dist-lib/numbl-core/executors/jit/session.d.ts +1 -1
  161. package/dist-lib/numbl-core/executors/jit/topLevelExecutor.d.ts +13 -33
  162. package/dist-lib/numbl-core/executors/jit/valueAdapterC.d.ts +32 -48
  163. package/dist-lib/numbl-core/executors/lowering.d.ts +38 -96
  164. package/dist-lib/numbl-core/executors/plugins.d.ts +14 -28
  165. package/dist-lib/numbl-core/executors/registry.d.ts +32 -133
  166. package/dist-lib/numbl-core/executors/types.d.ts +30 -92
  167. package/dist-lib/numbl-core/functionResolve.d.ts +3 -13
  168. package/dist-lib/numbl-core/helpers/check-helpers.d.ts +0 -5
  169. package/dist-lib/numbl-core/helpers/glob.d.ts +14 -0
  170. package/dist-lib/numbl-core/helpers/linsolve.d.ts +3 -13
  171. package/dist-lib/numbl-core/helpers/reduction-helpers.d.ts +2 -4
  172. package/dist-lib/numbl-core/helpers/shape-utils.d.ts +10 -0
  173. package/dist-lib/numbl-core/helpers/sparse-direct.d.ts +107 -0
  174. package/dist-lib/numbl-core/helpers/warn.d.ts +9 -0
  175. package/dist-lib/numbl-core/interpreter/builtins/index.d.ts +4 -1
  176. package/dist-lib/numbl-core/interpreter/builtins/sparse-solvers.d.ts +16 -0
  177. package/dist-lib/numbl-core/interpreter/builtins/time-system.d.ts +0 -1
  178. package/dist-lib/numbl-core/interpreter/builtins/types.d.ts +7 -7
  179. package/dist-lib/numbl-core/interpreter/interpreter.d.ts +6 -6
  180. package/dist-lib/numbl-core/interpreter/interpreterFunctions.d.ts +9 -1
  181. package/dist-lib/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +6 -3
  182. package/dist-lib/numbl-core/jit/builtins/defs/_shared.d.ts +1 -5
  183. package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/_elemwise.d.ts +1 -2
  184. package/dist-lib/numbl-core/jit/builtins/defs/logical/_unary_pred.d.ts +3 -3
  185. package/dist-lib/numbl-core/jit/builtins/defs/logical/fieldnames.d.ts +1 -1
  186. package/dist-lib/numbl-core/jit/builtins/defs/logical/strcmp.d.ts +1 -1
  187. package/dist-lib/numbl-core/jit/builtins/defs/math/_unary_real.d.ts +5 -2
  188. package/dist-lib/numbl-core/jit/builtins/defs/math/realsqrt.d.ts +6 -0
  189. package/dist-lib/numbl-core/jit/builtins/defs/reduction/_shape.d.ts +0 -5
  190. package/dist-lib/numbl-core/jit/builtins/defs/shape/_construct.d.ts +0 -4
  191. package/dist-lib/numbl-core/jit/builtins/defs/shape/_triangular.d.ts +2 -8
  192. package/dist-lib/numbl-core/jit/builtins/defs/system/deal.d.ts +4 -5
  193. package/dist-lib/numbl-core/jit/builtins/defs/system/feval.d.ts +7 -29
  194. package/dist-lib/numbl-core/jit/builtins/registry.d.ts +15 -30
  195. package/dist-lib/numbl-core/jit/builtins/runtime/system/cdiv.d.ts +4 -0
  196. package/dist-lib/numbl-core/jit/builtins/runtime/system/cscalar.d.ts +4 -0
  197. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real_fn.d.ts +45 -15
  198. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_real.d.ts +5 -5
  199. package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_real_math.d.ts +6 -0
  200. package/dist-lib/numbl-core/jit/codegen/emit.d.ts +9 -30
  201. package/dist-lib/numbl-core/jit/codegen/emitJs.d.ts +9 -27
  202. package/dist-lib/numbl-core/jit/codegen/emitStmt.d.ts +8 -31
  203. package/dist-lib/numbl-core/jit/codegen/emitTensorFused.d.ts +10 -9
  204. package/dist-lib/numbl-core/jit/codegen/inlinePass.d.ts +39 -48
  205. package/dist-lib/numbl-core/jit/codegen/prettyIR.d.ts +1 -6
  206. package/dist-lib/numbl-core/jit/codegen/runtime.d.ts +7 -28
  207. package/dist-lib/numbl-core/jit/compileSpec.d.ts +3 -6
  208. package/dist-lib/numbl-core/jit/compileSpecC.d.ts +5 -0
  209. package/dist-lib/numbl-core/jit/lowering/assignedFlags.d.ts +24 -0
  210. package/dist-lib/numbl-core/jit/lowering/definiteAssign.d.ts +3 -1
  211. package/dist-lib/numbl-core/jit/lowering/errors.d.ts +3 -15
  212. package/dist-lib/numbl-core/jit/lowering/ir.d.ts +0 -2
  213. package/dist-lib/numbl-core/jit/lowering/lower.d.ts +4 -12
  214. package/dist-lib/numbl-core/jit/lowering/types.d.ts +2 -7
  215. package/dist-lib/numbl-core/jit/numbl/index.d.ts +5 -14
  216. package/dist-lib/numbl-core/jit/parser/index.d.ts +4 -9
  217. package/dist-lib/numbl-core/jit/workspace/workspace.d.ts +32 -136
  218. package/dist-lib/numbl-core/jitDeclineDiagnostics.d.ts +1 -1
  219. package/dist-lib/numbl-core/jsUserFunctions.d.ts +10 -12
  220. package/dist-lib/numbl-core/lowering/classInfo.d.ts +4 -1
  221. package/dist-lib/numbl-core/lowering/loweringContext.d.ts +15 -23
  222. package/dist-lib/numbl-core/native/lapack-bridge.d.ts +137 -128
  223. package/dist-lib/numbl-core/native/ts-lapack-bridge.d.ts +4 -5
  224. package/dist-lib/numbl-core/native/ts-lapack-complex.d.ts +23 -0
  225. package/dist-lib/numbl-core/native/ts-lapack-eig-hermitian.d.ts +33 -0
  226. package/dist-lib/numbl-core/native/ts-lapack-qr-lu.d.ts +37 -0
  227. package/dist-lib/numbl-core/native/wasm-lapack-bridge.d.ts +4 -5
  228. package/dist-lib/numbl-core/ops/dispatch.d.ts +4 -5
  229. package/dist-lib/numbl-core/parser/types.d.ts +1 -21
  230. package/{dist-browser/numbl-core/runtime → dist-lib/numbl-core/plotting}/axisCommand.d.ts +2 -2
  231. package/{dist-graphics/graphics → dist-lib/numbl-core/plotting}/axisLimits.d.ts +14 -2
  232. package/dist-lib/numbl-core/plotting/builtins.d.ts +8 -0
  233. package/dist-lib/numbl-core/plotting/colormaps.d.ts +10 -0
  234. package/dist-lib/numbl-core/{runtime/plotBuiltinDispatch.d.ts → plotting/dispatch.d.ts} +14 -25
  235. package/dist-lib/numbl-core/plotting/imagescExtent.d.ts +19 -0
  236. package/dist-lib/numbl-core/{runtime/runtimePlot.d.ts → plotting/instructions.d.ts} +5 -17
  237. package/dist-lib/numbl-core/plotting/parseArgsChart.d.ts +94 -0
  238. package/dist-lib/numbl-core/plotting/parseArgsCommon.d.ts +64 -0
  239. package/dist-lib/numbl-core/plotting/parseArgsLine.d.ts +103 -0
  240. package/dist-lib/numbl-core/plotting/parseArgsPatch.d.ts +38 -0
  241. package/dist-lib/numbl-core/plotting/parseArgsQuiver.d.ts +32 -0
  242. package/dist-lib/numbl-core/plotting/parseArgsSurface.d.ts +75 -0
  243. package/dist-lib/numbl-core/plotting/streamline.d.ts +16 -0
  244. package/dist-lib/{graphics → numbl-core/plotting}/types.d.ts +9 -7
  245. package/dist-lib/numbl-core/runtime/cow.d.ts +0 -8
  246. package/dist-lib/numbl-core/runtime/refcount.d.ts +0 -3
  247. package/dist-lib/numbl-core/runtime/registerSpecial.d.ts +15 -0
  248. package/dist-lib/numbl-core/runtime/runtime.d.ts +11 -35
  249. package/dist-lib/numbl-core/runtime/runtimeDispatch.d.ts +6 -0
  250. package/dist-lib/numbl-core/runtime/specialBuiltins.d.ts +3 -9
  251. package/dist-lib/numbl-core/runtime/types.d.ts +12 -0
  252. package/dist-lib/numbl-core/runtime/uihtmlSession.d.ts +5 -13
  253. package/dist-lib/numbl-core/runtime/utils.d.ts +4 -1
  254. package/dist-lib/numbl-core/version.d.ts +1 -1
  255. package/dist-lib/numbl-core/workspace/workspace.d.ts +64 -0
  256. package/dist-lib/ts-lapack/src/BLAS/dsymv.d.ts +1 -0
  257. package/dist-lib/ts-lapack/src/BLAS/dsyr2.d.ts +1 -0
  258. package/dist-lib/ts-lapack/src/SRC/dlae2.d.ts +4 -0
  259. package/dist-lib/ts-lapack/src/SRC/dlaev2.d.ts +6 -0
  260. package/dist-lib/ts-lapack/src/SRC/dlanst.d.ts +1 -0
  261. package/dist-lib/ts-lapack/src/SRC/dlansy.d.ts +1 -0
  262. package/dist-lib/ts-lapack/src/SRC/dlasrt.d.ts +1 -0
  263. package/dist-lib/ts-lapack/src/SRC/dorgtr.d.ts +1 -0
  264. package/dist-lib/ts-lapack/src/SRC/dsteqr.d.ts +4 -0
  265. package/dist-lib/ts-lapack/src/SRC/dsyev.d.ts +1 -0
  266. package/dist-lib/ts-lapack/src/SRC/dsytd2.d.ts +1 -0
  267. package/dist-lib/vfs/unzipToFiles.d.ts +7 -0
  268. package/dist-plot-viewer/assets/index-C0fIevlp.js +4504 -0
  269. package/dist-plot-viewer/index.html +1 -1
  270. package/dist-site-viewer/assets/index-BDaviCH6.js +4832 -0
  271. package/dist-site-viewer/assets/numbl-worker-D6m4K2PP.js +5691 -0
  272. package/dist-site-viewer/index.html +2 -2
  273. package/native/lapack_eig.cpp +156 -0
  274. package/native/numbl_addon.cpp +8 -12
  275. package/native/numbl_addon_common.h +14 -5
  276. package/package.json +6 -5
  277. package/dist-browser/hooks/useProjectFiles.d.ts +0 -45
  278. package/dist-browser/numbl-core/executors/context.d.ts +0 -76
  279. package/dist-browser/numbl-core/executors/index.d.ts +0 -14
  280. package/dist-browser/numbl-core/executors/jit/cJitCallExecutor.d.ts +0 -35
  281. package/dist-browser/numbl-core/executors/jit/cJitLoopExecutor.d.ts +0 -31
  282. package/dist-browser/numbl-core/executors/jit/cJitTopLevelExecutor.d.ts +0 -29
  283. package/dist-browser/numbl-core/helpers/dummy.d.ts +0 -5
  284. package/dist-browser/numbl-core/jit/runtime/context.d.ts +0 -23
  285. package/dist-browser/numbl-core/jit/runtime/inferType.d.ts +0 -10
  286. package/dist-browser/numbl-core/jit/runtime/value.d.ts +0 -101
  287. package/dist-browser/numbl-core/jit/workspace/driverPrologue.d.ts +0 -59
  288. package/dist-browser/numbl-core/jit/workspace/mtoc2UserFunctionLoader.d.ts +0 -62
  289. package/dist-browser/numbl-core/native/bridge-resolve.d.ts +0 -14
  290. package/dist-browser/numbl-core/runtime/plotUtils.d.ts +0 -336
  291. package/dist-browser/numbl-core/runtime/specialBuiltinNames.d.ts +0 -2
  292. package/dist-graphics/graphics/surfColormap.d.ts +0 -2
  293. package/dist-lib/numbl-core/executors/context.d.ts +0 -76
  294. package/dist-lib/numbl-core/executors/index.d.ts +0 -14
  295. package/dist-lib/numbl-core/executors/jit/cJitCallExecutor.d.ts +0 -35
  296. package/dist-lib/numbl-core/executors/jit/cJitLoopExecutor.d.ts +0 -31
  297. package/dist-lib/numbl-core/executors/jit/cJitTopLevelExecutor.d.ts +0 -29
  298. package/dist-lib/numbl-core/helpers/dummy.d.ts +0 -5
  299. package/dist-lib/numbl-core/jit/runtime/context.d.ts +0 -23
  300. package/dist-lib/numbl-core/jit/runtime/inferType.d.ts +0 -10
  301. package/dist-lib/numbl-core/jit/runtime/value.d.ts +0 -101
  302. package/dist-lib/numbl-core/jit/workspace/driverPrologue.d.ts +0 -59
  303. package/dist-lib/numbl-core/jit/workspace/mtoc2UserFunctionLoader.d.ts +0 -62
  304. package/dist-lib/numbl-core/native/bridge-resolve.d.ts +0 -14
  305. package/dist-lib/numbl-core/runtime/plotUtils.d.ts +0 -336
  306. package/dist-lib/numbl-core/runtime/specialBuiltinNames.d.ts +0 -2
  307. package/dist-plot-viewer/assets/index-YeXWXIxH.js +0 -4504
  308. package/dist-site-viewer/assets/index-B5Y5557F.js +0 -4831
  309. package/dist-site-viewer/assets/numbl-worker-CtoT7C0f.js +0 -5355
  310. package/native/elemwise.cpp +0 -360
  311. package/native/unary_elemwise.cpp +0 -67
  312. /package/dist-browser/{graphics → numbl-core/plotting}/figuresReducer.d.ts +0 -0
  313. /package/dist-graphics/{graphics → numbl-core/plotting}/figuresReducer.d.ts +0 -0
  314. /package/dist-lib/{graphics → numbl-core/plotting}/figuresReducer.d.ts +0 -0
@@ -1,8 +1,7 @@
1
1
  /**
2
- * Builtin registry — the contract every mtoc2 builtin (and future
3
- * user `.mtoc2.js` function) implements.
2
+ * Builtin registry — the contract every JIT builtin implements.
4
3
  *
5
- * Each builtin can supply up to three mirrored hooks plus the
4
+ * Each builtin can supply two mirrored codegen hooks plus the
6
5
  * always-required `transfer`:
7
6
  *
8
7
  * transfer(argTypes, nargout) — required. Given input types and
@@ -32,15 +31,9 @@
32
31
  * outputs land in these locals via the framework's destructuring
33
32
  * wrapper. Activates JS-side runtime snippets via `useRuntime`.
34
33
  *
35
- * call({args, argTypes, nargout, ctx}) — optional. Direct JS
36
- * function used by the interpreter and as a JIT bailout target.
37
- * Returns one runtime value per output slot. The args shape
38
- * mirrors the emit hooks' shape so dispatch on `argTypes` /
39
- * `nargout` stays parallel across all three.
40
- *
41
- * elementwise? — when true, every defined emit hook (and `call`)
42
- * must also produce a correct scalar output when called with
43
- * scalar argTypes and scalar argsC/argsJs/args. The framework
34
+ * elementwise? — when true, every defined emit hook must also
35
+ * produce a correct scalar output when called with
36
+ * scalar argTypes and scalar argsC/argsJs. The framework
44
37
  * uses this for same-shape tensor fusion (and, later, broadcast
45
38
  * / reduction-inner / mask / stencil fusion). Absence = "do not
46
39
  * fuse me; use the regular emit on the full tensor types."
@@ -50,8 +43,6 @@
50
43
  * computes the maximum compatible backend per call site.
51
44
  */
52
45
  import type { Type } from "../lowering/types.js";
53
- import type { RuntimeValue } from "../runtime/value.js";
54
- import type { RuntimeContext } from "../runtime/context.js";
55
46
  /** Common across every hook — the type-level call descriptor. */
56
47
  interface CommonArgs {
57
48
  /** Per-arg type (after lowering / inference). */
@@ -71,7 +62,7 @@ export interface EmitCArgs extends CommonArgs {
71
62
  outArgsC?: string[];
72
63
  /** Activate a runtime C snippet on the current translation unit.
73
64
  * See `runtime.ts` for the registry and `InlineSnippet` for the
74
- * user-supplied form. */
65
+ * inline form. */
75
66
  useRuntime(spec: string | InlineSnippet): void;
76
67
  }
77
68
  export interface EmitJsArgs extends CommonArgs {
@@ -90,14 +81,6 @@ export interface EmitJsArgs extends CommonArgs {
90
81
  * (with a `jsCode` body) defines a one-off helper from a builtin. */
91
82
  useRuntime(spec: string | InlineSnippet): void;
92
83
  }
93
- export interface CallArgs extends CommonArgs {
94
- /** Per-arg runtime values, evaluated by the interpreter at the
95
- * call site. */
96
- args: RuntimeValue[];
97
- /** Host bag — `helpers.write` for stdout, future hooks for plot /
98
- * error / time. */
99
- ctx: RuntimeContext;
100
- }
101
84
  export interface Builtin {
102
85
  /** Source-level name (registry key). */
103
86
  name: string;
@@ -109,13 +92,18 @@ export interface Builtin {
109
92
  emitC?(args: EmitCArgs): string;
110
93
  /** Optional: JS codegen. */
111
94
  emitJs?(args: EmitJsArgs): string;
112
- /** Optional: direct JS function — interpreter / JIT bailout. */
113
- call?(args: CallArgs): RuntimeValue[];
114
95
  /** Elementwise = result is computed pointwise. */
115
96
  elementwise?: boolean;
97
+ /** Optional: elementwise for these argument types only, for a builtin
98
+ * whose forms differ by arity (two-argument `max(a, b)` is pointwise,
99
+ * one-argument `max(a)` is a reduction). Consulted when `elementwise`
100
+ * is not set. */
101
+ isElementwiseCall?(argTypes: Type[]): boolean;
116
102
  }
117
- /** Inline-defined runtime snippet supplied by a user `.mtoc2.js`
118
- * builtin's `emitC` / `emitJs`. Re-exported from `runtime.ts` — kept
103
+ /** Whether a call of `b` with these argument types is computed pointwise. */
104
+ export declare function isElementwiseCall(b: Builtin, argTypes: Type[]): boolean;
105
+ /** Inline-defined runtime snippet supplied by an emitter via
106
+ * `useRuntime({...})`. Re-exported from `runtime.ts` — kept
119
107
  * here for doc-locality with the `Builtin` contract. */
120
108
  export interface InlineSnippet {
121
109
  name: string;
@@ -130,9 +118,6 @@ export declare function registerBuiltin(b: Builtin): void;
130
118
  export declare function getBuiltin(name: string): Builtin | undefined;
131
119
  /** Names of every registered builtin. Drives Monaco syntax highlighting. */
132
120
  export declare function allBuiltinNames(): readonly string[];
133
- export type Backend = "c" | "js" | "interpreter";
134
- export declare function builtinSupports(b: Builtin, backend: Backend): boolean;
135
121
  export declare function requireEmitC(b: Builtin): (args: EmitCArgs) => string;
136
122
  export declare function requireEmitJs(b: Builtin): (args: EmitJsArgs) => string;
137
- export declare function requireCall(b: Builtin): (args: CallArgs) => RuntimeValue[];
138
123
  export {};
@@ -2,3 +2,7 @@ export function mtoc2_cdiv(a: any, b: any): {
2
2
  re: number;
3
3
  im: number;
4
4
  };
5
+ export function mtoc2_cdiv_mixed(a: any, b: any): {
6
+ re: number;
7
+ im: number;
8
+ };
@@ -16,6 +16,10 @@ export function mtoc2_cmul(a: any, b: any): {
16
16
  re: number;
17
17
  im: number;
18
18
  };
19
+ export function mtoc2_cmul_mixed(a: any, b: any): {
20
+ re: number;
21
+ im: number;
22
+ };
19
23
  export function mtoc2_cneg(z: any): {
20
24
  re: number;
21
25
  im: number;
@@ -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;