porffor 0.37.26 → 0.37.27
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/compiler/builtins_objects.js +19 -0
- package/package.json +1 -1
- package/runner/index.js +1 -1
- package/runner/repl.js +11 -4
@@ -106,6 +106,11 @@ export default function({ builtinFuncs }, Prefs) {
|
|
106
106
|
const k = prefix + x;
|
107
107
|
|
108
108
|
if (Object.hasOwn(d, 'value') && !Object.hasOwn(builtinFuncs, k) && !Object.hasOwn(this, k)) {
|
109
|
+
if (Array.isArray(d.value) || typeof d.value === 'function') {
|
110
|
+
this[k] = d.value;
|
111
|
+
continue;
|
112
|
+
}
|
113
|
+
|
109
114
|
if (typeof d.value === 'number') {
|
110
115
|
this[k] = number(d.value);
|
111
116
|
this[k].type = TYPES.number;
|
@@ -196,6 +201,20 @@ export default function({ builtinFuncs }, Prefs) {
|
|
196
201
|
// special case: Object.prototype.__proto__ = null
|
197
202
|
if (x === '__Object_prototype') Object.defineProperty(props, '__proto__', { value: { value: null }, enumerable: true });
|
198
203
|
|
204
|
+
// add constructor for constructors
|
205
|
+
const name = x.slice(2, x.indexOf('_', 2));
|
206
|
+
if (builtinFuncs[name]?.constr) {
|
207
|
+
const value = (scope, { funcRef }) => funcRef(name);
|
208
|
+
value.type = TYPES.function;
|
209
|
+
|
210
|
+
props.constructor = {
|
211
|
+
value,
|
212
|
+
writable: true,
|
213
|
+
enumerable: false,
|
214
|
+
configurable: true
|
215
|
+
};
|
216
|
+
}
|
217
|
+
|
199
218
|
object(x, props);
|
200
219
|
}
|
201
220
|
|
package/package.json
CHANGED
package/runner/index.js
CHANGED
package/runner/repl.js
CHANGED
@@ -88,10 +88,17 @@ const run = (source, _context, _filename, callback, run = true) => {
|
|
88
88
|
let toRun = (prev ? (prev + `;\nprint(-0x1337);\n`) : '') + source;
|
89
89
|
|
90
90
|
let shouldPrint = !prev;
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
91
|
+
let exports, pages;
|
92
|
+
try {
|
93
|
+
0, { exports, pages } = compile(toRun, process.argv.includes('--module') ? [ 'module' ] : [], {}, str => {
|
94
|
+
if (shouldPrint) process.stdout.write(str);
|
95
|
+
if (str === '-4919') shouldPrint = true;
|
96
|
+
});
|
97
|
+
} catch (e) {
|
98
|
+
console.log(e);
|
99
|
+
callback();
|
100
|
+
return;
|
101
|
+
}
|
95
102
|
|
96
103
|
if (run && exports.$) {
|
97
104
|
lastMemory = exports.$;
|