porffor 0.18.33 → 0.18.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/string.ts +66 -0
- package/compiler/generated_builtins.js +12 -0
- package/package.json +1 -1
- package/runner/index.js +1 -1
@@ -1110,6 +1110,72 @@ local.set ${x}`;
|
|
1110
1110
|
return out;
|
1111
1111
|
};
|
1112
1112
|
|
1113
|
+
export const __String_prototype_repeat = (_this: string, count: number) => {
|
1114
|
+
let out: string = Porffor.allocate();
|
1115
|
+
|
1116
|
+
count |= 0;
|
1117
|
+
if (count < 0) throw new RangeError('Invalid count value');
|
1118
|
+
|
1119
|
+
const thisLen: i32 = _this.length * 2;
|
1120
|
+
for (let i: i32 = 0; i < count; i++) {
|
1121
|
+
Porffor.wasm`
|
1122
|
+
;; dst = out + 4 + i * thisLen
|
1123
|
+
local.get ${out}
|
1124
|
+
i32.const 4
|
1125
|
+
i32.add
|
1126
|
+
local.get ${i}
|
1127
|
+
local.get ${thisLen}
|
1128
|
+
i32.mul
|
1129
|
+
i32.add
|
1130
|
+
|
1131
|
+
;; src = this + 4
|
1132
|
+
local.get ${_this}
|
1133
|
+
i32.const 4
|
1134
|
+
i32.add
|
1135
|
+
|
1136
|
+
;; size = thisLen
|
1137
|
+
local.get ${thisLen}
|
1138
|
+
|
1139
|
+
memory.copy 0 0`;
|
1140
|
+
}
|
1141
|
+
|
1142
|
+
Porffor.wasm.i32.store(out, thisLen * count, 0, 0);
|
1143
|
+
return out;
|
1144
|
+
};
|
1145
|
+
|
1146
|
+
export const __ByteString_prototype_repeat = (_this: string, count: number) => {
|
1147
|
+
let out: bytestring = Porffor.allocate();
|
1148
|
+
|
1149
|
+
count |= 0;
|
1150
|
+
if (count < 0) throw new RangeError('Invalid count value');
|
1151
|
+
|
1152
|
+
const thisLen: i32 = _this.length;
|
1153
|
+
for (let i: i32 = 0; i < count; i++) {
|
1154
|
+
Porffor.wasm`
|
1155
|
+
;; dst = out + 4 + i * thisLen
|
1156
|
+
local.get ${out}
|
1157
|
+
i32.const 4
|
1158
|
+
i32.add
|
1159
|
+
local.get ${i}
|
1160
|
+
local.get ${thisLen}
|
1161
|
+
i32.mul
|
1162
|
+
i32.add
|
1163
|
+
|
1164
|
+
;; src = this + 4
|
1165
|
+
local.get ${_this}
|
1166
|
+
i32.const 4
|
1167
|
+
i32.add
|
1168
|
+
|
1169
|
+
;; size = thisLen
|
1170
|
+
local.get ${thisLen}
|
1171
|
+
|
1172
|
+
memory.copy 0 0`;
|
1173
|
+
}
|
1174
|
+
|
1175
|
+
Porffor.wasm.i32.store(out, thisLen * count, 0, 0);
|
1176
|
+
return out;
|
1177
|
+
};
|
1178
|
+
|
1113
1179
|
|
1114
1180
|
// 22.1.3.29 String.prototype.toString ()
|
1115
1181
|
// https://tc39.es/ecma262/#sec-string.prototype.tostring
|
@@ -1676,6 +1676,18 @@ export const BuiltinFuncs = function() {
|
|
1676
1676
|
locals: [127,127,127,127,127,127,127,127,127,127,127], localNames: ["_this","_this#type","vals","vals#type","out","#last_type","concat_right_pointer","concat_right_length","concat_left_length","concat_left_pointer","concat_out_pointer","valsLen","i","x","x#type"],
|
1677
1677
|
hasRestArgument: 1,
|
1678
1678
|
};
|
1679
|
+
this.__String_prototype_repeat = {
|
1680
|
+
wasm: (scope, {builtin,internalThrow}) => [[16, builtin('__Porffor_allocate')],[33,5],[252,2],[33,4],[32,2],[65,0],[114],[34,2],[65,0],[72],[4,64],...internalThrow(scope, 'RangeError', `Invalid count value`),[11],[32,0],[40,1,0],[65,2],[108],[33,6],[65,0],[33,7],[3,64],[32,7],[32,2],[72],[4,64],[32,4],[65,4],[106],[32,7],[32,6],[108],[106],[32,0],[65,4],[106],[32,6],[252,10,0,0],[32,7],[65,1],[106],[33,7],[12,1],[11],[11],[32,4],[32,6],[32,2],[108],[54,0,0],[32,4],[65,194,0],[15]],
|
1681
|
+
params: [127,127,127,127], typedParams: 1,
|
1682
|
+
returns: [127,127], typedReturns: 1,
|
1683
|
+
locals: [127,127,127,127], localNames: ["_this","_this#type","count","count#type","out","#last_type","thisLen","i"],
|
1684
|
+
};
|
1685
|
+
this.__ByteString_prototype_repeat = {
|
1686
|
+
wasm: (scope, {builtin,internalThrow}) => [[16, builtin('__Porffor_allocate')],[33,5],[252,2],[33,4],[32,2],[65,0],[114],[34,2],[65,0],[72],[4,64],...internalThrow(scope, 'RangeError', `Invalid count value`),[11],[32,0],[40,1,0],[33,6],[65,0],[33,7],[3,64],[32,7],[32,2],[72],[4,64],[32,4],[65,4],[106],[32,7],[32,6],[108],[106],[32,0],[65,4],[106],[32,6],[252,10,0,0],[32,7],[65,1],[106],[33,7],[12,1],[11],[11],[32,4],[32,6],[32,2],[108],[54,0,0],[32,4],[65,194,1],[15]],
|
1687
|
+
params: [127,127,127,127], typedParams: 1,
|
1688
|
+
returns: [127,127], typedReturns: 1,
|
1689
|
+
locals: [127,127,127,127], localNames: ["_this","_this#type","count","count#type","out","#last_type","thisLen","i"],
|
1690
|
+
};
|
1679
1691
|
this.__String_prototype_toString = {
|
1680
1692
|
wasm: (scope, {}) => [[32,0],[65,194,0],[15]],
|
1681
1693
|
params: [127,127], typedParams: 1,
|
package/package.json
CHANGED