// The prelude: its exports are the global names of every module, such as // `String` or `console`. A module that does not declare a name, and does not // import it, refers to the prelude's export of that name. A module can declare // a binding of the same name, which hides it (see compiler/src/link.rs) // // The stdlib is built on the natives in compiler/src/native.rs, the common // layer of operations on primitive values, which `jsrt:native` exports. The // compiler's own code for operators (`+` on strings and so on) uses the runtime // directly, not these functions. // // Restrictions: // - The prototypes of `String`, `Number`, `Boolean` and `Array` are fixed: // the compiler reads them as the prelude's exports, 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 // - A global name cannot be assigned to // // `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 natives are global names too, as the runtime's own fns, with `__pending`, // where an IO op's callback waits for the host (see loop.js). The compiler // needs `jsrt:coroutine` for async fns and generators, so the prelude loads it. // It finds the host's `__complete` in `jsrt:loop` // // The modules run in the order of these imports, before any other module export { undefined, NaN, Infinity } from "jsrt:globals"; export { Object } from "jsrt:object"; export { String } from "jsrt:string"; export { Number } from "jsrt:number"; export { Boolean } from "jsrt:boolean"; export { Array } from "jsrt:array"; export { Promise, queueMicrotask } from "jsrt:promise"; export { setTimeout, clearTimeout } from "jsrt:timers"; export { fs } from "jsrt:io"; export { console } from "jsrt:console"; export * from "jsrt:native"; export { __pending } from "jsrt:loop"; import "jsrt:coroutine";