porffor 0.19.2 → 0.19.4
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/arraybuffer.ts +3 -3
- package/compiler/builtins/dataview.ts +2 -2
- package/compiler/builtins/set.ts +1 -1
- package/compiler/builtins/z_weakmap.ts +40 -0
- package/compiler/builtins/z_weakset.ts +34 -0
- package/compiler/codegen.js +1 -1
- package/compiler/generated_builtins.js +655 -617
- package/compiler/types.js +14 -9
- package/compiler/wrap.js +30 -46
- package/package.json +1 -1
- package/runner/index.js +1 -1
- package/compiler/builtins/weakset.ts +0 -102
@@ -32,7 +32,7 @@ i32.const 0
|
|
32
32
|
i32.ge_s
|
33
33
|
select
|
34
34
|
i32.from_u
|
35
|
-
i32.const
|
35
|
+
i32.const 1
|
36
36
|
return`;
|
37
37
|
};
|
38
38
|
|
@@ -49,7 +49,7 @@ i32.const 0
|
|
49
49
|
i32.ge_s
|
50
50
|
select
|
51
51
|
i32.from_u
|
52
|
-
i32.const
|
52
|
+
i32.const 1
|
53
53
|
return`;
|
54
54
|
};
|
55
55
|
|
@@ -61,7 +61,7 @@ i32.load 0 0
|
|
61
61
|
i32.const 4294967295
|
62
62
|
i32.eq
|
63
63
|
i32.from_u
|
64
|
-
i32.const
|
64
|
+
i32.const 2
|
65
65
|
return`;
|
66
66
|
};
|
67
67
|
|
@@ -67,7 +67,7 @@ i32.to_u
|
|
67
67
|
i32.add
|
68
68
|
i32.load8_u 0 4
|
69
69
|
i32.from_u
|
70
|
-
i32.const
|
70
|
+
i32.const 1
|
71
71
|
return`;
|
72
72
|
};
|
73
73
|
|
@@ -225,7 +225,7 @@ local.get ${int}
|
|
225
225
|
i32.to_u
|
226
226
|
f32.reinterpret_i32
|
227
227
|
f64.promote_f32
|
228
|
-
i32.const
|
228
|
+
i32.const 1
|
229
229
|
return`;
|
230
230
|
};
|
231
231
|
|
package/compiler/builtins/set.ts
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
import type {} from './porffor.d.ts';
|
2
|
+
|
3
|
+
export const __WeakMap_prototype_has = (_this: WeakMap, key: any) => __Map_prototype_has(_this, key);
|
4
|
+
|
5
|
+
export const __WeakMap_prototype_set = (_this: WeakMap, key: any, value: any) => {
|
6
|
+
if (Porffor.rawType(key) < 0x04) throw new TypeError('Value in WeakSet needs to be an object or symbol');
|
7
|
+
|
8
|
+
__Map_prototype_set(_this, key, value);
|
9
|
+
return _this;
|
10
|
+
};
|
11
|
+
|
12
|
+
export const __WeakMap_prototype_delete = (_this: WeakMap, key: any) => __Map_prototype_delete(_this, key);
|
13
|
+
|
14
|
+
export const WeakMap = function (iterable: any): WeakMap {
|
15
|
+
if (!new.target) throw new TypeError("Constructor WeakMap requires 'new'");
|
16
|
+
|
17
|
+
const out: WeakMap = Porffor.allocateBytes(8);
|
18
|
+
|
19
|
+
const keys: Set = Porffor.allocate();
|
20
|
+
Porffor.wasm.i32.store(out, keys, 0, 0);
|
21
|
+
|
22
|
+
const vals: any[] = Porffor.allocate();
|
23
|
+
Porffor.wasm.i32.store(out, vals, 0, 4);
|
24
|
+
|
25
|
+
if (Porffor.fastAnd(
|
26
|
+
Porffor.rawType(iterable) != Porffor.TYPES.undefined,
|
27
|
+
iterable !== null
|
28
|
+
)) for (const x of iterable) {
|
29
|
+
__WeakMap_prototype_set(out, x[0], x[1]);
|
30
|
+
}
|
31
|
+
|
32
|
+
return out;
|
33
|
+
};
|
34
|
+
|
35
|
+
export const __WeakMap_prototype_toString = (_this: WeakMap) => {
|
36
|
+
const out: bytestring = '[object WeakMap]';
|
37
|
+
return out;
|
38
|
+
};
|
39
|
+
|
40
|
+
export const __WeakMap_prototype_toLocaleString = (_this: WeakMap) => __WeakMap_prototype_toString(_this);
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import type {} from './porffor.d.ts';
|
2
|
+
|
3
|
+
export const __WeakSet_prototype_has = (_this: WeakSet, value: any) => __Set_prototype_has(_this, value);
|
4
|
+
|
5
|
+
export const __WeakSet_prototype_add = (_this: WeakSet, value: any) => {
|
6
|
+
if (Porffor.rawType(value) < 0x04) throw new TypeError('Value in WeakSet needs to be an object or symbol');
|
7
|
+
|
8
|
+
__Set_prototype_add(_this, value);
|
9
|
+
return _this;
|
10
|
+
};
|
11
|
+
|
12
|
+
export const __WeakSet_prototype_delete = (_this: WeakSet, value: any) => __Set_prototype_delete(_this, value);
|
13
|
+
|
14
|
+
export const WeakSet = function (iterable: any): WeakSet {
|
15
|
+
if (!new.target) throw new TypeError("Constructor WeakSet requires 'new'");
|
16
|
+
|
17
|
+
const out: WeakSet = __Porffor_allocate();
|
18
|
+
|
19
|
+
if (Porffor.fastAnd(
|
20
|
+
Porffor.rawType(iterable) != Porffor.TYPES.undefined,
|
21
|
+
iterable !== null
|
22
|
+
)) for (const x of iterable) {
|
23
|
+
__WeakSet_prototype_add(out, x);
|
24
|
+
}
|
25
|
+
|
26
|
+
return out;
|
27
|
+
};
|
28
|
+
|
29
|
+
export const __WeakSet_prototype_toString = (_this: WeakSet) => {
|
30
|
+
const out: bytestring = '[object WeakSet]';
|
31
|
+
return out;
|
32
|
+
};
|
33
|
+
|
34
|
+
export const __WeakSet_prototype_toLocaleString = (_this: WeakSet) => __WeakSet_prototype_toString(_this);
|
package/compiler/codegen.js
CHANGED
@@ -3095,8 +3095,8 @@ const generateUnary = (scope, decl) => {
|
|
3095
3095
|
[TYPES.undefined]: makeString(scope, 'undefined', false, '#typeof_result'),
|
3096
3096
|
[TYPES.function]: makeString(scope, 'function', false, '#typeof_result'),
|
3097
3097
|
[TYPES.symbol]: makeString(scope, 'symbol', false, '#typeof_result'),
|
3098
|
-
|
3099
3098
|
[TYPES.bytestring]: makeString(scope, 'string', false, '#typeof_result'),
|
3099
|
+
[TYPES.empty]: makeString(scope, 'undefined', false, '#typeof_result'),
|
3100
3100
|
|
3101
3101
|
// object and internal types
|
3102
3102
|
default: makeString(scope, 'object', false, '#typeof_result'),
|