porffor 0.55.32 → 0.55.34
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 +348 -239
- package/compiler/builtins/_internal_string.ts +4 -4
- package/compiler/builtins/annexb_string.js +12 -11
- package/compiler/builtins/array.ts +21 -22
- package/compiler/builtins/arraybuffer.ts +4 -4
- package/compiler/builtins/bigint.ts +4 -4
- package/compiler/builtins/console.ts +9 -9
- package/compiler/builtins/dataview.ts +3 -3
- package/compiler/builtins/date.ts +46 -52
- package/compiler/builtins/error.js +1 -1
- package/compiler/builtins/json.ts +6 -6
- package/compiler/builtins/math.ts +1 -1
- package/compiler/builtins/number.ts +9 -9
- package/compiler/builtins/object.ts +32 -32
- package/compiler/builtins/object_hiddenPrototype.js +42 -0
- package/compiler/builtins/porffor.d.ts +4 -3
- package/compiler/builtins/promise.ts +6 -6
- package/compiler/builtins/reflect.ts +1 -1
- package/compiler/builtins/set.ts +7 -7
- package/compiler/builtins/string_f64.ts +2 -2
- package/compiler/builtins/symbol.ts +2 -2
- package/compiler/builtins/typedarray.js +7 -7
- package/compiler/builtins/z_ecma262.ts +7 -7
- package/compiler/builtins.js +5 -6
- package/compiler/builtins_objects.js +27 -5
- package/compiler/builtins_precompiled.js +529 -525
- package/compiler/codegen.js +29 -39
- package/compiler/precompile.js +4 -3
- package/package.json +1 -1
- package/r.cjs +2 -9
- package/runner/index.js +1 -1
- package/compiler/builtins/__internal_object.ts +0 -83
- package/compiler/builtins/object_prototypeWithHidden.js +0 -47
@@ -28,7 +28,7 @@ export const __ecma262_ToPrimitive_String = (input: any): any => {
|
|
28
28
|
// 7.1.4 ToNumber (argument)
|
29
29
|
// https://tc39.es/ecma262/#sec-tonumber
|
30
30
|
export const __ecma262_ToNumber = (argument: unknown): number => {
|
31
|
-
const t: i32 = Porffor.
|
31
|
+
const t: i32 = Porffor.type(argument);
|
32
32
|
|
33
33
|
// 1. If argument is a Number, return argument.
|
34
34
|
if (t == Porffor.TYPES.number) return argument;
|
@@ -73,12 +73,12 @@ export const __ecma262_ToNumeric = (value: unknown): number => {
|
|
73
73
|
// 1. Let primValue be ? ToPrimitive(value, number).
|
74
74
|
// only run ToPrimitive if pure object for perf
|
75
75
|
let primValue: any = value;
|
76
|
-
if (Porffor.
|
76
|
+
if (Porffor.type(value) == Porffor.TYPES.object && Porffor.wasm`local.get ${value}` != 0)
|
77
77
|
primValue = __ecma262_ToPrimitive_Number(value);
|
78
78
|
|
79
79
|
// 2. If primValue is a BigInt, return primValue.
|
80
80
|
if (Porffor.comptime.flag`hasType.bigint`) {
|
81
|
-
if (Porffor.
|
81
|
+
if (Porffor.type(primValue) == Porffor.TYPES.bigint) return primValue;
|
82
82
|
}
|
83
83
|
|
84
84
|
// 3. Return ? ToNumber(primValue).
|
@@ -124,7 +124,7 @@ export const __ecma262_ToIndex = (value: unknown): number => {
|
|
124
124
|
// 7.1.17 ToString (argument)
|
125
125
|
// https://tc39.es/ecma262/#sec-tostring
|
126
126
|
export const __ecma262_ToString = (argument: unknown): any => {
|
127
|
-
const type: i32 = Porffor.
|
127
|
+
const type: i32 = Porffor.type(argument);
|
128
128
|
|
129
129
|
// 1. If argument is a String, return argument.
|
130
130
|
if (Porffor.fastOr(
|
@@ -180,11 +180,11 @@ export const __ecma262_ToPropertyKey = (argument: any): any => {
|
|
180
180
|
// 1. Let key be ? ToPrimitive(argument, string).
|
181
181
|
// only run ToPrimitive if pure object for perf
|
182
182
|
let key: any = argument;
|
183
|
-
if (Porffor.
|
183
|
+
if (Porffor.type(argument) == Porffor.TYPES.object && Porffor.wasm`local.get ${argument}` != 0)
|
184
184
|
key = __ecma262_ToPrimitive_String(argument);
|
185
185
|
|
186
186
|
// 2. If key is a Symbol, then
|
187
|
-
if (Porffor.
|
187
|
+
if (Porffor.type(key) == Porffor.TYPES.symbol) {
|
188
188
|
// a. Return key.
|
189
189
|
return key;
|
190
190
|
}
|
@@ -194,6 +194,6 @@ export const __ecma262_ToPropertyKey = (argument: any): any => {
|
|
194
194
|
};
|
195
195
|
|
196
196
|
export const __ecma262_IsConstructor = (argument: any): boolean => {
|
197
|
-
if (Porffor.
|
197
|
+
if (Porffor.type(argument) != Porffor.TYPES.function) return false;
|
198
198
|
return (__Porffor_funcLut_flags(argument) & 0b10) == 2;
|
199
199
|
};
|
package/compiler/builtins.js
CHANGED
@@ -735,19 +735,18 @@ export const BuiltinFuncs = function() {
|
|
735
735
|
this.__performance_now.usesImports = true;
|
736
736
|
|
737
737
|
|
738
|
-
this.
|
739
|
-
params: [
|
740
|
-
|
741
|
-
locals: [ Valtype.i32, Valtype.i32 ],
|
738
|
+
this.__Porffor_typeName = {
|
739
|
+
params: [ Valtype.i32 ],
|
740
|
+
locals: [],
|
742
741
|
returns: [ valtypeBinary ],
|
743
742
|
returnType: TYPES.bytestring,
|
744
743
|
wasm: (scope, { typeSwitch, makeString }) => {
|
745
744
|
const bc = {};
|
746
745
|
for (const x in TYPE_NAMES) {
|
747
|
-
bc[x] = makeString(scope, TYPE_NAMES[x]);
|
746
|
+
bc[x] = () => makeString(scope, TYPE_NAMES[x]);
|
748
747
|
}
|
749
748
|
|
750
|
-
return typeSwitch(scope, [ [ Opcodes.local_get,
|
749
|
+
return typeSwitch(scope, [ [ Opcodes.local_get, 0 ] ], bc);
|
751
750
|
}
|
752
751
|
};
|
753
752
|
|
@@ -15,7 +15,7 @@ export default function({ builtinFuncs }, Prefs) {
|
|
15
15
|
|
16
16
|
builtinFuncs['#get_' + name] = {
|
17
17
|
params: [],
|
18
|
-
locals: [],
|
18
|
+
locals: [ Valtype.i32 ],
|
19
19
|
returns: [ Valtype.i32 ],
|
20
20
|
returnType: TYPES.object,
|
21
21
|
wasm: (scope, { allocPage, makeString, generate, getNodeType, builtin, funcRef, glbl }) => {
|
@@ -41,7 +41,15 @@ export default function({ builtinFuncs }, Prefs) {
|
|
41
41
|
|
42
42
|
// set cache & ptr for use
|
43
43
|
number(ptr, Valtype.i32),
|
44
|
-
|
44
|
+
[ Opcodes.local_tee, 0 ],
|
45
|
+
glbl(Opcodes.global_set, `getptr_${name}`, Valtype.i32)[0],
|
46
|
+
|
47
|
+
[ Opcodes.local_get, 0 ],
|
48
|
+
Opcodes.i32_from_u,
|
49
|
+
number(existingFunc ? TYPES.function : TYPES.object, Valtype.i32),
|
50
|
+
[ Opcodes.call, builtin('__Porffor_object_underlying') ],
|
51
|
+
[ Opcodes.drop ],
|
52
|
+
[ Opcodes.local_set, 0 ]
|
45
53
|
];
|
46
54
|
|
47
55
|
for (const x in props) {
|
@@ -50,6 +58,20 @@ export default function({ builtinFuncs }, Prefs) {
|
|
50
58
|
name: prefix + x
|
51
59
|
};
|
52
60
|
|
61
|
+
if (x === '__proto__') {
|
62
|
+
out.push(
|
63
|
+
[ Opcodes.local_get, 0 ],
|
64
|
+
number(TYPES.object, Valtype.i32),
|
65
|
+
|
66
|
+
...generate(scope, value),
|
67
|
+
Opcodes.i32_to_u,
|
68
|
+
...getNodeType(scope, value),
|
69
|
+
|
70
|
+
[ Opcodes.call, builtin('__Porffor_object_setPrototype') ]
|
71
|
+
);
|
72
|
+
continue;
|
73
|
+
}
|
74
|
+
|
53
75
|
let flags = 0b0000;
|
54
76
|
|
55
77
|
const d = props[x];
|
@@ -61,8 +83,8 @@ export default function({ builtinFuncs }, Prefs) {
|
|
61
83
|
if (this[prefix + x]?.type === TYPES.object && this[prefix + x] !== this.null) value = { type: 'ObjectExpression', properties: [] };
|
62
84
|
|
63
85
|
out.push(
|
64
|
-
|
65
|
-
number(
|
86
|
+
[ Opcodes.local_get, 0 ],
|
87
|
+
number(TYPES.object, Valtype.i32),
|
66
88
|
|
67
89
|
...makeString(scope, x),
|
68
90
|
Opcodes.i32_to_u,
|
@@ -74,7 +96,7 @@ export default function({ builtinFuncs }, Prefs) {
|
|
74
96
|
number(flags, Valtype.i32),
|
75
97
|
number(TYPES.number, Valtype.i32),
|
76
98
|
|
77
|
-
[ Opcodes.call, builtin('
|
99
|
+
[ Opcodes.call, builtin('__Porffor_object_fastAdd') ]
|
78
100
|
);
|
79
101
|
}
|
80
102
|
|