Initial ES modules support

This commit is contained in:
2026-10-26 12:39:58 +00:00
parent f7c5b2c80f
commit 1e12e7be2e
35 changed files with 1266 additions and 505 deletions
+6 -19
View File
@@ -1,20 +1,7 @@
// The stdlib, compiled in front of every program. Its files are joined in the
// order of `STDLIB` in compiler/src/main.rs, and this one is first
//
// Built on the natives in compiler/src/native.rs, the common layer of
// operations on primitive values. The compiler's own code for operators (`+` on
// strings and so on) uses those natives directly, not these functions.
//
// Restrictions:
// - The prototypes of `String`, `Number`, `Boolean` and `Array` are fixed:
// the compiler reads them by name, as the prototypes of the primitives and of
// arrays. User code may not change them (no monkey-patching)
// - `new String(x)`, `new Number(x)` and `new Boolean(x)` (wrapper objects) are
// not supported. These functions only convert
//
// Needs `typeof`. `String.prototype.concat` is not here, because it needs rest
// params, which need arrays. `console.log` prints one arg only, for the same
// reason
// The global values that are not functions. `undefined` is a binding like any
// other: a global name refers to the prelude's export of that name (see
// prelude.js)
const NaN = 0 / 0;
const Infinity = 1 / 0;
export const undefined = void 0;
export const NaN = 0 / 0;
export const Infinity = 1 / 0;