porffor 0.2.0-664913c → 0.2.0-6922552
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/CONTRIBUTING.md +12 -4
- package/README.md +0 -7
- package/compiler/builtins/annexb_string.js +1 -1
- package/compiler/builtins/annexb_string.ts +4 -4
- package/compiler/builtins/array.ts +9 -9
- package/compiler/builtins/boolean.ts +6 -0
- package/compiler/builtins/date.ts +50 -51
- package/compiler/builtins/escape.ts +1 -1
- package/compiler/builtins/int.ts +2 -2
- package/compiler/builtins/number.ts +8 -1
- package/compiler/builtins/string.ts +36 -21
- package/compiler/builtins/tostring.ts +3 -3
- package/compiler/builtins.js +4 -4
- package/compiler/codegen.js +30 -30
- package/compiler/generated_builtins.js +145 -109
- package/compiler/precompile.js +1 -1
- package/compiler/prefs.js +1 -1
- package/compiler/prototype.js +14 -14
- package/compiler/types.js +1 -1
- package/compiler/wrap.js +3 -3
- package/package.json +1 -1
package/compiler/precompile.js
CHANGED
@@ -70,7 +70,7 @@ const compile = async (file, [ _funcs, _globals ]) => {
|
|
70
70
|
if (y[0] === Opcodes.const && (n[0] === Opcodes.local_set || n[0] === Opcodes.local_tee)) {
|
71
71
|
const l = locals[n[1]];
|
72
72
|
if (!l) continue;
|
73
|
-
if (![TYPES.string, TYPES.
|
73
|
+
if (![TYPES.string, TYPES.array, TYPES.bytestring].includes(l.metadata?.type)) continue;
|
74
74
|
if (!x.pages) continue;
|
75
75
|
|
76
76
|
const pageName = [...x.pages.keys()].find(z => z.endsWith(l.name));
|
package/compiler/prefs.js
CHANGED
package/compiler/prototype.js
CHANGED
@@ -14,7 +14,7 @@ export const PrototypeFuncs = function() {
|
|
14
14
|
if (Prefs.zeroChecks) zeroChecks = Prefs.zeroChecks.split('=')[1].split(',').reduce((acc, x) => { acc[x.toLowerCase()] = true; return acc; }, {});
|
15
15
|
else zeroChecks = {};
|
16
16
|
|
17
|
-
this[TYPES.
|
17
|
+
this[TYPES.array] = {
|
18
18
|
// lX = local accessor of X ({ get, set }), iX = local index of X, wX = wasm ops of X
|
19
19
|
at: (pointer, length, wIndex, iTmp) => [
|
20
20
|
...wIndex,
|
@@ -253,10 +253,10 @@ export const PrototypeFuncs = function() {
|
|
253
253
|
]
|
254
254
|
};
|
255
255
|
|
256
|
-
this[TYPES.
|
257
|
-
this[TYPES.
|
258
|
-
this[TYPES.
|
259
|
-
this[TYPES.
|
256
|
+
this[TYPES.array].at.local = Valtype.i32;
|
257
|
+
this[TYPES.array].push.noArgRetLength = true;
|
258
|
+
this[TYPES.array].fill.local = valtypeBinary;
|
259
|
+
this[TYPES.array].fill.returnType = TYPES.array;
|
260
260
|
|
261
261
|
this[TYPES.string] = {
|
262
262
|
at: (pointer, length, wIndex, iTmp, _, arrayShell) => {
|
@@ -476,7 +476,7 @@ export const PrototypeFuncs = function() {
|
|
476
476
|
this[TYPES.string].isWellFormed.returnType = TYPES.boolean;
|
477
477
|
|
478
478
|
if (Prefs.bytestring) {
|
479
|
-
this[TYPES.
|
479
|
+
this[TYPES.bytestring] = {
|
480
480
|
at: (pointer, length, wIndex, iTmp, _, arrayShell) => {
|
481
481
|
const [ newOut, newPointer ] = arrayShell(1, 'i8');
|
482
482
|
|
@@ -606,14 +606,14 @@ export const PrototypeFuncs = function() {
|
|
606
606
|
}
|
607
607
|
};
|
608
608
|
|
609
|
-
this[TYPES.
|
610
|
-
this[TYPES.
|
611
|
-
this[TYPES.
|
612
|
-
this[TYPES.
|
613
|
-
this[TYPES.
|
609
|
+
this[TYPES.bytestring].at.local = Valtype.i32;
|
610
|
+
this[TYPES.bytestring].at.returnType = TYPES.bytestring;
|
611
|
+
this[TYPES.bytestring].charAt.returnType = TYPES.bytestring;
|
612
|
+
this[TYPES.bytestring].charCodeAt.local = Valtype.i32;
|
613
|
+
this[TYPES.bytestring].charCodeAt.noPointerCache = zeroChecks.charcodeat;
|
614
614
|
|
615
|
-
this[TYPES.
|
616
|
-
this[TYPES.
|
617
|
-
this[TYPES.
|
615
|
+
this[TYPES.bytestring].isWellFormed.local = Valtype.i32;
|
616
|
+
this[TYPES.bytestring].isWellFormed.local2 = Valtype.i32;
|
617
|
+
this[TYPES.bytestring].isWellFormed.returnType = TYPES.boolean;
|
618
618
|
}
|
619
619
|
};
|
package/compiler/types.js
CHANGED
@@ -24,7 +24,7 @@ export const INTERNAL_TYPE_BASE = 0x10;
|
|
24
24
|
let internalTypeIndex = INTERNAL_TYPE_BASE;
|
25
25
|
const registerInternalType = name => {
|
26
26
|
const n = internalTypeIndex++;
|
27
|
-
TYPES[
|
27
|
+
TYPES[name.toLowerCase()] = n;
|
28
28
|
TYPE_NAMES[n] = name;
|
29
29
|
};
|
30
30
|
|
package/compiler/wrap.js
CHANGED
@@ -178,7 +178,7 @@ export default async (source, flags = [ 'module' ], customImports = {}, print =
|
|
178
178
|
return {[func.name]() {}}[func.name];
|
179
179
|
}
|
180
180
|
|
181
|
-
case TYPES.
|
181
|
+
case TYPES.array: {
|
182
182
|
const pointer = ret;
|
183
183
|
const length = (new Int32Array(memory.buffer, pointer, 1))[0];
|
184
184
|
|
@@ -188,14 +188,14 @@ export default async (source, flags = [ 'module' ], customImports = {}, print =
|
|
188
188
|
return Array.from(new Float64Array(buf));
|
189
189
|
}
|
190
190
|
|
191
|
-
case TYPES.
|
191
|
+
case TYPES.bytestring: {
|
192
192
|
const pointer = ret;
|
193
193
|
const length = (new Int32Array(memory.buffer, pointer, 1))[0];
|
194
194
|
|
195
195
|
return Array.from(new Uint8Array(memory.buffer, pointer + 4, length)).map(x => String.fromCharCode(x)).join('');
|
196
196
|
}
|
197
197
|
|
198
|
-
case TYPES.
|
198
|
+
case TYPES.date: {
|
199
199
|
const pointer = ret;
|
200
200
|
const value = (new Float64Array(memory.buffer, pointer, 1))[0];
|
201
201
|
|
package/package.json
CHANGED