porffor 0.28.6 → 0.28.8
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/assemble.js +8 -4
- package/compiler/builtins/z_weakmap.ts +10 -3
- package/compiler/builtins/z_weakset.ts +10 -3
- package/compiler/builtins.js +4 -2
- package/compiler/builtins_precompiled.js +433 -433
- package/compiler/codegen.js +124 -42
- package/compiler/precompile.js +2 -2
- package/package.json +1 -1
- package/runner/index.js +1 -1
package/compiler/assemble.js
CHANGED
@@ -170,14 +170,18 @@ export default (funcs, globals, tags, pages, data, flags, noTreeshake = false) =
|
|
170
170
|
const func = funcs[i];
|
171
171
|
let name = func.name;
|
172
172
|
|
173
|
+
// real argc
|
173
174
|
let argc = func.params.length;
|
174
175
|
if (func.constr) argc -= 4;
|
175
176
|
if (!func.internal || func.typedParams) argc = Math.floor(argc / 2);
|
177
|
+
bytes.push(argc % 256, (argc / 256 | 0) % 256);
|
176
178
|
|
177
|
-
//
|
178
|
-
|
179
|
+
// userland exposed .length
|
180
|
+
let length = argc;
|
181
|
+
// remove _this from internal prototype funcs
|
182
|
+
if (func.internal && name.includes('_prototype_')) length--;
|
179
183
|
|
180
|
-
bytes.push(
|
184
|
+
bytes.push(length % 256, (length / 256 | 0) % 256);
|
181
185
|
|
182
186
|
let flags = 0b00000000; // 8 flag bits
|
183
187
|
if (func.returnType != null) flags |= 0b01;
|
@@ -189,7 +193,7 @@ export default (funcs, globals, tags, pages, data, flags, noTreeshake = false) =
|
|
189
193
|
|
190
194
|
bytes.push(...new Uint8Array(new Int32Array([ name.length ]).buffer));
|
191
195
|
|
192
|
-
for (let i = 0; i < (128 -
|
196
|
+
for (let i = 0; i < (128 - 5 - 4); i++) {
|
193
197
|
const c = name.charCodeAt(i);
|
194
198
|
bytes.push((c || 0) % 256);
|
195
199
|
}
|
@@ -1,15 +1,22 @@
|
|
1
1
|
import type {} from './porffor.d.ts';
|
2
2
|
|
3
|
-
export const __WeakMap_prototype_has = (_this: WeakMap, key: any) =>
|
3
|
+
export const __WeakMap_prototype_has = (_this: WeakMap, key: any) => {
|
4
|
+
const map: Map = _this;
|
5
|
+
return __Map_prototype_has(map, key);
|
6
|
+
};
|
4
7
|
|
5
8
|
export const __WeakMap_prototype_set = (_this: WeakMap, key: any, value: any) => {
|
6
9
|
if (!Porffor.object.isObjectOrSymbol(key)) throw new TypeError('Value in WeakSet needs to be an object or symbol');
|
7
10
|
|
8
|
-
|
11
|
+
const map: Map = _this;
|
12
|
+
__Map_prototype_set(map, key, value);
|
9
13
|
return _this;
|
10
14
|
};
|
11
15
|
|
12
|
-
export const __WeakMap_prototype_delete = (_this: WeakMap, key: any) =>
|
16
|
+
export const __WeakMap_prototype_delete = (_this: WeakMap, key: any) => {
|
17
|
+
const map: Map = _this;
|
18
|
+
return __Map_prototype_delete(map, key);
|
19
|
+
};
|
13
20
|
|
14
21
|
export const WeakMap = function (iterable: any): WeakMap {
|
15
22
|
if (!new.target) throw new TypeError("Constructor WeakMap requires 'new'");
|
@@ -1,15 +1,22 @@
|
|
1
1
|
import type {} from './porffor.d.ts';
|
2
2
|
|
3
|
-
export const __WeakSet_prototype_has = (_this: WeakSet, value: any) =>
|
3
|
+
export const __WeakSet_prototype_has = (_this: WeakSet, value: any) => {
|
4
|
+
const set: Set = _this;
|
5
|
+
return __Set_prototype_has(set, value);
|
6
|
+
};
|
4
7
|
|
5
8
|
export const __WeakSet_prototype_add = (_this: WeakSet, value: any) => {
|
6
9
|
if (!Porffor.object.isObjectOrSymbol(value)) throw new TypeError('Value in WeakSet needs to be an object or symbol');
|
7
10
|
|
8
|
-
|
11
|
+
const set: Set = _this;
|
12
|
+
__Set_prototype_add(set, value);
|
9
13
|
return _this;
|
10
14
|
};
|
11
15
|
|
12
|
-
export const __WeakSet_prototype_delete = (_this: WeakSet, value: any) =>
|
16
|
+
export const __WeakSet_prototype_delete = (_this: WeakSet, value: any) => {
|
17
|
+
const set: Set = _this;
|
18
|
+
return __Set_prototype_delete(set, value);
|
19
|
+
};
|
13
20
|
|
14
21
|
export const WeakSet = function (iterable: any): WeakSet {
|
15
22
|
if (!new.target) throw new TypeError("Constructor WeakSet requires 'new'");
|
package/compiler/builtins.js
CHANGED
@@ -1052,7 +1052,7 @@ export const BuiltinFuncs = function() {
|
|
1052
1052
|
[ Opcodes.local_get, 0 ],
|
1053
1053
|
...number(128, Valtype.i32),
|
1054
1054
|
[ Opcodes.i32_mul ],
|
1055
|
-
...number(
|
1055
|
+
...number(4, Valtype.i32),
|
1056
1056
|
[ Opcodes.i32_add ],
|
1057
1057
|
[ Opcodes.i32_load8_u, 0, ...unsignedLEB128(allocPage(scope, 'func lut') * pageSize) ]
|
1058
1058
|
],
|
@@ -1067,6 +1067,8 @@ export const BuiltinFuncs = function() {
|
|
1067
1067
|
[ Opcodes.local_get, 0 ],
|
1068
1068
|
...number(128, Valtype.i32),
|
1069
1069
|
[ Opcodes.i32_mul ],
|
1070
|
+
...number(2, Valtype.i32),
|
1071
|
+
[ Opcodes.i32_add ],
|
1070
1072
|
[ Opcodes.i32_load16_u, 0, ...unsignedLEB128(allocPage(scope, 'func lut') * pageSize) ]
|
1071
1073
|
],
|
1072
1074
|
table: true
|
@@ -1080,7 +1082,7 @@ export const BuiltinFuncs = function() {
|
|
1080
1082
|
[ Opcodes.local_get, 0 ],
|
1081
1083
|
...number(128, Valtype.i32),
|
1082
1084
|
[ Opcodes.i32_mul ],
|
1083
|
-
...number(
|
1085
|
+
...number(5, Valtype.i32),
|
1084
1086
|
[ Opcodes.i32_add ],
|
1085
1087
|
...number(allocPage(scope, 'func lut') * pageSize, Valtype.i32),
|
1086
1088
|
[ Opcodes.i32_add ]
|