porffor 0.57.4 → 0.57.5

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.
@@ -95,6 +95,34 @@ export const BuiltinVars = function(ctx) {
95
95
  this.__BigInt64Array_BYTES_PER_ELEMENT = [ number(8) ];
96
96
  this.__BigUint64Array_BYTES_PER_ELEMENT = [ number(8) ];
97
97
 
98
+ // well-known symbols
99
+ for (const x of [
100
+ 'asyncIterator', 'hasInstance',
101
+ 'isConcatSpreadable', 'iterator',
102
+ 'match', 'matchAll', 'replace',
103
+ 'search', 'species', 'split',
104
+ 'toPrimitive', 'toStringTag', 'unscopables',
105
+ 'dispose', 'asyncDispose'
106
+ ]) {
107
+ this[`__Symbol_${x}`] = (scope, { glbl, builtin, makeString }) => [
108
+ [ Opcodes.block, Valtype.f64 ],
109
+ ...glbl(Opcodes.global_get, `#wellknown_${x}`, Valtype.f64),
110
+ Opcodes.i32_to_u,
111
+ [ Opcodes.if, Blocktype.void ],
112
+ ...glbl(Opcodes.global_get, `#wellknown_${x}`, Valtype.f64),
113
+ [ Opcodes.br, 1 ],
114
+ [ Opcodes.end ],
115
+
116
+ ...makeString(scope, `Symbol.${x}`),
117
+ number(TYPES.bytestring, Valtype.i32),
118
+ [ Opcodes.call, builtin('Symbol') ],
119
+ ...glbl(Opcodes.global_set, `#wellknown_${x}`, Valtype.f64),
120
+ ...glbl(Opcodes.global_get, `#wellknown_${x}`, Valtype.f64),
121
+ [ Opcodes.end ]
122
+ ];
123
+ this[`__Symbol_${x}`].type = TYPES.symbol;
124
+ }
125
+
98
126
  ObjectBuiltins.call(this, ctx, Prefs);
99
127
  };
100
128
 
@@ -1280,7 +1280,7 @@ const asmFuncToAsm = (scope, func, extra) => func(scope, {
1280
1280
  scope.initedGlobals ??= new Set();
1281
1281
  if (!scope.initedGlobals.has(name)) {
1282
1282
  scope.initedGlobals.add(name);
1283
- if (scope.globalInits[name]) out.unshift(
1283
+ if (scope.globalInits?.[name]) out.unshift(
1284
1284
  [ Opcodes.global_get, globals[globalName + '#glbl_inited'].idx ],
1285
1285
  [ Opcodes.i32_eqz ],
1286
1286
  [ Opcodes.if, Blocktype.void ],
package/compiler/wrap.js CHANGED
@@ -179,14 +179,8 @@ ${flags & 0b0001 ? ` get func idx: ${get}
179
179
  }
180
180
 
181
181
  case TYPES.symbol: {
182
- const page = pages.get('symbol.ts/descStore');
183
- if (!page) return Symbol();
184
-
185
- const descStore = page * pageSize;
186
- const offset = descStore + 4 + ((value - 1) * 9);
187
-
188
- const v = read(Float64Array, memory, offset, 1)[0];
189
- const t = read(Uint8Array, memory, offset + 8, 1)[0];
182
+ const v = read(Float64Array, memory, value, 1)[0];
183
+ const t = read(Uint8Array, memory, value + 8, 1)[0];
190
184
 
191
185
  const desc = porfToJSValue({ memory, funcs, pages }, v, t);
192
186
  return Symbol(desc);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "porffor",
3
3
  "description": "An ahead-of-time JavaScript compiler",
4
- "version": "0.57.4",
4
+ "version": "0.57.5",
5
5
  "author": "Oliver Medhurst <honk@goose.icu>",
6
6
  "license": "MIT",
7
7
  "scripts": {},
package/runtime/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import fs from 'node:fs';
3
- globalThis.version = '0.57.4';
3
+ globalThis.version = '0.57.5';
4
4
 
5
5
  // deno compat
6
6
  if (typeof process === 'undefined' && typeof Deno !== 'undefined') {