porffor 0.61.0 → 0.61.2
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/_internal_object.ts +1 -1
- package/compiler/builtins/annexb_string.js +5 -4
- package/compiler/builtins/array.ts +16 -16
- package/compiler/builtins/arraybuffer.ts +4 -4
- package/compiler/builtins/base64.ts +2 -2
- package/compiler/builtins/bigint.ts +5 -5
- package/compiler/builtins/crypto.ts +1 -1
- package/compiler/builtins/dataview.ts +1 -1
- package/compiler/builtins/date.ts +9 -9
- package/compiler/builtins/error.js +1 -1
- package/compiler/builtins/function.ts +1 -1
- package/compiler/builtins/json.ts +5 -5
- package/compiler/builtins/map.ts +5 -5
- package/compiler/builtins/number.ts +3 -3
- package/compiler/builtins/object.ts +8 -8
- package/compiler/builtins/porffor.d.ts +2 -2
- package/compiler/builtins/promise.ts +9 -9
- package/compiler/builtins/reflect.ts +1 -1
- package/compiler/builtins/regexp.ts +319 -388
- package/compiler/builtins/set.ts +2 -2
- package/compiler/builtins/string.ts +42 -42
- package/compiler/builtins/string_f64.ts +2 -2
- package/compiler/builtins/symbol.ts +2 -2
- package/compiler/builtins/typedarray.js +5 -5
- package/compiler/builtins/uint8array_base64.ts +2 -2
- package/compiler/builtins/uri.ts +145 -145
- package/compiler/builtins/weakmap.ts +3 -3
- package/compiler/builtins/weakref.ts +1 -1
- package/compiler/builtins/weakset.ts +1 -1
- package/compiler/builtins.js +43 -75
- package/compiler/builtins_precompiled.js +682 -676
- package/compiler/codegen.js +16 -11
- package/compiler/wrap.js +13 -0
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/runtime/index.js +1 -1
package/compiler/builtins/set.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const __Set_prototype_values = (_this: Set) => {
|
|
|
8
8
|
// todo: this should return an iterator not array
|
|
9
9
|
const size: number = Porffor.wasm.i32.load(_this, 0, 0);
|
|
10
10
|
|
|
11
|
-
const out: any[] =
|
|
11
|
+
const out: any[] = Porffor.malloc();
|
|
12
12
|
for (let i: number = 0; i < size; i++) {
|
|
13
13
|
Porffor.array.fastPush(out, (_this as any[])[i]);
|
|
14
14
|
}
|
|
@@ -78,7 +78,7 @@ export const __Set_prototype_forEach = (_this: Set, callbackFn: any) => {
|
|
|
78
78
|
export const Set = function (iterable: any): Set {
|
|
79
79
|
if (!new.target) throw new TypeError("Constructor Set requires 'new'");
|
|
80
80
|
|
|
81
|
-
const out: Set =
|
|
81
|
+
const out: Set = Porffor.malloc();
|
|
82
82
|
|
|
83
83
|
if (iterable != null) for (const x of iterable) {
|
|
84
84
|
__Set_prototype_add(out, x);
|
|
@@ -287,7 +287,7 @@ export const __Porffor_strcat = (a: any, b: any): any => {
|
|
|
287
287
|
if (Porffor.wasm`local.get ${a+1}` == Porffor.TYPES.bytestring) {
|
|
288
288
|
if (Porffor.wasm`local.get ${b+1}` == Porffor.TYPES.bytestring) {
|
|
289
289
|
// bytestring, bytestring
|
|
290
|
-
const out: bytestring = Porffor.
|
|
290
|
+
const out: bytestring = Porffor.malloc(4 + al + bl);
|
|
291
291
|
|
|
292
292
|
// out.length = a.length + b.length
|
|
293
293
|
Porffor.wasm.i32.store(out, al + bl, 0, 0);
|
|
@@ -301,7 +301,7 @@ export const __Porffor_strcat = (a: any, b: any): any => {
|
|
|
301
301
|
return out;
|
|
302
302
|
} else {
|
|
303
303
|
// bytestring, string
|
|
304
|
-
const out: string = Porffor.
|
|
304
|
+
const out: string = Porffor.malloc(4 + (al + bl) * 2);
|
|
305
305
|
|
|
306
306
|
// out.length = a.length + b.length
|
|
307
307
|
Porffor.wasm.i32.store(out, al + bl, 0, 0);
|
|
@@ -319,7 +319,7 @@ export const __Porffor_strcat = (a: any, b: any): any => {
|
|
|
319
319
|
} else {
|
|
320
320
|
if (Porffor.wasm`local.get ${b+1}` == Porffor.TYPES.bytestring) {
|
|
321
321
|
// string, bytestring
|
|
322
|
-
const out: string = Porffor.
|
|
322
|
+
const out: string = Porffor.malloc(4 + (al + bl) * 2);
|
|
323
323
|
|
|
324
324
|
// out.length = a.length + b.length
|
|
325
325
|
Porffor.wasm.i32.store(out, al + bl, 0, 0);
|
|
@@ -336,7 +336,7 @@ export const __Porffor_strcat = (a: any, b: any): any => {
|
|
|
336
336
|
return out;
|
|
337
337
|
} else {
|
|
338
338
|
// string, string
|
|
339
|
-
const out: string = Porffor.
|
|
339
|
+
const out: string = Porffor.malloc(4 + (al + bl) * 2);
|
|
340
340
|
|
|
341
341
|
// out.length = a.length + b.length
|
|
342
342
|
Porffor.wasm.i32.store(out, al + bl, 0, 0);
|
|
@@ -359,7 +359,7 @@ export const __String_prototype_at = (_this: string, index: number) => {
|
|
|
359
359
|
if (index < 0) index = len + index;
|
|
360
360
|
if (Porffor.fastOr(index < 0, index >= len)) return undefined;
|
|
361
361
|
|
|
362
|
-
let out: string = Porffor.
|
|
362
|
+
let out: string = Porffor.malloc(8);
|
|
363
363
|
Porffor.wasm.i32.store(out, 1, 0, 0); // out.length = 1
|
|
364
364
|
|
|
365
365
|
Porffor.wasm.i32.store16(
|
|
@@ -376,7 +376,7 @@ export const __ByteString_prototype_at = (_this: bytestring, index: number) => {
|
|
|
376
376
|
if (index < 0) index = len + index;
|
|
377
377
|
if (Porffor.fastOr(index < 0, index >= len)) return undefined;
|
|
378
378
|
|
|
379
|
-
let out: bytestring = Porffor.
|
|
379
|
+
let out: bytestring = Porffor.malloc(8);
|
|
380
380
|
Porffor.wasm.i32.store(out, 1, 0, 0); // out.length = 1
|
|
381
381
|
|
|
382
382
|
Porffor.wasm.i32.store8(
|
|
@@ -392,7 +392,7 @@ export const __String_prototype_charAt = (_this: string, index: number) => {
|
|
|
392
392
|
|
|
393
393
|
if (Porffor.fastOr(index < 0, index >= len)) return '';
|
|
394
394
|
|
|
395
|
-
let out: string = Porffor.
|
|
395
|
+
let out: string = Porffor.malloc(8);
|
|
396
396
|
Porffor.wasm.i32.store(out, 1, 0, 0); // out.length = 1
|
|
397
397
|
|
|
398
398
|
Porffor.wasm.i32.store16(
|
|
@@ -408,7 +408,7 @@ export const __ByteString_prototype_charAt = (_this: bytestring, index: number)
|
|
|
408
408
|
|
|
409
409
|
if (Porffor.fastOr(index < 0, index >= len)) return '';
|
|
410
410
|
|
|
411
|
-
let out: bytestring = Porffor.
|
|
411
|
+
let out: bytestring = Porffor.malloc(8);
|
|
412
412
|
Porffor.wasm.i32.store(out, 1, 0, 0); // out.length = 1
|
|
413
413
|
|
|
414
414
|
Porffor.wasm.i32.store8(
|
|
@@ -423,7 +423,7 @@ export const __String_prototype_toUpperCase = (_this: string) => {
|
|
|
423
423
|
// todo: unicode not just ascii
|
|
424
424
|
const len: i32 = _this.length;
|
|
425
425
|
|
|
426
|
-
let out: string = Porffor.
|
|
426
|
+
let out: string = Porffor.malloc();
|
|
427
427
|
Porffor.wasm.i32.store(out, len, 0, 0);
|
|
428
428
|
|
|
429
429
|
let i: i32 = Porffor.wasm`local.get ${_this}`,
|
|
@@ -446,7 +446,7 @@ export const __String_prototype_toUpperCase = (_this: string) => {
|
|
|
446
446
|
export const __ByteString_prototype_toUpperCase = (_this: bytestring) => {
|
|
447
447
|
const len: i32 = _this.length;
|
|
448
448
|
|
|
449
|
-
let out: bytestring = Porffor.
|
|
449
|
+
let out: bytestring = Porffor.malloc();
|
|
450
450
|
Porffor.wasm.i32.store(out, len, 0, 0);
|
|
451
451
|
|
|
452
452
|
let i: i32 = Porffor.wasm`local.get ${_this}`,
|
|
@@ -468,7 +468,7 @@ export const __String_prototype_toLowerCase = (_this: string) => {
|
|
|
468
468
|
// todo: unicode not just ascii
|
|
469
469
|
const len: i32 = _this.length;
|
|
470
470
|
|
|
471
|
-
let out: string = Porffor.
|
|
471
|
+
let out: string = Porffor.malloc();
|
|
472
472
|
Porffor.wasm.i32.store(out, len, 0, 0);
|
|
473
473
|
|
|
474
474
|
let i: i32 = Porffor.wasm`local.get ${_this}`,
|
|
@@ -491,7 +491,7 @@ export const __String_prototype_toLowerCase = (_this: string) => {
|
|
|
491
491
|
export const __ByteString_prototype_toLowerCase = (_this: bytestring) => {
|
|
492
492
|
const len: i32 = _this.length;
|
|
493
493
|
|
|
494
|
-
let out: bytestring = Porffor.
|
|
494
|
+
let out: bytestring = Porffor.malloc();
|
|
495
495
|
Porffor.wasm.i32.store(out, len, 0, 0);
|
|
496
496
|
|
|
497
497
|
let i: i32 = Porffor.wasm`local.get ${_this}`,
|
|
@@ -928,7 +928,7 @@ export const __ByteString_prototype_includes = (_this: bytestring, searchString:
|
|
|
928
928
|
|
|
929
929
|
|
|
930
930
|
export const __String_prototype_padStart = (_this: string, targetLength: number, padString: string = undefined) => {
|
|
931
|
-
let out: string = Porffor.
|
|
931
|
+
let out: string = Porffor.malloc();
|
|
932
932
|
|
|
933
933
|
let outPtr: i32 = Porffor.wasm`local.get ${out}`;
|
|
934
934
|
let thisPtr: i32 = Porffor.wasm`local.get ${_this}`;
|
|
@@ -972,7 +972,7 @@ export const __String_prototype_padStart = (_this: string, targetLength: number,
|
|
|
972
972
|
export const __ByteString_prototype_padStart = (_this: bytestring, targetLength: number, padString: bytestring = undefined) => {
|
|
973
973
|
// todo: handle padString being non-bytestring
|
|
974
974
|
|
|
975
|
-
let out: bytestring = Porffor.
|
|
975
|
+
let out: bytestring = Porffor.malloc();
|
|
976
976
|
|
|
977
977
|
let outPtr: i32 = Porffor.wasm`local.get ${out}`;
|
|
978
978
|
let thisPtr: i32 = Porffor.wasm`local.get ${_this}`;
|
|
@@ -1011,7 +1011,7 @@ export const __ByteString_prototype_padStart = (_this: bytestring, targetLength:
|
|
|
1011
1011
|
|
|
1012
1012
|
|
|
1013
1013
|
export const __String_prototype_padEnd = (_this: string, targetLength: number, padString: string = undefined) => {
|
|
1014
|
-
let out: string = Porffor.
|
|
1014
|
+
let out: string = Porffor.malloc();
|
|
1015
1015
|
|
|
1016
1016
|
let outPtr: i32 = Porffor.wasm`local.get ${out}`;
|
|
1017
1017
|
let thisPtr: i32 = Porffor.wasm`local.get ${_this}`;
|
|
@@ -1055,7 +1055,7 @@ export const __String_prototype_padEnd = (_this: string, targetLength: number, p
|
|
|
1055
1055
|
export const __ByteString_prototype_padEnd = (_this: bytestring, targetLength: number, padString: bytestring = undefined) => {
|
|
1056
1056
|
// todo: handle padString being non-bytestring
|
|
1057
1057
|
|
|
1058
|
-
let out: bytestring = Porffor.
|
|
1058
|
+
let out: bytestring = Porffor.malloc();
|
|
1059
1059
|
|
|
1060
1060
|
let outPtr: i32 = Porffor.wasm`local.get ${out}`;
|
|
1061
1061
|
let thisPtr: i32 = Porffor.wasm`local.get ${_this}`;
|
|
@@ -1108,7 +1108,7 @@ export const __String_prototype_substring = (_this: string, start: number, end:
|
|
|
1108
1108
|
if (end < 0) end = 0;
|
|
1109
1109
|
if (end > len) end = len;
|
|
1110
1110
|
|
|
1111
|
-
let out: string = Porffor.
|
|
1111
|
+
let out: string = Porffor.malloc();
|
|
1112
1112
|
|
|
1113
1113
|
let outPtr: i32 = Porffor.wasm`local.get ${out}`;
|
|
1114
1114
|
let thisPtr: i32 = Porffor.wasm`local.get ${_this}`;
|
|
@@ -1144,7 +1144,7 @@ export const __ByteString_prototype_substring = (_this: bytestring, start: numbe
|
|
|
1144
1144
|
if (end < 0) end = 0;
|
|
1145
1145
|
if (end > len) end = len;
|
|
1146
1146
|
|
|
1147
|
-
let out: bytestring = Porffor.
|
|
1147
|
+
let out: bytestring = Porffor.malloc();
|
|
1148
1148
|
|
|
1149
1149
|
let outPtr: i32 = Porffor.wasm`local.get ${out}`;
|
|
1150
1150
|
let thisPtr: i32 = Porffor.wasm`local.get ${_this}`;
|
|
@@ -1177,7 +1177,7 @@ export const __String_prototype_substr = (_this: string, start: number, length:
|
|
|
1177
1177
|
|
|
1178
1178
|
if (start + length > len) length = len - start;
|
|
1179
1179
|
|
|
1180
|
-
let out: string = Porffor.
|
|
1180
|
+
let out: string = Porffor.malloc();
|
|
1181
1181
|
|
|
1182
1182
|
let outPtr: i32 = Porffor.wasm`local.get ${out}`;
|
|
1183
1183
|
let thisPtr: i32 = Porffor.wasm`local.get ${_this}`;
|
|
@@ -1212,7 +1212,7 @@ export const __ByteString_prototype_substr = (_this: bytestring, start: number,
|
|
|
1212
1212
|
|
|
1213
1213
|
if (start + length > len) length = len - start;
|
|
1214
1214
|
|
|
1215
|
-
let out: bytestring = Porffor.
|
|
1215
|
+
let out: bytestring = Porffor.malloc();
|
|
1216
1216
|
|
|
1217
1217
|
let outPtr: i32 = Porffor.wasm`local.get ${out}`;
|
|
1218
1218
|
let thisPtr: i32 = Porffor.wasm`local.get ${_this}`;
|
|
@@ -1247,7 +1247,7 @@ export const __String_prototype_slice = (_this: string, start: number, end: numb
|
|
|
1247
1247
|
}
|
|
1248
1248
|
if (end > len) end = len;
|
|
1249
1249
|
|
|
1250
|
-
let out: string = Porffor.
|
|
1250
|
+
let out: string = Porffor.malloc();
|
|
1251
1251
|
|
|
1252
1252
|
if (start > end) return out;
|
|
1253
1253
|
|
|
@@ -1286,7 +1286,7 @@ export const __ByteString_prototype_slice = (_this: bytestring, start: number, e
|
|
|
1286
1286
|
}
|
|
1287
1287
|
if (end > len) end = len;
|
|
1288
1288
|
|
|
1289
|
-
let out: bytestring = Porffor.
|
|
1289
|
+
let out: bytestring = Porffor.malloc();
|
|
1290
1290
|
|
|
1291
1291
|
if (start > end) return out;
|
|
1292
1292
|
|
|
@@ -1308,7 +1308,7 @@ export const __ByteString_prototype_slice = (_this: bytestring, start: number, e
|
|
|
1308
1308
|
|
|
1309
1309
|
|
|
1310
1310
|
export const __String_prototype_trimStart = (_this: string) => {
|
|
1311
|
-
let out: string = Porffor.
|
|
1311
|
+
let out: string = Porffor.malloc();
|
|
1312
1312
|
|
|
1313
1313
|
let outPtr: i32 = Porffor.wasm`local.get ${out}`;
|
|
1314
1314
|
let thisPtr: i32 = Porffor.wasm`local.get ${_this}`;
|
|
@@ -1342,7 +1342,7 @@ export const __String_prototype_trimStart = (_this: string) => {
|
|
|
1342
1342
|
};
|
|
1343
1343
|
|
|
1344
1344
|
export const __ByteString_prototype_trimStart = (_this: bytestring) => {
|
|
1345
|
-
let out: bytestring = Porffor.
|
|
1345
|
+
let out: bytestring = Porffor.malloc();
|
|
1346
1346
|
|
|
1347
1347
|
let outPtr: i32 = Porffor.wasm`local.get ${out}`;
|
|
1348
1348
|
let thisPtr: i32 = Porffor.wasm`local.get ${_this}`;
|
|
@@ -1375,7 +1375,7 @@ export const __ByteString_prototype_trimStart = (_this: bytestring) => {
|
|
|
1375
1375
|
|
|
1376
1376
|
|
|
1377
1377
|
export const __String_prototype_trimEnd = (_this: string) => {
|
|
1378
|
-
let out: string = Porffor.
|
|
1378
|
+
let out: string = Porffor.malloc();
|
|
1379
1379
|
|
|
1380
1380
|
let outPtr: i32 = Porffor.wasm`local.get ${out}`;
|
|
1381
1381
|
let thisPtr: i32 = Porffor.wasm`local.get ${_this}`;
|
|
@@ -1413,7 +1413,7 @@ export const __String_prototype_trimEnd = (_this: string) => {
|
|
|
1413
1413
|
};
|
|
1414
1414
|
|
|
1415
1415
|
export const __ByteString_prototype_trimEnd = (_this: bytestring) => {
|
|
1416
|
-
let out: bytestring = Porffor.
|
|
1416
|
+
let out: bytestring = Porffor.malloc();
|
|
1417
1417
|
|
|
1418
1418
|
let outPtr: i32 = Porffor.wasm`local.get ${out}`;
|
|
1419
1419
|
let thisPtr: i32 = Porffor.wasm`local.get ${_this}`;
|
|
@@ -1461,7 +1461,7 @@ export const __ByteString_prototype_trim = (_this: bytestring) => {
|
|
|
1461
1461
|
|
|
1462
1462
|
|
|
1463
1463
|
export const __String_prototype_concat = (_this: string, ...vals: any[]) => {
|
|
1464
|
-
let out: any = Porffor.
|
|
1464
|
+
let out: any = Porffor.malloc();
|
|
1465
1465
|
Porffor.clone(_this, out);
|
|
1466
1466
|
|
|
1467
1467
|
// copy _this type to out
|
|
@@ -1500,7 +1500,7 @@ local.set ${out}`;
|
|
|
1500
1500
|
};
|
|
1501
1501
|
|
|
1502
1502
|
export const __ByteString_prototype_concat = (_this: bytestring, ...vals: any[]) => {
|
|
1503
|
-
let out: any = Porffor.
|
|
1503
|
+
let out: any = Porffor.malloc();
|
|
1504
1504
|
Porffor.clone(_this, out);
|
|
1505
1505
|
|
|
1506
1506
|
// copy _this type to out
|
|
@@ -1542,7 +1542,7 @@ export const __String_prototype_repeat = (_this: string, cnt: any) => {
|
|
|
1542
1542
|
const count: number = ecma262.ToIntegerOrInfinity(cnt);
|
|
1543
1543
|
if (count < 0) throw new RangeError('Invalid count value');
|
|
1544
1544
|
|
|
1545
|
-
let out: string = Porffor.
|
|
1545
|
+
let out: string = Porffor.malloc();
|
|
1546
1546
|
const thisLen: i32 = _this.length * 2;
|
|
1547
1547
|
if (thisLen == 0) return '';
|
|
1548
1548
|
|
|
@@ -1576,7 +1576,7 @@ export const __ByteString_prototype_repeat = (_this: bytestring, cnt: any) => {
|
|
|
1576
1576
|
const count: number = ecma262.ToIntegerOrInfinity(cnt);
|
|
1577
1577
|
if (count < 0) throw new RangeError('Invalid count value');
|
|
1578
1578
|
|
|
1579
|
-
let out: bytestring = Porffor.
|
|
1579
|
+
let out: bytestring = Porffor.malloc();
|
|
1580
1580
|
const thisLen: i32 = _this.length;
|
|
1581
1581
|
if (thisLen == 0) return '';
|
|
1582
1582
|
|
|
@@ -1608,7 +1608,7 @@ memory.copy 0 0`;
|
|
|
1608
1608
|
|
|
1609
1609
|
|
|
1610
1610
|
export const __String_prototype_split = (_this: string, separator: any, limit: any) => {
|
|
1611
|
-
let out: any[] = Porffor.
|
|
1611
|
+
let out: any[] = Porffor.malloc(), outLen: i32 = 0;
|
|
1612
1612
|
|
|
1613
1613
|
if (Porffor.wasm`local.get ${limit+1}` == Porffor.TYPES.undefined) limit = Number.MAX_SAFE_INTEGER;
|
|
1614
1614
|
if (limit < 0) limit = Number.MAX_SAFE_INTEGER;
|
|
@@ -1636,7 +1636,7 @@ i32.store8 0 12`;
|
|
|
1636
1636
|
separator = ecma262.ToString(separator);
|
|
1637
1637
|
}
|
|
1638
1638
|
|
|
1639
|
-
let tmp: string = Porffor.
|
|
1639
|
+
let tmp: string = Porffor.malloc(), tmpLen: i32 = 0;
|
|
1640
1640
|
const thisLen: i32 = _this.length * 2, sepLen: i32 = separator.length;
|
|
1641
1641
|
if (sepLen == 1) {
|
|
1642
1642
|
// fast path: single char separator
|
|
@@ -1670,7 +1670,7 @@ i32.const 67
|
|
|
1670
1670
|
i32.store8 0 12`;
|
|
1671
1671
|
outLen++;
|
|
1672
1672
|
|
|
1673
|
-
tmp = Porffor.
|
|
1673
|
+
tmp = Porffor.malloc();
|
|
1674
1674
|
tmpLen = 0;
|
|
1675
1675
|
continue;
|
|
1676
1676
|
}
|
|
@@ -1682,7 +1682,7 @@ i32.store8 0 12`;
|
|
|
1682
1682
|
tmpLen = 1;
|
|
1683
1683
|
let produced: i32 = 0;
|
|
1684
1684
|
for (let i = 0; i < thisLen && produced < limit; i += 2) {
|
|
1685
|
-
tmp = Porffor.
|
|
1685
|
+
tmp = Porffor.malloc(8);
|
|
1686
1686
|
const x: i32 = Porffor.wasm.i32.load16_u(Porffor.wasm`local.get ${_this}` + i, 0, 4);
|
|
1687
1687
|
|
|
1688
1688
|
Porffor.wasm.i32.store16(Porffor.wasm`local.get ${tmp}`, x, 0, 4);
|
|
@@ -1741,7 +1741,7 @@ i32.const 67
|
|
|
1741
1741
|
i32.store8 0 12`;
|
|
1742
1742
|
outLen++;
|
|
1743
1743
|
|
|
1744
|
-
tmp = Porffor.
|
|
1744
|
+
tmp = Porffor.malloc();
|
|
1745
1745
|
tmpLen = 0;
|
|
1746
1746
|
continue;
|
|
1747
1747
|
}
|
|
@@ -1780,7 +1780,7 @@ i32.store8 0 12`;
|
|
|
1780
1780
|
};
|
|
1781
1781
|
|
|
1782
1782
|
export const __ByteString_prototype_split = (_this: bytestring, separator: any, limit: any) => {
|
|
1783
|
-
let out: any[] = Porffor.
|
|
1783
|
+
let out: any[] = Porffor.malloc(), outLen: i32 = 0;
|
|
1784
1784
|
|
|
1785
1785
|
if (Porffor.wasm`local.get ${limit+1}` == Porffor.TYPES.undefined) limit = Number.MAX_SAFE_INTEGER;
|
|
1786
1786
|
if (limit < 0) limit = Number.MAX_SAFE_INTEGER;
|
|
@@ -1808,7 +1808,7 @@ i32.store8 0 12`;
|
|
|
1808
1808
|
separator = ecma262.ToString(separator);
|
|
1809
1809
|
}
|
|
1810
1810
|
|
|
1811
|
-
let tmp: bytestring = Porffor.
|
|
1811
|
+
let tmp: bytestring = Porffor.malloc(), tmpLen: i32 = 0;
|
|
1812
1812
|
const thisLen: i32 = _this.length, sepLen: i32 = separator.length;
|
|
1813
1813
|
if (sepLen == 1) {
|
|
1814
1814
|
// fast path: single char separator
|
|
@@ -1842,7 +1842,7 @@ i32.const 195
|
|
|
1842
1842
|
i32.store8 0 12`;
|
|
1843
1843
|
outLen++;
|
|
1844
1844
|
|
|
1845
|
-
tmp = Porffor.
|
|
1845
|
+
tmp = Porffor.malloc();
|
|
1846
1846
|
tmpLen = 0;
|
|
1847
1847
|
continue;
|
|
1848
1848
|
}
|
|
@@ -1854,7 +1854,7 @@ i32.store8 0 12`;
|
|
|
1854
1854
|
tmpLen = 1;
|
|
1855
1855
|
let produced: i32 = 0;
|
|
1856
1856
|
for (let i = 0; i < thisLen && produced < limit; i++) {
|
|
1857
|
-
tmp = Porffor.
|
|
1857
|
+
tmp = Porffor.malloc(8);
|
|
1858
1858
|
const x: i32 = Porffor.wasm.i32.load8_u(Porffor.wasm`local.get ${_this}` + i, 0, 4);
|
|
1859
1859
|
|
|
1860
1860
|
Porffor.wasm.i32.store8(Porffor.wasm`local.get ${tmp}`, x, 0, 4);
|
|
@@ -1914,7 +1914,7 @@ i32.const 195
|
|
|
1914
1914
|
i32.store8 0 12`;
|
|
1915
1915
|
outLen++;
|
|
1916
1916
|
|
|
1917
|
-
tmp = Porffor.
|
|
1917
|
+
tmp = Porffor.malloc();
|
|
1918
1918
|
tmpLen = 0;
|
|
1919
1919
|
continue;
|
|
1920
1920
|
}
|
|
@@ -2031,7 +2031,7 @@ export const __ByteString_prototype_isWellFormed = (_this: bytestring) => {
|
|
|
2031
2031
|
};
|
|
2032
2032
|
|
|
2033
2033
|
export const __String_prototype_toWellFormed = (_this: string) => {
|
|
2034
|
-
let out: string = Porffor.
|
|
2034
|
+
let out: string = Porffor.malloc();
|
|
2035
2035
|
Porffor.clone(_this, out);
|
|
2036
2036
|
|
|
2037
2037
|
let ptr: i32 = Porffor.wasm`local.get ${out}`;
|
|
@@ -2065,7 +2065,7 @@ export const __String_prototype_toWellFormed = (_this: string) => {
|
|
|
2065
2065
|
|
|
2066
2066
|
export const __ByteString_prototype_toWellFormed = (_this: bytestring) => {
|
|
2067
2067
|
// bytestrings cannot have surrogates, so just copy
|
|
2068
|
-
let out: bytestring = Porffor.
|
|
2068
|
+
let out: bytestring = Porffor.malloc();
|
|
2069
2069
|
Porffor.clone(_this, out);
|
|
2070
2070
|
|
|
2071
2071
|
return out;
|
|
@@ -77,7 +77,7 @@ export const String = function (...args: any[]): string|bytestring|StringObject
|
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
export const __String_fromCharCode = (...codes: any[]): bytestring|string => {
|
|
80
|
-
let out: string = Porffor.
|
|
80
|
+
let out: string = Porffor.malloc();
|
|
81
81
|
|
|
82
82
|
const len: i32 = codes.length;
|
|
83
83
|
out.length = len;
|
|
@@ -106,7 +106,7 @@ export const __String_fromCharCode = (...codes: any[]): bytestring|string => {
|
|
|
106
106
|
};
|
|
107
107
|
|
|
108
108
|
export const __String_fromCodePoint = (...codePoints: any[]): string => {
|
|
109
|
-
let out: string = Porffor.
|
|
109
|
+
let out: string = Porffor.malloc();
|
|
110
110
|
|
|
111
111
|
const len: i32 = codePoints.length;
|
|
112
112
|
let outLength: i32 = 0;
|
|
@@ -18,7 +18,7 @@ export const Symbol = (description: any): Symbol => {
|
|
|
18
18
|
Porffor.wasm`
|
|
19
19
|
local symbol i32
|
|
20
20
|
i32.const 16
|
|
21
|
-
call
|
|
21
|
+
call __Porffor_malloc
|
|
22
22
|
local.tee symbol
|
|
23
23
|
local.get ${descString}
|
|
24
24
|
f64.store 0 0
|
|
@@ -40,7 +40,7 @@ return`;
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export const __Symbol_prototype_toString = (_this: Symbol) => {
|
|
43
|
-
let out: bytestring = Porffor.
|
|
43
|
+
let out: bytestring = Porffor.malloc();
|
|
44
44
|
|
|
45
45
|
// Symbol(
|
|
46
46
|
Porffor.wasm.i32.store8(out, 83, 0, 4);
|
|
@@ -14,7 +14,7 @@ export default async () => {
|
|
|
14
14
|
out += `export const ${name} = function (arg: any, byteOffset: any, length: any): ${name} {
|
|
15
15
|
if (!new.target) throw new TypeError("Constructor ${name} requires 'new'");
|
|
16
16
|
|
|
17
|
-
const out: ${name} = Porffor.
|
|
17
|
+
const out: ${name} = Porffor.malloc(12);
|
|
18
18
|
const outPtr: i32 = Porffor.wasm\`local.get \${out}\`;
|
|
19
19
|
|
|
20
20
|
let len: i32 = 0;
|
|
@@ -41,7 +41,7 @@ export default async () => {
|
|
|
41
41
|
if (!Number.isInteger(len)) throw new RangeError('Byte length of ${name} should be divisible by BYTES_PER_ELEMENT');
|
|
42
42
|
} else len = Math.trunc(length);
|
|
43
43
|
} else {
|
|
44
|
-
bufferPtr = Porffor.
|
|
44
|
+
bufferPtr = Porffor.malloc();
|
|
45
45
|
Porffor.wasm.i32.store(outPtr, bufferPtr, 0, 4);
|
|
46
46
|
|
|
47
47
|
if (Porffor.fastOr(
|
|
@@ -72,7 +72,7 @@ export default async () => {
|
|
|
72
72
|
export const __${name}_of = (...items: any[]): ${name} => new ${name}(items);
|
|
73
73
|
|
|
74
74
|
export const __${name}_from = (arg: any, mapFn: any): ${name} => {
|
|
75
|
-
const arr: any[] = Porffor.
|
|
75
|
+
const arr: any[] = Porffor.malloc();
|
|
76
76
|
let len: i32 = 0;
|
|
77
77
|
|
|
78
78
|
if (Porffor.fastOr(
|
|
@@ -142,7 +142,7 @@ export const __${name}_prototype_slice = (_this: ${name}, start: number, end: nu
|
|
|
142
142
|
}
|
|
143
143
|
if (end > len) end = len;
|
|
144
144
|
|
|
145
|
-
const out: ${name} = Porffor.
|
|
145
|
+
const out: ${name} = Porffor.malloc();
|
|
146
146
|
|
|
147
147
|
if (start > end) return out;
|
|
148
148
|
|
|
@@ -194,7 +194,7 @@ export const __${name}_prototype_subarray = (_this: ${name}, start: number, end:
|
|
|
194
194
|
}
|
|
195
195
|
if (end > len) end = len;
|
|
196
196
|
|
|
197
|
-
const out: ${name} = Porffor.
|
|
197
|
+
const out: ${name} = Porffor.malloc(12);
|
|
198
198
|
Porffor.wasm.i32.store(out, end - start, 0, 0);
|
|
199
199
|
Porffor.wasm.i32.store(out, Porffor.wasm.i32.load(_this, 0, 4) + start * ${name}.BYTES_PER_ELEMENT, 0, 4);
|
|
200
200
|
Porffor.wasm.i32.store(out, Porffor.wasm.i32.load(_this, 0, 8) + start * ${name}.BYTES_PER_ELEMENT, 0, 8);
|
|
@@ -40,7 +40,7 @@ export const __Uint8Array_prototype_toBase64 = (_this: Uint8Array, options: any
|
|
|
40
40
|
const len: i32 = Porffor.wasm.i32.load(taPtr, 0, 0);
|
|
41
41
|
const bufferPtr: i32 = Porffor.wasm.i32.load(taPtr, 0, 4);
|
|
42
42
|
|
|
43
|
-
const output: bytestring = Porffor.
|
|
43
|
+
const output: bytestring = Porffor.malloc();
|
|
44
44
|
const outPtr: i32 = Porffor.wasm`local.get ${output}`;
|
|
45
45
|
|
|
46
46
|
let alphabetStr: bytestring;
|
|
@@ -108,7 +108,7 @@ export const __Uint8Array_prototype_toHex = (_this: Uint8Array) => {
|
|
|
108
108
|
const len: i32 = Porffor.wasm.i32.load(taPtr, 0, 0);
|
|
109
109
|
const bufferPtr: i32 = Porffor.wasm.i32.load(taPtr, 0, 4);
|
|
110
110
|
|
|
111
|
-
const output: bytestring = Porffor.
|
|
111
|
+
const output: bytestring = Porffor.malloc();
|
|
112
112
|
const outPtr: i32 = Porffor.wasm`local.get ${output}`;
|
|
113
113
|
|
|
114
114
|
const hexChars: bytestring = '0123456789abcdef';
|