numbl 0.3.0 → 0.3.3
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 +16 -33
- package/dist-cli/cli.js +20535 -25629
- package/dist-lib/graphics/types.d.ts +22 -0
- package/dist-lib/lib.d.ts +1 -0
- package/dist-lib/lib.js +59075 -63895
- package/dist-lib/numbl-core/executeCode.d.ts +11 -14
- package/dist-lib/numbl-core/executors/cJit/builtins.d.ts +30 -0
- package/dist-lib/numbl-core/executors/cJit/chainCodegen.d.ts +59 -0
- package/dist-lib/numbl-core/executors/cJit/chainExecutor.d.ts +27 -0
- package/dist-lib/numbl-core/executors/cJit/chainPass.d.ts +42 -0
- package/dist-lib/numbl-core/executors/cJit/codegen.d.ts +44 -0
- package/dist-lib/numbl-core/executors/cJit/compile.d.ts +45 -0
- package/dist-lib/numbl-core/executors/cJit/elemwiseCodegen.d.ts +23 -0
- package/dist-lib/numbl-core/executors/cJit/elemwiseStructural.d.ts +33 -0
- package/dist-lib/numbl-core/executors/cJit/fuseAnalyze.d.ts +39 -0
- package/dist-lib/numbl-core/executors/cJit/fuseCodegen.d.ts +16 -0
- package/dist-lib/numbl-core/executors/cJit/fuseExecutor.d.ts +28 -0
- package/dist-lib/numbl-core/executors/cJit/loopExecutor.d.ts +32 -0
- package/dist-lib/numbl-core/executors/cJit/register.d.ts +10 -0
- package/dist-lib/numbl-core/executors/cJit/whitelist.d.ts +15 -0
- package/dist-lib/numbl-core/executors/cache.d.ts +26 -0
- package/dist-lib/numbl-core/executors/context.d.ts +76 -0
- package/dist-lib/numbl-core/executors/index.d.ts +17 -0
- package/dist-lib/numbl-core/executors/jsJit/callExecutor.d.ts +25 -0
- package/dist-lib/numbl-core/{jit/js → executors/jsJit/codegen}/jitCodegen.d.ts +2 -2
- package/dist-lib/numbl-core/{jit/js → executors/jsJit/codegen}/jitCodegenHoist.d.ts +1 -1
- package/dist-lib/numbl-core/{jit/js → executors/jsJit/codegen}/jsMultiReduction.d.ts +10 -13
- package/dist-lib/numbl-core/executors/jsJit/helpers/alloc.d.ts +12 -0
- package/dist-lib/numbl-core/{jit/js → executors/jsJit/helpers}/jitHelpers.d.ts +2 -2
- package/dist-lib/numbl-core/{jit/js → executors/jsJit/helpers}/jitHelpersComplex.d.ts +1 -1
- package/dist-lib/numbl-core/executors/jsJit/helpers/jitHelpersIndex.d.ts +33 -0
- package/dist-lib/numbl-core/{jit/js → executors/jsJit/helpers}/jitHelpersTensor.d.ts +7 -7
- package/dist-lib/numbl-core/executors/jsJit/jitCall.d.ts +59 -0
- package/dist-lib/numbl-core/executors/jsJit/jitLoop.d.ts +53 -0
- package/dist-lib/numbl-core/executors/jsJit/jitTopLevel.d.ts +44 -0
- package/dist-lib/numbl-core/executors/jsJit/loopExecutor.d.ts +15 -0
- package/dist-lib/numbl-core/{jit/jitLoopAnalysis.d.ts → executors/jsJit/lower/blockAnalysis.d.ts} +5 -5
- package/dist-lib/numbl-core/{jit → executors/jsJit/lower}/jitBailSafety.d.ts +1 -1
- package/dist-lib/numbl-core/{jit → executors/jsJit/lower}/jitLower.d.ts +18 -4
- package/dist-lib/numbl-core/{jit → executors/jsJit/lower}/jitLowerExpr.d.ts +11 -2
- package/dist-lib/numbl-core/{jit → executors/jsJit/lower}/jitLowerStmt.d.ts +2 -2
- package/dist-lib/numbl-core/{jit → executors/jsJit/lower}/jitLowerTypes.d.ts +2 -2
- package/dist-lib/numbl-core/{jit → executors/jsJit/lower}/scalarEmit.d.ts +2 -2
- package/dist-lib/numbl-core/executors/jsJit/shared.d.ts +120 -0
- package/dist-lib/numbl-core/executors/jsJit/topLevelExecutor.d.ts +17 -0
- package/dist-lib/numbl-core/executors/lowering.d.ts +166 -0
- package/dist-lib/numbl-core/executors/plugins.d.ts +39 -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/interpreter/builtins/datetime.d.ts +2 -1
- package/dist-lib/numbl-core/interpreter/builtins/misc.d.ts +4 -1
- package/dist-lib/numbl-core/interpreter/builtins/types.d.ts +4 -91
- package/dist-lib/numbl-core/interpreter/interpreter.d.ts +33 -47
- 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/jitTypes.d.ts → jitTypes.d.ts} +15 -1
- package/dist-lib/numbl-core/jsUserFunctions.d.ts +8 -0
- 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/types.d.ts +20 -0
- 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 +3 -2
- package/dist-lib/numbl-core/runtime/indexing.d.ts +6 -1
- 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 +27 -66
- 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 +104 -62
- package/dist-lib/numbl-core/runtime/utils.d.ts +2 -8
- package/dist-lib/numbl-core/version.d.ts +1 -1
- package/dist-plot-viewer/assets/index-COAM8o1E.js +4426 -0
- package/dist-plot-viewer/index.html +1 -1
- package/native/lapack_linsolve.cpp +1 -1
- package/native/numbl_addon_common.h +2 -2
- package/native/ops/comparison.c +1 -1
- package/package.json +3 -6
- 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/index.d.ts +0 -7
- package/dist-lib/numbl-core/jit/jitLoop.d.ts +0 -25
- package/dist-lib/numbl-core/jit/jitTopLevel.d.ts +0 -22
- package/dist-lib/numbl-core/jit/js/jitHelpersIndex.d.ts +0 -33
- package/dist-lib/numbl-core/jit/js/jsFusedCodegen.d.ts +0 -17
- package/dist-lib/numbl-core/runtime/alloc.d.ts +0 -23
- 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,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plot builtin dispatch — the single source of truth for the
|
|
3
|
+
* `(name, args)` → `PlotInstruction[]` mapping that every plotting
|
|
4
|
+
* builtin performs.
|
|
5
|
+
*
|
|
6
|
+
* Historically this logic was scattered across two places:
|
|
7
|
+
* - `runtime.ts` registered the data-bearing plot names
|
|
8
|
+
* (`plot`, `surf`, `imagesc`, …) inside `initBuiltins`.
|
|
9
|
+
* - `specialBuiltins.ts` registered the graphics ops (`figure`,
|
|
10
|
+
* `title`, `xlabel`, `hold`, `subplot`, `clf`, …) inside
|
|
11
|
+
* `registerSpecialBuiltins`.
|
|
12
|
+
*
|
|
13
|
+
* Both sites pushed onto `rt.plotInstructions` and (for `hold` /
|
|
14
|
+
* `tiledlayout` / `nexttile`) updated small flags on the Runtime.
|
|
15
|
+
* `dispatchPlotBuiltin` is the consolidation. The Runtime registers
|
|
16
|
+
* each name with a 1-line wrapper that calls this function and then
|
|
17
|
+
* returns the right `nargout`-handle value; the side-effect (the
|
|
18
|
+
* push) lives here.
|
|
19
|
+
*
|
|
20
|
+
* Out-of-scope names — kept registered separately because their
|
|
21
|
+
* semantics need the full Runtime context:
|
|
22
|
+
* - `fplot` / `fplot3` — evaluate a user function-handle, need
|
|
23
|
+
* the Runtime's executor.
|
|
24
|
+
* - `drawnow` / `pause` — call the `ExecOptions` callbacks
|
|
25
|
+
* (`onDrawnow`, `onPause`).
|
|
26
|
+
* - `streamline` / `stream2` — return non-trivial values.
|
|
27
|
+
* - `ishold` — reads `state.holdState`, but is a pure query (no
|
|
28
|
+
* instructions pushed); the Runtime can call `state.holdState`
|
|
29
|
+
* directly.
|
|
30
|
+
*
|
|
31
|
+
* Reusable from outside numbl: mtoc2 (the static-translation
|
|
32
|
+
* sibling project) imports this function to render plots in its
|
|
33
|
+
* browser IDE without reimplementing per-builtin logic.
|
|
34
|
+
*/
|
|
35
|
+
import type { RuntimeValue } from "./types.js";
|
|
36
|
+
import type { PlotInstruction } from "../../graphics/types.js";
|
|
37
|
+
/** State carried by graphics ops that need to remember things between
|
|
38
|
+
* calls. `holdState` is read by `ishold()` so `hold on; if ishold ...`
|
|
39
|
+
* works; `tiledLayoutState` lets `nexttile` know where to place the
|
|
40
|
+
* next axes. The `Runtime` class implements this interface; mtoc2's
|
|
41
|
+
* browser viewer keeps its own instance. */
|
|
42
|
+
export interface PlotDispatchState {
|
|
43
|
+
holdState: boolean;
|
|
44
|
+
tiledLayoutState: TiledLayoutState | null;
|
|
45
|
+
}
|
|
46
|
+
/** Active tiled-layout grid. `mode` controls how the grid grows: in
|
|
47
|
+
* `flow` (default), nexttile expands rows/cols to fit; `vertical` and
|
|
48
|
+
* `horizontal` extend one axis; `fixed` uses the M/N from the
|
|
49
|
+
* tiledlayout(M,N) call verbatim. */
|
|
50
|
+
export interface TiledLayoutState {
|
|
51
|
+
rows: number;
|
|
52
|
+
cols: number;
|
|
53
|
+
mode: "fixed" | "flow" | "vertical" | "horizontal";
|
|
54
|
+
count: number;
|
|
55
|
+
}
|
|
56
|
+
/** Run a single plot-builtin call. Pushes onto `instructions` and
|
|
57
|
+
* updates `state` to mirror what numbl's runtime did before this
|
|
58
|
+
* refactor. Returns `true` iff `name` was a recognized plot builtin;
|
|
59
|
+
* callers fall through to their own dispatch on `false`. */
|
|
60
|
+
export declare function dispatchPlotBuiltin(name: string, args: RuntimeValue[], instructions: PlotInstruction[], state: PlotDispatchState): boolean;
|
|
61
|
+
/** Names handled by `dispatchPlotBuiltin`. Useful for registering all
|
|
62
|
+
* of them in a loop (numbl's `initBuiltins` / `registerSpecialBuiltins`
|
|
63
|
+
* do that for the side-effect-only subset). Stays in sync with the
|
|
64
|
+
* cases above by construction. */
|
|
65
|
+
export declare const PLOT_DISPATCH_NAMES: ReadonlyArray<string>;
|
|
66
|
+
/** Graphics-related names numbl exposes as no-op (or near-no-op)
|
|
67
|
+
* stubs — they don't push plot instructions and don't render, but
|
|
68
|
+
* numbl accepts them so MATLAB scripts compile and run. Sources:
|
|
69
|
+
* - `interpreter/builtins/misc.ts` (`groot`, `gcf`, `gca`, `shg`,
|
|
70
|
+
* `newplot`, `xlim`, `ylim`, `set`, `get`, `ishold`)
|
|
71
|
+
* - `runtime/specialBuiltins.ts` (`drawnow`, `pause`)
|
|
72
|
+
*
|
|
73
|
+
* These names belong here, alongside `PLOT_DISPATCH_NAMES`, because
|
|
74
|
+
* downstream consumers (mtoc2's translator, syntax highlighters,
|
|
75
|
+
* doc generators) want to know the full "plot-script surface area"
|
|
76
|
+
* numbl tolerates — not just the renderable subset. Keeping the
|
|
77
|
+
* union in one place is the whole point of consolidating dispatch
|
|
78
|
+
* here. */
|
|
79
|
+
export declare const PLOT_STUB_NAMES: ReadonlyArray<string>;
|
|
80
|
+
/** The union of `PLOT_DISPATCH_NAMES` (renderable) and
|
|
81
|
+
* `PLOT_STUB_NAMES` (recognized-but-no-render). Every name a plotting
|
|
82
|
+
* script might invoke that numbl tolerates. Mtoc2 imports this to
|
|
83
|
+
* drive its own builtin registration so the two repos stay in
|
|
84
|
+
* lockstep — when numbl gains a new plot builtin, mtoc2 picks it up
|
|
85
|
+
* at the next `tsc` / `vite build` with no mtoc2-side edit. */
|
|
86
|
+
export declare const PLOT_ALL_NAMES: ReadonlyArray<string>;
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* plot(X1,Y1,LineSpec1,...), and Name-Value pairs like 'Color','r','LineWidth',2.
|
|
6
6
|
*/
|
|
7
7
|
import { type RuntimeValue } from "./types.js";
|
|
8
|
-
export type { PlotTrace, Plot3Trace, SurfTrace, ImagescTrace, PcolorTrace, ContourTrace, BarTrace, Bar3Trace, ErrorBarTrace, BoxTrace, PieTrace, HeatmapTrace, } from "../../graphics/types.js";
|
|
9
|
-
import type { PlotTrace, Plot3Trace, SurfTrace, ImagescTrace, PcolorTrace, ContourTrace, BarTrace, Bar3Trace, ErrorBarTrace, BoxTrace, PieTrace, HeatmapTrace } from "../../graphics/types.js";
|
|
8
|
+
export type { PlotTrace, Plot3Trace, SurfTrace, ImagescTrace, PcolorTrace, ContourTrace, BarTrace, Bar3Trace, ErrorBarTrace, BoxTrace, PieTrace, HeatmapTrace, QuiverTrace, } from "../../graphics/types.js";
|
|
9
|
+
import type { PlotTrace, Plot3Trace, SurfTrace, ImagescTrace, PcolorTrace, ContourTrace, BarTrace, Bar3Trace, ErrorBarTrace, BoxTrace, PieTrace, HeatmapTrace, QuiverTrace } from "../../graphics/types.js";
|
|
10
10
|
export interface ParsedLineSpec {
|
|
11
11
|
color?: string;
|
|
12
12
|
lineStyle?: string;
|
|
@@ -222,3 +222,18 @@ export declare function parsePiechartArgs(args: RuntimeValue[], innerRadius: num
|
|
|
222
222
|
* heatmap(xvalues, yvalues, cdata) — with axis labels
|
|
223
223
|
*/
|
|
224
224
|
export declare function parseHeatmapArgs(args: RuntimeValue[]): HeatmapTrace;
|
|
225
|
+
/**
|
|
226
|
+
* Parse quiver() arguments.
|
|
227
|
+
*
|
|
228
|
+
* Supported forms:
|
|
229
|
+
* quiver(U, V)
|
|
230
|
+
* quiver(X, Y, U, V)
|
|
231
|
+
* quiver(..., scale) — scale: nonnegative number or 'off'
|
|
232
|
+
* quiver(..., LineSpec)
|
|
233
|
+
* quiver(..., LineSpec, 'filled')
|
|
234
|
+
* quiver(..., Name, Value) — Color, LineStyle, LineWidth, ShowArrowHead, etc.
|
|
235
|
+
*
|
|
236
|
+
* X, Y, U, V can be vectors or matrices. If U,V are matrices and X,Y are
|
|
237
|
+
* vectors, X and Y are expanded to a meshgrid.
|
|
238
|
+
*/
|
|
239
|
+
export declare function parseQuiverArgs(args: RuntimeValue[]): QuiverTrace[];
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reference counting for RuntimeValue containers, used both for
|
|
3
|
+
* lifecycle (decref → _destroy chain) and for refcount-driven COW.
|
|
4
|
+
*
|
|
5
|
+
* Every container kind extends `Refcounted`. The count starts at 0
|
|
6
|
+
* (newly-constructed value, not yet bound to anything), is incremented
|
|
7
|
+
* when a slot (env binding, struct field, cell element, ...) takes
|
|
8
|
+
* ownership, and decremented when the slot releases ownership. When the
|
|
9
|
+
* count reaches 0, `_destroy` runs and decrefs every child value.
|
|
10
|
+
*
|
|
11
|
+
* COW uses `effectiveRc(v)` — the count minus the number of currently
|
|
12
|
+
* active per-statement scopes that hold the value. Scope adoption is
|
|
13
|
+
* a transient lifecycle artifact (it keeps the wrapper alive across an
|
|
14
|
+
* expression's evaluation); it isn't an ownership relationship that
|
|
15
|
+
* should force a copy.
|
|
16
|
+
*
|
|
17
|
+
* Strict mode (`rt.strictRefcount`) makes a decref of an already-zero
|
|
18
|
+
* count throw.
|
|
19
|
+
*/
|
|
20
|
+
export declare function pushCurrentRuntime(rt: RefcountRuntime): void;
|
|
21
|
+
export declare function popCurrentRuntime(rt: RefcountRuntime): void;
|
|
22
|
+
export declare function getCurrentRuntime(): RefcountRuntime | null;
|
|
23
|
+
/** Minimal runtime surface used by the refcount API. The real `Runtime`
|
|
24
|
+
* class satisfies this; using an interface here avoids a circular
|
|
25
|
+
* import between refcount.ts ↔ runtime.ts ↔ types.ts. */
|
|
26
|
+
export interface RefcountRuntime {
|
|
27
|
+
/** When true, decref of a zero count throws. */
|
|
28
|
+
strictRefcount?: boolean;
|
|
29
|
+
/** Per-statement transient scope. Constructors auto-adopt fresh
|
|
30
|
+
* values here so an unbound expression result stays alive until end
|
|
31
|
+
* of statement. Null when no statement is in flight. */
|
|
32
|
+
currentScope?: RefScope | null;
|
|
33
|
+
}
|
|
34
|
+
/** Base class for every refcounted runtime value. */
|
|
35
|
+
export declare abstract class Refcounted {
|
|
36
|
+
/** Public so type guards can look for a `kind` discriminator without
|
|
37
|
+
* walking the prototype. The string is set by every subclass. */
|
|
38
|
+
abstract readonly kind: string;
|
|
39
|
+
/** Reference count. Starts at 0; incremented when bound to a slot. */
|
|
40
|
+
_rc: number;
|
|
41
|
+
/** Subset of `_rc` contributed by active per-statement scopes. The
|
|
42
|
+
* COW check uses `_rc - _scopeHolds` so transient scope holds don't
|
|
43
|
+
* force unnecessary copies (a value freshly constructed during a
|
|
44
|
+
* statement and passed to a function would otherwise look "shared"
|
|
45
|
+
* to the callee). */
|
|
46
|
+
_scopeHolds: number;
|
|
47
|
+
constructor();
|
|
48
|
+
incref(): void;
|
|
49
|
+
decref(rt: RefcountRuntime): void;
|
|
50
|
+
/** Subclasses release child refs. Idempotent must NOT be assumed —
|
|
51
|
+
* callers guarantee this fires exactly once. Default is a no-op for
|
|
52
|
+
* kinds that have no child refs (RuntimeChar, RuntimeComplexNumber,
|
|
53
|
+
* RuntimeDummyHandle, etc.). */
|
|
54
|
+
protected _destroy(_rt: RefcountRuntime): void;
|
|
55
|
+
}
|
|
56
|
+
/** True if the value is a container that participates in refcounting.
|
|
57
|
+
* Primitives (number, boolean, string) return false. */
|
|
58
|
+
export declare function isRefcountable(v: unknown): v is Refcounted;
|
|
59
|
+
/** Increment refcount on a value if it's a container; primitives are noop. */
|
|
60
|
+
export declare function incref(v: unknown): void;
|
|
61
|
+
/** Decrement refcount on a value if it's a container; primitives are noop. */
|
|
62
|
+
export declare function decref(rt: RefcountRuntime, v: unknown): void;
|
|
63
|
+
/** True if `v` has more than one external (non-scope) holder — i.e. a
|
|
64
|
+
* mutation through one slot would observably affect another holder.
|
|
65
|
+
* Primitives return false; primitives can never be "shared" since
|
|
66
|
+
* every slot stores a copy of the value. */
|
|
67
|
+
export declare function isShared(v: unknown): boolean;
|
|
68
|
+
/** Per-statement transients harness. Fresh values produced by constructors
|
|
69
|
+
* and operators are adopted here at rc=1; on `drain`, every member is
|
|
70
|
+
* decref'd. Anything bound to a slot during the statement gets an extra
|
|
71
|
+
* incref from the slot, so it survives drain at slot count.
|
|
72
|
+
*
|
|
73
|
+
* Each adopt also increments the value's `_scopeHolds`, which the COW
|
|
74
|
+
* check (`isShared`) subtracts from `_rc` — the scope's hold is a
|
|
75
|
+
* lifecycle artifact, not an ownership relationship that should force
|
|
76
|
+
* a copy. */
|
|
77
|
+
export declare class RefScope {
|
|
78
|
+
private members;
|
|
79
|
+
/** Take ownership of a fresh value: incref and remember for drain. */
|
|
80
|
+
adopt(v: unknown): void;
|
|
81
|
+
/** Release every adopted value. Called in `withScope`'s finally. */
|
|
82
|
+
drain(rt: RefcountRuntime): void;
|
|
83
|
+
/** Number of currently-adopted values (for assertions/tests). */
|
|
84
|
+
size(): number;
|
|
85
|
+
}
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
* runtimeDispatch.ts, and helper types/utilities in runtimeHelpers.ts.
|
|
12
12
|
*/
|
|
13
13
|
import { type RuntimeValue, type RuntimeLogical, type RuntimeTensor, type RuntimeStruct, type RuntimeString, type RuntimeFunction, RuntimeError, type CallFrame } from "../runtime/index.js";
|
|
14
|
+
import { RefScope } from "./refcount.js";
|
|
14
15
|
import { RuntimeChar, RuntimeCell, type RuntimeComplexNumber, type RuntimeClassInstance } from "../runtime/types.js";
|
|
15
16
|
import { type ItemType } from "../lowering/itemTypes.js";
|
|
16
17
|
import type { PlotInstruction } from "../../graphics/types.js";
|
|
@@ -25,6 +26,12 @@ export declare class Runtime {
|
|
|
25
26
|
plotInstructions: PlotInstruction[];
|
|
26
27
|
variableValues: Record<string, RuntimeValue>;
|
|
27
28
|
holdState: boolean;
|
|
29
|
+
tiledLayoutState: {
|
|
30
|
+
rows: number;
|
|
31
|
+
cols: number;
|
|
32
|
+
mode: "fixed" | "flow" | "vertical" | "horizontal";
|
|
33
|
+
count: number;
|
|
34
|
+
} | null;
|
|
28
35
|
private cancelFlag;
|
|
29
36
|
$line: number;
|
|
30
37
|
$file: string | null;
|
|
@@ -37,12 +44,12 @@ export declare class Runtime {
|
|
|
37
44
|
END: symbol;
|
|
38
45
|
RTV: {
|
|
39
46
|
num(value: number): import("../runtime/types.js").RuntimeNumber;
|
|
40
|
-
tensor(data:
|
|
41
|
-
tensorRaw(data:
|
|
47
|
+
tensor(data: Float64Array | number[], shape: number[], imag?: Float64Array | number[]): RuntimeTensor;
|
|
48
|
+
tensorRaw(data: Float64Array, shape: number[]): RuntimeTensor;
|
|
42
49
|
scalar(value: number): import("../runtime/types.js").RuntimeNumber;
|
|
43
50
|
row(data: number[], imag?: number[]): RuntimeTensor;
|
|
44
51
|
col(data: number[], imag?: number[]): RuntimeTensor;
|
|
45
|
-
matrix(rows: number, cols: number, data: number[] |
|
|
52
|
+
matrix(rows: number, cols: number, data: number[] | Float64Array, imag?: number[] | Float64Array): RuntimeTensor;
|
|
46
53
|
string(value: string): RuntimeString;
|
|
47
54
|
char(value: string): RuntimeChar;
|
|
48
55
|
logical(value: boolean): RuntimeLogical;
|
|
@@ -60,8 +67,19 @@ export declare class Runtime {
|
|
|
60
67
|
value: RuntimeValue;
|
|
61
68
|
}>, keyType?: string, valueType?: string): import("../runtime/types.js").RuntimeDictionary;
|
|
62
69
|
};
|
|
63
|
-
|
|
70
|
+
persistentStore: Map<string, Map<string, RuntimeValue>>;
|
|
64
71
|
$g: Record<string, RuntimeValue>;
|
|
72
|
+
/** Active per-statement transient scope. New refcounted values are
|
|
73
|
+
* auto-adopted into this scope (rc 0→1) on construction so they
|
|
74
|
+
* survive long enough to be bound somewhere; on scope drain at end
|
|
75
|
+
* of statement, anything still held only by the scope is decref'd
|
|
76
|
+
* to 0 and destroyed. Null when no statement is in flight. */
|
|
77
|
+
currentScope: RefScope | null;
|
|
78
|
+
/** When true, `decref` on a zero count throws (loud at the
|
|
79
|
+
* underflow site rather than silently leaking). On by default — the
|
|
80
|
+
* refcount-driven COW system relies on accurate refcounts to make
|
|
81
|
+
* correct mutate-vs-copy decisions. */
|
|
82
|
+
strictRefcount: boolean;
|
|
65
83
|
activeAccessors: Set<string>;
|
|
66
84
|
resolveClassMethod: ((className: string, methodName: string) => ((...args: any[]) => any) | null) | null;
|
|
67
85
|
getClassParent: ((className: string) => string | null) | null;
|
|
@@ -112,6 +130,10 @@ export declare class Runtime {
|
|
|
112
130
|
constructor(options: ExecOptions, initialVariableValues?: Record<string, RuntimeValue> | undefined);
|
|
113
131
|
/** Throw CancellationError if the cancel flag has been set. */
|
|
114
132
|
checkCancel(): void;
|
|
133
|
+
/** Run `fn` with a fresh `RefScope` as `this.currentScope`. On return,
|
|
134
|
+
* every value adopted into the scope is decref'd. Used by `execStmt`
|
|
135
|
+
* to bound the lifetime of expression transients to one statement. */
|
|
136
|
+
withScope<T>(fn: () => T): T;
|
|
115
137
|
private initBuiltins;
|
|
116
138
|
profileEnter(key: string): void;
|
|
117
139
|
profileLeave(): void;
|
|
@@ -146,7 +168,6 @@ export declare class Runtime {
|
|
|
146
168
|
lg(v: boolean): RuntimeLogical;
|
|
147
169
|
/** Scalar power that returns complex for negative base with fractional exponent */
|
|
148
170
|
pow(a: number, b: number): number | RuntimeComplexNumber;
|
|
149
|
-
share(v: unknown): RuntimeValue;
|
|
150
171
|
get displayResults(): boolean;
|
|
151
172
|
displayResult(v: unknown): void;
|
|
152
173
|
displayAssign(name: string, v: unknown): void;
|
|
@@ -270,68 +291,8 @@ export declare class Runtime {
|
|
|
270
291
|
memberChainAssign(base: unknown, names: string[], rhs: unknown): unknown;
|
|
271
292
|
narginchk(actualNargin: unknown, minArgs: unknown, maxArgs: unknown): void;
|
|
272
293
|
nargoutchk(actualNargout: unknown, minArgs: unknown, maxArgs: unknown): void;
|
|
273
|
-
|
|
274
|
-
type: "set_figure_handle";
|
|
275
|
-
handle: unknown;
|
|
276
|
-
} | {
|
|
277
|
-
type: "plot";
|
|
278
|
-
x: unknown;
|
|
279
|
-
y: unknown;
|
|
280
|
-
} | {
|
|
281
|
-
type: "set_hold";
|
|
282
|
-
value: unknown;
|
|
283
|
-
} | {
|
|
284
|
-
type: "close";
|
|
285
|
-
} | {
|
|
286
|
-
type: "close_all";
|
|
287
|
-
} | {
|
|
288
|
-
type: "clf";
|
|
289
|
-
} | {
|
|
290
|
-
type: "set_subplot";
|
|
291
|
-
rows: unknown;
|
|
292
|
-
cols: unknown;
|
|
293
|
-
index: unknown;
|
|
294
|
-
} | {
|
|
295
|
-
type: "set_sgtitle";
|
|
296
|
-
text: unknown;
|
|
297
|
-
} | {
|
|
298
|
-
type: "set_grid";
|
|
299
|
-
value: unknown;
|
|
300
|
-
}): void;
|
|
294
|
+
/** Read the hold state, for `ishold()` queries. */
|
|
301
295
|
ishold(): RuntimeValue;
|
|
302
|
-
plot_call(args: RuntimeValue[]): void;
|
|
303
|
-
plot3_call(args: RuntimeValue[]): void;
|
|
304
|
-
surf_call(args: RuntimeValue[]): void;
|
|
305
|
-
scatter_call(args: RuntimeValue[]): void;
|
|
306
|
-
imagesc_call(args: RuntimeValue[]): void;
|
|
307
|
-
pcolor_call(args: RuntimeValue[]): void;
|
|
308
|
-
contour_call(args: RuntimeValue[], filled: boolean): void;
|
|
309
|
-
mesh_call(args: RuntimeValue[]): void;
|
|
310
|
-
bar_call(args: RuntimeValue[]): void;
|
|
311
|
-
barh_call(args: RuntimeValue[]): void;
|
|
312
|
-
bar3_call(args: RuntimeValue[]): void;
|
|
313
|
-
bar3h_call(args: RuntimeValue[]): void;
|
|
314
|
-
stairs_call(args: RuntimeValue[]): void;
|
|
315
|
-
errorbar_call(args: RuntimeValue[]): void;
|
|
316
|
-
semilogx_call(args: RuntimeValue[]): void;
|
|
317
|
-
semilogy_call(args: RuntimeValue[]): void;
|
|
318
|
-
loglog_call(args: RuntimeValue[]): void;
|
|
319
|
-
area_call(args: RuntimeValue[]): void;
|
|
320
|
-
fplot_call(args: RuntimeValue[]): void;
|
|
321
|
-
fplot3_call(args: RuntimeValue[]): void;
|
|
322
|
-
scatter3_call(args: RuntimeValue[]): void;
|
|
323
|
-
histogram_call(args: RuntimeValue[]): void;
|
|
324
|
-
histogram2_call(args: RuntimeValue[]): void;
|
|
325
|
-
boxchart_call(args: RuntimeValue[]): void;
|
|
326
|
-
swarmchart_call(args: RuntimeValue[]): void;
|
|
327
|
-
swarmchart3_call(args: RuntimeValue[]): void;
|
|
328
|
-
piechart_call(args: RuntimeValue[]): void;
|
|
329
|
-
donutchart_call(args: RuntimeValue[]): void;
|
|
330
|
-
heatmap_call(args: RuntimeValue[]): void;
|
|
331
|
-
streamline_call(args: RuntimeValue[]): RuntimeValue;
|
|
332
|
-
stream2_call(args: RuntimeValue[]): RuntimeValue;
|
|
333
|
-
view_call(args: RuntimeValue[]): void;
|
|
334
|
-
legend_call(args: RuntimeValue[]): void;
|
|
335
296
|
drawnow(): void;
|
|
336
297
|
pause(seconds: unknown): void;
|
|
337
298
|
readInput(prompt: string): string;
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* Standalone functions that take the Runtime instance as the first parameter.
|
|
5
5
|
* Handles function/class dispatch, arrayfun/cellfun/bsxfun, and subsref/subsasgn.
|
|
6
6
|
*/
|
|
7
|
-
import { type RuntimeValue, type RuntimeLogical,
|
|
7
|
+
import { type RuntimeValue, type RuntimeLogical, RuntimeFunction } from "../runtime/index.js";
|
|
8
8
|
import type { Runtime } from "./runtime.js";
|
|
9
9
|
export declare function getFuncHandle(name: string): RuntimeFunction;
|
|
10
10
|
export declare function makeUserFuncHandle(jsFn: (...args: unknown[]) => unknown, nargin?: number): RuntimeFunction;
|
|
11
11
|
export declare function isa(rt: Runtime, value: unknown, classNameArg: unknown): RuntimeLogical;
|
|
12
|
-
export declare function callSuperConstructor(target: unknown, superInstance: unknown): RuntimeValue;
|
|
12
|
+
export declare function callSuperConstructor(target: unknown, superInstance: unknown, rt?: Runtime): RuntimeValue;
|
|
13
13
|
export declare function createClassInstance(_rt: Runtime, className: string, propertyNames: string[], defaults?: Record<string, unknown>, isHandleClass?: boolean): RuntimeValue;
|
|
14
14
|
export declare function dispatch(rt: Runtime, name: string, nargout: number, args: unknown[], targetClassName?: string): unknown;
|
|
15
15
|
/** Direct builtin call — skips local/workspace/registry lookup. */
|
|
@@ -20,9 +20,9 @@ export declare function indexStore(rt: Runtime, base: unknown, indices: unknown[
|
|
|
20
20
|
/**
|
|
21
21
|
* Cell-indexed assignment (curly braces).
|
|
22
22
|
*/
|
|
23
|
-
export declare function indexCellStore(base: unknown, indices: unknown[], rhs: unknown): unknown;
|
|
23
|
+
export declare function indexCellStore(base: unknown, indices: unknown[], rhs: unknown, rt?: import("./refcount.js").RefcountRuntime): unknown;
|
|
24
24
|
/**
|
|
25
25
|
* Multi-output assignment to cell elements: [c{idx}] = func()
|
|
26
26
|
* Distributes individual results to individual cell positions.
|
|
27
27
|
*/
|
|
28
|
-
export declare function multiOutputCellAssign(base: unknown, indices: unknown, results: unknown[]): unknown;
|
|
28
|
+
export declare function multiOutputCellAssign(base: unknown, indices: unknown, results: unknown[], rt?: import("./refcount.js").RefcountRuntime): unknown;
|
|
@@ -7,7 +7,7 @@ export declare function getMember(rt: Runtime, base: unknown, name: string): unk
|
|
|
7
7
|
export declare function getMemberDynamic(base: unknown, nameExpr: unknown): RuntimeValue;
|
|
8
8
|
export declare function getMemberOrEmpty(base: unknown, name: string): RuntimeValue;
|
|
9
9
|
export declare function setMemberReturn(rt: Runtime, base: unknown, name: string, rhs: unknown): unknown;
|
|
10
|
-
export declare function setMemberDynamicReturn(base: unknown, nameExpr: unknown, rhs: unknown): RuntimeValue;
|
|
10
|
+
export declare function setMemberDynamicReturn(rt: Runtime, base: unknown, nameExpr: unknown, rhs: unknown): RuntimeValue;
|
|
11
11
|
/**
|
|
12
12
|
* Call a user-defined subsref method on a class instance.
|
|
13
13
|
* Constructs S = struct('type', '.', 'subs', name) for each name in the chain.
|
|
@@ -100,6 +100,7 @@ export declare function swarmchart3Call(plotInstructions: PlotInstruction[], arg
|
|
|
100
100
|
export declare function piechartCall(plotInstructions: PlotInstruction[], args: RuntimeValue[]): void;
|
|
101
101
|
export declare function donutchartCall(plotInstructions: PlotInstruction[], args: RuntimeValue[]): void;
|
|
102
102
|
export declare function heatmapCall(plotInstructions: PlotInstruction[], args: RuntimeValue[]): void;
|
|
103
|
+
export declare function quiverCall(plotInstructions: PlotInstruction[], args: RuntimeValue[]): void;
|
|
103
104
|
export declare function legendCall(plotInstructions: PlotInstruction[], args: RuntimeValue[]): void;
|
|
104
105
|
export declare function drawnow(plotInstructions: PlotInstruction[], options: ExecOptions): void;
|
|
105
106
|
export declare function pause(seconds: unknown): void;
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
* Struct and class instance field access.
|
|
3
3
|
*/
|
|
4
4
|
import { type RuntimeValue } from "./types.js";
|
|
5
|
+
import { type RefcountRuntime } from "./refcount.js";
|
|
5
6
|
export declare function getRTValueField(base: RuntimeValue, field: string): RuntimeValue;
|
|
6
|
-
export declare function setRTValueField(base: RuntimeValue, field: string, value: RuntimeValue): RuntimeValue;
|
|
7
|
+
export declare function setRTValueField(base: RuntimeValue, field: string, value: RuntimeValue, rt?: RefcountRuntime): RuntimeValue;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
+
import { Refcounted, type RefcountRuntime } from "./refcount.js";
|
|
1
2
|
export declare const USE_FLOAT32: boolean;
|
|
2
|
-
export declare const FloatXArray: Float32ArrayConstructor | Float64ArrayConstructor;
|
|
3
|
-
export type FloatXArrayType = Float32Array | Float64Array;
|
|
4
3
|
export type RuntimeValue = number | boolean | string | RuntimeTensor | RuntimeChar | RuntimeCell | RuntimeStruct | RuntimeFunction | RuntimeClassInstance | RuntimeComplexNumber | RuntimeDummyHandle | RuntimeGraphicsHandle | RuntimeStructArray | RuntimeClassInstanceArray | RuntimeSparseMatrix | RuntimeDictionary;
|
|
5
4
|
export type RuntimeNumber = number;
|
|
6
5
|
export type RuntimeLogical = boolean;
|
|
@@ -22,104 +21,147 @@ export declare const isRuntimeClassInstanceArray: (value: RuntimeValue) => value
|
|
|
22
21
|
export declare const isRuntimeSparseMatrix: (value: RuntimeValue) => value is RuntimeSparseMatrix;
|
|
23
22
|
export declare const isRuntimeDictionary: (value: RuntimeValue) => value is RuntimeDictionary;
|
|
24
23
|
export declare const kstr: (value: RuntimeValue) => string;
|
|
25
|
-
export
|
|
26
|
-
kind: "tensor";
|
|
27
|
-
data:
|
|
28
|
-
imag
|
|
24
|
+
export declare class RuntimeTensor extends Refcounted {
|
|
25
|
+
readonly kind: "tensor";
|
|
26
|
+
data: Float64Array;
|
|
27
|
+
imag: Float64Array | undefined;
|
|
29
28
|
shape: number[];
|
|
30
|
-
/** When true, this tensor represents a logical (boolean) array from
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
export
|
|
36
|
-
kind: "char";
|
|
29
|
+
/** When true, this tensor represents a logical (boolean) array from
|
|
30
|
+
* comparisons/logical ops. */
|
|
31
|
+
_isLogical: boolean | undefined;
|
|
32
|
+
constructor(data: Float64Array, shape: number[], imag?: Float64Array, _isLogical?: boolean);
|
|
33
|
+
}
|
|
34
|
+
export declare class RuntimeChar extends Refcounted {
|
|
35
|
+
readonly kind: "char";
|
|
37
36
|
value: string;
|
|
38
|
-
/** Optional shape for multi-row char arrays. If absent, shape is
|
|
39
|
-
* For multi-row arrays, value contains all rows
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
/** Optional shape for multi-row char arrays. If absent, shape is
|
|
38
|
+
* [1, value.length]. For multi-row arrays, value contains all rows
|
|
39
|
+
* concatenated (each row is shape[1] chars). */
|
|
40
|
+
shape: number[] | undefined;
|
|
41
|
+
constructor(value: string, shape?: number[]);
|
|
42
|
+
}
|
|
43
|
+
export declare class RuntimeCell extends Refcounted {
|
|
44
|
+
readonly kind: "cell";
|
|
44
45
|
data: RuntimeValue[];
|
|
45
46
|
shape: number[];
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
constructor(data: RuntimeValue[], shape: number[]);
|
|
48
|
+
/** Replace element at idx, decref-old / incref-new. Caller resizes the
|
|
49
|
+
* shape if necessary; this method does not touch shape. */
|
|
50
|
+
bindElement(rt: RefcountRuntime, idx: number, value: RuntimeValue): void;
|
|
51
|
+
protected _destroy(rt: RefcountRuntime): void;
|
|
52
|
+
}
|
|
53
|
+
export declare class RuntimeStruct extends Refcounted {
|
|
54
|
+
readonly kind: "struct";
|
|
51
55
|
fields: Map<string, RuntimeValue>;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
56
|
+
constructor(fields: Map<string, RuntimeValue>);
|
|
57
|
+
/** Set/replace a field value, decref-old / incref-new. */
|
|
58
|
+
bindField(rt: RefcountRuntime, name: string, value: RuntimeValue): void;
|
|
59
|
+
protected _destroy(rt: RefcountRuntime): void;
|
|
60
|
+
}
|
|
61
|
+
export declare class RuntimeFunction extends Refcounted {
|
|
62
|
+
readonly kind: "function";
|
|
55
63
|
name: string;
|
|
56
64
|
/** For closures: captured variables */
|
|
57
65
|
captures: RuntimeValue[];
|
|
58
66
|
/** The underlying callable — either a builtin or user-defined function name */
|
|
59
67
|
impl: "builtin" | "user";
|
|
60
68
|
/** For anonymous functions and user function handles: the underlying JS closure */
|
|
61
|
-
jsFn
|
|
69
|
+
jsFn: ((...args: unknown[]) => unknown) | undefined;
|
|
62
70
|
/** When true, jsFn expects nargout as its first argument */
|
|
63
|
-
jsFnExpectsNargout
|
|
71
|
+
jsFnExpectsNargout: boolean | undefined;
|
|
64
72
|
/** Number of input parameters (for nargin(handle)) */
|
|
65
|
-
nargin
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
nargin: number | undefined;
|
|
74
|
+
/** Cleanup hook fired by `_destroy`. Anonymous functions use this to
|
|
75
|
+
* decref values held in their captured environment snapshot, since
|
|
76
|
+
* those refs live in the JS closure (not in `captures`). */
|
|
77
|
+
releaseExtra: ((rt: RefcountRuntime) => void) | undefined;
|
|
78
|
+
/** For anonymous-function snapshots: the captured environment, made
|
|
79
|
+
* visible to the alias sweep so a tensor stored both here and in
|
|
80
|
+
* the parent env triggers copy-on-write on parent-side mutations.
|
|
81
|
+
* (Only the structural shape `{ vars, parent }` is needed; typed
|
|
82
|
+
* loosely to avoid a runtime↔interpreter circular import.) */
|
|
83
|
+
capturedEnv: {
|
|
84
|
+
vars: Map<string, RuntimeValue>;
|
|
85
|
+
parent?: unknown;
|
|
86
|
+
} | undefined;
|
|
87
|
+
constructor(name: string, impl: "builtin" | "user", captures: RuntimeValue[], jsFn?: (...args: unknown[]) => unknown, jsFnExpectsNargout?: boolean, nargin?: number);
|
|
88
|
+
protected _destroy(rt: RefcountRuntime): void;
|
|
89
|
+
}
|
|
90
|
+
export declare class RuntimeClassInstance extends Refcounted {
|
|
91
|
+
readonly kind: "class_instance";
|
|
69
92
|
className: string;
|
|
70
93
|
fields: Map<string, RuntimeValue>;
|
|
71
94
|
/** True if this class inherits from handle (reference semantics). */
|
|
72
95
|
isHandleClass: boolean;
|
|
73
96
|
/** For classes that inherit from built-in types (e.g. classdef Foo < double),
|
|
74
97
|
* stores the underlying built-in data. */
|
|
75
|
-
_builtinData
|
|
76
|
-
|
|
98
|
+
_builtinData: RuntimeValue | undefined;
|
|
99
|
+
constructor(className: string, fields: Map<string, RuntimeValue>, isHandleClass: boolean, _builtinData?: RuntimeValue);
|
|
100
|
+
/** Set/replace a field value (handle-class in-place mutation), with
|
|
101
|
+
* proper decref-old / incref-new bookkeeping. Used for handle-class
|
|
102
|
+
* field assigns; value-class field assigns construct a new instance. */
|
|
103
|
+
bindField(rt: RefcountRuntime, name: string, value: RuntimeValue): void;
|
|
104
|
+
protected _destroy(rt: RefcountRuntime): void;
|
|
105
|
+
}
|
|
77
106
|
/** A 1-D array of class instances that all share the same class.
|
|
78
107
|
* Created by default horzcat/vertcat when the class doesn't overload them. */
|
|
79
|
-
export
|
|
80
|
-
kind: "class_instance_array";
|
|
108
|
+
export declare class RuntimeClassInstanceArray extends Refcounted {
|
|
109
|
+
readonly kind: "class_instance_array";
|
|
81
110
|
className: string;
|
|
82
111
|
elements: RuntimeClassInstance[];
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
112
|
+
constructor(className: string, elements: RuntimeClassInstance[]);
|
|
113
|
+
protected _destroy(rt: RefcountRuntime): void;
|
|
114
|
+
}
|
|
115
|
+
export declare class RuntimeComplexNumber extends Refcounted {
|
|
116
|
+
readonly kind: "complex_number";
|
|
86
117
|
re: number;
|
|
87
118
|
im: number;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
119
|
+
constructor(re: number, im: number);
|
|
120
|
+
}
|
|
121
|
+
export declare class RuntimeDummyHandle extends Refcounted {
|
|
122
|
+
readonly kind: "dummy_handle";
|
|
123
|
+
constructor();
|
|
124
|
+
}
|
|
92
125
|
/** Handle to a graphics object (e.g. surface returned by pcolor) with a mutable trace reference. */
|
|
93
|
-
export
|
|
94
|
-
kind: "graphics_handle";
|
|
126
|
+
export declare class RuntimeGraphicsHandle extends Refcounted {
|
|
127
|
+
readonly kind: "graphics_handle";
|
|
95
128
|
_trace: Record<string, unknown>;
|
|
96
129
|
_traceType: string;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
130
|
+
constructor(_trace: Record<string, unknown>, _traceType: string);
|
|
131
|
+
}
|
|
132
|
+
/** A 1-D array of structs that all share the same field names. */
|
|
133
|
+
export declare class RuntimeStructArray extends Refcounted {
|
|
134
|
+
readonly kind: "struct_array";
|
|
101
135
|
fieldNames: string[];
|
|
102
136
|
elements: RuntimeStruct[];
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
137
|
+
constructor(fieldNames: string[], elements: RuntimeStruct[]);
|
|
138
|
+
protected _destroy(rt: RefcountRuntime): void;
|
|
139
|
+
}
|
|
140
|
+
/** Sparse matrix in CSC (Compressed Sparse Column) format, matching MATLAB's
|
|
141
|
+
* internal representation. */
|
|
142
|
+
export declare class RuntimeSparseMatrix extends Refcounted {
|
|
143
|
+
readonly kind: "sparse_matrix";
|
|
107
144
|
m: number;
|
|
108
145
|
n: number;
|
|
109
146
|
ir: Int32Array;
|
|
110
147
|
jc: Int32Array;
|
|
111
148
|
pr: Float64Array;
|
|
112
|
-
pi
|
|
113
|
-
|
|
114
|
-
}
|
|
149
|
+
pi: Float64Array | undefined;
|
|
150
|
+
constructor(m: number, n: number, ir: Int32Array, jc: Int32Array, pr: Float64Array, pi?: Float64Array);
|
|
151
|
+
}
|
|
115
152
|
/** Dictionary mapping unique keys to values (MATLAB R2022b+). */
|
|
116
|
-
export
|
|
117
|
-
kind: "dictionary";
|
|
153
|
+
export declare class RuntimeDictionary extends Refcounted {
|
|
154
|
+
readonly kind: "dictionary";
|
|
118
155
|
/** Entries keyed by a hash string of the RuntimeValue key, preserving insertion order. */
|
|
119
156
|
entries: Map<string, {
|
|
120
157
|
key: RuntimeValue;
|
|
121
158
|
value: RuntimeValue;
|
|
122
159
|
}>;
|
|
123
|
-
keyType
|
|
124
|
-
valueType
|
|
125
|
-
|
|
160
|
+
keyType: string | undefined;
|
|
161
|
+
valueType: string | undefined;
|
|
162
|
+
constructor(entries?: Map<string, {
|
|
163
|
+
key: RuntimeValue;
|
|
164
|
+
value: RuntimeValue;
|
|
165
|
+
}>, keyType?: string, valueType?: string);
|
|
166
|
+
protected _destroy(rt: RefcountRuntime): void;
|
|
167
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tensor shape/indexing utilities
|
|
2
|
+
* Tensor shape/indexing utilities.
|
|
3
3
|
*/
|
|
4
|
-
import { type
|
|
4
|
+
import { type RuntimeTensor } from "./types.js";
|
|
5
5
|
/** Get 2D size (rows, cols) from shape, padding with 1s as needed.
|
|
6
6
|
* For N-D tensors (N>2), trailing dimensions are collapsed into cols,
|
|
7
7
|
* matching MATLAB's behavior when fewer subscripts than dimensions. */
|
|
@@ -14,9 +14,3 @@ export declare function colMajorIndex(row: number, col: number, rows: number): n
|
|
|
14
14
|
export declare function ind2sub(shape: number[], idx: number): number[];
|
|
15
15
|
/** Convert subscripts to linear index (column-major) */
|
|
16
16
|
export declare function sub2ind(shape: number[], subs: number[]): number;
|
|
17
|
-
/**
|
|
18
|
-
* Share an RuntimeValue for assignment (COW): increments refcount on tensors/cells
|
|
19
|
-
* so that mIndexStore knows to copy before mutating.
|
|
20
|
-
* Returns a new wrapper object that shares the same underlying data.
|
|
21
|
-
*/
|
|
22
|
-
export declare function shareRuntimeValue(v: RuntimeValue): RuntimeValue;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Numbl version, used for JIT disk cache invalidation. */
|
|
2
|
-
export declare const NUMBL_VERSION = "0.3.
|
|
2
|
+
export declare const NUMBL_VERSION = "0.3.3";
|