porffor 0.18.35 → 0.18.36
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/string.ts +32 -0
- package/compiler/generated_builtins.js +12 -0
- package/package.json +1 -1
- package/runner/index.js +1 -1
@@ -96,6 +96,38 @@ export const __ByteString_prototype_toLocaleUpperCase = (_this: bytestring) => _
|
|
96
96
|
export const __String_prototype_toLocaleLowerCase = (_this: string) => __String_prototype_toUpperCase(_this);
|
97
97
|
export const __ByteString_prototype_toLocaleLowerCase = (_this: bytestring) => __ByteString_prototype_toLowerCase(_this);
|
98
98
|
|
99
|
+
export const __String_prototype_codePointAt = (_this: string, index: number) => {
|
100
|
+
const len: i32 = _this.length;
|
101
|
+
|
102
|
+
index |= 0;
|
103
|
+
if (Porffor.fastOr(index < 0, index >= len)) return undefined;
|
104
|
+
|
105
|
+
index *= 2;
|
106
|
+
const c1: i32 = Porffor.wasm.i32.load16_u(Porffor.wasm`local.get ${_this}` + index, 0, 4);
|
107
|
+
if (Porffor.fastAnd(c1 >= 0xD800, c1 <= 0xDBFF)) {
|
108
|
+
// 1st char is leading surrogate, handle 2nd char
|
109
|
+
// check oob
|
110
|
+
if (index + 1 >= len) return c1;
|
111
|
+
|
112
|
+
const c2: i32 = Porffor.wasm.i32.load16_u(Porffor.wasm`local.get ${_this}` + index + 2, 0, 4);
|
113
|
+
if (Porffor.fastAnd(c2 >= 0xDC00, c2 <= 0xDFFF)) {
|
114
|
+
// 2nd char is trailing surrogate, return code point
|
115
|
+
return (c1 << 10) + c2 - 56613888;
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
return c1;
|
120
|
+
};
|
121
|
+
|
122
|
+
export const __ByteString_prototype_codePointAt = (_this: bytestring, index: number) => {
|
123
|
+
const len: i32 = _this.length;
|
124
|
+
|
125
|
+
index |= 0;
|
126
|
+
if (Porffor.fastOr(index < 0, index >= len)) return undefined;
|
127
|
+
|
128
|
+
// bytestrings cannot have surrogates, so just do charCodeAt
|
129
|
+
return Porffor.wasm.i32.load8_u(Porffor.wasm`local.get ${_this}` + index, 0, 4);
|
130
|
+
};
|
99
131
|
|
100
132
|
export const __String_prototype_startsWith = (_this: string, searchString: string, position: number) => {
|
101
133
|
// todo: handle bytestring searchString
|
@@ -1530,6 +1530,18 @@ export const BuiltinFuncs = function() {
|
|
1530
1530
|
returns: [127,127], typedReturns: 1,
|
1531
1531
|
locals: [127], localNames: ["_this","_this#type","#last_type"],
|
1532
1532
|
};
|
1533
|
+
this.__String_prototype_codePointAt = {
|
1534
|
+
wasm: (scope, {}) => [[32,0],[40,1,0],[33,4],[32,2],[65,0],[114],[34,2],[65,0],[72],[32,2],[32,4],[78],[114],[4,64],[65,0],[65,3],[15],[11],[32,2],[65,2],[108],[33,2],[32,0],[32,2],[106],[47,0,4],[34,5],[65,128,176,3],[78],[32,5],[65,255,183,3],[76],[113],[4,64],[32,2],[65,1],[106],[32,4],[78],[4,64],[32,5],[65,0],[15],[11],[32,0],[32,2],[106],[65,2],[106],[47,0,4],[34,6],[65,128,184,3],[78],[32,6],[65,255,191,3],[76],[113],[4,64],[32,5],[65,10],[116],[32,6],[106],[65,128,184,255,26],[107],[65,0],[15],[11],[11],[32,5],[65,0],[15]],
|
1535
|
+
params: [127,127,127,127], typedParams: 1,
|
1536
|
+
returns: [127,127], typedReturns: 1,
|
1537
|
+
locals: [127,127,127], localNames: ["_this","_this#type","index","index#type","len","c1","c2"],
|
1538
|
+
};
|
1539
|
+
this.__ByteString_prototype_codePointAt = {
|
1540
|
+
wasm: (scope, {}) => [[32,0],[40,1,0],[33,4],[32,2],[65,0],[114],[34,2],[65,0],[72],[32,2],[32,4],[78],[114],[4,64],[65,0],[65,3],[15],[11],[32,0],[32,2],[106],[45,0,4],[65,0],[15]],
|
1541
|
+
params: [127,127,127,127], typedParams: 1,
|
1542
|
+
returns: [127,127], typedReturns: 1,
|
1543
|
+
locals: [127], localNames: ["_this","_this#type","index","index#type","len"],
|
1544
|
+
};
|
1533
1545
|
this.__String_prototype_startsWith = {
|
1534
1546
|
wasm: (scope, {}) => [[32,0],[33,6],[32,2],[33,7],[32,0],[40,1,0],[33,8],[32,4],[65,0],[74],[4,64],[32,4],[32,8],[74],[4,64],[32,8],[33,4],[5],[32,4],[65,0],[114],[33,4],[11],[5],[65,0],[33,4],[11],[32,6],[32,4],[65,2],[108],[106],[33,6],[32,2],[40,1,0],[65,2],[108],[33,9],[65,0],[33,10],[3,64],[32,10],[32,9],[72],[4,64],[32,6],[32,10],[106],[47,0,4],[33,11],[32,7],[32,10],[106],[47,0,4],[33,12],[32,11],[32,12],[71],[4,64],[65,0],[65,1],[15],[11],[32,10],[65,2],[106],[34,10],[12,1],[11],[11],[65,1],[65,1],[15]],
|
1535
1547
|
params: [127,127,127,127,127,127], typedParams: 1,
|
package/package.json
CHANGED