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,271 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mtoc2 lowerer. Walks the numbl AST, threads a type env (with exact-
|
|
3
|
+
* value tracking), and produces typed IR. The same pass:
|
|
4
|
+
* - resolves every function-call site through the shared
|
|
5
|
+
* `Workspace` (which delegates to numbl's `resolveFunction`),
|
|
6
|
+
* so MATLAB precedence rules (local > workspace > builtin, plus
|
|
7
|
+
* class-method dispatch on `obj.method(args)` and
|
|
8
|
+
* `ClassName.method(args)`) are inherited from numbl wholesale;
|
|
9
|
+
* - allocates per-call function specializations (mangled by the
|
|
10
|
+
* FNV-1a hash of the canonicalized arg-type tuple, salted by
|
|
11
|
+
* the defining file so two files defining a subfunction with
|
|
12
|
+
* the same name get distinct C names);
|
|
13
|
+
* - merges types across control-flow joins;
|
|
14
|
+
* - widens variables assigned inside loop bodies (strips exact)
|
|
15
|
+
* before lowering the body, so the one-pass lowering doesn't
|
|
16
|
+
* bake the entry-state value into the emitted code.
|
|
17
|
+
*
|
|
18
|
+
* Exact-value tracking threads through the type system (builtin
|
|
19
|
+
* transfer fns still compute exact results), but the only place the
|
|
20
|
+
* lowerer substitutes a literal for a computation is the `if` /
|
|
21
|
+
* `elseif` condition — when the cond's type has a `number` exact, the
|
|
22
|
+
* branch is statically taken or dropped. Arithmetic, comparisons,
|
|
23
|
+
* builtin calls, and Ident reads all emit runtime IR even when their
|
|
24
|
+
* exact value is known.
|
|
25
|
+
*
|
|
26
|
+
* MVP scope: scalar real double + arithmetic + comparisons + disp +
|
|
27
|
+
* if/while/for + user functions (0 or 1 outputs; 0-output calls return
|
|
28
|
+
* `Void` and are only valid as the expression of an `ExprStmt`) +
|
|
29
|
+
* classes (instance methods, static methods, constructors), with
|
|
30
|
+
* resolution against sibling `.m` files in the workspace via numbl's
|
|
31
|
+
* vendored resolver. Anything outside that throws
|
|
32
|
+
* `UnsupportedConstruct` with a span.
|
|
33
|
+
*/
|
|
34
|
+
import type { AbstractSyntaxTree, Expr, Stmt, Span } from "../parser/index.js";
|
|
35
|
+
import { type Type, type NumericType } from "./types.js";
|
|
36
|
+
import type { ClassRegistration } from "./classDefs.js";
|
|
37
|
+
import type { Workspace } from "../workspace/workspace.js";
|
|
38
|
+
import type { CallSite } from "../numbl/index.js";
|
|
39
|
+
/** Hook for the `%!numbl:printtype` directive's compile-time output.
|
|
40
|
+
* Defaults to `console.error` (so emitted lines go to stderr and
|
|
41
|
+
* don't mix with the cross-runner's stdout comparison). Tests
|
|
42
|
+
* replace this with a capturing function. */
|
|
43
|
+
export declare let printTypeSink: (line: string) => void;
|
|
44
|
+
export declare function setPrintTypeSink(sink: (line: string) => void): void;
|
|
45
|
+
export declare function resetPrintTypeSink(): void;
|
|
46
|
+
import { type Assign, type IRExpr, type IRStmt, type IRFunc, type IRProgram } from "./ir.js";
|
|
47
|
+
export interface EnvEntry {
|
|
48
|
+
cName: string;
|
|
49
|
+
ty: Type;
|
|
50
|
+
/** True when the variable is assigned on only SOME arms of an
|
|
51
|
+
* enclosing `if` (not all), so a read may hit a never-assigned value.
|
|
52
|
+
* MATLAB raises "Undefined ..." at runtime on the unassigned path; the
|
|
53
|
+
* JIT predeclares the local with a default and would silently read it,
|
|
54
|
+
* so a read of a flagged var (or returning it as an output) declines
|
|
55
|
+
* to the interpreter, which performs the runtime definite-assignment
|
|
56
|
+
* check. */
|
|
57
|
+
maybeUnassigned?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export declare class Lowerer {
|
|
60
|
+
workspace: Workspace;
|
|
61
|
+
env: Map<string, EnvEntry>;
|
|
62
|
+
specializations: Map<string, IRFunc>;
|
|
63
|
+
/** Stack of contexts for resolving the `end` keyword inside an
|
|
64
|
+
* index slot. Pushed by the index-lowering helpers (lowerIndexLoad
|
|
65
|
+
* / lowerIndexStore / lowerIndexSlice / lowerIndexSliceStore)
|
|
66
|
+
* around each slot they lower; consumed by the `EndKeyword` arm of
|
|
67
|
+
* `lowerExpr`. `axis === "linear"` flags the single-slot form
|
|
68
|
+
* whose `end` resolves to `numel(base)`. Outside an index slot the
|
|
69
|
+
* stack is empty and `end` raises `UnsupportedConstruct`. */
|
|
70
|
+
endStack: Array<{
|
|
71
|
+
baseCName: string;
|
|
72
|
+
baseTy: NumericType;
|
|
73
|
+
axis: number | "linear";
|
|
74
|
+
}>;
|
|
75
|
+
/** Monotonic counter for synthesizing `_mtoc2_t1`, `_mtoc2_t2`, ...
|
|
76
|
+
* hoist-temp names. Reset per function specialization. */
|
|
77
|
+
tempCounter: number;
|
|
78
|
+
/** Monotonic counter for the synthetic suffix used when an
|
|
79
|
+
* incompatible reassignment is split into a fresh binding
|
|
80
|
+
* (`_mtoc2_<cName>__v<N>`). See `recordAssignment`. Per-Lowerer, so
|
|
81
|
+
* each function specialization / script scope numbers independently. */
|
|
82
|
+
splitCounter: number;
|
|
83
|
+
/** Nesting depth inside `if` / `while` / `for` bodies. Bumped by
|
|
84
|
+
* `withControlDepth` around each body lowering. An incompatible
|
|
85
|
+
* reassignment can only be *split* at depth 0 (straight-line scope);
|
|
86
|
+
* inside a branch or loop the env merge can't reconcile two storage
|
|
87
|
+
* categories under one name, so it throws instead. */
|
|
88
|
+
controlDepth: number;
|
|
89
|
+
/** Expression-level hoist statements queued by sub-lowerings that
|
|
90
|
+
* can't pass a `hoists` array up the IR-expression return chain.
|
|
91
|
+
* Used today by member-rooted indexing (`obj.field(args)`) to push a
|
|
92
|
+
* fresh `Assign(temp = MemberLoad)` so the downstream `IndexLoad` /
|
|
93
|
+
* `IndexSlice` has a real `Var` to anchor `end`-keyword resolution
|
|
94
|
+
* on. `lowerStmt` drains this list around every statement boundary
|
|
95
|
+
* and prepends the hoists to whatever the inner lowering emitted. */
|
|
96
|
+
pendingExprHoists: IRStmt[];
|
|
97
|
+
/** Monotonic counter for synthesizing anonymous-function names
|
|
98
|
+
* (`anon_0`, `anon_1`, ...). Shared across the whole program so two
|
|
99
|
+
* textually distinct `@(...)` expressions get distinct identities. */
|
|
100
|
+
anonCounter: number;
|
|
101
|
+
/** Source file the lowerer is currently inside. Defaults to the
|
|
102
|
+
* workspace's main file at construction; pushed/popped by
|
|
103
|
+
* `specializeUserFunction` so a call from inside `helper.m`'s
|
|
104
|
+
* subfunction reports the right file in its `CallSite`. */
|
|
105
|
+
currentFile: string;
|
|
106
|
+
/** Per-specialization `nargin` / `nargout` values. Pushed by
|
|
107
|
+
* `specializeUserFunction` before lowering a function body; popped
|
|
108
|
+
* after. Read by the matching identifier arms of `lowerIdent`. Empty
|
|
109
|
+
* at top level — MATLAB rejects `nargin` / `nargout` outside a
|
|
110
|
+
* function body, which we mirror by leaving the reference
|
|
111
|
+
* unresolved (which falls through to the "undefined" error). */
|
|
112
|
+
callFrameStack: {
|
|
113
|
+
nargin: number;
|
|
114
|
+
nargout: number;
|
|
115
|
+
}[];
|
|
116
|
+
/** Spec keys whose still-empty placeholder was consumed via a cache
|
|
117
|
+
* hit while lowering some other (or the same) spec. Tracked so
|
|
118
|
+
* `specializeUserFunction` knows when a recursive self-call used a
|
|
119
|
+
* stale `outputTypes` seed and a second pass is needed to refine
|
|
120
|
+
* the recursive-call IR's `ty`. The set is populated by
|
|
121
|
+
* `specializeUserFunction`'s cache-hit branch and consumed by the
|
|
122
|
+
* same function after body lowering. */
|
|
123
|
+
recursiveSpecsConsumed: Set<string>;
|
|
124
|
+
/** Number of distinct specializations created so far per
|
|
125
|
+
* `<sourceName>|<definingFile>`. Read by
|
|
126
|
+
* `specializeUserFunction`'s cache-miss branch; when the count for
|
|
127
|
+
* any one source-level function crosses `MAX_SPECS_PER_FUNCTION`,
|
|
128
|
+
* translation aborts with a clear error rather than letting the
|
|
129
|
+
* spec map (and the emitted C / JS) grow without bound. Exact-
|
|
130
|
+
* value tracking shards the cache by arg value, so a tight call
|
|
131
|
+
* with hundreds of distinct literal args (or value-keyed loop
|
|
132
|
+
* bodies) is the typical trigger. */
|
|
133
|
+
specCountPerSource: Map<string, number>;
|
|
134
|
+
constructor(workspace: Workspace);
|
|
135
|
+
/** Built `CallSite` for the vendored numbl resolver. New
|
|
136
|
+
* resolver-relevant fields added later (`className`, `methodName`,
|
|
137
|
+
* ...) only need to be threaded here. */
|
|
138
|
+
callSite(): CallSite;
|
|
139
|
+
/** Public env lookup used by the index-lowering helpers. Returns
|
|
140
|
+
* the env entry (cName + ty) if a binding exists in the current
|
|
141
|
+
* scope, or undefined otherwise. */
|
|
142
|
+
envLookup(name: string): EnvEntry | undefined;
|
|
143
|
+
/** Run `fn` with `controlDepth` incremented; restored on exit. Used by
|
|
144
|
+
* `lowerIf` / `lowerWhile` / `lowerFor` to mark "we're inside a
|
|
145
|
+
* branch or loop body" so an incompatible reassignment throws rather
|
|
146
|
+
* than splitting (see `recordAssignment`). */
|
|
147
|
+
withControlDepth<T>(fn: () => T): T;
|
|
148
|
+
/** Look up a registered class (workspace or local) by name.
|
|
149
|
+
* Re-throws the saved `UnsupportedConstruct` if numbl knew the
|
|
150
|
+
* class but mtoc2's `registerClassDef` rejected it in the JIT
|
|
151
|
+
* bridge's `fromExistingContext` mode — surfacing the error at
|
|
152
|
+
* the first actual use rather than at workspace finalize. */
|
|
153
|
+
classReg(name: string): ClassRegistration | undefined;
|
|
154
|
+
lowerProgram(ast: AbstractSyntaxTree): IRProgram;
|
|
155
|
+
lowerStmts(stmts: Stmt[]): IRStmt[];
|
|
156
|
+
private lowerStmt;
|
|
157
|
+
private lowerStmtInner;
|
|
158
|
+
/** Numbl directives (`%!numbl:<name> <args>`). Numbl interprets a
|
|
159
|
+
* small set (e.g. `assert_jit`) and ignores the rest. Mtoc2 reuses
|
|
160
|
+
* the same parsed-directive AST node to host translator-side hints
|
|
161
|
+
* that numbl silently passes over:
|
|
162
|
+
*
|
|
163
|
+
* - `%!numbl:opaque <var> [<var>...]` — strip `exact` from each
|
|
164
|
+
* named variable in the current env. Used in test scripts to
|
|
165
|
+
* force the runtime codegen path on values mtoc2 would otherwise
|
|
166
|
+
* fold at compile time.
|
|
167
|
+
* - `%!numbl:showtype <var> [<var>...]` — snapshot each variable's
|
|
168
|
+
* type and emit a `/_ type ... _/` comment in the generated C
|
|
169
|
+
* at this position. Debug aid; no runtime effect.
|
|
170
|
+
* - `%!numbl:printtype <var> [<var>...]` — same snapshot, but
|
|
171
|
+
* written to stderr (via `printTypeSink`) at compile time. Fires
|
|
172
|
+
* once per function specialization. No IR node, no codegen
|
|
173
|
+
* interaction.
|
|
174
|
+
*
|
|
175
|
+
* Numbl ignores all three directives, so cross-runner output is
|
|
176
|
+
* unaffected. */
|
|
177
|
+
private lowerDirective;
|
|
178
|
+
/** Look up each name in `args` in the current env, snapshotting its
|
|
179
|
+
* `cName` and current `Type`. Throws `UnsupportedConstruct` with
|
|
180
|
+
* the directive's span on the first unknown name. Used by the
|
|
181
|
+
* `showtype` and `printtype` directive branches. */
|
|
182
|
+
private snapshotTypeEntries;
|
|
183
|
+
private lowerExprStmt;
|
|
184
|
+
/** Reject Void in a value-consuming context with a clear span. The
|
|
185
|
+
* Void type tags a call to a zero-output user function; it has no
|
|
186
|
+
* representation as a value and is only valid as the direct
|
|
187
|
+
* expression of an `ExprStmt`. */
|
|
188
|
+
requireValueType(e: IRExpr, what: string): void;
|
|
189
|
+
/** Recursively rewrite sub-expressions of `e`, hoisting any owned-
|
|
190
|
+
* producing non-Var sub-expression to a fresh temp Assign. The
|
|
191
|
+
* top-level `e` itself is NOT hoisted by this function — the caller
|
|
192
|
+
* decides what context `e` sits in (Assign RHS at an owned consume
|
|
193
|
+
* site can keep an owned producer; everywhere else requires
|
|
194
|
+
* `anfRequireScalarOrVar`). */
|
|
195
|
+
private anfChildren;
|
|
196
|
+
/** Walk `e` and ensure the returned expression is either non-owned or
|
|
197
|
+
* a Var. Recursively ANFs children; if `e` itself is owned-producing
|
|
198
|
+
* (multi-element tensor / struct / class / handle / char / string,
|
|
199
|
+
* in non-Var form), hoist it to a fresh temp. The ANF invariant is
|
|
200
|
+
* that owned-producing expressions appear only as direct Assign RHSs
|
|
201
|
+
* at owned consume sites; every other position holds a Var read. */
|
|
202
|
+
anfRequireScalarOrVar(e: IRExpr, hoists: IRStmt[]): IRExpr;
|
|
203
|
+
private hoistToTemp;
|
|
204
|
+
freshTempName(): string;
|
|
205
|
+
private lowerAssign;
|
|
206
|
+
/** `s.f = rhs` or chained `s.inner.f = rhs`. Lowers to a single
|
|
207
|
+
* `MemberStore` IR node with the root `Var` as `base` and the
|
|
208
|
+
* field chain in `fieldPath`. v1 requires the root variable to be
|
|
209
|
+
* already in env (no implicit struct introduction — use
|
|
210
|
+
* `s = struct('f', v, ...)` or a class constructor). Every step
|
|
211
|
+
* of the chain must already exist on the corresponding nested
|
|
212
|
+
* struct/class type.
|
|
213
|
+
*
|
|
214
|
+
* Type discipline: the rhs and the field must occupy the same
|
|
215
|
+
* C-level slot — checked by `storageEquivalent`, which calls
|
|
216
|
+
* `cFieldTypeStr` on both. Scalar↔tensor, different elem, or
|
|
217
|
+
* different struct/class typedef name → rejected. Otherwise the
|
|
218
|
+
* write is accepted and env is updated so subsequent reads of
|
|
219
|
+
* the field report the rhs's full internal type (the C typedef
|
|
220
|
+
* is unaffected — the typedef hash sees only the C-level type
|
|
221
|
+
* via `cFieldTypeStr`, not the internal lattice precision). */
|
|
222
|
+
lowerAssignLValue(s: Extract<Stmt, {
|
|
223
|
+
type: "AssignLValue";
|
|
224
|
+
}>): IRStmt | IRStmt[];
|
|
225
|
+
recordAssignment(name: string, expr: IRExpr, span: Span): Assign;
|
|
226
|
+
private lowerIf;
|
|
227
|
+
private lowerElseChain;
|
|
228
|
+
private lowerWhile;
|
|
229
|
+
private lowerFor;
|
|
230
|
+
lowerExpr(e: Expr): IRExpr;
|
|
231
|
+
/** `end` keyword inside an index slot — resolves through the top of
|
|
232
|
+
* `endStack`. Outside an index slot it raises with a span. When the
|
|
233
|
+
* axis size is statically known, emit a `NumLit`; otherwise emit
|
|
234
|
+
* an `EndRef` IR node and let codegen render the runtime axis-size
|
|
235
|
+
* read. */
|
|
236
|
+
private lowerEndKeyword;
|
|
237
|
+
/** `a : b` or `a : s : b` used as a value (outside an index slot
|
|
238
|
+
* and outside a for-loop iterable). Emits a `MakeRange` IR node
|
|
239
|
+
* whose result is a freshly-allocated row vector. */
|
|
240
|
+
private lowerRangeAsValue;
|
|
241
|
+
/** `s.f` or chained `s.inner.f`. Lowers each nesting level into a
|
|
242
|
+
* fresh `MemberLoad` whose `base` is the inner load. The leaf
|
|
243
|
+
* type is the field's static type on the immediate container.
|
|
244
|
+
*
|
|
245
|
+
* Dependent-property routing: when `base` is a class instance and
|
|
246
|
+
* the class declares a `get.<name>` accessor, the read is replaced
|
|
247
|
+
* by a single-output method call. The result is an owned `Call`
|
|
248
|
+
* IRExpr; ANF in the surrounding context hoists it like any other
|
|
249
|
+
* owned producer. */
|
|
250
|
+
private lowerMember;
|
|
251
|
+
private lowerIdent;
|
|
252
|
+
private lowerBinary;
|
|
253
|
+
private lowerUnary;
|
|
254
|
+
private requireScalarReal;
|
|
255
|
+
/** Like `requireScalarReal` but also accepts scalar complex —
|
|
256
|
+
* used by `if` / `while` / `elseif` conds, where MATLAB's `toBool`
|
|
257
|
+
* rule (`creal(z) != 0 || cimag(z) != 0`) gives the boolean. */
|
|
258
|
+
private requireScalarCondType;
|
|
259
|
+
private mergeBranchEnvs;
|
|
260
|
+
}
|
|
261
|
+
/** Map a user-source variable name to a safe C / JS identifier.
|
|
262
|
+
* Reserved words get a `v_` prefix; other names pass through unchanged
|
|
263
|
+
* so emitted code remains readable for the common case. The numbl
|
|
264
|
+
* parser already rejects identifiers starting with `_`, so a user
|
|
265
|
+
* `for` only collides with the keyword (not with `v_for` from any
|
|
266
|
+
* other source). */
|
|
267
|
+
export declare function cIdentForUserName(name: string): string;
|
|
268
|
+
export { tryExtractDottedName } from "../parser/astUtils.js";
|
|
269
|
+
/** Strip the surrounding `'` or `"` quotes the numbl parser stores as
|
|
270
|
+
* part of a `Char`/`String` literal's lexeme. */
|
|
271
|
+
export declare function stripQuotes(s: string): string;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brace-indexed cell read lowering: `c{i}`, `c{i, j}`.
|
|
3
|
+
*
|
|
4
|
+
* Routed from `lowerExpr` when the AST node is `IndexCell` AND the
|
|
5
|
+
* base resolves to an in-scope cell variable. The base must be a
|
|
6
|
+
* bare `Ident` for now — member-rooted `obj.field{i}` is rejected
|
|
7
|
+
* pending the broader member-rooted-index work.
|
|
8
|
+
*
|
|
9
|
+
* Result type depends on the cell's mode:
|
|
10
|
+
* - Tuple mode + every index a `NumLit` matching an in-range
|
|
11
|
+
* slot → the specific slot's `Type`.
|
|
12
|
+
* - Tuple mode + any non-exact index → the unified slot type
|
|
13
|
+
* (rejected with `UnsupportedConstruct` if slot types diverge).
|
|
14
|
+
* - Uniform mode → the cell's `elem` type.
|
|
15
|
+
*
|
|
16
|
+
* Per-axis (`c{i, j}`) reads are accepted only for tuple cells
|
|
17
|
+
* whose shape is exact 2-D; uniform cells route through the same
|
|
18
|
+
* column-major linear offset at runtime.
|
|
19
|
+
*/
|
|
20
|
+
import type { Expr, LValue, Span } from "../parser/index.js";
|
|
21
|
+
import type { IRExpr, IRStmt } from "./ir.js";
|
|
22
|
+
import type { Lowerer } from "./lower.js";
|
|
23
|
+
export declare function lowerCellIndexLoad(this: Lowerer, e: Extract<Expr, {
|
|
24
|
+
type: "IndexCell";
|
|
25
|
+
}>): IRExpr;
|
|
26
|
+
/** Brace-write lowering: `c{i} = rhs`, `c{i, j} = rhs`. The base
|
|
27
|
+
* must be a bare cell-typed variable. After the store, the env's
|
|
28
|
+
* recorded type for `c` is refreshed to reflect the new slot type:
|
|
29
|
+
*
|
|
30
|
+
* - Tuple mode + static index → update the slot's `Type` to the
|
|
31
|
+
* rhs's type.
|
|
32
|
+
* - Tuple mode + non-static index → require every slot type to
|
|
33
|
+
* unify with the rhs type; demote the env entry to a uniform
|
|
34
|
+
* cell with the unified elem.
|
|
35
|
+
* - Uniform mode → rhs must unify with the cell's `elem`.
|
|
36
|
+
*
|
|
37
|
+
* If neither path applies, raise `UnsupportedConstruct` (no LUB /
|
|
38
|
+
* heterogeneous fallback per the design — see docs/cells_plan.md). */
|
|
39
|
+
export declare function lowerCellIndexStore(this: Lowerer, lv: Extract<LValue, {
|
|
40
|
+
type: "IndexCell";
|
|
41
|
+
}>, exprAst: Expr, span: Span): IRStmt | IRStmt[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cell-literal lowering: `{a, b, c}`, `{1; 2; 3}`, `{1, 'hi'; [1 2], "x"}`.
|
|
3
|
+
*
|
|
4
|
+
* Reached from `lowerExpr` whenever the AST node is a `Cell`. The
|
|
5
|
+
* literal always produces a tuple-mode `CellType` with per-slot types
|
|
6
|
+
* (matching the lowered slot expressions). Empty `{}` produces a
|
|
7
|
+
* 0×0 tuple cell with `elements: []`.
|
|
8
|
+
*
|
|
9
|
+
* Slot expressions accept any value-typed expression — scalars,
|
|
10
|
+
* tensors, structs, classes, handles, strings, chars. The lowerer
|
|
11
|
+
* relies on the ANF pass to hoist owned-producing slot values to
|
|
12
|
+
* fresh temps before the `CellLit` becomes an Assign RHS.
|
|
13
|
+
*/
|
|
14
|
+
import type { Expr } from "../parser/index.js";
|
|
15
|
+
import type { IRExpr } from "./ir.js";
|
|
16
|
+
import type { Lowerer } from "./lower.js";
|
|
17
|
+
export declare function lowerCellLit(this: Lowerer, e: Extract<Expr, {
|
|
18
|
+
type: "Cell";
|
|
19
|
+
}>): IRExpr;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class-constructor lowering.
|
|
3
|
+
*
|
|
4
|
+
* Three responsibilities:
|
|
5
|
+
*
|
|
6
|
+
* - `lowerClassConstructorCall` — produces the `Call` IR node that
|
|
7
|
+
* invokes the user-declared constructor, after settling the
|
|
8
|
+
* class's `ClassType` and synthesizing the default-valued
|
|
9
|
+
* receiver that the constructor body sees on entry.
|
|
10
|
+
*
|
|
11
|
+
* - `resolveClassType` — for classes whose property types weren't
|
|
12
|
+
* fully inferred at registration (because at least one property
|
|
13
|
+
* declares no default), pre-scan the constructor body for the
|
|
14
|
+
* first top-level `<receiver>.<prop> = <rhs>` write per pending
|
|
15
|
+
* property and lower its RHS in a temp env to derive the
|
|
16
|
+
* property's type. The first call wins; subsequent calls reuse
|
|
17
|
+
* `reg.ty` and validate via the normal `MemberStore` storage-
|
|
18
|
+
* equivalence check.
|
|
19
|
+
*
|
|
20
|
+
* - `makeInitialClassReceiver` — synthesize a `StructLit` whose
|
|
21
|
+
* ty is the just-resolved `ClassType` and whose field values are
|
|
22
|
+
* either the registered defaults or a zero/empty placeholder for
|
|
23
|
+
* pending properties. The constructor body's first write
|
|
24
|
+
* overwrites the placeholder.
|
|
25
|
+
*/
|
|
26
|
+
import type { Expr, Span } from "../parser/index.js";
|
|
27
|
+
import type { IRExpr } from "./ir.js";
|
|
28
|
+
import { type ClassType, type Type } from "./types.js";
|
|
29
|
+
import type { ClassRegistration } from "./classDefs.js";
|
|
30
|
+
import type { Lowerer } from "./lower.js";
|
|
31
|
+
/** Lower `ClassName(args)` to the `Call` IR node that invokes the
|
|
32
|
+
* user-declared constructor. The constructor's first statement gets
|
|
33
|
+
* a synthetic `obj = <default-receiver>` prepended (via
|
|
34
|
+
* `specializeUserFunction`'s `preSeedOutput`) so the body's reads
|
|
35
|
+
* and writes against the receiver work against an initialized
|
|
36
|
+
* slot. */
|
|
37
|
+
export declare function lowerClassConstructorCall(this: Lowerer, reg: ClassRegistration, args: Expr[], span: Span): IRExpr;
|
|
38
|
+
/** Settle the class's `ClassType`. For a class with every property
|
|
39
|
+
* declaring a default, `reg.ty` is already filled in at
|
|
40
|
+
* registration and we just return it. For a class with pending
|
|
41
|
+
* properties, we pre-scan the constructor body for direct
|
|
42
|
+
* `obj.<prop> = <rhs>` writes (where `obj` is the constructor's
|
|
43
|
+
* output receiver) and lower each first-write RHS in a temp env
|
|
44
|
+
* bound to the call's `argTypes`. The first call wins — subsequent
|
|
45
|
+
* specs validate against the cached type via the normal
|
|
46
|
+
* `MemberStore` storage-equivalence check. */
|
|
47
|
+
export declare function resolveClassType(this: Lowerer, reg: ClassRegistration, argTypes: Type[], span: Span): ClassType;
|
|
48
|
+
/** Synthesize a `StructLit` whose ty is `classTy` and whose field
|
|
49
|
+
* values are the property defaults from `reg.defaults` — for any
|
|
50
|
+
* property without a default, synthesize a zero-value matching the
|
|
51
|
+
* inferred C-level type (the constructor body's first write
|
|
52
|
+
* overwrites it anyway; the zero is just a typed placeholder so
|
|
53
|
+
* the C designated initializer is well-formed and any
|
|
54
|
+
* read-before-write reads as 0 / empty). */
|
|
55
|
+
export declare function makeInitialClassReceiver(this: Lowerer, reg: ClassRegistration, classTy: ClassType, span: Span): IRExpr;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bare-name function-call lowering: `name(args)`.
|
|
3
|
+
*
|
|
4
|
+
* Resolution priority — checked in this order:
|
|
5
|
+
* 0. The literal name `struct` (no shadowing local) → `StructLit`.
|
|
6
|
+
* 1. The literal name `bsxfun` (no shadowing local) → rewrite to
|
|
7
|
+
* `fn(A, B)` when the first arg is `@<knownElementwiseBinary>`.
|
|
8
|
+
* 2. An in-scope `HandleType` variable → `dispatchHandleCall`.
|
|
9
|
+
* 3. An in-scope class name with no shadowing local → class
|
|
10
|
+
* constructor.
|
|
11
|
+
* 4. An in-scope variable: multi-element numeric routes through
|
|
12
|
+
* the index helpers; other types raise UnsupportedConstruct.
|
|
13
|
+
* 5. Zero-arity builtin paren-form (`pi()`, `Inf()`).
|
|
14
|
+
* 6. Numbl resolver verdict — builtin / user-function / class
|
|
15
|
+
* method.
|
|
16
|
+
* 7. Fallback to mtoc2's own builtin registry for plot-drawing
|
|
17
|
+
* builtins numbl wires through runtime dispatch.
|
|
18
|
+
*/
|
|
19
|
+
import type { Expr } from "../parser/index.js";
|
|
20
|
+
import type { IRExpr } from "./ir.js";
|
|
21
|
+
import type { Lowerer } from "./lower.js";
|
|
22
|
+
export declare function lowerFuncCall(this: Lowerer, e: Extract<Expr, {
|
|
23
|
+
type: "FuncCall";
|
|
24
|
+
}>): IRExpr;
|
|
25
|
+
/** Shared AST rewrite used by both `lowerFevalCall` (single-output
|
|
26
|
+
* expression context) and the multi-assign path (`lowerMultiAssign`
|
|
27
|
+
* calls this to rewrite the RHS before its own dispatch). Returns a
|
|
28
|
+
* fresh `FuncCall` node naming the resolved target with `args[0]`
|
|
29
|
+
* consumed. */
|
|
30
|
+
export declare function rewriteFevalToDirectCall(e: Extract<Expr, {
|
|
31
|
+
type: "FuncCall";
|
|
32
|
+
}>): Extract<Expr, {
|
|
33
|
+
type: "FuncCall";
|
|
34
|
+
}>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Function-handle lowering:
|
|
3
|
+
* - `@name` → `lowerFuncHandle` (HandleLit with no captures)
|
|
4
|
+
* - `@(p1,...) body` → `lowerAnonFunc` (HandleLit with captures
|
|
5
|
+
* of the surrounding scope)
|
|
6
|
+
* - `h(args)` → `dispatchHandleCall` (specialize + Call IR)
|
|
7
|
+
*
|
|
8
|
+
* Captures are deep-copied into the handle struct at the `@(...)`
|
|
9
|
+
* site (MATLAB by-value snapshot). Owned-typed captures (tensor,
|
|
10
|
+
* struct, class instance, another handle) ship per-shape
|
|
11
|
+
* `_empty/_copy/_assign/_free` helpers so they participate in the
|
|
12
|
+
* standard scope-exit-free / early-free lifecycle.
|
|
13
|
+
*/
|
|
14
|
+
import type { Expr, LValue, Span } from "../parser/index.js";
|
|
15
|
+
import type { IRExpr, IRStmt } from "./ir.js";
|
|
16
|
+
import type { EnvEntry, Lowerer } from "./lower.js";
|
|
17
|
+
/** `@name` — a named handle to a top-level user function. Builds the
|
|
18
|
+
* handle type, captures empty, and returns a HandleLit. Builtin
|
|
19
|
+
* targets (`@disp`, `@sin`) are rejected — mtoc2 v1 doesn't support
|
|
20
|
+
* them. Class methods (`@SomeClass.method`) aren't reachable via
|
|
21
|
+
* this AST (the parser emits a different shape for those). The
|
|
22
|
+
* workspace resolver finds local + cross-file function targets. */
|
|
23
|
+
export declare function lowerFuncHandle(this: Lowerer, e: Extract<Expr, {
|
|
24
|
+
type: "FuncHandle";
|
|
25
|
+
}>): IRExpr;
|
|
26
|
+
/** `@(p1, ..., pN) <body>` — an anonymous function. Detects every
|
|
27
|
+
* free Ident in the body that's bound in the enclosing scope (and
|
|
28
|
+
* not in the param list) as a capture, then synthesizes a top-level
|
|
29
|
+
* `function out = anon_<N>(p1, ..., pN, c1, ..., cM)` whose body
|
|
30
|
+
* assigns the source body expression to the synthesized output. The
|
|
31
|
+
* synthesized AST is parked on `handleTy.ast` so every call site
|
|
32
|
+
* routes through the same specialization cache used for
|
|
33
|
+
* user-declared functions.
|
|
34
|
+
*
|
|
35
|
+
* Captures may be scalar real numeric, tensor, struct, class
|
|
36
|
+
* instance, or another handle — the handle's C struct ships with
|
|
37
|
+
* per-shape `_empty/_copy/_assign/_free` helpers (just like
|
|
38
|
+
* structs/classes), so owned-typed fields participate in the
|
|
39
|
+
* standard scope-exit-free / early-free lifecycle. String / Void /
|
|
40
|
+
* Unknown captures are rejected with `UnsupportedConstruct`. */
|
|
41
|
+
export declare function lowerAnonFunc(this: Lowerer, e: Extract<Expr, {
|
|
42
|
+
type: "AnonFunc";
|
|
43
|
+
}>): IRExpr;
|
|
44
|
+
/** Dispatch `h(args)` where `h` is an in-scope handle variable.
|
|
45
|
+
* Reads the handle's `ast` off its type, lowers the user-supplied
|
|
46
|
+
* args, appends per-capture `HandleCaptureLoad` reads, specializes
|
|
47
|
+
* the underlying function on the combined arg-type tuple, and emits
|
|
48
|
+
* a direct call to the mangled name. */
|
|
49
|
+
export declare function dispatchHandleCall(this: Lowerer, handleName: string, handleEntry: EnvEntry, argExprs: Expr[], span: Span): IRExpr;
|
|
50
|
+
/** `[a, b, ...] = h(args)` where `h` is an in-scope handle variable.
|
|
51
|
+
* Mirrors `dispatchHandleCall`'s user-arg + capture-load wiring, then
|
|
52
|
+
* specializes the target at the caller's nargout. Emits a Call (when
|
|
53
|
+
* the spec truncates to 1 output) or a MultiAssignCall (N>=2 outputs);
|
|
54
|
+
* drop-all bare-statement use (`h(args);`) passes 0 lvalues and emits
|
|
55
|
+
* an ExprStmt. Returns the IR statement(s) to splice into the parent
|
|
56
|
+
* block. */
|
|
57
|
+
export declare function dispatchHandleMultiAssign(this: Lowerer, handleName: string, handleEntry: EnvEntry, argExprs: Expr[], lvalues: ReadonlyArray<LValue>, span: Span): IRStmt | IRStmt[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scalar index-read lowering: `v(i)` / `M(i, j)` / `T(i, j, k)` /
|
|
3
|
+
* `v(end)` / `M(end, end)` / etc.
|
|
4
|
+
*
|
|
5
|
+
* Reached from `lowerFuncCall` whenever a `FuncCall` name resolves to
|
|
6
|
+
* an in-scope multi-element numeric variable AND none of the args are
|
|
7
|
+
* a range / bare colon (that case routes to `lowerIndexSlice`). Each
|
|
8
|
+
* index slot must lower to a scalar real expression; an `end` token
|
|
9
|
+
* inside a slot resolves through the Lowerer's `endStack` to the
|
|
10
|
+
* appropriate axis size.
|
|
11
|
+
*/
|
|
12
|
+
import type { Expr, Span } from "../parser/index.js";
|
|
13
|
+
import type { IRExpr } from "./ir.js";
|
|
14
|
+
import type { Lowerer } from "./lower.js";
|
|
15
|
+
/** Lower an index-read of an in-scope variable. */
|
|
16
|
+
export declare function lowerIndexLoad(this: Lowerer, name: string, argExprs: ReadonlyArray<Expr>, span: Span): IRExpr;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Range / colon / scalar-mix indexed-read lowering: `v(:)`, `v(a:b)`,
|
|
3
|
+
* `M(:, j)`, `T(:, :, i)`, … .
|
|
4
|
+
*
|
|
5
|
+
* Reached from `lowerFuncCall` whenever a `FuncCall` name resolves to
|
|
6
|
+
* an in-scope multi-element numeric variable AND at least one arg is a
|
|
7
|
+
* `Range` or bare `Colon`. Two acceptable arities: 1 slot (linear) or
|
|
8
|
+
* `base.ty.dims.length` slots (one per axis). Result-shape rules
|
|
9
|
+
* mirror numbl and mtoc:
|
|
10
|
+
*
|
|
11
|
+
* single-slot Colon → column vector, length numel(base)
|
|
12
|
+
* single-slot Range, row-vec base → row vector, count(range)
|
|
13
|
+
* single-slot Range, col-vec base → col vector, count(range)
|
|
14
|
+
* single-slot Range, matrix / N-D base → row vector, count(range)
|
|
15
|
+
* multi-slot Colon at axis k → base.dims[k]
|
|
16
|
+
* multi-slot Range at axis k → exact count when statically
|
|
17
|
+
* derivable, else unknown
|
|
18
|
+
* multi-slot Scalar at axis k → exact 1
|
|
19
|
+
*/
|
|
20
|
+
import type { Expr, Span } from "../parser/index.js";
|
|
21
|
+
import type { IRExpr, IndexSliceArg } from "./ir.js";
|
|
22
|
+
import { type NumericType } from "./types.js";
|
|
23
|
+
import type { Lowerer } from "./lower.js";
|
|
24
|
+
export declare function lowerIndexSlice(this: Lowerer, name: string, argExprs: ReadonlyArray<Expr>, span: Span): IRExpr;
|
|
25
|
+
/** Lower a single AST index slot into an `IndexSliceArg`. The
|
|
26
|
+
* `endStack` is pushed around each sub-expression so an embedded
|
|
27
|
+
* `end` token resolves against the right axis. Exported so the
|
|
28
|
+
* store-side helper reuses the same logic. */
|
|
29
|
+
export declare function lowerSliceArg(this: Lowerer, baseCName: string, baseTy: NumericType, axis: number | "linear", arg: Expr): IndexSliceArg;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Range / colon / scalar-mix indexed-write lowering: `v(:) = w`,
|
|
3
|
+
* `v(a:b) = w`, `M(:, j) = w`, `T(:, :, i) = w`, … .
|
|
4
|
+
*
|
|
5
|
+
* Companion to `lowerIndexSlice` for slice writes. RHS shape:
|
|
6
|
+
* - scalar real numeric → broadcast into every slot.
|
|
7
|
+
* - named multi-element tensor (`Var`) → per-slot copy.
|
|
8
|
+
*
|
|
9
|
+
* Other RHS forms (a fresh `TensorBuild`, an `IndexSlice`, a tensor
|
|
10
|
+
* Binary, etc.) are rejected with a clear message — the user must
|
|
11
|
+
* assign the expression to a name first so the temporary lifetime is
|
|
12
|
+
* explicit.
|
|
13
|
+
*/
|
|
14
|
+
import type { Expr, LValue, Span } from "../parser/index.js";
|
|
15
|
+
import type { IRStmt } from "./ir.js";
|
|
16
|
+
import type { Lowerer } from "./lower.js";
|
|
17
|
+
export declare function lowerIndexSliceStore(this: Lowerer, lvalue: Extract<LValue, {
|
|
18
|
+
type: "Index";
|
|
19
|
+
}>, exprAst: Expr, span: Span): IRStmt | IRStmt[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scalar indexed-write lowering: `v(i) = x`, `M(i, j) = x`,
|
|
3
|
+
* `T(i, j, k) = x`, `v(end) = x`.
|
|
4
|
+
*
|
|
5
|
+
* Reached from `lowerAssignLValue` whenever the lvalue is an `Index`
|
|
6
|
+
* with a simple `Ident` base AND none of the index slots are a range
|
|
7
|
+
* / colon (that case routes to `lowerIndexSliceStore`).
|
|
8
|
+
*/
|
|
9
|
+
import type { Expr, LValue, Span } from "../parser/index.js";
|
|
10
|
+
import type { IRStmt } from "./ir.js";
|
|
11
|
+
import type { Lowerer } from "./lower.js";
|
|
12
|
+
export declare function lowerIndexStore(this: Lowerer, lvalue: Extract<LValue, {
|
|
13
|
+
type: "Index";
|
|
14
|
+
}>, exprAst: Expr, span: Span): IRStmt | IRStmt[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Method-call lowering — every `<base>.<name>(args)` AST node:
|
|
3
|
+
*
|
|
4
|
+
* - **Package call**: `pkg.foo(args)` and `pkg.sub.foo(args)` —
|
|
5
|
+
* leftmost segment is not an in-scope variable. Routes to the
|
|
6
|
+
* userFunction / classConstructor verdict from the resolver.
|
|
7
|
+
* - **Static method call**: `ClassName.staticMethod(args)` — base
|
|
8
|
+
* resolves to a class name. Receiver is not present in the arg
|
|
9
|
+
* tuple.
|
|
10
|
+
* - **Instance method call**: `obj.method(args)` — base evaluates
|
|
11
|
+
* to a class instance. The receiver becomes the first arg when
|
|
12
|
+
* numbl's resolver decides this is an instance dispatch
|
|
13
|
+
* (`stripInstance === false`).
|
|
14
|
+
* - **Member-rooted indexing**: `obj.field(args)` where `field` is
|
|
15
|
+
* a property (not a method). The field load lands in a fresh
|
|
16
|
+
* temp and the args run through the standard `lowerIndexLoad` /
|
|
17
|
+
* `lowerIndexSlice` path.
|
|
18
|
+
*/
|
|
19
|
+
import type { Expr, Span } from "../parser/index.js";
|
|
20
|
+
import type { IRExpr } from "./ir.js";
|
|
21
|
+
import type { Lowerer } from "./lower.js";
|
|
22
|
+
export declare function lowerMethodCall(this: Lowerer, e: Extract<Expr, {
|
|
23
|
+
type: "MethodCall";
|
|
24
|
+
}>): IRExpr;
|
|
25
|
+
/** Lowers `obj.depProp(args)` where `depProp` is a `Dependent`
|
|
26
|
+
* property: call the getter to produce the value, hoist the result
|
|
27
|
+
* to a fresh temp, then run the args through the standard
|
|
28
|
+
* `lowerIndexLoad` / `lowerIndexSlice` path on the temp. v1
|
|
29
|
+
* rejects the corresponding write form (`obj.depProp(args) = rhs`)
|
|
30
|
+
* at `lowerAssignLValue` — splicing through the getter then setter
|
|
31
|
+
* is deferred. */
|
|
32
|
+
export declare function lowerDependentPropertyIndex(this: Lowerer, base: IRExpr, reg: import("./classDefs.js").ClassRegistration, propName: string, argExprs: ReadonlyArray<Expr>, span: Span): IRExpr;
|
|
33
|
+
/** Lowers `obj.field(args)` where `field` is a class property (not a
|
|
34
|
+
* method): load the field into a fresh temp, then run the args
|
|
35
|
+
* through the standard `lowerIndexLoad` / `lowerIndexSlice` path
|
|
36
|
+
* using the temp's name. The synthetic `Assign(temp = MemberLoad)`
|
|
37
|
+
* is queued on `pendingExprHoists` so `lowerStmt` prepends it to
|
|
38
|
+
* the emitted statement. */
|
|
39
|
+
export declare function lowerMemberRootedIndex(this: Lowerer, base: IRExpr, field: string, argExprs: ReadonlyArray<Expr>, span: Span): IRExpr;
|
|
40
|
+
/** `ClassName.staticMethod(args)` — static method called via class
|
|
41
|
+
* name. The receiver is not present; arg types feed the resolver
|
|
42
|
+
* directly. */
|
|
43
|
+
export declare function lowerStaticMethodCall(this: Lowerer, className: string, e: Extract<Expr, {
|
|
44
|
+
type: "MethodCall";
|
|
45
|
+
}>, span: Span): IRExpr;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-assign statement lowering: `[a, b] = foo(x);` (with mix of
|
|
3
|
+
* named lvalues, `~` discards, and trailing-omitted slots) and the
|
|
4
|
+
* drop-all bare-statement variant `foo(x);` where `foo` has N≥2
|
|
5
|
+
* outputs. Handles both user-function and multi-output builtin (e.g.
|
|
6
|
+
* `[v, i] = sort(...)`) targets.
|
|
7
|
+
*
|
|
8
|
+
* 1-output declarations reached through this path (because the call
|
|
9
|
+
* site has lvalues.length === 1) take the classic single-output ABI
|
|
10
|
+
* — return-by-value via a `Call` IR node and an `Assign` / `ExprStmt`
|
|
11
|
+
* wrapper. Only N≥2 outputs produce a `MultiAssignCall` IR node
|
|
12
|
+
* (which carries the sret out-pointer ABI).
|
|
13
|
+
*/
|
|
14
|
+
import type { Span, Stmt, LValue } from "../parser/index.js";
|
|
15
|
+
import type { IRStmt } from "./ir.js";
|
|
16
|
+
import { type Type } from "./types.js";
|
|
17
|
+
import type { Lowerer } from "./lower.js";
|
|
18
|
+
export declare function lowerMultiAssign(this: Lowerer, s: Extract<Stmt, {
|
|
19
|
+
type: "MultiAssign";
|
|
20
|
+
}>): IRStmt | IRStmt[];
|
|
21
|
+
/** Validate each multi-output slot type, register the lvalue
|
|
22
|
+
* bindings in env (or mark them as discarded), and return the
|
|
23
|
+
* `MultiAssignCall.outputs` list. Single chokepoint for the
|
|
24
|
+
* user-function and builtin multi-output paths.
|
|
25
|
+
*
|
|
26
|
+
* `slotLabel(i)` returns a per-slot description for the error
|
|
27
|
+
* message when a slot's type isn't supported — e.g. `output 'a'`
|
|
28
|
+
* for declared user-function outputs or `output slot 1` for builtin
|
|
29
|
+
* slots that have no source-level name. */
|
|
30
|
+
export declare function buildMultiOutputSlots(this: Lowerer, callName: string, slotTypes: ReadonlyArray<Type>, lvalues: ReadonlyArray<LValue>, slotLabel: (i: number) => string, span: Span): {
|
|
31
|
+
ty: Type;
|
|
32
|
+
binding: {
|
|
33
|
+
name: string;
|
|
34
|
+
cName: string;
|
|
35
|
+
} | null;
|
|
36
|
+
}[];
|