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.
@@ -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
- // hack: argc-- for prototype methods to remove _this hack from count
178
- if (name.includes('_prototype_')) argc--;
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(argc % 256, (argc / 256 | 0) % 256);
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 - 3 - 4); i++) {
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) => __Map_prototype_has(_this, key);
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
- __Map_prototype_set(_this, key, value);
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) => __Map_prototype_delete(_this, key);
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) => __Set_prototype_has(_this, value);
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
- __Set_prototype_add(_this, value);
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) => __Set_prototype_delete(_this, value);
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'");
@@ -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(2, Valtype.i32),
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(3, Valtype.i32),
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 ]