porffor 0.17.0-05070e1f0 → 0.17.0-30b9c5fa5
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/package.json +1 -1
- package/rhemyn/compile.js +4 -15
package/package.json
CHANGED
package/rhemyn/compile.js
CHANGED
@@ -6,7 +6,6 @@ import { TYPES } from '../compiler/types.js';
|
|
6
6
|
|
7
7
|
// local indexes
|
8
8
|
const BasePointer = 0; // base string pointer
|
9
|
-
const IterPointer = 1; // this iteration base pointer
|
10
9
|
const Counter = 2; // what char we are running on
|
11
10
|
const Pointer = 3; // next char pointer
|
12
11
|
const Length = 4;
|
@@ -23,17 +22,13 @@ const generate = (node, negated = false, get = true, stringSize = 2, func = 'tes
|
|
23
22
|
[ Opcodes.i32_load, Math.log2(ValtypeSize.i32) - 1, 0 ],
|
24
23
|
[ Opcodes.local_set, Length ],
|
25
24
|
|
26
|
-
//
|
25
|
+
// pointer = base + sizeof i32
|
27
26
|
[ Opcodes.local_get, BasePointer ],
|
28
27
|
...number(ValtypeSize.i32, Valtype.i32),
|
29
28
|
[ Opcodes.i32_add ],
|
30
|
-
[ Opcodes.local_set,
|
29
|
+
[ Opcodes.local_set, Pointer ],
|
31
30
|
|
32
31
|
[ Opcodes.loop, Blocktype.void ],
|
33
|
-
// reset pointer as iter pointer
|
34
|
-
[ Opcodes.local_get, IterPointer ],
|
35
|
-
[ Opcodes.local_set, Pointer ],
|
36
|
-
|
37
32
|
[ Opcodes.block, Blocktype.void ],
|
38
33
|
// generate checks
|
39
34
|
...node.body.flatMap(x => generate(x, negated, true, stringSize, func)),
|
@@ -48,12 +43,6 @@ const generate = (node, negated = false, get = true, stringSize = 2, func = 'tes
|
|
48
43
|
[ Opcodes.return ],
|
49
44
|
[ Opcodes.end ],
|
50
45
|
|
51
|
-
// increment iter pointer by string size
|
52
|
-
[ Opcodes.local_get, IterPointer ],
|
53
|
-
...number(stringSize, Valtype.i32),
|
54
|
-
[ Opcodes.i32_add ],
|
55
|
-
[ Opcodes.local_set, IterPointer ],
|
56
|
-
|
57
46
|
// increment counter by 1, check if eq length, if not loop
|
58
47
|
[ Opcodes.local_get, Counter ],
|
59
48
|
...number(1, Valtype.i32),
|
@@ -268,7 +257,7 @@ const wrapFunc = (regex, func, name, index) => {
|
|
268
257
|
const parsed = parse(regex);
|
269
258
|
|
270
259
|
return outputFunc([
|
271
|
-
[ Opcodes.local_get,
|
260
|
+
[ Opcodes.local_get, 1 ],
|
272
261
|
...number(TYPES.string, Valtype.i32),
|
273
262
|
[ Opcodes.i32_eq ],
|
274
263
|
[ Opcodes.if, Valtype.i32 ],
|
@@ -295,7 +284,7 @@ const outputFunc = (wasm, name, index) => ({
|
|
295
284
|
returnType: TYPES.boolean,
|
296
285
|
locals: {
|
297
286
|
basePointer: { idx: 0, type: Valtype.i32 },
|
298
|
-
|
287
|
+
inputType: { idx: 1, type: Valtype.i32 },
|
299
288
|
counter: { idx: 2, type: Valtype.i32 },
|
300
289
|
pointer: { idx: 3, type: Valtype.i32 },
|
301
290
|
length: { idx: 4, type: Valtype.i32 },
|