porffor 0.41.1 → 0.41.3
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/{nova.comp.cjs → .hermes.cjs} +1 -1
- package/compiler/builtins/__internal_object.ts +4 -1
- package/compiler/builtins/_internal_string.ts +0 -4
- package/compiler/builtins/object.ts +2 -1
- package/compiler/builtins/porffor.d.ts +4 -2
- package/compiler/builtins/string_f64.ts +30 -5
- package/compiler/builtins/z_ecma262.ts +6 -0
- package/compiler/builtins.js +1 -5
- package/compiler/builtins_precompiled.js +60 -60
- package/compiler/codegen.js +40 -16
- package/compiler/types.js +1 -0
- package/compiler/wrap.js +2 -0
- package/package.json +1 -1
- package/runner/index.js +1 -1
- package/r.js +0 -5
@@ -1,3 +1,3 @@
|
|
1
|
-
const uniq = [...new Set(require('../
|
1
|
+
const uniq = [...new Set(require('../hermes.json').pass.map(x => x.slice(5))).difference(new Set(require('./test262/results.json').passes))];
|
2
2
|
console.log([...uniq.reduce((acc, x) => { let k = x.split('/').slice(0, -1).join('/'); return acc.set(k, (acc.get(k) || 0) + 1); }, new Map()).entries()].sort((a, b) => a[1] - b[1]).slice(-20).map(x => x[0] + ': ' + x[1]).join('\n'));
|
3
3
|
console.log(uniq.filter(x => x.startsWith('built-ins/Object/defineProperty')).join('\n'))
|
@@ -13,7 +13,10 @@ export const __Porffor_object_underlying = (obj: any): any => {
|
|
13
13
|
}
|
14
14
|
|
15
15
|
if (Porffor.fastAnd(t > 0x05, t != Porffor.TYPES.undefined)) {
|
16
|
-
|
16
|
+
// this causes memory corruption things in some situations in test262?
|
17
|
+
// let idx: i32 = Porffor.array.fastIndexOf(underlyingKeys, obj);
|
18
|
+
|
19
|
+
let idx: i32 = underlyingKeys.indexOf(obj);
|
17
20
|
if (idx == -1) {
|
18
21
|
const underlying: object = {};
|
19
22
|
|
@@ -16,7 +16,6 @@ export const __Porffor_compareStrings = (a: any, b: any): boolean => {
|
|
16
16
|
|
17
17
|
// todo/perf: just use a.toString()?
|
18
18
|
a = ecma262.ToString(a);
|
19
|
-
at = Porffor.rawType(a);
|
20
19
|
}
|
21
20
|
|
22
21
|
if ((bt | 0b10000000) != Porffor.TYPES.bytestring) {
|
@@ -31,7 +30,6 @@ export const __Porffor_compareStrings = (a: any, b: any): boolean => {
|
|
31
30
|
|
32
31
|
// todo/perf: just use b.toString()?
|
33
32
|
b = ecma262.ToString(b);
|
34
|
-
bt = Porffor.rawType(b);
|
35
33
|
}
|
36
34
|
|
37
35
|
return Porffor.strcmp(a, b);
|
@@ -45,14 +43,12 @@ export const __Porffor_concatStrings = (a: any, b: any): boolean => {
|
|
45
43
|
// a is not string or bytestring
|
46
44
|
// todo/perf: just use a.toString()?
|
47
45
|
a = ecma262.ToString(a);
|
48
|
-
at = Porffor.rawType(a);
|
49
46
|
}
|
50
47
|
|
51
48
|
if ((bt | 0b10000000) != Porffor.TYPES.bytestring) {
|
52
49
|
// b is not string or bytestring
|
53
50
|
// todo/perf: just use b.toString()?
|
54
51
|
b = ecma262.ToString(b);
|
55
|
-
bt = Porffor.rawType(b);
|
56
52
|
}
|
57
53
|
|
58
54
|
return Porffor.strcat(a, b);
|
@@ -703,7 +703,8 @@ export const __Object_prototype_toString = (_this: any) => {
|
|
703
703
|
t == Porffor.TYPES.numberobject)) return out = '[object Number]';
|
704
704
|
if (Porffor.fastOr(
|
705
705
|
t == Porffor.TYPES.string,
|
706
|
-
t == Porffor.TYPES.bytestring
|
706
|
+
t == Porffor.TYPES.bytestring,
|
707
|
+
t == Porffor.TYPES.stringobject)) return out = '[object String]';
|
707
708
|
if (t == Porffor.TYPES.date) return out = '[object Date]';
|
708
709
|
if (t == Porffor.TYPES.regexp) return out = '[object RegExp]';
|
709
710
|
|
@@ -4,7 +4,8 @@ export type f64 = number;
|
|
4
4
|
export type bytestring = string;
|
5
5
|
|
6
6
|
export type BooleanObject = Boolean;
|
7
|
-
export type NumberObject =
|
7
|
+
export type NumberObject = Number;
|
8
|
+
export type StringObject = String;
|
8
9
|
|
9
10
|
type PorfforGlobal = {
|
10
11
|
wasm: {
|
@@ -146,5 +147,6 @@ declare global {
|
|
146
147
|
type bytestring = string;
|
147
148
|
|
148
149
|
type BooleanObject = Boolean;
|
149
|
-
type NumberObject =
|
150
|
+
type NumberObject = Number;
|
151
|
+
type StringObject = String;
|
150
152
|
}
|
@@ -1,10 +1,35 @@
|
|
1
1
|
import type {} from './porffor.d.ts';
|
2
2
|
|
3
|
-
//
|
4
|
-
//
|
5
|
-
export const String = function (
|
6
|
-
|
7
|
-
|
3
|
+
// 22.1.1.1 String (value)
|
4
|
+
// https://tc39.es/ecma262/#sec-string-constructor-string-value
|
5
|
+
export const String = function (...args: any[]): string|bytestring|StringObject {
|
6
|
+
let s: bytestring|string = '';
|
7
|
+
|
8
|
+
// 1. If value is not present, then
|
9
|
+
// a. Let s be the empty String.
|
10
|
+
// s is already empty
|
11
|
+
|
12
|
+
// 2. Else,
|
13
|
+
if (args.length > 0) {
|
14
|
+
const value: any = args[0];
|
15
|
+
|
16
|
+
// a. If NewTarget is undefined and value is a Symbol, return SymbolDescriptiveString(value).
|
17
|
+
if (!new.target && Porffor.rawType(value) == Porffor.TYPES.symbol) return __Symbol_prototype_toString(value);
|
18
|
+
|
19
|
+
// b. Let s be ? ToString(value).
|
20
|
+
s = ecma262.ToString(value);
|
21
|
+
}
|
22
|
+
|
23
|
+
// 3. If NewTarget is undefined, return s.
|
24
|
+
if (!new.target) return s;
|
25
|
+
|
26
|
+
// 4. Return StringCreate(s, ? GetPrototypeFromConstructor(NewTarget, "%String.prototype%")).
|
27
|
+
|
28
|
+
// force bytestrings to strings
|
29
|
+
if (Porffor.rawType(s) == Porffor.TYPES.bytestring) s = Porffor.bytestringToString(s, s.length);
|
30
|
+
|
31
|
+
const O: StringObject = s;
|
32
|
+
return O;
|
8
33
|
};
|
9
34
|
|
10
35
|
export const __String_fromCharCode = (...codes: any[]): bytestring|string => {
|
@@ -154,6 +154,12 @@ export const __ecma262_ToString = (argument: unknown): any => {
|
|
154
154
|
|
155
155
|
// 8. If argument is a BigInt, return BigInt::toString(argument, 10).
|
156
156
|
|
157
|
+
// hack: StringObject -> String
|
158
|
+
if (type == Porffor.TYPES.stringobject) {
|
159
|
+
const remap: string = argument;
|
160
|
+
return remap;
|
161
|
+
}
|
162
|
+
|
157
163
|
// 9. Assert: argument is an Object.
|
158
164
|
// 10. Let primValue be ? ToPrimitive(argument, string).
|
159
165
|
const primValue: any = __ecma262_ToPrimitive_String(argument);
|
package/compiler/builtins.js
CHANGED
@@ -952,7 +952,7 @@ export const BuiltinFuncs = function() {
|
|
952
952
|
this.__Porffor_bytestringToString = {
|
953
953
|
params: [ Valtype.i32, Valtype.i32 ],
|
954
954
|
locals: [ Valtype.i32, Valtype.i32 ],
|
955
|
-
localNames: [ 'src', 'len', '
|
955
|
+
localNames: [ 'src', 'len', 'counter', 'dst' ],
|
956
956
|
returns: [ Valtype.i32 ],
|
957
957
|
returnType: TYPES.string,
|
958
958
|
wasm: [
|
@@ -967,10 +967,6 @@ export const BuiltinFuncs = function() {
|
|
967
967
|
[ Opcodes.local_get, 1 ],
|
968
968
|
[ Opcodes.i32_store, 0, 0 ],
|
969
969
|
|
970
|
-
// counter = 0
|
971
|
-
[ Opcodes.i32_const, 0 ],
|
972
|
-
[ Opcodes.local_set, 2 ],
|
973
|
-
|
974
970
|
[ Opcodes.loop, Blocktype.void ],
|
975
971
|
|
976
972
|
// base for store later
|