21 lines
960 B
JavaScript
21 lines
960 B
JavaScript
// 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
|
|
|
|
const NaN = 0 / 0;
|
|
const Infinity = 1 / 0;
|