Skip to content

Export the runtime helper table (sysHelpers) from the runtime entry - #657

Closed
enumeratio wants to merge 1 commit into
cortex-js:mainfrom
enumeratio:runtime-helpers-export
Closed

enumeratio wants to merge 1 commit into
cortex-js:mainfrom
enumeratio:runtime-helpers-export

Conversation

@enumeratio

Copy link
Copy Markdown
Contributor

The code of a JavaScript compilation result calls helpers as _SYS.<name>. Until now the table behind them was internal, so a host that lowers its own operators the same way had to read an engine internal. @cortex-js/compute-engine/runtime now exports it as sysHelpers:

import { sysHelpers, createJavaScriptRuntime } from '@cortex-js/compute-engine/runtime';

sysHelpers.binomial(8, 3); // 56
Object.getPrototypeOf(createJavaScriptRuntime()) === sysHelpers; // true

It is the stateless table (SYS_HELPERS); the engine-bound helpers (the random family, integrate, tick) stay members of a runtime, which inherits the table. runtime.ts already imports javascript-runtime.ts, so the entry stays self-contained (the existing bundle test still holds). The names and signatures follow the code of a compilation and may change in any release, so a host should compare runtimeVersion; docs/COMPILATION-MODEL.md says so.

Tests (js-runtime.test.ts): a runtime inherits sysHelpers; Binomial(8, x) compiles to _SYS.binomial(...) and Digamma(x) to _SYS.ir.digamma(...), and run() and load() give the same value as the exported table.

Item 1 only; items 2 and 3 of #527 are not part of this PR.

Part of #527

…s from the runtime entry; test that a runtime inherits them and that compiled code agrees with the table; document and add a CHANGELOG entry. Part of cortex-js#527
@arnog

arnog commented Nov 23, 2026

Copy link
Copy Markdown
Member

Landed in f42a02d, with fixes made while landing (see the commit message). Thanks!

@arnog arnog closed this Nov 23, 2026
arnog added a commit that referenced this pull request Nov 23, 2026
…(m, n, d), the optional combinatorics library, PiecewiseExpand

- #657: @cortex-js/compute-engine/runtime exports sysHelpers, the stateless
  helpers that compiled code calls as _SYS.<name> (#527 item 1).
- #658: Mod(m, n, d) is d + Mod(m - d, n), in [d, d + n) (#548). Every
  compile target declines the three-operand form; the derivative, limit,
  enclosure and measurement code leave it unevaluated. Fixed on landing:
  .N() reads exact operands exactly as the two-operand Mod does (exact
  cancellation of d, a symbol with an exact value near a jump, a dividend
  past the range of a double, no second evaluation of an impure operand);
  exact radicals stay exact; the type is real only for real operands.
- #659: the optional combinatorics entry, loadCombinatorics(ce, { areas }),
  with about 350 permutation and 195 integer-partition statistics checked
  against FindStat (#531). Fixed on landing: the report of a re-load, a
  skipped head declared once the engine's definition is removed, the CI
  comment, string nodes without source offsets in compiled.ts, the synonym
  head LargestCycleLength removed (LongestCycleLength stays), one compiler
  decline test per area, and notes on list literals and time limits.
- #660: PiecewiseExpand rewrites Abs, Sign, Min, Max and Heaviside into a
  Which (#516). Fixed on landing: an argument declared complex or number is
  not split; the arm limit is checked before the product is built; Max()
  and Min() with no operand; exact conditions between radicals; an impure
  expression is returned unchanged; the lazy-operator list and the search
  ranking test.
- Issues CE-1734, CE-1735, CE-1736 filed from the decline census of #638.

Co-authored-by: enumeratio <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants