numbl 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +17 -33
- package/dist-cli/cli.js +61511 -46223
- package/dist-lib/graphics/types.d.ts +22 -0
- package/dist-lib/lib.js +37582 -22275
- package/dist-lib/numbl-core/executeCode.d.ts +11 -16
- package/dist-lib/numbl-core/executors/cache.d.ts +26 -0
- package/dist-lib/numbl-core/executors/classification.d.ts +134 -0
- package/dist-lib/numbl-core/executors/context.d.ts +76 -0
- package/dist-lib/numbl-core/executors/handleInline.d.ts +42 -0
- package/dist-lib/numbl-core/executors/index.d.ts +14 -0
- package/dist-lib/numbl-core/executors/jit/cJitCallExecutor.d.ts +35 -0
- package/dist-lib/numbl-core/executors/jit/cJitLoopExecutor.d.ts +31 -0
- package/dist-lib/numbl-core/executors/jit/cJitTopLevelExecutor.d.ts +29 -0
- package/dist-lib/numbl-core/executors/jit/callExecutor.d.ts +45 -0
- package/dist-lib/numbl-core/executors/jit/compileC.d.ts +51 -0
- package/dist-lib/numbl-core/executors/jit/compileC.node.d.ts +25 -0
- package/dist-lib/numbl-core/executors/jit/hostHelpers.d.ts +27 -0
- package/dist-lib/numbl-core/executors/jit/loopExecutor.d.ts +41 -0
- package/dist-lib/numbl-core/executors/jit/session.d.ts +17 -0
- package/dist-lib/numbl-core/executors/jit/topLevelExecutor.d.ts +36 -0
- package/dist-lib/numbl-core/executors/jit/typeAdapter.d.ts +28 -0
- package/dist-lib/numbl-core/executors/jit/typeAdapterC.d.ts +73 -0
- package/dist-lib/numbl-core/executors/jit/valueAdapter.d.ts +48 -0
- package/dist-lib/numbl-core/executors/jit/valueAdapterC.d.ts +108 -0
- package/dist-lib/numbl-core/executors/lowering.d.ts +120 -0
- package/dist-lib/numbl-core/executors/plugins.d.ts +32 -0
- package/dist-lib/numbl-core/executors/registry.d.ts +148 -0
- package/dist-lib/numbl-core/executors/types.d.ts +103 -0
- package/dist-lib/numbl-core/functionResolve.d.ts +7 -0
- package/dist-lib/numbl-core/helpers/check-helpers.d.ts +4 -5
- package/dist-lib/numbl-core/helpers/linsolve.d.ts +2 -3
- package/dist-lib/numbl-core/helpers/prng.d.ts +1 -2
- package/dist-lib/numbl-core/helpers/reduction-helpers.d.ts +4 -1
- package/dist-lib/numbl-core/interpreter/builtins/datetime.d.ts +2 -1
- package/dist-lib/numbl-core/interpreter/builtins/index.d.ts +1 -1
- package/dist-lib/numbl-core/interpreter/builtins/misc.d.ts +4 -1
- package/dist-lib/numbl-core/interpreter/builtins/types.d.ts +4 -109
- package/dist-lib/numbl-core/interpreter/interpreter.d.ts +51 -49
- package/dist-lib/numbl-core/interpreter/interpreterExec.d.ts +6 -0
- package/dist-lib/numbl-core/interpreter/interpreterSpecialBuiltins.d.ts +6 -3
- package/dist-lib/numbl-core/interpreter/types.d.ts +27 -12
- package/dist-lib/numbl-core/jit/builtins/defs/_shared.d.ts +43 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/_elemwise.d.ts +123 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/minus.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/mpower.d.ts +12 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/mrdivide.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/mtimes.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/plus.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/power.d.ts +30 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/rdivide.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/times.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/arithmetic/uminus.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/_compare.d.ts +12 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/eq.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/ge.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/gt.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/le.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/lt.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/compare/ne.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/diag/assert.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/defs/io/_format_args.d.ts +17 -0
- package/dist-lib/numbl-core/jit/builtins/defs/io/disp.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/io/error.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/io/fprintf.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/io/sprintf.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/io/warning.d.ts +15 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/_shortcircuit.d.ts +30 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/_unary_pred.d.ts +30 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/and.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/andand.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/boolconst.d.ts +3 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/classBuiltin.d.ts +21 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/fieldnames.d.ts +15 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isa.d.ts +13 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/iscell.d.ts +8 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isempty.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isequal.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isfield.d.ts +20 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isinf.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isnan.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isnumeric.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isreal.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isscalar.d.ts +20 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/isstruct.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/logical.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/not.d.ts +15 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/or.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/oror.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/strcmp.d.ts +21 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/typequery.d.ts +10 -0
- package/dist-lib/numbl-core/jit/builtins/defs/logical/xor.d.ts +12 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/_complex_fold.d.ts +34 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/_unary_real.d.ts +51 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/abs.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/angle.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/asinh.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/atan.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/atan2.d.ts +3 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/besselh.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/ceil.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/conj.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/constants.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/cos.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/cosh.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/dot.d.ts +20 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/double.d.ts +28 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/exp.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/fix.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/floor.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/hypot.d.ts +3 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/imag.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/linspace.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/log.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/log10.d.ts +3 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/log2.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/logspace.d.ts +8 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/mod.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/norm.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/real.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/rem.d.ts +3 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/round.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/sign.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/sin.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/sinh.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/sqrt.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/tan.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/tanh.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/math/uniquetol.d.ts +22 -0
- package/dist-lib/numbl-core/jit/builtins/defs/plot/dispatch.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/_cumulative.d.ts +49 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/_shape.d.ts +126 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/_variance.d.ts +17 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/all.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/any.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/cummax.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/cummin.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/cumprod.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/cumsum.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/diff.d.ts +16 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/length.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/max.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/mean.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/min.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/numel.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/prod.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/std.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/sum.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/reduction/var.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/_construct.d.ts +67 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/_triangular.d.ts +34 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/cat.d.ts +33 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/diag.d.ts +29 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/eye.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/flip.d.ts +7 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/meshgrid.d.ts +12 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/ones.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/repmat.d.ts +37 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/reshape.d.ts +39 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/size.d.ts +20 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/sort.d.ts +19 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/transpose.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/tril.d.ts +16 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/triu.d.ts +16 -0
- package/dist-lib/numbl-core/jit/builtins/defs/shape/zeros.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/defs/system/deal.d.ts +20 -0
- package/dist-lib/numbl-core/jit/builtins/defs/system/feval.d.ts +36 -0
- package/dist-lib/numbl-core/jit/builtins/defs/system/pathBuiltins.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/defs/system/tic.d.ts +8 -0
- package/dist-lib/numbl-core/jit/builtins/defs/system/toc.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/index.d.ts +16 -0
- package/dist-lib/numbl-core/jit/builtins/registry.d.ts +138 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/cell/cell.d.ts +24 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/indexing/loop_count.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/indexing/range_value.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/indexing/scalar_index.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/indexing/tensor_make_range.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/assert_fmt.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_complex.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_double.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_struct.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_tensor.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/disp_tensor_complex.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/error_fmt.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/format_complex.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/format_double.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/format_engine.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/fprintf.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/sprintf.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/io/warning_fmt.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/plot/plot_dispatch.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/snippets.gen.d.ts +86 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/system/cdiv.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/system/cscalar.d.ts +103 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/system/deep_clone.d.ts +1 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/system/isequal.d.ts +2 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/system/tictoc.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc_nd.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_alloc_nd_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_copy_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_matrix.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_matrix_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_row.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor/tensor_from_row_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_cat.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_cumulative.d.ts +32 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_diag.d.ts +33 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_diff.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_dot.d.ts +16 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_complex.d.ts +90 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real.d.ts +75 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_elemwise_real_fn.d.ts +95 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_eye.d.ts +10 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_fill_nd.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_fill_square.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_flip.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_linspace.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_logical_real.d.ts +10 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_logspace.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_meshgrid.d.ts +29 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_mtimes_complex.d.ts +10 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_mtimes_real.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_norm.d.ts +4 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_ones_nd.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_ones_square.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_predicate.d.ts +42 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_complex.d.ts +53 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reduce_real.d.ts +42 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_repmat.d.ts +11 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reshape_nd.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_reshape_nd_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_size.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_sort_real.d.ts +36 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_transpose.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_transpose_complex.d.ts +6 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_triangular.d.ts +22 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_complex_math.d.ts +128 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_unary_real_math.d.ts +95 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_uniquetol.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_var.d.ts +12 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_zeros_nd.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/tensor_ops/tensor_zeros_square.d.ts +5 -0
- package/dist-lib/numbl-core/jit/builtins/runtime/text/strcmp.d.ts +2 -0
- package/dist-lib/numbl-core/jit/codegen/cFormat.d.ts +36 -0
- package/dist-lib/numbl-core/jit/codegen/cHelpers.d.ts +48 -0
- package/dist-lib/numbl-core/jit/codegen/emit.d.ts +55 -0
- package/dist-lib/numbl-core/jit/codegen/emitCellTypedef.d.ts +23 -0
- package/dist-lib/numbl-core/jit/codegen/emitExpr.d.ts +33 -0
- package/dist-lib/numbl-core/jit/codegen/emitIndex.d.ts +56 -0
- package/dist-lib/numbl-core/jit/codegen/emitJs.d.ts +64 -0
- package/dist-lib/numbl-core/jit/codegen/emitNamedTypedef.d.ts +58 -0
- package/dist-lib/numbl-core/jit/codegen/emitStmt.d.ts +76 -0
- package/dist-lib/numbl-core/jit/codegen/emitTensorConcat.d.ts +23 -0
- package/dist-lib/numbl-core/jit/codegen/emitTensorConcatJs.d.ts +16 -0
- package/dist-lib/numbl-core/jit/codegen/emitTensorFused.d.ts +77 -0
- package/dist-lib/numbl-core/jit/codegen/inlinePass.d.ts +66 -0
- package/dist-lib/numbl-core/jit/codegen/liveness.d.ts +58 -0
- package/dist-lib/numbl-core/jit/codegen/prettyIR.d.ts +24 -0
- package/dist-lib/numbl-core/jit/codegen/runtime.d.ts +150 -0
- package/dist-lib/numbl-core/jit/compileSpec.d.ts +84 -0
- package/dist-lib/numbl-core/jit/compileSpecC.d.ts +93 -0
- package/dist-lib/numbl-core/jit/index.d.ts +13 -5
- package/dist-lib/numbl-core/jit/lowering/classDefs.d.ts +109 -0
- package/dist-lib/numbl-core/jit/lowering/errors.d.ts +35 -0
- package/dist-lib/numbl-core/jit/lowering/indexFold.d.ts +31 -0
- package/dist-lib/numbl-core/jit/lowering/indexResolve.d.ts +100 -0
- package/dist-lib/numbl-core/jit/lowering/ir.d.ts +584 -0
- package/dist-lib/numbl-core/jit/lowering/lower.d.ts +271 -0
- package/dist-lib/numbl-core/jit/lowering/lowerCellIndex.d.ts +41 -0
- package/dist-lib/numbl-core/jit/lowering/lowerCellLit.d.ts +19 -0
- package/dist-lib/numbl-core/jit/lowering/lowerClassConstructor.d.ts +55 -0
- package/dist-lib/numbl-core/jit/lowering/lowerFuncCall.d.ts +34 -0
- package/dist-lib/numbl-core/jit/lowering/lowerHandle.d.ts +57 -0
- package/dist-lib/numbl-core/jit/lowering/lowerIndexLoad.d.ts +16 -0
- package/dist-lib/numbl-core/jit/lowering/lowerIndexSlice.d.ts +29 -0
- package/dist-lib/numbl-core/jit/lowering/lowerIndexSliceStore.d.ts +19 -0
- package/dist-lib/numbl-core/jit/lowering/lowerIndexStore.d.ts +14 -0
- package/dist-lib/numbl-core/jit/lowering/lowerMethodCall.d.ts +45 -0
- package/dist-lib/numbl-core/jit/lowering/lowerMultiAssign.d.ts +36 -0
- package/dist-lib/numbl-core/jit/lowering/lowerTensorLit.d.ts +25 -0
- package/dist-lib/numbl-core/jit/lowering/rangeCount.d.ts +19 -0
- package/dist-lib/numbl-core/jit/lowering/specialize.d.ts +93 -0
- package/dist-lib/numbl-core/jit/lowering/types.d.ts +503 -0
- package/dist-lib/numbl-core/jit/lowering/walk.d.ts +17 -0
- package/dist-lib/numbl-core/jit/numbl/index.d.ts +30 -0
- package/dist-lib/numbl-core/jit/parser/astUtils.d.ts +43 -0
- package/dist-lib/numbl-core/jit/parser/index.d.ts +12 -0
- package/dist-lib/numbl-core/jit/parser/sourceLoc.d.ts +12 -0
- package/dist-lib/numbl-core/jit/runtime/context.d.ts +23 -0
- package/dist-lib/numbl-core/jit/runtime/inferType.d.ts +10 -0
- package/dist-lib/numbl-core/jit/runtime/value.d.ts +101 -0
- package/dist-lib/numbl-core/jit/workspace/driverPrologue.d.ts +59 -0
- package/dist-lib/numbl-core/jit/workspace/mtoc2UserFunctionLoader.d.ts +62 -0
- package/dist-lib/numbl-core/jit/workspace/workspace.d.ts +243 -0
- package/dist-lib/numbl-core/jitTypes.d.ts +94 -0
- package/dist-lib/numbl-core/jsUserFunctions.d.ts +10 -2
- package/dist-lib/numbl-core/lowering/loweringContext.d.ts +24 -0
- package/dist-lib/numbl-core/native/lapack-bridge.d.ts +3 -3
- package/dist-lib/numbl-core/parser/ClassParser.d.ts +3 -0
- package/dist-lib/numbl-core/parser/types.d.ts +20 -0
- package/dist-lib/numbl-core/runtime/alloc.d.ts +12 -23
- package/dist-lib/numbl-core/runtime/constructors.d.ts +6 -6
- package/dist-lib/numbl-core/runtime/cow.d.ts +33 -0
- package/dist-lib/numbl-core/runtime/index.d.ts +4 -3
- package/dist-lib/numbl-core/runtime/indexing.d.ts +17 -2
- package/dist-lib/numbl-core/runtime/plotBuiltinDispatch.d.ts +86 -0
- package/dist-lib/numbl-core/runtime/plotUtils.d.ts +17 -2
- package/dist-lib/numbl-core/runtime/refcount.d.ts +85 -0
- package/dist-lib/numbl-core/runtime/runtime.d.ts +43 -67
- package/dist-lib/numbl-core/runtime/runtimeDispatch.d.ts +2 -2
- package/dist-lib/numbl-core/runtime/runtimeIndexing.d.ts +2 -2
- package/dist-lib/numbl-core/runtime/runtimeMemberAccess.d.ts +1 -1
- package/dist-lib/numbl-core/runtime/runtimePlot.d.ts +1 -0
- package/dist-lib/numbl-core/runtime/struct-access.d.ts +2 -1
- package/dist-lib/numbl-core/runtime/types.d.ts +117 -62
- package/dist-lib/numbl-core/runtime/utils.d.ts +2 -8
- package/dist-lib/numbl-core/version.d.ts +1 -1
- package/dist-lib/numbl-core/workspace/types.d.ts +8 -0
- package/dist-plot-viewer/assets/index-COAM8o1E.js +4426 -0
- package/dist-plot-viewer/index.html +1 -1
- package/dist-site-viewer/404.html +33 -0
- package/dist-site-viewer/assets/index-CgBUy7v7.js +4748 -0
- package/dist-site-viewer/assets/index-D5YY8PKx.css +1 -0
- package/dist-site-viewer/assets/numbl-worker-VkVtodCX.js +11836 -0
- package/dist-site-viewer/coi-serviceworker.js +70 -0
- package/dist-site-viewer/favicon.svg +23 -0
- package/dist-site-viewer/index.html +16 -0
- package/dist-site-viewer/logo.svg +26 -0
- package/dist-site-viewer/numbl-embed.js +111 -0
- package/dist-site-viewer/vite.svg +1 -0
- package/native/lapack_linsolve.cpp +1 -1
- package/native/numbl_addon_common.h +2 -2
- package/native/ops/comparison.c +1 -1
- package/native/ops/real_unary_elemwise.c +3 -1
- package/package.json +16 -13
- package/dist-lib/numbl-core/jit/c/abi.d.ts +0 -90
- package/dist-lib/numbl-core/jit/c/assemble.d.ts +0 -56
- package/dist-lib/numbl-core/jit/c/classify.d.ts +0 -70
- package/dist-lib/numbl-core/jit/c/compile.d.ts +0 -37
- package/dist-lib/numbl-core/jit/c/context.d.ts +0 -152
- package/dist-lib/numbl-core/jit/c/emit/assign.d.ts +0 -20
- package/dist-lib/numbl-core/jit/c/emit/complexScalar.d.ts +0 -18
- package/dist-lib/numbl-core/jit/c/emit/fused.d.ts +0 -42
- package/dist-lib/numbl-core/jit/c/emit/helpers.d.ts +0 -40
- package/dist-lib/numbl-core/jit/c/emit/index.d.ts +0 -14
- package/dist-lib/numbl-core/jit/c/emit/scalar.d.ts +0 -23
- package/dist-lib/numbl-core/jit/c/emit/stmt.d.ts +0 -25
- package/dist-lib/numbl-core/jit/c/emit/tensor.d.ts +0 -127
- package/dist-lib/numbl-core/jit/c/emit/userCall.d.ts +0 -58
- package/dist-lib/numbl-core/jit/c/epilogue.d.ts +0 -26
- package/dist-lib/numbl-core/jit/c/feasibility.d.ts +0 -44
- package/dist-lib/numbl-core/jit/c/prelude.d.ts +0 -37
- package/dist-lib/numbl-core/jit/c/visit.d.ts +0 -63
- package/dist-lib/numbl-core/jit/e1/complexKernelEmit.d.ts +0 -46
- package/dist-lib/numbl-core/jit/e1/hash.d.ts +0 -10
- package/dist-lib/numbl-core/jit/e1/install.d.ts +0 -13
- package/dist-lib/numbl-core/jit/e1/kernelEmit.d.ts +0 -54
- package/dist-lib/numbl-core/jit/e1/multiReductionKernel.d.ts +0 -66
- package/dist-lib/numbl-core/jit/e1/openmpFlag.d.ts +0 -13
- package/dist-lib/numbl-core/jit/e1/scalarFnKernel.d.ts +0 -44
- package/dist-lib/numbl-core/jit/e2/assignKernel.d.ts +0 -34
- package/dist-lib/numbl-core/jit/e2/astToJitExpr.d.ts +0 -25
- package/dist-lib/numbl-core/jit/e2/cache.d.ts +0 -80
- package/dist-lib/numbl-core/jit/e2/chainKernelEmit.d.ts +0 -55
- package/dist-lib/numbl-core/jit/e2/classify.d.ts +0 -119
- package/dist-lib/numbl-core/jit/e2/compileFn.d.ts +0 -16
- package/dist-lib/numbl-core/jit/e2/complexChainKernelEmit.d.ts +0 -79
- package/dist-lib/numbl-core/jit/e2/emitShared.d.ts +0 -71
- package/dist-lib/numbl-core/jit/e2/install.d.ts +0 -11
- package/dist-lib/numbl-core/jit/e2/liveness.d.ts +0 -29
- package/dist-lib/numbl-core/jit/e2/loopKernel.d.ts +0 -49
- package/dist-lib/numbl-core/jit/e2/loopKernelEmit.d.ts +0 -75
- package/dist-lib/numbl-core/jit/e2/multiReductionDriver.d.ts +0 -24
- package/dist-lib/numbl-core/jit/e2/reductionKernelEmit.d.ts +0 -72
- package/dist-lib/numbl-core/jit/e2/scalarFnDriver.d.ts +0 -29
- package/dist-lib/numbl-core/jit/fusedChainHelpers.d.ts +0 -65
- package/dist-lib/numbl-core/jit/fusedScalarEmit.d.ts +0 -69
- package/dist-lib/numbl-core/jit/fusion.d.ts +0 -71
- package/dist-lib/numbl-core/jit/fusionOps.d.ts +0 -25
- package/dist-lib/numbl-core/jit/heavyOps.d.ts +0 -15
- package/dist-lib/numbl-core/jit/jitBailSafety.d.ts +0 -41
- package/dist-lib/numbl-core/jit/jitLoop.d.ts +0 -25
- package/dist-lib/numbl-core/jit/jitLoopAnalysis.d.ts +0 -37
- package/dist-lib/numbl-core/jit/jitLower.d.ts +0 -122
- package/dist-lib/numbl-core/jit/jitLowerExpr.d.ts +0 -27
- package/dist-lib/numbl-core/jit/jitLowerStmt.d.ts +0 -9
- package/dist-lib/numbl-core/jit/jitLowerTypes.d.ts +0 -29
- package/dist-lib/numbl-core/jit/jitTopLevel.d.ts +0 -22
- package/dist-lib/numbl-core/jit/jitTypes.d.ts +0 -394
- package/dist-lib/numbl-core/jit/js/jitCodegen.d.ts +0 -7
- package/dist-lib/numbl-core/jit/js/jitCodegenHoist.d.ts +0 -70
- package/dist-lib/numbl-core/jit/js/jitHelpers.d.ts +0 -34
- package/dist-lib/numbl-core/jit/js/jitHelpersComplex.d.ts +0 -21
- package/dist-lib/numbl-core/jit/js/jitHelpersIndex.d.ts +0 -33
- package/dist-lib/numbl-core/jit/js/jitHelpersTensor.d.ts +0 -34
- package/dist-lib/numbl-core/jit/js/jsFusedCodegen.d.ts +0 -17
- package/dist-lib/numbl-core/jit/js/jsMultiReduction.d.ts +0 -70
- package/dist-lib/numbl-core/jit/scalarEmit.d.ts +0 -58
- package/dist-plot-viewer/assets/index-GiUNnMQg.js +0 -4426
- package/native/jit_runtime/jit_runtime.c +0 -261
- package/native/jit_runtime/jit_runtime.h +0 -204
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
export function mtoc2_tensor_cos(a: any): {
|
|
2
|
+
mtoc2Tag: string;
|
|
3
|
+
shape: any;
|
|
4
|
+
data: any;
|
|
5
|
+
};
|
|
6
|
+
export function mtoc2_tensor_sin(a: any): {
|
|
7
|
+
mtoc2Tag: string;
|
|
8
|
+
shape: any;
|
|
9
|
+
data: any;
|
|
10
|
+
};
|
|
11
|
+
export function mtoc2_tensor_tan(a: any): {
|
|
12
|
+
mtoc2Tag: string;
|
|
13
|
+
shape: any;
|
|
14
|
+
data: any;
|
|
15
|
+
};
|
|
16
|
+
export function mtoc2_tensor_atan(a: any): {
|
|
17
|
+
mtoc2Tag: string;
|
|
18
|
+
shape: any;
|
|
19
|
+
data: any;
|
|
20
|
+
};
|
|
21
|
+
export function mtoc2_tensor_sinh(a: any): {
|
|
22
|
+
mtoc2Tag: string;
|
|
23
|
+
shape: any;
|
|
24
|
+
data: any;
|
|
25
|
+
};
|
|
26
|
+
export function mtoc2_tensor_cosh(a: any): {
|
|
27
|
+
mtoc2Tag: string;
|
|
28
|
+
shape: any;
|
|
29
|
+
data: any;
|
|
30
|
+
};
|
|
31
|
+
export function mtoc2_tensor_tanh(a: any): {
|
|
32
|
+
mtoc2Tag: string;
|
|
33
|
+
shape: any;
|
|
34
|
+
data: any;
|
|
35
|
+
};
|
|
36
|
+
export function mtoc2_tensor_asinh(a: any): {
|
|
37
|
+
mtoc2Tag: string;
|
|
38
|
+
shape: any;
|
|
39
|
+
data: any;
|
|
40
|
+
};
|
|
41
|
+
export function mtoc2_tensor_exp(a: any): {
|
|
42
|
+
mtoc2Tag: string;
|
|
43
|
+
shape: any;
|
|
44
|
+
data: any;
|
|
45
|
+
};
|
|
46
|
+
export function mtoc2_tensor_log(a: any): {
|
|
47
|
+
mtoc2Tag: string;
|
|
48
|
+
shape: any;
|
|
49
|
+
data: any;
|
|
50
|
+
};
|
|
51
|
+
export function mtoc2_tensor_log2(a: any): {
|
|
52
|
+
mtoc2Tag: string;
|
|
53
|
+
shape: any;
|
|
54
|
+
data: any;
|
|
55
|
+
};
|
|
56
|
+
export function mtoc2_tensor_log10(a: any): {
|
|
57
|
+
mtoc2Tag: string;
|
|
58
|
+
shape: any;
|
|
59
|
+
data: any;
|
|
60
|
+
};
|
|
61
|
+
export function mtoc2_tensor_sqrt(a: any): {
|
|
62
|
+
mtoc2Tag: string;
|
|
63
|
+
shape: any;
|
|
64
|
+
data: any;
|
|
65
|
+
};
|
|
66
|
+
export function mtoc2_tensor_abs(a: any): {
|
|
67
|
+
mtoc2Tag: string;
|
|
68
|
+
shape: any;
|
|
69
|
+
data: any;
|
|
70
|
+
};
|
|
71
|
+
export function mtoc2_tensor_floor(a: any): {
|
|
72
|
+
mtoc2Tag: string;
|
|
73
|
+
shape: any;
|
|
74
|
+
data: any;
|
|
75
|
+
};
|
|
76
|
+
export function mtoc2_tensor_ceil(a: any): {
|
|
77
|
+
mtoc2Tag: string;
|
|
78
|
+
shape: any;
|
|
79
|
+
data: any;
|
|
80
|
+
};
|
|
81
|
+
export function mtoc2_tensor_fix(a: any): {
|
|
82
|
+
mtoc2Tag: string;
|
|
83
|
+
shape: any;
|
|
84
|
+
data: any;
|
|
85
|
+
};
|
|
86
|
+
export function mtoc2_tensor_round(a: any): {
|
|
87
|
+
mtoc2Tag: string;
|
|
88
|
+
shape: any;
|
|
89
|
+
data: any;
|
|
90
|
+
};
|
|
91
|
+
export function mtoc2_tensor_sign(a: any): {
|
|
92
|
+
mtoc2Tag: string;
|
|
93
|
+
shape: any;
|
|
94
|
+
data: any;
|
|
95
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function mtoc2_var_all(t: any, w: any): any;
|
|
2
|
+
export function mtoc2_var_dim(t: any, dim: any, w: any): {
|
|
3
|
+
mtoc2Tag: string;
|
|
4
|
+
shape: any;
|
|
5
|
+
data: any;
|
|
6
|
+
};
|
|
7
|
+
export function mtoc2_std_all(t: any, w: any): any;
|
|
8
|
+
export function mtoc2_std_dim(t: any, dim: any, w: any): {
|
|
9
|
+
mtoc2Tag: string;
|
|
10
|
+
shape: any;
|
|
11
|
+
data: any;
|
|
12
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure C-source formatting utilities used by the codegen modules. No
|
|
3
|
+
* runtime-state threading, no IR dependencies — string in, string out.
|
|
4
|
+
* Lives separately so the emit-* modules can import them without
|
|
5
|
+
* cycling through emit.ts.
|
|
6
|
+
*/
|
|
7
|
+
import type { Type } from "../lowering/types.js";
|
|
8
|
+
/** Encode `s` as a C string literal `"..."` whose bytes are the UTF-8
|
|
9
|
+
* encoding of `s`. Returns `{ lit, byteLen }` where `byteLen` is the
|
|
10
|
+
* encoded byte count (excluding the trailing NUL). Non-printable bytes
|
|
11
|
+
* use `\xHH`; backslash/quote/standard whitespace use the C escapes.
|
|
12
|
+
*
|
|
13
|
+
* Why hex over `\uHHHH`: narrow C string literals don't accept
|
|
14
|
+
* universal-character names; we need byte-level escapes to keep the
|
|
15
|
+
* emitted code portable. */
|
|
16
|
+
export declare function cStringLiteral(s: string): {
|
|
17
|
+
lit: string;
|
|
18
|
+
byteLen: number;
|
|
19
|
+
};
|
|
20
|
+
/** Format a Span as a quoted "<file>:<offset>" string literal for
|
|
21
|
+
* passing to a runtime helper. The file path is JSON-escaped (the
|
|
22
|
+
* emitter already requires a single C-string-safe form), and the
|
|
23
|
+
* offset is the byte offset of the violating expression — matches
|
|
24
|
+
* the format used by translate-time `UnsupportedConstruct` errors,
|
|
25
|
+
* so the user sees a familiar location for runtime OOB too. */
|
|
26
|
+
export declare function locStringOf(span: {
|
|
27
|
+
file: string;
|
|
28
|
+
start: number;
|
|
29
|
+
}): string;
|
|
30
|
+
/** Build the C expression for `numel(<cName>)` as the product of its
|
|
31
|
+
* per-axis `.dims[i]` slots. Returns `"0L"` for an empty / non-numeric
|
|
32
|
+
* type so the emitted C still parses on degenerate inputs. */
|
|
33
|
+
export declare function dimsProductExpr(cName: string, ty: Type): string;
|
|
34
|
+
/** Compute the column-major linear offset for an N-D access given
|
|
35
|
+
* per-axis source terms and a stride source. */
|
|
36
|
+
export declare function formatNdOffset(terms: ReadonlyArray<string>, stride: (axisIndex: number) => string): string;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared C-type and owned-helper renderers used by both `emit.ts` and
|
|
3
|
+
* `emitNamedTypedef.ts`. Lives in its own module so the two emitters
|
|
4
|
+
* don't have to import each other (the previous arrangement had
|
|
5
|
+
* `emitNamedTypedef.ts` duplicating these helpers to avoid a circular
|
|
6
|
+
* import).
|
|
7
|
+
*/
|
|
8
|
+
import { type Type } from "../lowering/types.js";
|
|
9
|
+
/** C type for any mtoc2 IR-typed value: tensor / string / char →
|
|
10
|
+
* per-kind runtime struct; struct / class / handle → per-shape
|
|
11
|
+
* generated typedef; everything else (scalar real numeric) → `double`. */
|
|
12
|
+
export declare function cTypeFor(t: Type): string;
|
|
13
|
+
/** Per-owned-kind helper-name family. Tensors / strings / chars use
|
|
14
|
+
* the global `mtoc2_*` runtime snippet names; structs, classes, and
|
|
15
|
+
* handles use their program-emitted `<typedef>_*` family. */
|
|
16
|
+
export interface OwnedHelpers {
|
|
17
|
+
empty: string;
|
|
18
|
+
assign: string;
|
|
19
|
+
copy: string;
|
|
20
|
+
free: string;
|
|
21
|
+
/** When true, `empty`/`assign`/`copy`/`free` are loaded from the
|
|
22
|
+
* runtime snippet registry. When false, they're emitted directly
|
|
23
|
+
* into the generated C by `emitNamedTypedef` and need no
|
|
24
|
+
* `useRuntimeByName` activation. */
|
|
25
|
+
isRuntime: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Owned-helper family for any type. Returns `null` for non-owned
|
|
28
|
+
* (POD) types — those get plain assignment / no copy / no free. */
|
|
29
|
+
export declare function ownedHelpersFor(t: Type): OwnedHelpers | null;
|
|
30
|
+
/** Asserting form: returns helpers for a type known to be owned, and
|
|
31
|
+
* throws if it isn't. Use this at sites where the caller has already
|
|
32
|
+
* proven the type is owned (e.g. via `isOwned(t)`) and the null check
|
|
33
|
+
* would be a redundant nuisance. */
|
|
34
|
+
export declare function requireOwnedHelpers(t: Type): OwnedHelpers;
|
|
35
|
+
/** C expression that disps one value of type `t`, including the
|
|
36
|
+
* trailing newline that matches numbl's `disp` contract. Activates
|
|
37
|
+
* any runtime snippets the chosen helper needs via `useRuntime`.
|
|
38
|
+
* Returns `null` when no disp helper exists for the type (Class /
|
|
39
|
+
* Handle / Void / Unknown — call sites decide whether to skip or
|
|
40
|
+
* raise). Single dispatch shared by the `disp` builtin's `emitC`
|
|
41
|
+
* and the per-field disp inside struct typedefs, so the two can't
|
|
42
|
+
* drift apart when a new value kind becomes a valid struct field. */
|
|
43
|
+
export declare function emitDispCallC(t: Type, valueC: string, useRuntime: (name: string) => void): string | null;
|
|
44
|
+
/** Format a JS number as a C double literal that round-trips. Single
|
|
45
|
+
* source of truth — both the per-expression emit path and the fused
|
|
46
|
+
* per-element template emitter route through here so NaN / ±Infinity
|
|
47
|
+
* format consistently as `NAN` / `INFINITY` / `(-INFINITY)`. */
|
|
48
|
+
export declare function formatDouble(v: number): string;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-file C codegen for mtoc2 IR. Emits:
|
|
3
|
+
* 1. Standard headers + activated runtime snippets (in dep order).
|
|
4
|
+
* 2. Forward declarations for user-function specializations.
|
|
5
|
+
* 3. Function specialization bodies.
|
|
6
|
+
* 4. `main()` containing top-level statements.
|
|
7
|
+
*
|
|
8
|
+
* Scalars compile to bare `double`. Multi-element tensors compile to
|
|
9
|
+
* `mtoc2_tensor_t` — no refcount, no COW. The codegen invariant
|
|
10
|
+
* (matching mtoc's): every tensor RHS is freshly owned, every
|
|
11
|
+
* ownership-transferring use of a Var read wraps in
|
|
12
|
+
* `mtoc2_tensor_copy(name)`. Pre-declaration of every owned local
|
|
13
|
+
* via `mtoc2_tensor_empty()` at function top makes the first-vs-
|
|
14
|
+
* later distinction uniform (the assign helper releases the prior
|
|
15
|
+
* buffer, which is NULL on first call). Scope-exit emits a
|
|
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
|
+
*/
|
|
24
|
+
import type { IRProgram } from "../lowering/ir.js";
|
|
25
|
+
import { type Type } from "../lowering/types.js";
|
|
26
|
+
import { type RuntimeState } from "./runtime.js";
|
|
27
|
+
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;
|
|
48
|
+
}
|
|
49
|
+
export declare function emitProgram(prog: IRProgram, opts?: EmitOptions): string;
|
|
50
|
+
export declare function activateOwnedRuntime(t: Type, state: RuntimeState): void;
|
|
51
|
+
/** Activate the runtime snippets needed for an owned type AND return
|
|
52
|
+
* its OwnedHelpers descriptor. Shorthand for the
|
|
53
|
+
* `activateOwnedRuntime(t, state); requireOwnedHelpers(t)` pair that
|
|
54
|
+
* appears at every owned-codegen site. */
|
|
55
|
+
export declare function activatedOwnedHelpers(t: Type, state: RuntimeState): import("./cHelpers.js").OwnedHelpers;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-shape cell-array typedef + owned-helper emission. Sibling of
|
|
3
|
+
* `emitNamedTypedef` (which covers struct / class / handle). Cells
|
|
4
|
+
* differ enough that they get their own emitter:
|
|
5
|
+
*
|
|
6
|
+
* - **tuple-mode** cells have one C field per slot
|
|
7
|
+
* (`slot_0`, `slot_1`, …, `slot_{n-1}`) — direct analogue of a
|
|
8
|
+
* struct with positional fields. Helpers walk each slot once.
|
|
9
|
+
* - **uniform-mode** cells have a small descriptor (`ndim`, `dims[]`,
|
|
10
|
+
* `slots[]`) and a heap-allocated slot buffer. Helpers loop over
|
|
11
|
+
* the slot count, calling the elem type's owned helpers on each.
|
|
12
|
+
*
|
|
13
|
+
* Both modes ship the same five-helper family used elsewhere
|
|
14
|
+
* (`_empty / _assign / _copy / _free / _disp`).
|
|
15
|
+
*
|
|
16
|
+
* Output format for `disp(c)` matches numbl's `formatCell`
|
|
17
|
+
* (`runtime/display.ts:244-251`): single line `{e1, e2, ...}` with
|
|
18
|
+
* chars in `'...'`, strings in `"..."`, other values via the
|
|
19
|
+
* scalar / tensor / struct disp helper. Empty cell renders as `{}`.
|
|
20
|
+
*/
|
|
21
|
+
import { type CellType } from "../lowering/types.js";
|
|
22
|
+
import { type RuntimeState } from "./runtime.js";
|
|
23
|
+
export declare function emitCellTypedef(t: CellType, state: RuntimeState): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `emitExpr` and the per-IRExpr-kind helpers that don't belong in
|
|
3
|
+
* their own module. The big switch dispatches on `IRExpr.kind` and
|
|
4
|
+
* returns the C expression string. Owned-aware sites (Var copy,
|
|
5
|
+
* StructLit owned fields, …) route through `emitOwnedRhs`, which is
|
|
6
|
+
* also defined here so the regular-expression and consume-site emit
|
|
7
|
+
* paths share a single source of truth.
|
|
8
|
+
*/
|
|
9
|
+
import type { IRExpr } from "../lowering/ir.js";
|
|
10
|
+
import { type RuntimeState } from "./runtime.js";
|
|
11
|
+
/** Owned-typed RHS for an Assign or MemberStore (or a Call arg that
|
|
12
|
+
* binds to an owned callee param). Every owned C value produced
|
|
13
|
+
* here is freshly-owned; the consumer's `_assign` helper releases
|
|
14
|
+
* the prior slot and consumes the rhs.
|
|
15
|
+
*
|
|
16
|
+
* - `Var` → `<type>_copy(name)` (deep copy)
|
|
17
|
+
* - `MemberLoad` → `<type>_copy(<base>.<field>)` (the load
|
|
18
|
+
* itself is a struct-by-value read; we wrap
|
|
19
|
+
* it in copy so the consumer gets a freshly-
|
|
20
|
+
* owned buffer)
|
|
21
|
+
* - `HandleCaptureLoad` → `<type>_copy(<base>.cap_<name>)` (same
|
|
22
|
+
* rationale — the handle's capture slot is
|
|
23
|
+
* read by value and we copy it for the
|
|
24
|
+
* consumer)
|
|
25
|
+
* - anything else → `emitExpr` (TensorBuild / StructLit /
|
|
26
|
+
* HandleLit / Binary / Call etc. already
|
|
27
|
+
* emit fresh-allocating helpers) */
|
|
28
|
+
export declare function emitOwnedRhs(e: IRExpr, state: RuntimeState): string;
|
|
29
|
+
/** Lower a scalar cond expression to a C bool expression. Complex
|
|
30
|
+
* scalars use the numbl/MATLAB `creal(z) != 0 || cimag(z) != 0` rule
|
|
31
|
+
* via the `mtoc2_cnonzero` helper; real scalars compare against `0.0`. */
|
|
32
|
+
export declare function emitCondToBoolExpr(e: IRExpr, state: RuntimeState): string;
|
|
33
|
+
export declare function emitExpr(e: IRExpr, state: RuntimeState): string;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Index-related codegen — scalar offsets, slice slot setup, range and
|
|
3
|
+
* logical-mask setup, slice producer (`IndexSlice`), and slice store
|
|
4
|
+
* (`IndexSliceStore`). Shared by `emit.ts`'s `emitStmt` / `emitExpr`
|
|
5
|
+
* arms for IndexLoad / IndexStore / IndexSlice / IndexSliceStore.
|
|
6
|
+
*
|
|
7
|
+
* Everything here ultimately emits column-major offset arithmetic
|
|
8
|
+
* against an `mtoc2_tensor_t`'s `.real` / `.imag` flat buffers, with
|
|
9
|
+
* bounds checks via the `mtoc2_idx_*` / `mtoc2_check_*` runtime
|
|
10
|
+
* helpers (per-axis, per-linear-index, or full per-range).
|
|
11
|
+
*/
|
|
12
|
+
import type { IRExpr, IRStmt, IndexSliceArg } from "../lowering/ir.js";
|
|
13
|
+
import { type RuntimeState } from "./runtime.js";
|
|
14
|
+
/** Compute the column-major linear buffer offset for a scalar
|
|
15
|
+
* IndexLoad / IndexStore: 1-arg linear, 2-arg row/col, or N-arg N-D.
|
|
16
|
+
* Each axis index is wrapped in a runtime bounds-check call
|
|
17
|
+
* (`mtoc2_idx_axis` for per-axis; `mtoc2_idx_lin` for 1-arg linear)
|
|
18
|
+
* so an OOB access aborts with a numbl-style "Index exceeds array
|
|
19
|
+
* bounds" message instead of silently reading/writing past the
|
|
20
|
+
* buffer. Mirrors mtoc's `emitNdScalarOffset` — one source of truth
|
|
21
|
+
* for the offset formula.
|
|
22
|
+
*
|
|
23
|
+
* `grow` selects the indexed-STORE variant: the `*_grow` bounds
|
|
24
|
+
* checks bail (longjmp to the host-entry guard → host re-runs on the
|
|
25
|
+
* interpreter) instead of aborting when the index exceeds the extent,
|
|
26
|
+
* because a store past the end GROWS the array in MATLAB — which the
|
|
27
|
+
* JIT can't model. Reads pass `grow = false` (OOB is a genuine
|
|
28
|
+
* error). See `grow_bail.h`. */
|
|
29
|
+
export declare function emitNdScalarOffset(state: RuntimeState, indices: ReadonlyArray<IRExpr>, baseCName: string, grow?: boolean): string;
|
|
30
|
+
/** Emit per-slot setup for a multi-slot slice (read or write): pushes
|
|
31
|
+
* `_mtoc2_n_<i>` (per-slot iteration count) and any Range / Scalar
|
|
32
|
+
* locals into `lines`. Returns the per-slot source-index expression
|
|
33
|
+
* (in terms of `_mtoc2_k_<i>` for Colon/Range, or the precomputed
|
|
34
|
+
* `_mtoc2_src_<i>` local for Scalar slots).
|
|
35
|
+
*
|
|
36
|
+
* `cleanups`, when provided, is populated with lines that must run
|
|
37
|
+
* after the iter loop (currently used for LogicalMask slots to free
|
|
38
|
+
* the precomputed source-index buffer). The caller is expected to
|
|
39
|
+
* emit these lines immediately after closing the slot iteration
|
|
40
|
+
* loops and before the GCC statement-expression's yield expression. */
|
|
41
|
+
export declare function emitSliceSlotSetup(state: RuntimeState, lines: string[], indent: string, slotsTyped: ReadonlyArray<IndexSliceArg>, baseCName: string, cleanups?: string[]): string[];
|
|
42
|
+
/** Emit an `IndexSlice` as a C statement-expression-style block that
|
|
43
|
+
* allocates the result tensor, fills it, and evaluates to the result
|
|
44
|
+
* via a comma expression. The result is consumed at an owned consume
|
|
45
|
+
* site (`mtoc2_tensor_assign(&v, <here>)`); ANF guarantees IndexSlice
|
|
46
|
+
* appears only as the direct RHS of an Assign. */
|
|
47
|
+
export declare function emitIndexSliceProducer(e: Extract<IRExpr, {
|
|
48
|
+
kind: "IndexSlice";
|
|
49
|
+
}>, state: RuntimeState): string;
|
|
50
|
+
/** Emit an `IndexSliceStore` statement: mutate `base` in place.
|
|
51
|
+
* Member-rooted stores target a field slot `<rootCName>.<fieldPath>`
|
|
52
|
+
* with the field's NumericType replacing the (struct/class) base
|
|
53
|
+
* type for offset / complex-lane decisions. */
|
|
54
|
+
export declare function emitIndexSliceStore(s: Extract<IRStmt, {
|
|
55
|
+
kind: "IndexSliceStore";
|
|
56
|
+
}>, indent: string, state: RuntimeState): string;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Single-file JS codegen for mtoc2 IR. Mirrors `emit.ts` (the C path)
|
|
3
|
+
* intentionally — same control flow, same variable layout, same call
|
|
4
|
+
* shape — differing only in language and the I/O primitive (`$write(s)`
|
|
5
|
+
* vs `printf(...)`).
|
|
6
|
+
*
|
|
7
|
+
* Pass-by-value protocol: owned-typed RHSes (Var / MemberLoad /
|
|
8
|
+
* HandleCaptureLoad) at Assign, user-function Call args, and
|
|
9
|
+
* MultiAssignCall args route through `emitOwnedRhsJs`, which wraps
|
|
10
|
+
* the expression in `mtoc2_deep_clone(...)`. JS GC handles lifetime,
|
|
11
|
+
* but value-semantics still need an explicit copy — otherwise
|
|
12
|
+
* `b = a; b.f = rhs` would mutate `a`. Owned-producing expressions
|
|
13
|
+
* (TensorBuild, StructLit, HandleLit, fresh-allocating helpers) are
|
|
14
|
+
* left alone — they already yield a fresh value.
|
|
15
|
+
*
|
|
16
|
+
* Builtin dispatch routes through `builtin.emitJs`. If a needed
|
|
17
|
+
* builtin has no `emitJs` hook yet, `requireEmitJs` throws a clear
|
|
18
|
+
* "no emitJs hook" error.
|
|
19
|
+
*
|
|
20
|
+
* The emitted module has the shape:
|
|
21
|
+
* ```js
|
|
22
|
+
* <inlined runtime snippet bodies>
|
|
23
|
+
* function <user-fn-spec-1>(...) { ... }
|
|
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;
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* The CLI / engine evals the source via `new Function(source)(...)`
|
|
34
|
+
* which returns `run`, then invokes `run(ctx.helpers)`.
|
|
35
|
+
*/
|
|
36
|
+
import type { IRProgram } from "../lowering/ir.js";
|
|
37
|
+
import { type WorkspaceLike } from "./runtime.js";
|
|
38
|
+
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;
|
|
53
|
+
}
|
|
54
|
+
export interface EmitJsResult {
|
|
55
|
+
/** 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(...)`. */
|
|
59
|
+
source: string;
|
|
60
|
+
/** Names of every runtime snippet activated during emit (debug aid;
|
|
61
|
+
* also useful to gate dependency wiring in tests). */
|
|
62
|
+
activatedSnippets: ReadonlyArray<string>;
|
|
63
|
+
}
|
|
64
|
+
export declare function emitJsProgram(prog: IRProgram, opts?: EmitJsOptions): EmitJsResult;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-shape struct/class typedef + owned-helper emission.
|
|
3
|
+
*
|
|
4
|
+
* Structs and class instances live as generated C `typedef struct
|
|
5
|
+
* <name> { ... } <name>;` definitions, one per distinct canonical
|
|
6
|
+
* shape. Each typedef ships with the four owned-kind helpers —
|
|
7
|
+
* `_empty()`, `_assign()`, `_copy()`, `_free()` — so the existing
|
|
8
|
+
* codegen pipeline (predeclare at function top, scope-exit free,
|
|
9
|
+
* early-free, ANF) treats struct/class locals uniformly with tensors.
|
|
10
|
+
*
|
|
11
|
+
* Structs additionally get a `_disp()` helper used by `disp(s)`; v1
|
|
12
|
+
* doesn't emit `_disp` for class instances.
|
|
13
|
+
*
|
|
14
|
+
* The renderer walks each field once and emits the right helper
|
|
15
|
+
* pattern for that field:
|
|
16
|
+
* - scalar (Numeric / Handle / Unknown): plain C assignment / no
|
|
17
|
+
* free / no recursive copy.
|
|
18
|
+
* - owned (multi-element Numeric / nested Struct / nested Class):
|
|
19
|
+
* route through the field's own owned-kind helper family.
|
|
20
|
+
*
|
|
21
|
+
* Tensor fields call `mtoc2_tensor_*` directly; nested struct/class
|
|
22
|
+
* fields call the corresponding `<inner-typedef>_*` helper, so a
|
|
23
|
+
* topological order over the typedef-dependency graph guarantees each
|
|
24
|
+
* helper is defined before the one that uses it.
|
|
25
|
+
*/
|
|
26
|
+
import { type ClassType, type HandleType, type StructType, type Type } from "../lowering/types.js";
|
|
27
|
+
import { type RuntimeState } from "./runtime.js";
|
|
28
|
+
export interface NamedTypedefSpec {
|
|
29
|
+
/** Typedef name. The C output uses this as both the struct tag and
|
|
30
|
+
* the typedef alias. */
|
|
31
|
+
name: string;
|
|
32
|
+
/** Field list — canonical order (sorted by name). */
|
|
33
|
+
fields: ReadonlyArray<{
|
|
34
|
+
name: string;
|
|
35
|
+
ty: Type;
|
|
36
|
+
}>;
|
|
37
|
+
/** Emit a `_disp(value)` helper (true for structs, false for
|
|
38
|
+
* classes in v1). */
|
|
39
|
+
emitDisp: boolean;
|
|
40
|
+
/** Source description for the function-leading comment (e.g.
|
|
41
|
+
* `struct{x:double,y:double}` or `class Foo`). */
|
|
42
|
+
pretty: string;
|
|
43
|
+
}
|
|
44
|
+
/** Emit the typedef and its four (or five) owned-kind helpers as
|
|
45
|
+
* one block of C source. Activates any runtime snippets the helpers
|
|
46
|
+
* call into (e.g. `mtoc2_tensor_copy`). */
|
|
47
|
+
export declare function emitNamedTypedef(spec: NamedTypedefSpec, state: RuntimeState): string;
|
|
48
|
+
/** Helper for emit.ts: build a `NamedTypedefSpec` for a `StructType`. */
|
|
49
|
+
export declare function specForStruct(t: StructType): NamedTypedefSpec;
|
|
50
|
+
/** Helper for emit.ts: build a `NamedTypedefSpec` for a `ClassType`. */
|
|
51
|
+
export declare function specForClass(t: ClassType): NamedTypedefSpec;
|
|
52
|
+
/** Helper for emit.ts: build a `NamedTypedefSpec` for a `HandleType`.
|
|
53
|
+
* Captures map to fields named `cap_<captureName>` — matching the
|
|
54
|
+
* layout that `HandleCaptureLoad` codegen reads. The no-capture
|
|
55
|
+
* shape emits as a placeholder-bearing struct (handled by the empty-
|
|
56
|
+
* fields branch in `emitNamedTypedef`). Handles never emit `_disp` —
|
|
57
|
+
* `disp(handle)` is rejected at lowering. */
|
|
58
|
+
export declare function specForHandle(t: HandleType): NamedTypedefSpec;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function-shape + statement-level codegen — `emitFunction`,
|
|
3
|
+
* `emitBody`, `emitStmt`, and the locals-collection / param-list
|
|
4
|
+
* helpers they share. Statement emit is mutually recursive with body
|
|
5
|
+
* emit (If/While/For wrap nested bodies), so they live together.
|
|
6
|
+
*
|
|
7
|
+
* Expression-side emit lives in `emitExpr.ts`; index slice store /
|
|
8
|
+
* scalar offset and named-typedef helpers are in their own modules.
|
|
9
|
+
*/
|
|
10
|
+
import type { IRExpr, IRFunc, IRStmt } from "../lowering/ir.js";
|
|
11
|
+
import { type Type } from "../lowering/types.js";
|
|
12
|
+
import { type RuntimeState } from "./runtime.js";
|
|
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
|
+
export declare function fnRetType(fn: IRFunc): string;
|
|
20
|
+
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
|
+
/** Emits the function/scope's exit cleanup + return statements at a
|
|
40
|
+
* given indent. Called from two places: at every `ReturnFromFunction`
|
|
41
|
+
* site (inline cleanup — no goto), and at the fall-through bottom of
|
|
42
|
+
* the function. Single source of truth so the two callers can't
|
|
43
|
+
* drift on which locals get freed in what order.
|
|
44
|
+
*
|
|
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;
|
|
51
|
+
export declare function emitFunction(fn: IRFunc, state: RuntimeState,
|
|
52
|
+
/** 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
|
|
55
|
+
* linkage so a JIT host can resolve it via `dlsym` / koffi after
|
|
56
|
+
* `dlopen`'ing the compiled `.so`. */
|
|
57
|
+
storageClass?: "static" | ""): string;
|
|
58
|
+
/** Emit a sequence of statements with their per-stmt early-frees.
|
|
59
|
+
* After each stmt, owned C-names that aren't in the stmt's
|
|
60
|
+
* futureTouchOut (i.e. their last use was at this stmt) get a
|
|
61
|
+
* `<owned-kind>_free(&v);` call dispatched on the variable's
|
|
62
|
+
* recorded owned type. Scope-exit frees still emit unconditionally
|
|
63
|
+
* — they're no-ops for buffers already nulled by the early-free. */
|
|
64
|
+
export declare function emitBody(stmts: IRStmt[], indent: string, state: RuntimeState, futureTouches: FutureTouchMap, ownedTypes: ReadonlyMap<string, Type>, emitReturnTail: EmitReturnTail): string;
|
|
65
|
+
/** Compute a column-major linear offset expression from cell-brace
|
|
66
|
+
* indices. The base's shape supplies the row count for the 2-D
|
|
67
|
+
* formula. Indices are 1-based in source; we subtract 1 to land
|
|
68
|
+
* in C's 0-based slot/buffer array. */
|
|
69
|
+
export declare function cellLinearOffsetExpr(indices: ReadonlyArray<IRExpr>, baseTy: Extract<Type, {
|
|
70
|
+
kind: "Cell";
|
|
71
|
+
}>, baseCName: string, state: RuntimeState): string;
|
|
72
|
+
/** Try to compute a static slot offset from a tuple cell's indices.
|
|
73
|
+
* Returns `null` if any index isn't a NumLit. */
|
|
74
|
+
export declare function tryStaticCellOffset(indices: ReadonlyArray<IRExpr>, baseTy: Extract<Type, {
|
|
75
|
+
kind: "Cell";
|
|
76
|
+
}>): number | null;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `TensorConcat` codegen — the bracket-concatenation IR node produced
|
|
3
|
+
* by `lowerTensorLit`'s mixed-cell path (`[a, b; c, d]` where at least
|
|
4
|
+
* one cell is a tensor). Two paths: a fully-static one that bakes per-
|
|
5
|
+
* cell row/col offsets into literals, and a dynamic one that walks
|
|
6
|
+
* runtime `.dims[k]` reads.
|
|
7
|
+
*
|
|
8
|
+
* Both emit a GCC statement-expression that allocs a destination
|
|
9
|
+
* tensor, writes every cell's rectangle, and evaluates to the
|
|
10
|
+
* destination. ANF guarantees every tensor cell is already a Var, so
|
|
11
|
+
* cell reads carry no allocation cost.
|
|
12
|
+
*
|
|
13
|
+
* Mirrors numbl's `catAlongDim` (runtime/tensor-construction.ts) for
|
|
14
|
+
* the output layout — column-major destination, per-cell rectangle.
|
|
15
|
+
*/
|
|
16
|
+
import type { IRExpr } from "../lowering/ir.js";
|
|
17
|
+
import { type RuntimeState } from "./runtime.js";
|
|
18
|
+
/** Top-level entry: dispatch to the static or dynamic codegen path
|
|
19
|
+
* based on whether every per-cell dim and the output shape are
|
|
20
|
+
* compile-time known. */
|
|
21
|
+
export declare function emitTensorConcat(e: Extract<IRExpr, {
|
|
22
|
+
kind: "TensorConcat";
|
|
23
|
+
}>, state: RuntimeState): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JS sibling of `emitTensorConcat.ts`. Same two-path structure
|
|
3
|
+
* (fully-static vs. runtime-dim), same per-cell rectangle-copy
|
|
4
|
+
* shape — only the language and field names differ:
|
|
5
|
+
* `.real` (C) → `.data` (JS)
|
|
6
|
+
* `.dims[k]` (C) → `.shape[k]` (JS)
|
|
7
|
+
*
|
|
8
|
+
* GCC statement-expressions don't exist in JS; the destination
|
|
9
|
+
* tensor and per-cell writes are wrapped in an IIFE that returns
|
|
10
|
+
* the result.
|
|
11
|
+
*/
|
|
12
|
+
import type { IRExpr } from "../lowering/ir.js";
|
|
13
|
+
import { type RuntimeState } from "./runtime.js";
|
|
14
|
+
export declare function emitTensorConcatJs(e: Extract<IRExpr, {
|
|
15
|
+
kind: "TensorConcat";
|
|
16
|
+
}>, state: RuntimeState, emit: (e: IRExpr, state: RuntimeState) => string): string;
|