diff --git a/lexer.js b/lexer.js index 1614fd9..c3c35cf 100755 --- a/lexer.js +++ b/lexer.js @@ -111,12 +111,14 @@ function parseSource (cjsSource) { case 105/*i*/: if (source.startsWith('mport', pos + 1) && keywordStart(pos)) throwIfImportStatement(); + skipTokenRun(); lastTokenPos = pos; continue; case 114/*r*/: const startPos = pos; if (tryParseRequire(Import) && keywordStart(startPos)) tryBacktrackAddStarExportBinding(startPos - 1); + skipTokenRun(); lastTokenPos = pos; continue; case 95/*_*/: @@ -143,6 +145,7 @@ function parseSource (cjsSource) { } } } + skipTokenRun(); lastTokenPos = pos; continue; } @@ -156,18 +159,22 @@ function parseSource (cjsSource) { else if (openTokenDepth === 0) throwIfExportStatement(); } + skipTokenRun(); break; case 99/*c*/: if (keywordStart(pos) && source.startsWith('lass', pos + 1) && isBrOrWs(source.charCodeAt(pos + 5))) nextBraceIsClass = true; + skipTokenRun(); break; case 109/*m*/: if (source.startsWith('odule', pos + 1) && keywordStart(pos)) tryParseModuleExportsDotAssign(); + skipTokenRun(); break; case 79/*O*/: if (source.startsWith('bject', pos + 1) && keywordStart(pos)) tryParseObjectDefineOrKeys(openTokenDepth === 0); + skipTokenRun(); break; case 40/*(*/: openTokenPosStack[openTokenDepth++] = lastTokenPos; @@ -239,6 +246,9 @@ function parseSource (cjsSource) { case 96/*`*/: templateString(); break; + default: + if (isTokenRunChar(ch)) + skipTokenRun(); } lastTokenPos = pos; } @@ -1471,6 +1481,20 @@ function isBrOrWsOrPunctuatorNotDot (c) { return c > 8 && c < 14 || c === 32 || c === 160 || isPunctuator(c) && c !== 46/*.*/; } +/** @param {number} ch */ +function isTokenRunChar (ch) { + const lower = ch | 32; + return lower >= 97/*a*/ && lower <= 122/*z*/ || ch >= 48/*0*/ && ch <= 57/*9*/ || + ch === 36/*$*/ || ch === 95/*_*/ || ch === 92/*\\*/ || ch > 127 && ch !== 160; +} + +function skipTokenRun () { + if (!isTokenRunChar(source.charCodeAt(pos))) + return; + while (isTokenRunChar(source.charCodeAt(pos + 1))) + pos++; +} + function keywordStart (pos) { return pos === 0 || isBrOrWsOrPunctuatorNotDot(source.charCodeAt(pos - 1)); } diff --git a/lib/lexer.wasm b/lib/lexer.wasm index 3ff889c..598446b 100755 Binary files a/lib/lexer.wasm and b/lib/lexer.wasm differ diff --git a/lib/lexer.wat b/lib/lexer.wat index 7f1fad4..4e304fb 100644 --- a/lib/lexer.wat +++ b/lib/lexer.wat @@ -4,9 +4,9 @@ (type (;2;) (func (param i32) (result i32))) (type (;3;) (func (result i32))) (type (;4;) (func (param i32 i32 i32 i32 i32 i32) (result i32))) - (type (;5;) (func (param i32))) - (type (;6;) (func (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32))) - (type (;7;) (func (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32))) + (type (;5;) (func (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32))) + (type (;6;) (func (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32))) + (type (;7;) (func (param i32))) (type (;8;) (func (param i32 i32 i32 i32 i32 i32 i32) (result i32))) (type (;9;) (func (param i32 i32 i32) (result i32))) (type (;10;) (func (param i32 i32 i32 i32 i32) (result i32))) @@ -404,29 +404,29 @@ block ;; label = @4 block ;; label = @5 block ;; label = @6 - local.get 4 - local.get 3 - i32.ge_u - br_if 0 (;@6;) - block ;; label = @7 - local.get 0 - i32.load16_u - local.tee 1 - i32.const -9 - i32.add - local.tee 3 - i32.const 23 - i32.gt_u - br_if 0 (;@7;) - i32.const 1 - local.get 3 - i32.shl - i32.const 8388639 - i32.and - br_if 4 (;@3;) - end block ;; label = @7 block ;; label = @8 + local.get 4 + local.get 3 + i32.ge_u + br_if 0 (;@8;) + block ;; label = @9 + local.get 0 + i32.load16_u + local.tee 1 + i32.const -9 + i32.add + local.tee 3 + i32.const 23 + i32.gt_u + br_if 0 (;@9;) + i32.const 1 + local.get 3 + i32.shl + i32.const 8388639 + i32.and + br_if 6 (;@3;) + end block ;; label = @9 block ;; label = @10 block ;; label = @11 @@ -439,117 +439,159 @@ block ;; label = @18 block ;; label = @19 block ;; label = @20 - i32.const 0 - i32.load16_u offset=8198 - local.tee 3 - br_if 0 (;@20;) block ;; label = @21 block ;; label = @22 + i32.const 0 + i32.load16_u offset=8198 + local.tee 3 + br_if 0 (;@22;) block ;; label = @23 - local.get 1 - i32.const -95 + block ;; label = @24 + block ;; label = @25 + local.get 1 + i32.const -95 + i32.add + br_table 2 (;@23;) 15 (;@10;) 20 (;@5;) 20 (;@5;) 6 (;@19;) 20 (;@5;) 5 (;@20;) 20 (;@5;) 20 (;@5;) 20 (;@5;) 1 (;@24;) 20 (;@5;) 20 (;@5;) 20 (;@5;) 4 (;@21;) 0 (;@25;) + end + block ;; label = @25 + local.get 1 + i32.const -39 + i32.add + br_table 13 (;@12;) 16 (;@9;) 8 (;@17;) 20 (;@5;) 20 (;@5;) 20 (;@5;) 20 (;@5;) 20 (;@5;) 14 (;@11;) 0 (;@25;) + end + block ;; label = @25 + local.get 1 + i32.const -123 + i32.add + br_table 10 (;@15;) 20 (;@5;) 11 (;@14;) 0 (;@25;) + end + local.get 1 + i32.const 34 + i32.eq + br_if 12 (;@12;) + local.get 1 + i32.const 60 + i32.eq + br_if 20 (;@4;) + local.get 1 + i32.const 79 + i32.eq + br_if 6 (;@18;) + local.get 1 + i32.const 114 + i32.ne + br_if 19 (;@5;) + i32.const 0 + call 16 + i32.eqz + br_if 19 (;@5;) + local.get 0 + call 17 + i32.eqz + br_if 19 (;@5;) + br 18 (;@6;) + end + local.get 4 + i32.const 4 i32.add - br_table 2 (;@21;) 16 (;@7;) 19 (;@4;) 19 (;@4;) 6 (;@17;) 19 (;@4;) 5 (;@18;) 19 (;@4;) 19 (;@4;) 19 (;@4;) 1 (;@22;) 19 (;@4;) 19 (;@4;) 19 (;@4;) 4 (;@19;) 0 (;@23;) + i32.const 109 + i32.const 112 + i32.const 111 + i32.const 114 + i32.const 116 + call 18 + i32.eqz + br_if 18 (;@5;) + local.get 0 + call 17 + i32.eqz + br_if 18 (;@5;) + call 19 + br 18 (;@5;) end block ;; label = @23 - local.get 1 - i32.const -39 + local.get 4 + i32.const 4 i32.add - br_table 14 (;@9;) 8 (;@15;) 9 (;@14;) 19 (;@4;) 19 (;@4;) 19 (;@4;) 19 (;@4;) 19 (;@4;) 15 (;@8;) 0 (;@23;) - end - block ;; label = @23 - local.get 1 - i32.const -123 + local.tee 3 + i32.const 105 + i32.const 110 + i32.const 116 + i32.const 101 + i32.const 114 + i32.const 111 + i32.const 112 + i32.const 82 + i32.const 101 + i32.const 113 + i32.const 117 + i32.const 105 + i32.const 114 + i32.const 101 + i32.const 87 + i32.const 105 + i32.const 108 + i32.const 100 + i32.const 99 + i32.const 97 + i32.const 114 + i32.const 100 + call 20 + i32.eqz + br_if 0 (;@23;) + block ;; label = @24 + local.get 0 + call 17 + br_if 0 (;@24;) + local.get 4 + i32.load16_u + i32.const 46 + i32.ne + br_if 1 (;@23;) + end + i32.const 0 + local.get 4 + i32.const 48 i32.add - br_table 11 (;@12;) 19 (;@4;) 12 (;@11;) 0 (;@23;) - end - local.get 1 - i32.const 34 - i32.eq - br_if 13 (;@9;) - local.get 1 - i32.const 79 - i32.eq - br_if 6 (;@16;) - local.get 1 - i32.const 114 - i32.ne - br_if 18 (;@4;) - block ;; label = @23 + i32.store offset=20540 + local.get 4 + i32.load16_u offset=48 + i32.const 40 + i32.ne + br_if 18 (;@5;) + i32.const 0 + local.get 4 + i32.const 50 + i32.add + i32.store offset=20540 + i32.const 0 + i32.const 1 + i32.store16 offset=8198 + i32.const 0 + i32.load offset=20528 + i32.const 0 + i32.load offset=8204 + i32.store i32.const 0 call 16 i32.eqz - br_if 0 (;@23;) + br_if 18 (;@5;) local.get 0 call 17 - i32.eqz - br_if 0 (;@23;) - local.get 4 - call 18 + br_if 17 (;@6;) + br 18 (;@5;) end - i32.const 0 - i32.const 0 - i32.load offset=20540 - i32.store offset=8204 - br 19 (;@3;) - end - block ;; label = @22 - local.get 4 - i32.const 4 - i32.add - i32.const 109 + local.get 3 + i32.const 95 + i32.const 101 + i32.const 120 i32.const 112 i32.const 111 i32.const 114 i32.const 116 - call 19 - i32.eqz - br_if 0 (;@22;) - local.get 0 - call 17 - i32.eqz - br_if 0 (;@22;) - call 20 - i32.const 0 - i32.load offset=20540 - local.set 0 - end - i32.const 0 - local.get 0 - i32.store offset=8204 - br 18 (;@3;) - end - block ;; label = @21 - block ;; label = @22 - local.get 4 - i32.const 4 - i32.add - local.tee 3 - i32.const 105 - i32.const 110 - i32.const 116 - i32.const 101 - i32.const 114 - i32.const 111 - i32.const 112 - i32.const 82 - i32.const 101 - i32.const 113 - i32.const 117 - i32.const 105 - i32.const 114 - i32.const 101 - i32.const 87 - i32.const 105 - i32.const 108 - i32.const 100 - i32.const 99 - i32.const 97 - i32.const 114 - i32.const 100 call 21 i32.eqz - br_if 0 (;@22;) + br_if 17 (;@5;) block ;; label = @23 local.get 0 call 17 @@ -558,269 +600,231 @@ i32.load16_u i32.const 46 i32.ne - br_if 1 (;@22;) + br_if 18 (;@5;) end i32.const 0 local.get 4 - i32.const 48 + i32.const 18 i32.add i32.store offset=20540 - local.get 4 - i32.load16_u offset=48 + block ;; label = @23 + local.get 4 + i32.load16_u offset=18 + local.tee 3 + i32.const 83 + i32.ne + br_if 0 (;@23;) + local.get 4 + i32.load16_u offset=20 + i32.const 116 + i32.ne + br_if 18 (;@5;) + local.get 4 + i32.load16_u offset=22 + i32.const 97 + i32.ne + br_if 18 (;@5;) + local.get 4 + i32.load16_u offset=24 + i32.const 114 + i32.ne + br_if 18 (;@5;) + i32.const 0 + local.get 4 + i32.const 26 + i32.add + i32.store offset=20540 + local.get 4 + i32.load16_u offset=26 + local.set 3 + end + local.get 3 + i32.const 65535 + i32.and i32.const 40 i32.ne - br_if 1 (;@21;) - i32.const 0 - local.get 4 - i32.const 50 - i32.add - i32.store offset=20540 - i32.const 0 - i32.const 1 - i32.store16 offset=8198 + br_if 17 (;@5;) i32.const 0 i32.load offset=20528 i32.const 0 i32.load offset=8204 i32.store i32.const 0 - call 16 - i32.eqz - br_if 1 (;@21;) - local.get 0 - call 17 - i32.eqz - br_if 1 (;@21;) - local.get 4 - call 18 - br 1 (;@21;) - end - local.get 3 - i32.const 95 - i32.const 101 - i32.const 120 - i32.const 112 - i32.const 111 - i32.const 114 - i32.const 116 - call 22 - i32.eqz - br_if 0 (;@21;) - block ;; label = @22 - local.get 0 - call 17 - br_if 0 (;@22;) - local.get 4 - i32.load16_u - i32.const 46 - i32.ne - br_if 1 (;@21;) - end - i32.const 0 - local.get 4 - i32.const 18 - i32.add - i32.store offset=20540 - block ;; label = @22 - local.get 4 - i32.load16_u offset=18 - local.tee 3 - i32.const 83 - i32.ne - br_if 0 (;@22;) - local.get 4 - i32.load16_u offset=20 - i32.const 116 - i32.ne - br_if 1 (;@21;) - local.get 4 - i32.load16_u offset=22 - i32.const 97 - i32.ne - br_if 1 (;@21;) - local.get 4 - i32.load16_u offset=24 + i32.const 1 + i32.store16 offset=8198 + i32.const 0 + i32.load offset=20540 + local.tee 4 + i32.load16_u offset=2 i32.const 114 i32.ne - br_if 1 (;@21;) + br_if 17 (;@5;) i32.const 0 local.get 4 - i32.const 26 + i32.const 2 i32.add i32.store offset=20540 - local.get 4 - i32.load16_u offset=26 - local.set 3 + i32.const 2 + call 16 + drop + br 17 (;@5;) end - local.get 3 - i32.const 65535 - i32.and - i32.const 40 - i32.ne - br_if 0 (;@21;) - i32.const 0 - i32.load offset=20528 - i32.const 0 - i32.load offset=8204 - i32.store - i32.const 0 - i32.const 1 - i32.store16 offset=8198 - i32.const 0 - i32.load offset=20540 - local.tee 4 - i32.load16_u offset=2 - i32.const 114 + block ;; label = @22 + local.get 1 + i32.const -39 + i32.add + br_table 10 (;@12;) 13 (;@9;) 6 (;@16;) 17 (;@5;) 17 (;@5;) 17 (;@5;) 17 (;@5;) 17 (;@5;) 11 (;@11;) 0 (;@22;) + end + block ;; label = @22 + local.get 1 + i32.const -96 + i32.add + br_table 12 (;@10;) 17 (;@5;) 17 (;@5;) 3 (;@19;) 17 (;@5;) 2 (;@20;) 0 (;@22;) + end + block ;; label = @22 + local.get 1 + i32.const -123 + i32.add + br_table 7 (;@15;) 17 (;@5;) 9 (;@13;) 0 (;@22;) + end + local.get 1 + i32.const 34 + i32.eq + br_if 9 (;@12;) + local.get 1 + i32.const 60 + i32.eq + br_if 17 (;@4;) + local.get 1 + i32.const 79 + i32.eq + br_if 3 (;@18;) + local.get 1 + i32.const 109 i32.ne - br_if 0 (;@21;) - i32.const 0 - local.get 4 - i32.const 2 - i32.add - i32.store offset=20540 - i32.const 2 - call 16 - drop + br_if 16 (;@5;) end - i32.const 0 - i32.const 0 - i32.load offset=20540 - i32.store offset=8204 - br 17 (;@3;) - end - block ;; label = @20 - local.get 1 - i32.const -39 - i32.add - br_table 11 (;@9;) 5 (;@15;) 7 (;@13;) 16 (;@4;) 16 (;@4;) 16 (;@4;) 16 (;@4;) 16 (;@4;) 12 (;@8;) 0 (;@20;) - end - block ;; label = @20 - local.get 1 - i32.const -96 + local.get 4 + i32.const 4 i32.add - br_table 13 (;@7;) 16 (;@4;) 16 (;@4;) 3 (;@17;) 16 (;@4;) 2 (;@18;) 0 (;@20;) + i32.const 111 + i32.const 100 + i32.const 117 + i32.const 108 + i32.const 101 + call 18 + i32.eqz + br_if 15 (;@5;) + local.get 0 + call 17 + i32.eqz + br_if 15 (;@5;) + call 22 + br 15 (;@5;) end + local.get 4 + i32.const 4 + i32.add + i32.const 120 + i32.const 112 + i32.const 111 + i32.const 114 + i32.const 116 + call 18 + i32.eqz + br_if 14 (;@5;) + local.get 0 + call 17 + i32.eqz + br_if 14 (;@5;) block ;; label = @20 - local.get 1 - i32.const -123 - i32.add - br_table 8 (;@12;) 16 (;@4;) 10 (;@10;) 0 (;@20;) + local.get 4 + i32.load16_u offset=14 + i32.const 115 + i32.ne + br_if 0 (;@20;) + i32.const 0 + call 23 + br 15 (;@5;) end - local.get 1 - i32.const 34 - i32.eq - br_if 10 (;@9;) - local.get 1 - i32.const 79 - i32.eq - br_if 3 (;@16;) - local.get 1 - i32.const 109 - i32.ne - br_if 15 (;@4;) + local.get 3 + br_if 14 (;@5;) + call 24 + br 14 (;@5;) end - local.get 4 - i32.const 4 - i32.add - i32.const 111 - i32.const 100 - i32.const 117 - i32.const 108 - i32.const 101 - call 19 - i32.eqz - br_if 14 (;@4;) local.get 0 call 17 i32.eqz - br_if 14 (;@4;) - call 23 - br 14 (;@4;) + br_if 13 (;@5;) + local.get 4 + i32.load16_u offset=4 + i32.const 108 + i32.ne + br_if 13 (;@5;) + local.get 4 + i32.load16_u offset=6 + i32.const 97 + i32.ne + br_if 13 (;@5;) + local.get 4 + i32.load16_u offset=8 + i32.const 115 + i32.ne + br_if 13 (;@5;) + local.get 4 + i32.load16_u offset=10 + i32.const 115 + i32.ne + br_if 13 (;@5;) + local.get 4 + i32.load16_u offset=12 + call 25 + i32.eqz + br_if 13 (;@5;) + i32.const 0 + i32.const 1 + i32.store8 offset=20536 + br 13 (;@5;) end local.get 4 i32.const 4 i32.add - i32.const 120 - i32.const 112 - i32.const 111 - i32.const 114 + i32.const 98 + i32.const 106 + i32.const 101 + i32.const 99 i32.const 116 - call 19 + call 18 i32.eqz - br_if 13 (;@4;) + br_if 12 (;@5;) local.get 0 call 17 i32.eqz - br_if 13 (;@4;) - block ;; label = @18 - local.get 4 - i32.load16_u offset=14 - i32.const 115 - i32.ne - br_if 0 (;@18;) - i32.const 0 - call 24 - br 14 (;@4;) - end + br_if 12 (;@5;) local.get 3 - br_if 13 (;@4;) - call 25 - br 13 (;@4;) + i32.eqz + call 26 + br 12 (;@5;) end - local.get 0 - call 17 - i32.eqz - br_if 12 (;@4;) - local.get 4 - i32.load16_u offset=4 - i32.const 108 - i32.ne - br_if 12 (;@4;) - local.get 4 - i32.load16_u offset=6 - i32.const 97 - i32.ne - br_if 12 (;@4;) - local.get 4 - i32.load16_u offset=8 - i32.const 115 - i32.ne - br_if 12 (;@4;) - local.get 4 - i32.load16_u offset=10 - i32.const 115 - i32.ne - br_if 12 (;@4;) - local.get 4 - i32.load16_u offset=12 - call 26 - i32.eqz - br_if 12 (;@4;) + i32.const 8 + call 27 i32.const 0 - i32.const 1 - i32.store8 offset=20536 - br 12 (;@4;) + i32.load offset=4080 + return end - local.get 4 - i32.const 4 - i32.add - i32.const 98 - i32.const 106 - i32.const 101 - i32.const 99 - i32.const 116 - call 19 - i32.eqz - br_if 11 (;@4;) - local.get 0 - call 17 - i32.eqz - br_if 11 (;@4;) + i32.const 0 local.get 3 - i32.eqz - call 27 + i32.const -1 + i32.add + i32.store16 offset=8198 br 11 (;@4;) end + local.get 3 + i32.const 20560 + i32.add + i32.const 0 + i32.load8_u offset=20536 + i32.store8 i32.const 0 local.get 3 i32.const 1 @@ -835,272 +839,360 @@ i32.const 0 i32.load offset=8204 i32.store + i32.const 0 + i32.const 0 + i32.store8 offset=20536 br 10 (;@4;) end - i32.const 8 - call 28 + i32.const 2 + call 27 i32.const 0 - i32.load offset=4080 return end i32.const 0 local.get 3 i32.const -1 i32.add + local.tee 0 i32.store16 offset=8198 - br 8 (;@4;) + block ;; label = @13 + local.get 3 + i32.const 0 + i32.load16_u offset=8200 + local.tee 4 + i32.ne + br_if 0 (;@13;) + i32.const 0 + i32.const 0 + i32.load16_u offset=8196 + i32.const -1 + i32.add + local.tee 4 + i32.store16 offset=8196 + i32.const 0 + i32.const 0 + i32.load offset=12320 + local.get 4 + i32.const 65535 + i32.and + i32.const 1 + i32.shl + i32.add + i32.load16_u + i32.store16 offset=8200 + br 6 (;@7;) + end + local.get 4 + i32.const 65535 + i32.eq + br_if 8 (;@4;) + local.get 0 + i32.const 65535 + i32.and + local.get 4 + i32.ge_u + br_if 8 (;@4;) + i32.const 3 + call 27 + i32.const 0 + i32.load offset=4080 + return end - local.get 3 - i32.const 20560 - i32.add - i32.const 0 - i32.load8_u offset=20536 - i32.store8 - i32.const 0 - local.get 3 - i32.const 1 - i32.add - i32.store16 offset=8198 - i32.const 0 - i32.load offset=20528 - local.get 3 - i32.const 2 - i32.shl - i32.add - i32.const 0 - i32.load offset=8204 - i32.store - i32.const 0 - i32.const 0 - i32.store8 offset=20536 + local.get 1 + call 28 br 7 (;@4;) end - i32.const 2 - call 28 - i32.const 0 - return - end - i32.const 0 - local.get 3 - i32.const -1 - i32.add - local.tee 0 - i32.store16 offset=8198 - block ;; label = @10 - local.get 3 - i32.const 0 - i32.load16_u offset=8200 - local.tee 4 - i32.ne - br_if 0 (;@10;) - i32.const 0 - i32.const 0 - i32.load16_u offset=8196 - i32.const -1 - i32.add - local.tee 4 - i32.store16 offset=8196 - i32.const 0 - i32.const 0 - i32.load offset=12320 - local.get 4 - i32.const 65535 - i32.and - i32.const 1 - i32.shl - i32.add - i32.load16_u - i32.store16 offset=8200 - br 5 (;@5;) - end - local.get 4 - i32.const 65535 - i32.eq - br_if 5 (;@4;) - local.get 0 - i32.const 65535 - i32.and - local.get 4 - i32.ge_u - br_if 5 (;@4;) - i32.const 3 - call 28 - i32.const 0 - i32.load offset=4080 - return - end - local.get 1 - call 29 - br 4 (;@4;) - end - block ;; label = @8 - block ;; label = @9 - local.get 4 - i32.load16_u offset=4 - local.tee 4 - i32.const 42 - i32.eq - br_if 0 (;@9;) - local.get 4 - i32.const 47 - i32.ne - br_if 1 (;@8;) - call 30 - br 6 (;@3;) - end - call 31 - br 5 (;@3;) - end - block ;; label = @8 - block ;; label = @9 - block ;; label = @10 block ;; label = @11 - i32.const 0 - i32.load offset=8204 - local.tee 0 - i32.load16_u - local.tee 4 - call 32 - i32.eqz - br_if 0 (;@11;) + block ;; label = @12 + local.get 4 + i32.load16_u offset=4 + local.tee 4 + i32.const 42 + i32.eq + br_if 0 (;@12;) + local.get 4 + i32.const 47 + i32.ne + br_if 1 (;@11;) + call 29 + br 9 (;@3;) + end + call 30 + br 8 (;@3;) + end + block ;; label = @11 block ;; label = @12 block ;; label = @13 block ;; label = @14 - local.get 4 - i32.const -43 + i32.const 0 + i32.load offset=8204 + local.tee 0 + i32.load16_u + local.tee 4 + call 31 + i32.eqz + br_if 0 (;@14;) + block ;; label = @15 + block ;; label = @16 + block ;; label = @17 + local.get 4 + i32.const -43 + i32.add + br_table 1 (;@16;) 5 (;@12;) 2 (;@15;) 0 (;@17;) 5 (;@12;) + end + local.get 0 + i32.const -2 + i32.add + i32.load16_u + i32.const -48 + i32.add + i32.const 65535 + i32.and + i32.const 10 + i32.lt_u + br_if 3 (;@13;) + br 4 (;@12;) + end + local.get 0 + i32.const -2 + i32.add + i32.load16_u + i32.const 43 + i32.eq + br_if 2 (;@13;) + br 3 (;@12;) + end + local.get 0 + i32.const -2 i32.add - br_table 1 (;@13;) 5 (;@9;) 2 (;@12;) 0 (;@14;) 5 (;@9;) + i32.load16_u + i32.const 45 + i32.eq + br_if 1 (;@13;) + br 2 (;@12;) end - local.get 0 - i32.const -2 - i32.add - i32.load16_u - i32.const -48 - i32.add - i32.const 65535 - i32.and - i32.const 10 - i32.lt_u - br_if 3 (;@10;) - br 4 (;@9;) + block ;; label = @14 + block ;; label = @15 + local.get 4 + i32.const 125 + i32.eq + br_if 0 (;@15;) + local.get 4 + i32.const 47 + i32.eq + br_if 1 (;@14;) + local.get 4 + i32.const 41 + i32.ne + br_if 2 (;@13;) + i32.const 0 + i32.load offset=20528 + local.get 3 + i32.const 2 + i32.shl + i32.add + i32.load + call 32 + i32.eqz + br_if 2 (;@13;) + br 3 (;@12;) + end + i32.const 0 + i32.load offset=20528 + local.get 3 + i32.const 2 + i32.shl + i32.add + i32.load + call 33 + br_if 2 (;@12;) + local.get 3 + i32.const 20560 + i32.add + i32.load8_u + i32.eqz + br_if 1 (;@13;) + br 2 (;@12;) + end + i32.const 0 + i32.load8_u offset=8208 + br_if 1 (;@12;) end local.get 0 - i32.const -2 - i32.add - i32.load16_u - i32.const 43 - i32.eq - br_if 2 (;@10;) - br 3 (;@9;) - end - local.get 0 - i32.const -2 - i32.add - i32.load16_u - i32.const 45 - i32.eq - br_if 1 (;@10;) - br 2 (;@9;) - end - block ;; label = @11 - block ;; label = @12 + call 34 + local.set 3 local.get 4 - i32.const 125 - i32.eq + i32.eqz br_if 0 (;@12;) - local.get 4 - i32.const 47 - i32.eq - br_if 1 (;@11;) - local.get 4 - i32.const 41 - i32.ne - br_if 2 (;@10;) - i32.const 0 - i32.load offset=20528 + i32.const 1 + local.set 4 local.get 3 - i32.const 2 - i32.shl - i32.add - i32.load - call 33 i32.eqz - br_if 2 (;@10;) - br 3 (;@9;) + br_if 1 (;@11;) end + call 35 i32.const 0 - i32.load offset=20528 - local.get 3 - i32.const 2 - i32.shl - i32.add - i32.load - call 34 - br_if 2 (;@9;) - local.get 3 - i32.const 20560 - i32.add - i32.load8_u - i32.eqz - br_if 1 (;@10;) - br 2 (;@9;) + local.set 4 end i32.const 0 - i32.load8_u offset=8208 - br_if 1 (;@9;) + local.get 4 + i32.store8 offset=8208 + br 6 (;@4;) end - local.get 0 - call 35 - local.set 3 - local.get 4 - i32.eqz - br_if 0 (;@9;) - i32.const 1 - local.set 4 - local.get 3 - i32.eqz - br_if 1 (;@8;) + i32.const 0 + i32.load16_u offset=8200 + i32.const 65534 + i32.ne + br_if 2 (;@7;) + i32.const 4 + call 27 + i32.const 0 + i32.load offset=4080 + return end - call 36 i32.const 0 - local.set 4 + local.get 3 + i32.const 1 + i32.add + i32.store16 offset=8198 + i32.const 0 + i32.load offset=20528 + local.get 3 + i32.const 2 + i32.shl + i32.add + i32.const 0 + i32.load offset=8204 + i32.store + br 4 (;@4;) end i32.const 0 + i32.load offset=4080 + local.tee 4 + local.get 4 + local.get 4 + i32.const 0 local.get 4 - i32.store8 offset=8208 - br 3 (;@4;) + select + i32.const 0 + i32.load16_u offset=8198 + select + i32.const 0 + i32.load16_u offset=8200 + i32.const 65535 + i32.ne + select + local.set 4 + br 6 (;@1;) end - i32.const 0 - i32.load16_u offset=8200 - i32.const 65534 - i32.ne - br_if 1 (;@5;) - i32.const 4 - call 28 - i32.const 0 - i32.load offset=4080 - return + call 36 + br 2 (;@4;) end + local.get 4 + call 37 + end + block ;; label = @5 i32.const 0 - i32.load offset=4080 + i32.load offset=20540 + local.tee 3 + i32.load16_u local.tee 4 + i32.const -48 + i32.add + i32.const 65535 + i32.and + i32.const 10 + i32.lt_u + br_if 0 (;@5;) local.get 4 + i32.const 32 + i32.or + i32.const -97 + i32.add + i32.const 65535 + i32.and + i32.const 26 + i32.lt_u + br_if 0 (;@5;) + block ;; label = @6 + block ;; label = @7 + local.get 4 + i32.const -92 + i32.add + br_table 2 (;@5;) 1 (;@6;) 1 (;@6;) 2 (;@5;) 0 (;@7;) + end + local.get 4 + i32.const 36 + i32.eq + br_if 1 (;@5;) + end local.get 4 - i32.const 0 + i32.const 128 + i32.lt_u + br_if 1 (;@4;) local.get 4 - select - i32.const 0 - i32.load16_u offset=8198 - select + i32.const 160 + i32.eq + br_if 1 (;@4;) + end + local.get 3 + i32.const 2 + i32.add + local.set 4 + loop ;; label = @5 + local.get 4 + i32.load16_u + local.tee 3 + i32.const 32 + i32.or + i32.const -97 + i32.add + local.set 0 + block ;; label = @6 + local.get 3 + i32.const -48 + i32.add + i32.const 65535 + i32.and + i32.const 10 + i32.lt_u + br_if 0 (;@6;) + local.get 0 + i32.const 65535 + i32.and + i32.const 26 + i32.lt_u + br_if 0 (;@6;) + block ;; label = @7 + block ;; label = @8 + local.get 3 + i32.const -92 + i32.add + br_table 2 (;@6;) 1 (;@7;) 1 (;@7;) 2 (;@6;) 0 (;@8;) + end + local.get 3 + i32.const 36 + i32.eq + br_if 1 (;@6;) + end + local.get 3 + i32.const 128 + i32.lt_u + br_if 2 (;@4;) + local.get 3 + i32.const 160 + i32.eq + br_if 2 (;@4;) + end i32.const 0 - i32.load16_u offset=8200 - i32.const 65535 - i32.ne - select + local.get 4 + i32.store offset=20540 + local.get 4 + i32.const 2 + i32.add local.set 4 - br 4 (;@1;) + br 0 (;@5;) end - call 37 end i32.const 0 i32.const 0 @@ -1170,7 +1262,7 @@ br_if 1 (;@2;) end local.get 3 - call 29 + call 28 i32.const 0 i32.const 0 i32.load offset=20540 @@ -1196,227 +1288,48 @@ i32.load offset=4000 call_indirect (type 0) i32.const 1 - return - end - local.get 4 - local.get 3 - i32.const 0 - i32.load offset=4000 - call_indirect (type 0) - i32.const 1 - return - end - i32.const 0 - i32.load offset=20532 - local.get 4 - i32.store - i32.const 0 - i32.load offset=20532 - local.get 3 - i32.store offset=4 - i32.const 1 - return - end - i32.const 0 - local.get 2 - i32.store offset=20540 - end - local.get 1) - (func (;17;) (type 2) (param i32) (result i32) - block ;; label = @1 - i32.const 0 - i32.load offset=3992 - local.get 0 - i32.ne - br_if 0 (;@1;) - i32.const 1 - return - end - local.get 0 - i32.const -2 - i32.add - i32.load16_u - call 38) - (func (;18;) (type 5) (param i32) - (local i32 i32 i32 i32 i32) - i32.const 0 - i32.load offset=3992 - local.set 1 - block ;; label = @1 - loop ;; label = @2 - local.get 0 - i32.const -2 - i32.add - local.set 2 - local.get 0 - i32.load16_u - local.tee 3 - i32.const 32 - i32.ne - br_if 1 (;@1;) - local.get 0 - local.get 1 - i32.gt_u - local.set 4 - local.get 2 - local.set 0 - local.get 4 - br_if 0 (;@2;) - end - end - block ;; label = @1 - local.get 3 - i32.const 61 - i32.ne - br_if 0 (;@1;) - block ;; label = @2 - loop ;; label = @3 - local.get 2 - i32.const -2 - i32.add - local.set 0 - local.get 2 - i32.load16_u - i32.const 32 - i32.ne - br_if 1 (;@2;) - local.get 2 - local.get 1 - i32.gt_u - local.set 4 - local.get 0 - local.set 2 - local.get 4 - br_if 0 (;@3;) - end - end - local.get 0 - i32.const 2 - i32.add - local.set 2 - local.get 0 - i32.const 4 - i32.add - local.set 3 - i32.const 0 - local.set 4 - block ;; label = @2 - loop ;; label = @3 - local.get 2 - call 41 - local.tee 0 - i32.eqz - br_if 1 (;@2;) - local.get 2 - local.get 1 - i32.le_u - br_if 1 (;@2;) - local.get 0 - i32.const 92 - i32.eq - br_if 2 (;@1;) - local.get 0 - call 42 - i32.eqz - br_if 1 (;@2;) - local.get 2 - i32.const -2 - i32.const -4 - local.get 0 - i32.const 65536 - i32.lt_u - select - i32.add - local.set 2 - local.get 0 - call 43 - local.set 4 - br 0 (;@3;) - end - end - local.get 4 - i32.const 1 - i32.and - i32.eqz - br_if 0 (;@1;) - local.get 2 - i32.load16_u - i32.const 32 - i32.ne - br_if 0 (;@1;) - i32.const 0 - i32.load offset=20532 - local.tee 5 - i32.const 0 - i32.load offset=4016 - i32.eq - br_if 0 (;@1;) - local.get 5 - local.get 3 - i32.store offset=12 - local.get 5 - local.get 2 - i32.const 2 - i32.add - i32.store offset=8 - block ;; label = @2 - loop ;; label = @3 - local.get 2 - i32.const -2 - i32.add - local.set 0 - local.get 2 - i32.load16_u - local.tee 3 - i32.const 32 - i32.ne - br_if 1 (;@2;) - local.get 2 - local.get 1 - i32.gt_u - local.set 4 - local.get 0 - local.set 2 - local.get 4 - br_if 0 (;@3;) - end - end - block ;; label = @2 - block ;; label = @3 - block ;; label = @4 - local.get 3 - i32.const -114 - i32.add - br_table 0 (;@4;) 3 (;@1;) 1 (;@3;) 3 (;@1;) + return end - local.get 0 - i32.const 118 - i32.const 97 - call 44 - br_if 1 (;@2;) - br 2 (;@1;) + local.get 4 + local.get 3 + i32.const 0 + i32.load offset=4000 + call_indirect (type 0) + i32.const 1 + return end - local.get 0 - i32.const 108 - i32.const 101 - call 44 - br_if 0 (;@2;) - local.get 0 - i32.const 99 - i32.const 111 - i32.const 110 - i32.const 115 - call 45 - i32.eqz - br_if 1 (;@1;) + i32.const 0 + i32.load offset=20532 + local.get 4 + i32.store + i32.const 0 + i32.load offset=20532 + local.get 3 + i32.store offset=4 + i32.const 1 + return end i32.const 0 - local.get 5 - i32.const 16 - i32.add - i32.store offset=20532 - end) - (func (;19;) (type 4) (param i32 i32 i32 i32 i32 i32) (result i32) + local.get 2 + i32.store offset=20540 + end + local.get 1) + (func (;17;) (type 2) (param i32) (result i32) + block ;; label = @1 + i32.const 0 + i32.load offset=3992 + local.get 0 + i32.ne + br_if 0 (;@1;) + i32.const 1 + return + end + local.get 0 + i32.const -2 + i32.add + i32.load16_u + call 38) + (func (;18;) (type 4) (param i32 i32 i32 i32 i32 i32) (result i32) (local i32) i32.const 0 local.set 6 @@ -1448,7 +1361,7 @@ local.set 6 end local.get 6) - (func (;20;) (type 1) + (func (;19;) (type 1) (local i32 i32 i32) i32.const 0 i32.const 0 @@ -1516,13 +1429,13 @@ return end i32.const 5 - call 28 + call 27 return end i32.const 6 - call 28 + call 27 end) - (func (;21;) (type 6) (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32) + (func (;20;) (type 5) (param i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32) (result i32) (local i32) i32.const 0 local.set 23 @@ -1639,7 +1552,7 @@ local.set 23 end local.get 23) - (func (;22;) (type 7) (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32) + (func (;21;) (type 6) (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32) (local i32) i32.const 0 local.set 8 @@ -1681,7 +1594,7 @@ local.set 8 end local.get 8) - (func (;23;) (type 1) + (func (;22;) (type 1) (local i32) i32.const 0 i32.const 0 @@ -1719,7 +1632,7 @@ i32.eqz br_if 0 (;@1;) i32.const 1 - call 24 + call 23 return end i32.const 0 @@ -1727,7 +1640,7 @@ i32.const 10 i32.add i32.store offset=20540) - (func (;24;) (type 5) (param i32) + (func (;23;) (type 7) (param i32) (local i32 i32) i32.const 0 i32.const 0 @@ -1802,7 +1715,7 @@ i32.load offset=20540 local.set 0 local.get 2 - call 29 + call 28 i32.const 0 i32.const 0 i32.load offset=20540 @@ -1865,7 +1778,7 @@ i32.const 12 i32.add i32.store offset=20540) - (func (;25;) (type 1) + (func (;24;) (type 1) (local i32 i32) i32.const 0 i32.const 0 @@ -1889,9 +1802,9 @@ br_if 1 (;@1;) end i32.const 7 - call 28 + call 27 end) - (func (;26;) (type 2) (param i32) (result i32) + (func (;25;) (type 2) (param i32) (result i32) (local i32) block ;; label = @1 block ;; label = @2 @@ -1917,7 +1830,7 @@ return end i32.const 1) - (func (;27;) (type 5) (param i32) + (func (;26;) (type 7) (param i32) (local i32 i32 i32 i32 i32 i32 i32 i32) i32.const 0 i32.const 0 @@ -2017,7 +1930,7 @@ i32.load offset=20540 local.set 2 local.get 0 - call 29 + call 28 i32.const 0 i32.const 0 i32.load offset=20540 @@ -2217,7 +2130,7 @@ i32.const 105 i32.const 111 i32.const 110 - call 22 + call 21 i32.eqz br_if 2 (;@2;) i32.const 0 @@ -2289,7 +2202,7 @@ i32.const 117 i32.const 114 i32.const 110 - call 19 + call 18 i32.eqz br_if 1 (;@2;) i32.const 0 @@ -2342,7 +2255,7 @@ br_if 4 (;@2;) end local.get 3 - call 29 + call 28 i32.const 0 i32.const 0 i32.load offset=20540 @@ -2555,7 +2468,7 @@ i32.const 105 i32.const 111 i32.const 110 - call 22 + call 21 i32.eqz br_if 1 (;@1;) i32.const 0 @@ -2713,7 +2626,7 @@ i32.const 117 i32.const 108 i32.const 116 - call 22 + call 21 i32.eqz br_if 5 (;@1;) i32.const 0 @@ -2852,7 +2765,7 @@ i32.const 117 i32.const 114 i32.const 110 - call 19 + call 18 i32.eqz br_if 5 (;@1;) i32.const 0 @@ -2932,7 +2845,7 @@ i32.const 117 i32.const 114 i32.const 110 - call 19 + call 18 i32.eqz br_if 6 (;@1;) i32.const 0 @@ -3174,7 +3087,7 @@ i32.const 117 i32.const 114 i32.const 110 - call 19 + call 18 i32.eqz br_if 5 (;@1;) i32.const 0 @@ -3228,7 +3141,7 @@ i32.const 117 i32.const 108 i32.const 116 - call 22 + call 21 i32.eqz br_if 4 (;@1;) i32.const 0 @@ -3526,7 +3439,7 @@ i32.const 101 i32.const 99 i32.const 116 - call 19 + call 18 i32.eqz br_if 3 (;@1;) i32.const 0 @@ -3760,7 +3673,7 @@ i32.const 105 i32.const 111 i32.const 110 - call 22 + call 21 i32.eqz br_if 4 (;@1;) i32.const 0 @@ -3832,7 +3745,7 @@ i32.const 117 i32.const 114 i32.const 110 - call 19 + call 18 i32.eqz br_if 3 (;@1;) i32.const 0 @@ -4044,7 +3957,7 @@ i32.const 0 local.get 1 i32.store offset=20540) - (func (;28;) (type 5) (param i32) + (func (;27;) (type 7) (param i32) block ;; label = @1 i32.const 0 i32.load offset=4080 @@ -4070,7 +3983,7 @@ i32.const 1 i32.shr_s i32.store offset=4076) - (func (;29;) (type 5) (param i32) + (func (;28;) (type 7) (param i32) (local i32 i32 i32 i32) i32.const 0 i32.load offset=20540 @@ -4132,13 +4045,13 @@ local.get 1 i32.store offset=20540 i32.const 9 - call 28 + call 27 return end i32.const 0 local.get 1 i32.store offset=20540) - (func (;30;) (type 1) + (func (;29;) (type 1) (local i32 i32 i32) i32.const 0 i32.load offset=20540 @@ -4171,7 +4084,7 @@ i32.const 0 local.get 2 i32.store offset=20540) - (func (;31;) (type 1) + (func (;30;) (type 1) (local i32 i32) i32.const 0 i32.load offset=20540 @@ -4221,7 +4134,7 @@ local.set 0 br 0 (;@1;) end) - (func (;32;) (type 2) (param i32) (result i32) + (func (;31;) (type 2) (param i32) (result i32) (local i32) block ;; label = @1 block ;; label = @2 @@ -4288,7 +4201,7 @@ i32.const 4 i32.lt_u i32.and) - (func (;33;) (type 2) (param i32) (result i32) + (func (;32;) (type 2) (param i32) (result i32) (local i32) i32.const 1 local.set 1 @@ -4314,7 +4227,7 @@ local.set 1 end local.get 1) - (func (;34;) (type 2) (param i32) (result i32) + (func (;33;) (type 2) (param i32) (result i32) (local i32 i32) i32.const 1 local.set 1 @@ -4388,7 +4301,7 @@ local.set 1 end local.get 1) - (func (;35;) (type 2) (param i32) (result i32) + (func (;34;) (type 2) (param i32) (result i32) (local i32 i32) i32.const 0 local.set 1 @@ -4606,7 +4519,7 @@ local.set 1 end local.get 1) - (func (;36;) (type 1) + (func (;35;) (type 1) (local i32 i32 i32 i32) loop ;; label = @1 i32.const 0 @@ -4660,7 +4573,7 @@ local.get 2 i32.store offset=20540 i32.const 11 - call 28 + call 27 return end local.get 2 @@ -4674,7 +4587,7 @@ i32.const 0 local.get 2 i32.store offset=20540) - (func (;37;) (type 1) + (func (;36;) (type 1) (local i32 i32 i32 i32) i32.const 0 i32.load offset=20540 @@ -4756,12 +4669,191 @@ local.get 0 i32.store offset=20540 i32.const 8 - call 28 + call 27 return end i32.const 0 local.get 0 i32.store offset=20540) + (func (;37;) (type 7) (param i32) + (local i32 i32 i32 i32 i32) + i32.const 0 + i32.load offset=3992 + local.set 1 + block ;; label = @1 + loop ;; label = @2 + local.get 0 + i32.const -2 + i32.add + local.set 2 + local.get 0 + i32.load16_u + local.tee 3 + i32.const 32 + i32.ne + br_if 1 (;@1;) + local.get 0 + local.get 1 + i32.gt_u + local.set 4 + local.get 2 + local.set 0 + local.get 4 + br_if 0 (;@2;) + end + end + block ;; label = @1 + local.get 3 + i32.const 61 + i32.ne + br_if 0 (;@1;) + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const -2 + i32.add + local.set 0 + local.get 2 + i32.load16_u + i32.const 32 + i32.ne + br_if 1 (;@2;) + local.get 2 + local.get 1 + i32.gt_u + local.set 4 + local.get 0 + local.set 2 + local.get 4 + br_if 0 (;@3;) + end + end + local.get 0 + i32.const 2 + i32.add + local.set 2 + local.get 0 + i32.const 4 + i32.add + local.set 3 + i32.const 0 + local.set 4 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + call 41 + local.tee 0 + i32.eqz + br_if 1 (;@2;) + local.get 2 + local.get 1 + i32.le_u + br_if 1 (;@2;) + local.get 0 + i32.const 92 + i32.eq + br_if 2 (;@1;) + local.get 0 + call 42 + i32.eqz + br_if 1 (;@2;) + local.get 2 + i32.const -2 + i32.const -4 + local.get 0 + i32.const 65536 + i32.lt_u + select + i32.add + local.set 2 + local.get 0 + call 43 + local.set 4 + br 0 (;@3;) + end + end + local.get 4 + i32.const 1 + i32.and + i32.eqz + br_if 0 (;@1;) + local.get 2 + i32.load16_u + i32.const 32 + i32.ne + br_if 0 (;@1;) + i32.const 0 + i32.load offset=20532 + local.tee 5 + i32.const 0 + i32.load offset=4016 + i32.eq + br_if 0 (;@1;) + local.get 5 + local.get 3 + i32.store offset=12 + local.get 5 + local.get 2 + i32.const 2 + i32.add + i32.store offset=8 + block ;; label = @2 + loop ;; label = @3 + local.get 2 + i32.const -2 + i32.add + local.set 0 + local.get 2 + i32.load16_u + local.tee 3 + i32.const 32 + i32.ne + br_if 1 (;@2;) + local.get 2 + local.get 1 + i32.gt_u + local.set 4 + local.get 0 + local.set 2 + local.get 4 + br_if 0 (;@3;) + end + end + block ;; label = @2 + block ;; label = @3 + block ;; label = @4 + local.get 3 + i32.const -114 + i32.add + br_table 0 (;@4;) 3 (;@1;) 1 (;@3;) 3 (;@1;) + end + local.get 0 + i32.const 118 + i32.const 97 + call 44 + br_if 1 (;@2;) + br 2 (;@1;) + end + local.get 0 + i32.const 108 + i32.const 101 + call 44 + br_if 0 (;@2;) + local.get 0 + i32.const 99 + i32.const 111 + i32.const 110 + i32.const 115 + call 45 + i32.eqz + br_if 1 (;@1;) + end + i32.const 0 + local.get 5 + i32.const 16 + i32.add + i32.store offset=20532 + end) (func (;38;) (type 2) (param i32) (result i32) (local i32) block ;; label = @1 @@ -4856,14 +4948,14 @@ i32.const 47 i32.ne br_if 4 (;@1;) - call 30 + call 29 br 2 (;@3;) end - call 31 + call 30 br 1 (;@3;) end local.get 1 - call 26 + call 25 i32.eqz br_if 2 (;@1;) end @@ -5277,7 +5369,7 @@ i32.load offset=20540 local.set 2 local.get 1 - call 29 + call 28 i32.const 0 i32.const 0 i32.load offset=20540 @@ -5476,7 +5568,7 @@ i32.const 117 i32.const 108 i32.const 101 - call 19 + call 18 i32.eqz br_if 1 (;@1;) i32.const 0 @@ -5660,7 +5752,7 @@ i32.const 101 i32.const 99 i32.const 116 - call 19 + call 18 i32.eqz br_if 0 (;@1;) i32.const 0 @@ -5883,7 +5975,7 @@ local.get 3 local.get 4 local.get 5 - call 19 + call 18 i32.eqz br_if 0 (;@1;) block ;; label = @2 @@ -6021,7 +6113,7 @@ local.set 2 end local.get 2) - (func (;57;) (type 7) (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32) + (func (;57;) (type 6) (param i32 i32 i32 i32 i32 i32 i32 i32) (result i32) (local i32 i32 i32) i32.const 0 local.set 8 @@ -6043,7 +6135,7 @@ local.get 5 local.get 6 local.get 7 - call 22 + call 21 i32.eqz br_if 0 (;@1;) block ;; label = @2 @@ -9554,7 +9646,7 @@ local.get 2 i32.store offset=20540 i32.const 10 - call 28 + call 27 i32.const 0 return end diff --git a/src/lexer.c b/src/lexer.c index fd7ba8b..2e0a5b0 100755 --- a/src/lexer.c +++ b/src/lexer.c @@ -44,6 +44,11 @@ void (*addReexport)(const uint16_t*, const uint16_t*); void (*addUnsafeGetter)(const uint16_t*, const uint16_t*); void (*clearReexports)(); +static inline __attribute__((always_inline)) bool isTokenRunChar (uint16_t ch) { + return (uint16_t)((ch | 32) - 'a') < 26 || (uint16_t)(ch - '0') < 10 || + ch == '$' || ch == '_' || ch == '\\' || (ch > 127 && ch != 160); +} + // Note: parsing is based on the _assumption_ that the source is already valid uint32_t parseCJS (uint16_t* _source, uint32_t _sourceLen, void (*_addExport)(const uint16_t*, const uint16_t*), void (*_addReexport)(const uint16_t*, const uint16_t*), void (*_addUnsafeGetter)(const uint16_t*, const uint16_t*), void (*_clearReexports)()) { source = _source; @@ -94,14 +99,12 @@ uint32_t parseCJS (uint16_t* _source, uint32_t _sourceLen, void (*_addExport)(co case 'i': if (str_eq5(pos + 1, 'm', 'p', 'o', 'r', 't') && keywordStart(pos)) throwIfImportStatement(); - lastTokenPos = pos; - continue; + goto skipTokenRun; case 'r': { uint16_t* startPos = pos; if (tryParseRequire(Import) && keywordStart(startPos)) tryBacktrackAddStarExportBinding(startPos - 1); - lastTokenPos = pos; - continue; + goto skipTokenRun; } case '_': if (str_eq22(pos + 1, 'i', 'n', 't', 'e', 'r', 'o', 'p', 'R', 'e', 'q', 'u', 'i', 'r', 'e', 'W', 'i', 'l', 'd', 'c', 'a', 'r', 'd') && (keywordStart(pos) || *(pos - 1) == '.')) { @@ -126,8 +129,7 @@ uint32_t parseCJS (uint16_t* _source, uint32_t _sourceLen, void (*_addExport)(co } } } - lastTokenPos = pos; - continue; + goto skipTokenRun; } } @@ -139,19 +141,19 @@ uint32_t parseCJS (uint16_t* _source, uint32_t _sourceLen, void (*_addExport)(co else if (openTokenDepth == 0) throwIfExportStatement(); } - break; + goto skipTokenRun; case 'c': if (keywordStart(pos) && str_eq4(pos + 1, 'l', 'a', 's', 's') && isBrOrWs(*(pos + 5))) nextBraceIsClass = true; - break; + goto skipTokenRun; case 'm': if (str_eq5(pos + 1, 'o', 'd', 'u', 'l', 'e') && keywordStart(pos)) tryParseModuleExportsDotAssign(); - break; + goto skipTokenRun; case 'O': if (str_eq5(pos + 1, 'b', 'j', 'e', 'c', 't') && keywordStart(pos)) tryParseObjectDefineOrKeys(openTokenDepth == 0); - break; + goto skipTokenRun; case '(': openTokenPosStack[openTokenDepth++] = lastTokenPos; break; @@ -224,6 +226,12 @@ uint32_t parseCJS (uint16_t* _source, uint32_t _sourceLen, void (*_addExport)(co return syntaxError(4), error; templateString(); break; + default: + skipTokenRun: + if (!isTokenRunChar(*pos)) + break; + while (isTokenRunChar(*(pos + 1))) + pos++; } lastTokenPos = pos; } diff --git a/test/_unit.js b/test/_unit.js index 0458f17..2dffd7a 100755 --- a/test/_unit.js +++ b/test/_unit.js @@ -478,6 +478,38 @@ suite('Lexer', () => { `); }); + test('Identifier and number runs preserve token boundaries', () => { + const result = parse(` + const importName = 1; + const requireName = importName; + const _helperName = requireName; + const someexports = {}; + const somemodule = {}; + const someObject = {}; + const \\u0065scapedIdentifier = 1234567890.5 / 2; + const café = escapedIdentifier; + const templateResult = \`value \${someexports.value}\`; + class LongClassName { + #privateField = café; + method () { return /exports/.test('exports'); } + } + \u00a0exports.value = templateResult; + `); + assert.deepStrictEqual(result.exports, ['value']); + assert.deepStrictEqual(result.reexports, []); + }); + + test('Token runs stop at parsed construct boundaries', () => { + const result = parse(` + exports.a=exports.b=1; + exports.c=Object.defineProperty(exports,'d',{value:1}); + `); + assert.deepStrictEqual(result.exports, ['a', 'b', 'c', 'd']); + assert.deepStrictEqual(result.reexports, []); + assert.throws(() => parse('exports.a=import.meta'), { code: 'ERR_LEXER_ESM_SYNTAX' }); + assert.throws(() => parse('exports.a=export { value }'), { code: 'ERR_LEXER_ESM_SYNTAX' }); + }); + test('Regexp division', () => { parse(`\nconst x = num / /'/.exec(l)[0].slice(1, -1)//'"`); });