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.
@@ -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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "a basic experimental wip aot optimizing js -> wasm engine/compiler/runtime in js",
4
- "version": "0.37.26+4f2db33d1",
4
+ "version": "0.37.27+40152c2db",
5
5
  "author": "CanadaHonk",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runner/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.37.26+4f2db33d1';
3
+ globalThis.version = '0.37.27+40152c2db';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {
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
- const { exports, pages } = compile(toRun, process.argv.includes('--module') ? [ 'module' ] : [], {}, str => {
92
- if (shouldPrint) process.stdout.write(str);
93
- if (str === '-4919') shouldPrint = true;
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.$;