porffor 0.57.3 → 0.57.5
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 +0 -11
- package/compiler/builtins/error.js +32 -13
- package/compiler/builtins.js +28 -0
- package/compiler/builtins_precompiled.js +597 -468
- package/compiler/codegen.js +11 -17
- package/compiler/types.js +0 -1
- package/compiler/wrap.js +7 -12
- package/package.json +1 -1
- package/runtime/index.js +1 -1
@@ -247,17 +247,6 @@ i32.const 7 ;; object
|
|
247
247
|
return`;
|
248
248
|
}
|
249
249
|
|
250
|
-
if (Porffor.fastAnd(
|
251
|
-
Porffor.type(_obj) >= Porffor.TYPES.error,
|
252
|
-
Porffor.type(_obj) < 0x40
|
253
|
-
)) {
|
254
|
-
Porffor.wasm`
|
255
|
-
local.get ${_obj}
|
256
|
-
i32.trunc_sat_f64_u
|
257
|
-
i32.const 7 ;; object
|
258
|
-
return`;
|
259
|
-
}
|
260
|
-
|
261
250
|
if (Porffor.fastAnd(
|
262
251
|
Porffor.type(_obj) > 0x05,
|
263
252
|
Porffor.type(_obj) != Porffor.TYPES.undefined
|
@@ -2,29 +2,49 @@ export default () => {
|
|
2
2
|
let out = '';
|
3
3
|
|
4
4
|
const errors = [];
|
5
|
-
const error =
|
6
|
-
|
7
|
-
out += `export const ${name} = function (message: any): ${
|
5
|
+
const error = name => {
|
6
|
+
errors.push(name);
|
7
|
+
out += `export const ${name} = function (message: any): ${name} {
|
8
8
|
if (message === undefined) message = '';
|
9
9
|
else message = ecma262.ToString(message);
|
10
10
|
|
11
|
-
const obj:
|
12
|
-
obj
|
13
|
-
obj.message
|
14
|
-
obj.constructor = ${name};
|
11
|
+
const obj: ${name} = Porffor.allocateBytes(8);
|
12
|
+
Porffor.wasm.i32.store(obj, message, 0, 0);
|
13
|
+
Porffor.wasm.i32.store8(obj, Porffor.type(message), 0, 4);
|
15
14
|
|
16
|
-
return obj
|
15
|
+
return obj;
|
17
16
|
};
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
export const __${name}_prototype_constructor$get = (_this: ${name}) => {
|
19
|
+
return ${name};
|
20
|
+
};
|
21
|
+
|
22
|
+
export const __${name}_prototype_name$get = (_this: ${name}) => {
|
23
|
+
return '${name}';
|
24
|
+
};
|
25
|
+
|
26
|
+
export const __${name}_prototype_message$get = (_this: ${name}) => {
|
27
|
+
Porffor.wasm\`
|
28
|
+
local.get \${_this}
|
29
|
+
i32.trunc_sat_f64_u
|
30
|
+
i32.load 0 0
|
31
|
+
f64.convert_i32_u
|
32
|
+
|
33
|
+
local.get \${_this}
|
34
|
+
i32.trunc_sat_f64_u
|
35
|
+
i32.load8_u 0 4
|
36
|
+
return\`;
|
37
|
+
};
|
38
|
+
|
39
|
+
export const __${name}_prototype_toString = (_this: ${name}) => {
|
40
|
+
const name: any = _this.name;
|
41
|
+
const message: any = _this.message;
|
22
42
|
if (message.length == 0) {
|
23
43
|
return name;
|
24
44
|
}
|
25
45
|
|
26
46
|
return name + ': ' + message;
|
27
|
-
}
|
47
|
+
};\n`;
|
28
48
|
};
|
29
49
|
|
30
50
|
error('Error');
|
@@ -36,7 +56,6 @@ ${type ? `export const __${name}_prototype_toString = (_this: ${name}) => {
|
|
36
56
|
error('EvalError');
|
37
57
|
error('URIError');
|
38
58
|
error('Test262Error');
|
39
|
-
error('TodoError', false);
|
40
59
|
|
41
60
|
out += `
|
42
61
|
export const __Test262Error_thrower = message => {
|
package/compiler/builtins.js
CHANGED
@@ -95,6 +95,34 @@ export const BuiltinVars = function(ctx) {
|
|
95
95
|
this.__BigInt64Array_BYTES_PER_ELEMENT = [ number(8) ];
|
96
96
|
this.__BigUint64Array_BYTES_PER_ELEMENT = [ number(8) ];
|
97
97
|
|
98
|
+
// well-known symbols
|
99
|
+
for (const x of [
|
100
|
+
'asyncIterator', 'hasInstance',
|
101
|
+
'isConcatSpreadable', 'iterator',
|
102
|
+
'match', 'matchAll', 'replace',
|
103
|
+
'search', 'species', 'split',
|
104
|
+
'toPrimitive', 'toStringTag', 'unscopables',
|
105
|
+
'dispose', 'asyncDispose'
|
106
|
+
]) {
|
107
|
+
this[`__Symbol_${x}`] = (scope, { glbl, builtin, makeString }) => [
|
108
|
+
[ Opcodes.block, Valtype.f64 ],
|
109
|
+
...glbl(Opcodes.global_get, `#wellknown_${x}`, Valtype.f64),
|
110
|
+
Opcodes.i32_to_u,
|
111
|
+
[ Opcodes.if, Blocktype.void ],
|
112
|
+
...glbl(Opcodes.global_get, `#wellknown_${x}`, Valtype.f64),
|
113
|
+
[ Opcodes.br, 1 ],
|
114
|
+
[ Opcodes.end ],
|
115
|
+
|
116
|
+
...makeString(scope, `Symbol.${x}`),
|
117
|
+
number(TYPES.bytestring, Valtype.i32),
|
118
|
+
[ Opcodes.call, builtin('Symbol') ],
|
119
|
+
...glbl(Opcodes.global_set, `#wellknown_${x}`, Valtype.f64),
|
120
|
+
...glbl(Opcodes.global_get, `#wellknown_${x}`, Valtype.f64),
|
121
|
+
[ Opcodes.end ]
|
122
|
+
];
|
123
|
+
this[`__Symbol_${x}`].type = TYPES.symbol;
|
124
|
+
}
|
125
|
+
|
98
126
|
ObjectBuiltins.call(this, ctx, Prefs);
|
99
127
|
};
|
100
128
|
|