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/codegen.js
CHANGED
|
@@ -175,7 +175,8 @@ const funcRef = func => {
|
|
|
175
175
|
locals['#array'] = { idx: array + 1, type: valtypeBinary };
|
|
176
176
|
|
|
177
177
|
wasm.push(
|
|
178
|
-
|
|
178
|
+
number(pageSize, Valtype.i32),
|
|
179
|
+
[ Opcodes.call, includeBuiltin(wrapperFunc, '__Porffor_malloc').index ],
|
|
179
180
|
[ Opcodes.local_tee, array ],
|
|
180
181
|
Opcodes.i32_from_u,
|
|
181
182
|
[ Opcodes.local_set, array + 1 ],
|
|
@@ -2141,7 +2142,8 @@ const createThisArg = (scope, decl) => {
|
|
|
2141
2142
|
const proto = getObjProp(decl.callee, 'prototype');
|
|
2142
2143
|
|
|
2143
2144
|
return [
|
|
2144
|
-
|
|
2145
|
+
number(pageSize, Valtype.i32),
|
|
2146
|
+
[ Opcodes.call, includeBuiltin(scope, '__Porffor_malloc').index ],
|
|
2145
2147
|
Opcodes.i32_from_u,
|
|
2146
2148
|
[ Opcodes.local_tee, tmp ],
|
|
2147
2149
|
Opcodes.i32_to_u,
|
|
@@ -2653,7 +2655,7 @@ const generateCall = (scope, decl, _global, _name, unusedValue = false) => {
|
|
|
2653
2655
|
if (func && args.length < paramCount) {
|
|
2654
2656
|
// too little args, push undefineds
|
|
2655
2657
|
const underflow = paramCount - (func.hasRestArgument ? 1 : 0) - args.length;
|
|
2656
|
-
for (let i = 0; i < underflow; i++) args.push(DEFAULT_VALUE());
|
|
2658
|
+
for (let i = 0; i < underflow; i++) args.push(func.defaultParam ? func.defaultParam() : DEFAULT_VALUE());
|
|
2657
2659
|
}
|
|
2658
2660
|
|
|
2659
2661
|
if (func && func.hasRestArgument) {
|
|
@@ -4801,7 +4803,7 @@ const generateForOf = (scope, decl) => {
|
|
|
4801
4803
|
|
|
4802
4804
|
// allocate out string
|
|
4803
4805
|
number(8, Valtype.i32),
|
|
4804
|
-
[ Opcodes.call, includeBuiltin(scope, '
|
|
4806
|
+
[ Opcodes.call, includeBuiltin(scope, '__Porffor_malloc').index ],
|
|
4805
4807
|
[ Opcodes.local_tee, localTmp(scope, '#forof_allocd', Valtype.i32) ],
|
|
4806
4808
|
|
|
4807
4809
|
// set length to 1
|
|
@@ -4845,7 +4847,7 @@ const generateForOf = (scope, decl) => {
|
|
|
4845
4847
|
|
|
4846
4848
|
// allocate out string
|
|
4847
4849
|
number(8, Valtype.i32),
|
|
4848
|
-
[ Opcodes.call, includeBuiltin(scope, '
|
|
4850
|
+
[ Opcodes.call, includeBuiltin(scope, '__Porffor_malloc').index ],
|
|
4849
4851
|
[ Opcodes.local_tee, localTmp(scope, '#forof_allocd', Valtype.i32) ],
|
|
4850
4852
|
|
|
4851
4853
|
// set length to 1
|
|
@@ -4937,7 +4939,7 @@ const generateForOf = (scope, decl) => {
|
|
|
4937
4939
|
|
|
4938
4940
|
// allocate out array
|
|
4939
4941
|
number(128, Valtype.i32),
|
|
4940
|
-
[ Opcodes.call, includeBuiltin(scope, '
|
|
4942
|
+
[ Opcodes.call, includeBuiltin(scope, '__Porffor_malloc').index ],
|
|
4941
4943
|
[ Opcodes.local_tee, localTmp(scope, '#forof_allocd', Valtype.i32) ],
|
|
4942
4944
|
|
|
4943
4945
|
// set length to 2
|
|
@@ -5648,7 +5650,8 @@ const generateArray = (scope, decl, global = false, name = '$undeclared', static
|
|
|
5648
5650
|
} else {
|
|
5649
5651
|
const tmp = localTmp(scope, '#create_array' + uniqId(), Valtype.i32);
|
|
5650
5652
|
out.push(
|
|
5651
|
-
|
|
5653
|
+
number(pageSize, Valtype.i32),
|
|
5654
|
+
[ Opcodes.call, includeBuiltin(scope, '__Porffor_malloc').index ],
|
|
5652
5655
|
[ Opcodes.local_set, tmp ]
|
|
5653
5656
|
);
|
|
5654
5657
|
|
|
@@ -5727,7 +5730,8 @@ const toPropertyKey = (scope, wasm, type, computed = false, i32Conv = false) =>
|
|
|
5727
5730
|
|
|
5728
5731
|
const generateObject = (scope, decl, global = false, name = '$undeclared') => {
|
|
5729
5732
|
const out = [
|
|
5730
|
-
|
|
5733
|
+
number(pageSize, Valtype.i32),
|
|
5734
|
+
[ Opcodes.call, includeBuiltin(scope, '__Porffor_malloc').index ]
|
|
5731
5735
|
];
|
|
5732
5736
|
|
|
5733
5737
|
if (decl.properties.length > 0) {
|
|
@@ -5987,7 +5991,7 @@ const generateMember = (scope, decl, _global, _name) => {
|
|
|
5987
5991
|
[TYPES.string]: () => [
|
|
5988
5992
|
// allocate out string
|
|
5989
5993
|
number(8, Valtype.i32),
|
|
5990
|
-
[ Opcodes.call, includeBuiltin(scope, '
|
|
5994
|
+
[ Opcodes.call, includeBuiltin(scope, '__Porffor_malloc').index ],
|
|
5991
5995
|
[ Opcodes.local_tee, localTmp(scope, '#member_allocd', Valtype.i32) ],
|
|
5992
5996
|
|
|
5993
5997
|
// set length to 1
|
|
@@ -6022,7 +6026,7 @@ const generateMember = (scope, decl, _global, _name) => {
|
|
|
6022
6026
|
[TYPES.bytestring]: () => [
|
|
6023
6027
|
// allocate out string
|
|
6024
6028
|
number(8, Valtype.i32),
|
|
6025
|
-
[ Opcodes.call, includeBuiltin(scope, '
|
|
6029
|
+
[ Opcodes.call, includeBuiltin(scope, '__Porffor_malloc').index ],
|
|
6026
6030
|
[ Opcodes.local_tee, localTmp(scope, '#member_allocd', Valtype.i32) ],
|
|
6027
6031
|
|
|
6028
6032
|
// set length to 1
|
|
@@ -7004,7 +7008,8 @@ const generateFunc = (scope, decl, forceNoExpr = false) => {
|
|
|
7004
7008
|
if (func.generator) {
|
|
7005
7009
|
// make generator at the start
|
|
7006
7010
|
wasm.unshift(
|
|
7007
|
-
|
|
7011
|
+
number(pageSize, Valtype.i32),
|
|
7012
|
+
[ Opcodes.call, includeBuiltin(func, '__Porffor_malloc').index ],
|
|
7008
7013
|
Opcodes.i32_from_u,
|
|
7009
7014
|
number(TYPES.array, Valtype.i32),
|
|
7010
7015
|
|
package/compiler/wrap.js
CHANGED
|
@@ -421,6 +421,19 @@ ${flags & 0b0001 ? ` get func idx: ${get}
|
|
|
421
421
|
break;
|
|
422
422
|
}
|
|
423
423
|
|
|
424
|
+
case 0x0b: {
|
|
425
|
+
const [ target ] = read(Int16Array, bc, i, 1);
|
|
426
|
+
i += 2;
|
|
427
|
+
console.log('\x1b[93mpositive lookahead\x1b[0m', target, `\x1b[2m(${i + target - 3})\x1b[0m`);
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
case 0x0c: {
|
|
431
|
+
const [ target ] = read(Int16Array, bc, i, 1);
|
|
432
|
+
i += 2;
|
|
433
|
+
console.log('\x1b[93mnegative lookahead\x1b[0m', target, `\x1b[2m(${i + target - 3})\x1b[0m`);
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
|
|
424
437
|
case 0x10: {
|
|
425
438
|
console.log('\x1b[92maccept\x1b[0m');
|
|
426
439
|
break;
|
package/jsr.json
CHANGED
package/package.json
CHANGED