diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/prebuilt/wasm-ast-lexer-gen.c | 4328 | ||||
-rw-r--r-- | src/prebuilt/wasm-ast-parser-gen.c | 2120 | ||||
-rw-r--r-- | src/prebuilt/wasm-ast-parser-gen.h | 94 | ||||
-rw-r--r-- | src/wasm-apply-names.c | 43 | ||||
-rw-r--r-- | src/wasm-ast-checker.c | 769 | ||||
-rw-r--r-- | src/wasm-ast-checker.h | 6 | ||||
-rw-r--r-- | src/wasm-ast-lexer.c | 6 | ||||
-rw-r--r-- | src/wasm-ast-parser.y | 503 | ||||
-rw-r--r-- | src/wasm-ast-writer.c | 177 | ||||
-rw-r--r-- | src/wasm-ast.c | 200 | ||||
-rw-r--r-- | src/wasm-ast.h | 111 | ||||
-rw-r--r-- | src/wasm-binary-reader-ast.c | 678 | ||||
-rw-r--r-- | src/wasm-binary-reader.h | 2 | ||||
-rw-r--r-- | src/wasm-binary-writer-spec.c | 194 | ||||
-rw-r--r-- | src/wasm-binary-writer.c | 113 | ||||
-rw-r--r-- | src/wasm-common.h | 6 | ||||
-rw-r--r-- | src/wasm-generate-names.c | 4 | ||||
-rw-r--r-- | src/wast2wasm.c | 4 |
18 files changed, 4869 insertions, 4489 deletions
diff --git a/src/prebuilt/wasm-ast-lexer-gen.c b/src/prebuilt/wasm-ast-lexer-gen.c index bec84972..0b2ea73d 100644 --- a/src/prebuilt/wasm-ast-lexer-gen.c +++ b/src/prebuilt/wasm-ast-lexer-gen.c @@ -312,18 +312,18 @@ YYCOND_BLOCK_COMMENT: } yy19: ++lexer->cursor; -#line 442 "src/wasm-ast-lexer.c" +#line 444 "src/wasm-ast-lexer.c" { ERROR("unexpected EOF"); RETURN(EOF); } #line 318 "src/prebuilt/wasm-ast-lexer-gen.c" yy21: ++lexer->cursor; yy22: -#line 443 "src/wasm-ast-lexer.c" +#line 445 "src/wasm-ast-lexer.c" { continue; } #line 324 "src/prebuilt/wasm-ast-lexer-gen.c" yy23: ++lexer->cursor; -#line 441 "src/wasm-ast-lexer.c" +#line 443 "src/wasm-ast-lexer.c" { NEWLINE; continue; } #line 329 "src/prebuilt/wasm-ast-lexer-gen.c" yy25: @@ -336,12 +336,12 @@ yy26: goto yy22; yy27: ++lexer->cursor; -#line 437 "src/wasm-ast-lexer.c" +#line 439 "src/wasm-ast-lexer.c" { COMMENT_NESTING++; continue; } #line 342 "src/prebuilt/wasm-ast-lexer-gen.c" yy29: ++lexer->cursor; -#line 438 "src/wasm-ast-lexer.c" +#line 440 "src/wasm-ast-lexer.c" { if (--COMMENT_NESTING == 0) BEGIN(YYCOND_INIT); continue; } @@ -390,7 +390,7 @@ YYCOND_LINE_COMMENT: } goto yy36; yy33: -#line 435 "src/wasm-ast-lexer.c" +#line 437 "src/wasm-ast-lexer.c" { continue; } #line 396 "src/prebuilt/wasm-ast-lexer-gen.c" yy34: @@ -404,7 +404,7 @@ yy34: yy36: ++lexer->cursor; BEGIN(YYCOND_i); -#line 434 "src/wasm-ast-lexer.c" +#line 436 "src/wasm-ast-lexer.c" { NEWLINE; continue; } #line 410 "src/prebuilt/wasm-ast-lexer-gen.c" } @@ -416,7 +416,7 @@ YYCOND_i: 0, 8, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 72, 80, 0, 80, 80, 80, 80, 64, + 72, 80, 0, 80, 80, 80, 80, 80, 64, 64, 80, 80, 64, 80, 80, 80, 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, 80, 64, 80, 80, 80, 80, @@ -459,6 +459,7 @@ YYCOND_i: case '#': case '%': case '&': + case '\'': case '*': case '.': case '/': @@ -498,7 +499,6 @@ YYCOND_i: case '^': case '_': case '`': - case 'd': case 'h': case 'j': case 'k': @@ -530,32 +530,33 @@ YYCOND_i: case 'a': goto yy65; case 'b': goto yy66; case 'c': goto yy67; - case 'e': goto yy68; - case 'f': goto yy69; - case 'g': goto yy70; - case 'i': goto yy71; - case 'l': goto yy72; - case 'm': goto yy73; - case 'n': goto yy74; - case 'o': goto yy75; - case 'p': goto yy76; - case 'r': goto yy77; - case 's': goto yy78; - case 't': goto yy79; - case 'u': goto yy80; + case 'd': goto yy68; + case 'e': goto yy69; + case 'f': goto yy70; + case 'g': goto yy71; + case 'i': goto yy72; + case 'l': goto yy73; + case 'm': goto yy74; + case 'n': goto yy75; + case 'o': goto yy76; + case 'p': goto yy77; + case 'r': goto yy78; + case 's': goto yy79; + case 't': goto yy80; + case 'u': goto yy81; default: goto yy42; } yy40: ++lexer->cursor; -#line 449 "src/wasm-ast-lexer.c" +#line 451 "src/wasm-ast-lexer.c" { RETURN(EOF); } -#line 553 "src/prebuilt/wasm-ast-lexer-gen.c" +#line 554 "src/prebuilt/wasm-ast-lexer-gen.c" yy42: ++lexer->cursor; yy43: -#line 450 "src/wasm-ast-lexer.c" +#line 452 "src/wasm-ast-lexer.c" { ERROR("unexpected char"); continue; } -#line 559 "src/prebuilt/wasm-ast-lexer-gen.c" +#line 560 "src/prebuilt/wasm-ast-lexer-gen.c" yy44: ++lexer->cursor; if (lexer->limit <= lexer->cursor) FILL(1); @@ -563,14 +564,14 @@ yy44: if (yybm[0+yych] & 8) { goto yy44; } -#line 445 "src/wasm-ast-lexer.c" +#line 447 "src/wasm-ast-lexer.c" { continue; } -#line 569 "src/prebuilt/wasm-ast-lexer-gen.c" +#line 570 "src/prebuilt/wasm-ast-lexer-gen.c" yy47: ++lexer->cursor; -#line 444 "src/wasm-ast-lexer.c" +#line 446 "src/wasm-ast-lexer.c" { NEWLINE; continue; } -#line 574 "src/prebuilt/wasm-ast-lexer-gen.c" +#line 575 "src/prebuilt/wasm-ast-lexer-gen.c" yy49: ++lexer->cursor; if (lexer->limit <= lexer->cursor) FILL(1); @@ -580,77 +581,77 @@ yy50: goto yy49; } yy51: -#line 446 "src/wasm-ast-lexer.c" +#line 448 "src/wasm-ast-lexer.c" { ERROR("unexpected token \"%.*s\"", (int)yyleng, yytext); continue; } -#line 588 "src/prebuilt/wasm-ast-lexer-gen.c" +#line 589 "src/prebuilt/wasm-ast-lexer-gen.c" yy52: yych = *(lexer->marker = ++lexer->cursor); if (yych <= 0x1F) goto yy53; - if (yych != 0x7F) goto yy82; + if (yych != 0x7F) goto yy83; yy53: BEGIN(YYCOND_BAD_TEXT); #line 229 "src/wasm-ast-lexer.c" { continue; } -#line 597 "src/prebuilt/wasm-ast-lexer-gen.c" +#line 598 "src/prebuilt/wasm-ast-lexer-gen.c" yy54: yych = *++lexer->cursor; if (yych <= ';') { - if (yych <= '&') { - if (yych == '!') goto yy87; + if (yych <= '\'') { + if (yych == '!') goto yy88; if (yych <= '"') goto yy51; - goto yy87; + goto yy88; } else { if (yych <= '+') { if (yych <= ')') goto yy51; - goto yy87; + goto yy88; } else { if (yych <= ',') goto yy51; - if (yych <= ':') goto yy87; + if (yych <= ':') goto yy88; goto yy51; } } } else { if (yych <= 'z') { if (yych <= '[') { - if (yych <= 'Z') goto yy87; + if (yych <= 'Z') goto yy88; goto yy51; } else { if (yych == ']') goto yy51; - goto yy87; + goto yy88; } } else { if (yych <= '|') { if (yych <= '{') goto yy51; - goto yy87; + goto yy88; } else { - if (yych == '~') goto yy87; + if (yych == '~') goto yy88; goto yy51; } } } yy55: ++lexer->cursor; - if ((yych = *lexer->cursor) == ';') goto yy90; + if ((yych = *lexer->cursor) == ';') goto yy91; #line 220 "src/wasm-ast-lexer.c" { RETURN(LPAR); } -#line 639 "src/prebuilt/wasm-ast-lexer-gen.c" +#line 640 "src/prebuilt/wasm-ast-lexer-gen.c" yy57: ++lexer->cursor; #line 221 "src/wasm-ast-lexer.c" { RETURN(RPAR); } -#line 644 "src/prebuilt/wasm-ast-lexer-gen.c" +#line 645 "src/prebuilt/wasm-ast-lexer-gen.c" yy59: yych = *++lexer->cursor; if (yych <= 'h') { if (yych <= '/') goto yy50; - if (yych <= '0') goto yy92; - if (yych <= '9') goto yy94; + if (yych <= '0') goto yy93; + if (yych <= '9') goto yy95; goto yy50; } else { - if (yych <= 'i') goto yy96; - if (yych == 'n') goto yy97; + if (yych <= 'i') goto yy97; + if (yych == 'n') goto yy98; goto yy50; } yy60: @@ -663,18 +664,18 @@ yy60: if (yych <= '"') { if (yych == '!') goto yy49; } else { - if (yych <= '&') goto yy49; + if (yych <= '\'') goto yy49; if (yych >= '*') goto yy49; } } else { if (yych <= '.') { if (yych <= ',') goto yy61; if (yych <= '-') goto yy49; - goto yy98; + goto yy99; } else { if (yych == ';') goto yy61; if (yych <= 'D') goto yy49; - goto yy101; + goto yy102; } } } else { @@ -683,12 +684,12 @@ yy60: if (yych != '[') goto yy49; } else { if (yych <= ']') goto yy61; - if (yych == 'e') goto yy101; + if (yych == 'e') goto yy102; goto yy49; } } else { if (yych <= '{') { - if (yych <= 'x') goto yy102; + if (yych <= 'x') goto yy103; if (yych <= 'z') goto yy49; } else { if (yych == '}') goto yy61; @@ -699,7 +700,7 @@ yy60: yy61: #line 222 "src/wasm-ast-lexer.c" { LITERAL(INT); RETURN(NAT); } -#line 703 "src/prebuilt/wasm-ast-lexer-gen.c" +#line 704 "src/prebuilt/wasm-ast-lexer-gen.c" yy62: ++lexer->cursor; if ((lexer->limit - lexer->cursor) < 3) FILL(3); @@ -713,7 +714,7 @@ yy62: if (yych == '!') goto yy49; goto yy61; } else { - if (yych <= '&') goto yy49; + if (yych <= '\'') goto yy49; if (yych <= ')') goto yy61; goto yy49; } @@ -721,7 +722,7 @@ yy62: if (yych <= '.') { if (yych <= ',') goto yy61; if (yych <= '-') goto yy49; - goto yy98; + goto yy99; } else { if (yych == ';') goto yy61; goto yy49; @@ -730,7 +731,7 @@ yy62: } else { if (yych <= 'd') { if (yych <= '[') { - if (yych <= 'E') goto yy101; + if (yych <= 'E') goto yy102; if (yych <= 'Z') goto yy49; goto yy61; } else { @@ -739,7 +740,7 @@ yy62: } } else { if (yych <= '{') { - if (yych <= 'e') goto yy101; + if (yych <= 'e') goto yy102; if (yych <= 'z') goto yy49; goto yy61; } else { @@ -751,243 +752,252 @@ yy62: } yy64: yych = *++lexer->cursor; - if (yych == ';') goto yy103; + if (yych == ';') goto yy104; goto yy43; yy65: yych = *++lexer->cursor; - if (yych == 'l') goto yy105; - if (yych == 's') goto yy106; + if (yych == 'l') goto yy106; + if (yych == 's') goto yy107; goto yy50; yy66: yych = *++lexer->cursor; - if (yych == 'l') goto yy107; - if (yych == 'r') goto yy108; + if (yych == 'l') goto yy108; + if (yych == 'r') goto yy109; goto yy50; yy67: yych = *++lexer->cursor; - if (yych == 'a') goto yy110; - if (yych == 'u') goto yy111; + if (yych == 'a') goto yy111; + if (yych == 'u') goto yy112; goto yy50; yy68: yych = *++lexer->cursor; - if (yych == 'l') goto yy112; - if (yych == 'x') goto yy113; + if (yych == 'r') goto yy113; goto yy50; yy69: yych = *++lexer->cursor; - if (yych <= '5') { - if (yych == '3') goto yy114; + if (yych <= 'm') { + if (yych == 'l') goto yy114; goto yy50; } else { - if (yych <= '6') goto yy115; - if (yych == 'u') goto yy116; + if (yych <= 'n') goto yy115; + if (yych == 'x') goto yy116; goto yy50; } yy70: yych = *++lexer->cursor; - if (yych == 'e') goto yy117; - if (yych == 'r') goto yy118; - goto yy50; + if (yych <= '5') { + if (yych == '3') goto yy117; + goto yy50; + } else { + if (yych <= '6') goto yy118; + if (yych == 'u') goto yy119; + goto yy50; + } yy71: yych = *++lexer->cursor; + if (yych == 'e') goto yy120; + if (yych == 'r') goto yy121; + goto yy50; +yy72: + yych = *++lexer->cursor; if (yych <= 'e') { if (yych <= '3') { if (yych <= '2') goto yy50; - goto yy119; + goto yy122; } else { - if (yych == '6') goto yy120; + if (yych == '6') goto yy123; goto yy50; } } else { if (yych <= 'l') { - if (yych <= 'f') goto yy121; + if (yych <= 'f') goto yy124; goto yy50; } else { - if (yych <= 'm') goto yy123; - if (yych <= 'n') goto yy124; + if (yych <= 'm') goto yy126; + if (yych <= 'n') goto yy127; goto yy50; } } -yy72: - yych = *++lexer->cursor; - if (yych == 'o') goto yy125; - goto yy50; yy73: yych = *++lexer->cursor; - if (yych == 'e') goto yy126; - if (yych == 'o') goto yy127; + if (yych == 'o') goto yy128; goto yy50; yy74: yych = *++lexer->cursor; - if (yych == 'a') goto yy128; - if (yych == 'o') goto yy129; + if (yych == 'e') goto yy129; + if (yych == 'o') goto yy130; goto yy50; yy75: yych = *++lexer->cursor; - if (yych == 'f') goto yy130; + if (yych == 'a') goto yy131; + if (yych == 'o') goto yy132; goto yy50; yy76: yych = *++lexer->cursor; - if (yych == 'a') goto yy131; + if (yych == 'f') goto yy133; goto yy50; yy77: yych = *++lexer->cursor; - if (yych == 'e') goto yy132; + if (yych == 'a') goto yy134; goto yy50; yy78: yych = *++lexer->cursor; - if (yych == 'e') goto yy133; - if (yych == 't') goto yy134; + if (yych == 'e') goto yy135; goto yy50; yy79: yych = *++lexer->cursor; + if (yych == 'e') goto yy136; + if (yych == 't') goto yy137; + goto yy50; +yy80: + yych = *++lexer->cursor; if (yych <= 'g') { - if (yych == 'a') goto yy135; + if (yych == 'a') goto yy138; goto yy50; } else { - if (yych <= 'h') goto yy136; - if (yych == 'y') goto yy137; + if (yych <= 'h') goto yy139; + if (yych == 'y') goto yy140; goto yy50; } -yy80: +yy81: yych = *++lexer->cursor; - if (yych == 'n') goto yy138; + if (yych == 'n') goto yy141; goto yy50; -yy81: +yy82: ++lexer->cursor; if (lexer->limit <= lexer->cursor) FILL(1); yych = *lexer->cursor; -yy82: +yy83: if (yybm[0+yych] & 64) { - goto yy81; + goto yy82; } - if (yych <= 0x1F) goto yy83; - if (yych <= '"') goto yy84; - if (yych <= '\\') goto yy86; -yy83: + if (yych <= 0x1F) goto yy84; + if (yych <= '"') goto yy85; + if (yych <= '\\') goto yy87; +yy84: lexer->cursor = lexer->marker; goto yy53; -yy84: +yy85: ++lexer->cursor; #line 228 "src/wasm-ast-lexer.c" { TEXT; RETURN(TEXT); } -#line 875 "src/prebuilt/wasm-ast-lexer-gen.c" -yy86: +#line 885 "src/prebuilt/wasm-ast-lexer-gen.c" +yy87: ++lexer->cursor; if (lexer->limit <= lexer->cursor) FILL(1); yych = *lexer->cursor; if (yych <= 'F') { if (yych <= '\'') { - if (yych == '"') goto yy81; - if (yych <= '&') goto yy83; - goto yy81; + if (yych == '"') goto yy82; + if (yych <= '&') goto yy84; + goto yy82; } else { - if (yych <= '/') goto yy83; - if (yych <= '9') goto yy139; - if (yych <= '@') goto yy83; - goto yy139; + if (yych <= '/') goto yy84; + if (yych <= '9') goto yy142; + if (yych <= '@') goto yy84; + goto yy142; } } else { if (yych <= 'f') { - if (yych == '\\') goto yy81; - if (yych <= '`') goto yy83; - goto yy139; + if (yych == '\\') goto yy82; + if (yych <= '`') goto yy84; + goto yy142; } else { if (yych <= 'n') { - if (yych <= 'm') goto yy83; - goto yy81; + if (yych <= 'm') goto yy84; + goto yy82; } else { - if (yych == 't') goto yy81; - goto yy83; + if (yych == 't') goto yy82; + goto yy84; } } } -yy87: +yy88: ++lexer->cursor; if (lexer->limit <= lexer->cursor) FILL(1); yych = *lexer->cursor; if (yych <= ';') { - if (yych <= '&') { - if (yych == '!') goto yy87; - if (yych >= '#') goto yy87; + if (yych <= '\'') { + if (yych == '!') goto yy88; + if (yych >= '#') goto yy88; } else { if (yych <= '+') { - if (yych >= '*') goto yy87; + if (yych >= '*') goto yy88; } else { - if (yych <= ',') goto yy89; - if (yych <= ':') goto yy87; + if (yych <= ',') goto yy90; + if (yych <= ':') goto yy88; } } } else { if (yych <= 'z') { if (yych <= '[') { - if (yych <= 'Z') goto yy87; + if (yych <= 'Z') goto yy88; } else { - if (yych != ']') goto yy87; + if (yych != ']') goto yy88; } } else { if (yych <= '|') { - if (yych >= '|') goto yy87; + if (yych >= '|') goto yy88; } else { - if (yych == '~') goto yy87; + if (yych == '~') goto yy88; } } } -yy89: -#line 431 "src/wasm-ast-lexer.c" - { TEXT; RETURN(VAR); } -#line 940 "src/prebuilt/wasm-ast-lexer-gen.c" yy90: +#line 433 "src/wasm-ast-lexer.c" + { TEXT; RETURN(VAR); } +#line 950 "src/prebuilt/wasm-ast-lexer-gen.c" +yy91: ++lexer->cursor; BEGIN(YYCOND_BLOCK_COMMENT); -#line 436 "src/wasm-ast-lexer.c" +#line 438 "src/wasm-ast-lexer.c" { COMMENT_NESTING = 1; continue; } -#line 946 "src/prebuilt/wasm-ast-lexer-gen.c" -yy92: +#line 956 "src/prebuilt/wasm-ast-lexer-gen.c" +yy93: ++lexer->cursor; if ((yych = *lexer->cursor) <= 'D') { if (yych <= ',') { if (yych <= '"') { if (yych == '!') goto yy49; } else { - if (yych <= '&') goto yy49; - if (yych <= ')') goto yy93; + if (yych <= '\'') goto yy49; + if (yych <= ')') goto yy94; if (yych <= '+') goto yy49; } } else { if (yych <= '/') { - if (yych == '.') goto yy98; + if (yych == '.') goto yy99; goto yy49; } else { - if (yych <= '9') goto yy94; + if (yych <= '9') goto yy95; if (yych != ';') goto yy49; } } } else { if (yych <= 'e') { if (yych <= '[') { - if (yych <= 'E') goto yy101; + if (yych <= 'E') goto yy102; if (yych <= 'Z') goto yy49; } else { - if (yych == ']') goto yy93; + if (yych == ']') goto yy94; if (yych <= 'd') goto yy49; - goto yy101; + goto yy102; } } else { if (yych <= '{') { - if (yych == 'x') goto yy140; + if (yych == 'x') goto yy143; if (yych <= 'z') goto yy49; } else { - if (yych == '}') goto yy93; + if (yych == '}') goto yy94; if (yych <= '~') goto yy49; } } } -yy93: +yy94: #line 223 "src/wasm-ast-lexer.c" { LITERAL(INT); RETURN(INT); } -#line 990 "src/prebuilt/wasm-ast-lexer-gen.c" -yy94: +#line 1000 "src/prebuilt/wasm-ast-lexer-gen.c" +yy95: ++lexer->cursor; if ((lexer->limit - lexer->cursor) < 3) FILL(3); yych = *lexer->cursor; @@ -995,55 +1005,55 @@ yy94: if (yych <= '+') { if (yych <= '"') { if (yych == '!') goto yy49; - goto yy93; + goto yy94; } else { - if (yych <= '&') goto yy49; - if (yych <= ')') goto yy93; + if (yych <= '\'') goto yy49; + if (yych <= ')') goto yy94; goto yy49; } } else { if (yych <= '.') { - if (yych <= ',') goto yy93; + if (yych <= ',') goto yy94; if (yych <= '-') goto yy49; - goto yy98; + goto yy99; } else { if (yych <= '/') goto yy49; - if (yych <= '9') goto yy94; + if (yych <= '9') goto yy95; if (yych <= ':') goto yy49; - goto yy93; + goto yy94; } } } else { if (yych <= 'd') { if (yych <= 'Z') { - if (yych == 'E') goto yy101; + if (yych == 'E') goto yy102; goto yy49; } else { if (yych == '\\') goto yy49; - if (yych <= ']') goto yy93; + if (yych <= ']') goto yy94; goto yy49; } } else { if (yych <= '{') { - if (yych <= 'e') goto yy101; + if (yych <= 'e') goto yy102; if (yych <= 'z') goto yy49; - goto yy93; + goto yy94; } else { - if (yych == '}') goto yy93; + if (yych == '}') goto yy94; if (yych <= '~') goto yy49; - goto yy93; + goto yy94; } } } -yy96: - yych = *++lexer->cursor; - if (yych == 'n') goto yy141; - goto yy50; yy97: yych = *++lexer->cursor; - if (yych == 'a') goto yy128; + if (yych == 'n') goto yy144; goto yy50; yy98: + yych = *++lexer->cursor; + if (yych == 'a') goto yy131; + goto yy50; +yy99: ++lexer->cursor; if ((lexer->limit - lexer->cursor) < 3) FILL(3); yych = *lexer->cursor; @@ -1052,14 +1062,14 @@ yy98: if (yych <= '"') { if (yych == '!') goto yy49; } else { - if (yych <= '&') goto yy49; + if (yych <= '\'') goto yy49; if (yych >= '*') goto yy49; } } else { if (yych <= '9') { - if (yych <= ',') goto yy100; + if (yych <= ',') goto yy101; if (yych <= '/') goto yy49; - goto yy98; + goto yy99; } else { if (yych != ';') goto yy49; } @@ -1067,69 +1077,69 @@ yy98: } else { if (yych <= 'd') { if (yych <= '[') { - if (yych <= 'E') goto yy101; + if (yych <= 'E') goto yy102; if (yych <= 'Z') goto yy49; } else { if (yych != ']') goto yy49; } } else { if (yych <= '{') { - if (yych <= 'e') goto yy101; + if (yych <= 'e') goto yy102; if (yych <= 'z') goto yy49; } else { - if (yych == '}') goto yy100; + if (yych == '}') goto yy101; if (yych <= '~') goto yy49; } } } -yy100: +yy101: #line 224 "src/wasm-ast-lexer.c" { LITERAL(FLOAT); RETURN(FLOAT); } -#line 1089 "src/prebuilt/wasm-ast-lexer-gen.c" -yy101: +#line 1099 "src/prebuilt/wasm-ast-lexer-gen.c" +yy102: yych = *++lexer->cursor; if (yych <= ',') { - if (yych == '+') goto yy142; + if (yych == '+') goto yy145; goto yy50; } else { - if (yych <= '-') goto yy142; + if (yych <= '-') goto yy145; if (yych <= '/') goto yy50; - if (yych <= '9') goto yy143; + if (yych <= '9') goto yy146; goto yy50; } -yy102: +yy103: yych = *++lexer->cursor; if (yybm[0+yych] & 128) { - goto yy145; + goto yy148; } goto yy50; -yy103: +yy104: ++lexer->cursor; BEGIN(YYCOND_LINE_COMMENT); -#line 433 "src/wasm-ast-lexer.c" +#line 435 "src/wasm-ast-lexer.c" { continue; } -#line 1112 "src/prebuilt/wasm-ast-lexer-gen.c" -yy105: - yych = *++lexer->cursor; - if (yych == 'i') goto yy147; - goto yy50; +#line 1122 "src/prebuilt/wasm-ast-lexer-gen.c" yy106: yych = *++lexer->cursor; - if (yych == 's') goto yy148; + if (yych == 'i') goto yy150; goto yy50; yy107: yych = *++lexer->cursor; - if (yych == 'o') goto yy149; + if (yych == 's') goto yy151; goto yy50; yy108: + yych = *++lexer->cursor; + if (yych == 'o') goto yy152; + goto yy50; +yy109: ++lexer->cursor; if ((yych = *lexer->cursor) <= 'Z') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy109; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy110; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { @@ -1143,9 +1153,9 @@ yy108: if (yych <= '\\') { if (yych >= '\\') goto yy49; } else { - if (yych <= ']') goto yy109; + if (yych <= ']') goto yy110; if (yych <= '^') goto yy49; - goto yy150; + goto yy153; } } else { if (yych <= '|') { @@ -1155,64 +1165,72 @@ yy108: } } } -yy109: +yy110: #line 248 "src/wasm-ast-lexer.c" { RETURN(BR); } -#line 1162 "src/prebuilt/wasm-ast-lexer-gen.c" -yy110: - yych = *++lexer->cursor; - if (yych == 'l') goto yy151; - if (yych == 's') goto yy152; - goto yy50; +#line 1172 "src/prebuilt/wasm-ast-lexer-gen.c" yy111: yych = *++lexer->cursor; - if (yych == 'r') goto yy153; + if (yych == 'l') goto yy154; + if (yych == 's') goto yy155; goto yy50; yy112: yych = *++lexer->cursor; - if (yych == 's') goto yy154; + if (yych == 'r') goto yy156; goto yy50; yy113: yych = *++lexer->cursor; - if (yych == 'p') goto yy155; + if (yych == 'o') goto yy157; goto yy50; yy114: yych = *++lexer->cursor; - if (yych == '2') goto yy156; + if (yych == 's') goto yy158; goto yy50; yy115: yych = *++lexer->cursor; - if (yych == '4') goto yy158; + if (yych == 'd') goto yy159; goto yy50; yy116: yych = *++lexer->cursor; - if (yych == 'n') goto yy160; + if (yych == 'p') goto yy161; goto yy50; yy117: yych = *++lexer->cursor; - if (yych == 't') goto yy161; + if (yych == '2') goto yy162; goto yy50; yy118: yych = *++lexer->cursor; - if (yych == 'o') goto yy162; + if (yych == '4') goto yy164; goto yy50; yy119: yych = *++lexer->cursor; - if (yych == '2') goto yy163; + if (yych == 'n') goto yy166; goto yy50; yy120: yych = *++lexer->cursor; - if (yych == '4') goto yy165; + if (yych == 't') goto yy167; goto yy50; yy121: + yych = *++lexer->cursor; + if (yych == 'o') goto yy168; + goto yy50; +yy122: + yych = *++lexer->cursor; + if (yych == '2') goto yy169; + goto yy50; +yy123: + yych = *++lexer->cursor; + if (yych == '4') goto yy171; + goto yy50; +yy124: ++lexer->cursor; if ((yych = *lexer->cursor) <= 'Z') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy122; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy125; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { @@ -1226,9 +1244,9 @@ yy121: if (yych <= '\\') { if (yych >= '\\') goto yy49; } else { - if (yych <= ']') goto yy122; + if (yych <= ']') goto yy125; if (yych <= '^') goto yy49; - goto yy167; + goto yy173; } } else { if (yych <= '|') { @@ -1238,167 +1256,167 @@ yy121: } } } -yy122: +yy125: #line 243 "src/wasm-ast-lexer.c" { RETURN(IF); } -#line 1245 "src/prebuilt/wasm-ast-lexer-gen.c" -yy123: - yych = *++lexer->cursor; - if (yych == 'p') goto yy168; - goto yy50; -yy124: - yych = *++lexer->cursor; - if (yych == 'f') goto yy169; - if (yych == 'v') goto yy171; - goto yy50; -yy125: - yych = *++lexer->cursor; - if (yych == 'c') goto yy172; - if (yych == 'o') goto yy173; - goto yy50; +#line 1263 "src/prebuilt/wasm-ast-lexer-gen.c" yy126: yych = *++lexer->cursor; - if (yych == 'm') goto yy174; + if (yych == 'p') goto yy174; goto yy50; yy127: yych = *++lexer->cursor; - if (yych == 'd') goto yy175; + if (yych == 'f') goto yy175; + if (yych == 'v') goto yy177; goto yy50; yy128: yych = *++lexer->cursor; - if (yych == 'n') goto yy176; + if (yych == 'c') goto yy178; + if (yych == 'o') goto yy179; goto yy50; yy129: yych = *++lexer->cursor; - if (yych == 'p') goto yy178; + if (yych == 'm') goto yy180; goto yy50; yy130: yych = *++lexer->cursor; - if (yych == 'f') goto yy180; + if (yych == 'd') goto yy181; goto yy50; yy131: yych = *++lexer->cursor; - if (yych == 'r') goto yy181; + if (yych == 'n') goto yy182; goto yy50; yy132: yych = *++lexer->cursor; - if (yych <= 'r') goto yy50; - if (yych <= 's') goto yy182; - if (yych <= 't') goto yy183; + if (yych == 'p') goto yy184; goto yy50; yy133: yych = *++lexer->cursor; - if (yych <= 'k') { - if (yych == 'g') goto yy184; - goto yy50; - } else { - if (yych <= 'l') goto yy185; - if (yych == 't') goto yy186; - goto yy50; - } + if (yych == 'f') goto yy186; + goto yy50; yy134: yych = *++lexer->cursor; - if (yych == 'a') goto yy187; + if (yych == 'r') goto yy187; goto yy50; yy135: yych = *++lexer->cursor; - if (yych == 'b') goto yy188; + if (yych <= 'r') goto yy50; + if (yych <= 's') goto yy188; + if (yych <= 't') goto yy189; goto yy50; yy136: yych = *++lexer->cursor; - if (yych == 'e') goto yy189; - goto yy50; + if (yych <= 'k') { + if (yych == 'g') goto yy190; + goto yy50; + } else { + if (yych <= 'l') goto yy191; + if (yych == 't') goto yy192; + goto yy50; + } yy137: yych = *++lexer->cursor; - if (yych == 'p') goto yy190; + if (yych == 'a') goto yy193; goto yy50; yy138: yych = *++lexer->cursor; - if (yych == 'r') goto yy191; + if (yych == 'b') goto yy194; goto yy50; yy139: + yych = *++lexer->cursor; + if (yych == 'e') goto yy195; + goto yy50; +yy140: + yych = *++lexer->cursor; + if (yych == 'p') goto yy196; + goto yy50; +yy141: + yych = *++lexer->cursor; + if (yych == 'r') goto yy197; + goto yy50; +yy142: ++lexer->cursor; if (lexer->limit <= lexer->cursor) FILL(1); yych = *lexer->cursor; if (yych <= '@') { - if (yych <= '/') goto yy83; - if (yych <= '9') goto yy81; - goto yy83; + if (yych <= '/') goto yy84; + if (yych <= '9') goto yy82; + goto yy84; } else { - if (yych <= 'F') goto yy81; - if (yych <= '`') goto yy83; - if (yych <= 'f') goto yy81; - goto yy83; + if (yych <= 'F') goto yy82; + if (yych <= '`') goto yy84; + if (yych <= 'f') goto yy82; + goto yy84; } -yy140: +yy143: yych = *++lexer->cursor; if (yych <= '@') { if (yych <= '/') goto yy50; - if (yych <= '9') goto yy192; + if (yych <= '9') goto yy198; goto yy50; } else { - if (yych <= 'F') goto yy192; + if (yych <= 'F') goto yy198; if (yych <= '`') goto yy50; - if (yych <= 'f') goto yy192; + if (yych <= 'f') goto yy198; goto yy50; } -yy141: +yy144: yych = *++lexer->cursor; - if (yych == 'f') goto yy169; + if (yych == 'f') goto yy175; goto yy50; -yy142: +yy145: yych = *++lexer->cursor; if (yych <= '/') goto yy50; if (yych >= ':') goto yy50; -yy143: +yy146: ++lexer->cursor; if (lexer->limit <= lexer->cursor) FILL(1); yych = *lexer->cursor; if (yych <= ':') { if (yych <= ')') { if (yych <= '!') { - if (yych <= ' ') goto yy100; + if (yych <= ' ') goto yy101; goto yy49; } else { - if (yych <= '"') goto yy100; - if (yych <= '&') goto yy49; - goto yy100; + if (yych <= '"') goto yy101; + if (yych <= '\'') goto yy49; + goto yy101; } } else { if (yych <= ',') { if (yych <= '+') goto yy49; - goto yy100; + goto yy101; } else { if (yych <= '/') goto yy49; - if (yych <= '9') goto yy143; + if (yych <= '9') goto yy146; goto yy49; } } } else { if (yych <= ']') { if (yych <= 'Z') { - if (yych <= ';') goto yy100; + if (yych <= ';') goto yy101; goto yy49; } else { if (yych == '\\') goto yy49; - goto yy100; + goto yy101; } } else { if (yych <= '|') { - if (yych == '{') goto yy100; + if (yych == '{') goto yy101; goto yy49; } else { if (yych == '~') goto yy49; - goto yy100; + goto yy101; } } } -yy145: +yy148: ++lexer->cursor; if ((lexer->limit - lexer->cursor) < 3) FILL(3); yych = *lexer->cursor; if (yybm[0+yych] & 128) { - goto yy145; + goto yy148; } if (yych <= ';') { if (yych <= ')') { @@ -1407,7 +1425,7 @@ yy145: goto yy49; } else { if (yych <= '"') goto yy61; - if (yych <= '&') goto yy49; + if (yych <= '\'') goto yy49; goto yy61; } } else { @@ -1415,7 +1433,7 @@ yy145: if (yych == ',') goto yy61; goto yy49; } else { - if (yych <= '.') goto yy194; + if (yych <= '.') goto yy200; if (yych <= ':') goto yy49; goto yy61; } @@ -1428,7 +1446,7 @@ yy145: } else { if (yych <= ']') goto yy61; if (yych <= 'o') goto yy49; - goto yy196; + goto yy202; } } else { if (yych <= '|') { @@ -1440,58 +1458,70 @@ yy145: } } } -yy147: - yych = *++lexer->cursor; - if (yych == 'g') goto yy197; - goto yy50; -yy148: - yych = *++lexer->cursor; - if (yych == 'e') goto yy198; - goto yy50; -yy149: - yych = *++lexer->cursor; - if (yych == 'c') goto yy199; - goto yy50; yy150: yych = *++lexer->cursor; - if (yych == 'i') goto yy200; - if (yych == 't') goto yy201; + if (yych == 'g') goto yy203; goto yy50; yy151: yych = *++lexer->cursor; - if (yych == 'l') goto yy202; + if (yych == 'e') goto yy204; goto yy50; yy152: yych = *++lexer->cursor; - if (yych == 'e') goto yy204; + if (yych == 'c') goto yy205; goto yy50; yy153: yych = *++lexer->cursor; - if (yych == 'r') goto yy206; + if (yych == 'i') goto yy206; + if (yych == 't') goto yy207; goto yy50; yy154: yych = *++lexer->cursor; - if (yych == 'e') goto yy207; + if (yych == 'l') goto yy208; goto yy50; yy155: yych = *++lexer->cursor; - if (yych == 'o') goto yy209; + if (yych == 'e') goto yy210; goto yy50; yy156: + yych = *++lexer->cursor; + if (yych == 'r') goto yy212; + goto yy50; +yy157: + yych = *++lexer->cursor; + if (yych == 'p') goto yy213; + goto yy50; +yy158: + yych = *++lexer->cursor; + if (yych == 'e') goto yy215; + goto yy50; +yy159: + ++lexer->cursor; + if (yybm[0+(yych = *lexer->cursor)] & 16) { + goto yy49; + } +#line 256 "src/wasm-ast-lexer.c" + { RETURN(END); } +#line 1506 "src/prebuilt/wasm-ast-lexer-gen.c" +yy161: + yych = *++lexer->cursor; + if (yych == 'o') goto yy217; + goto yy50; +yy162: ++lexer->cursor; if ((yych = *lexer->cursor) <= ':') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy157; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy163; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { if (yych <= '+') goto yy49; } else { - if (yych == '.') goto yy210; + if (yych == '.') goto yy218; goto yy49; } } @@ -1510,25 +1540,25 @@ yy156: } } } -yy157: +yy163: #line 239 "src/wasm-ast-lexer.c" { TYPE(F32); RETURN(VALUE_TYPE); } -#line 1517 "src/prebuilt/wasm-ast-lexer-gen.c" -yy158: +#line 1547 "src/prebuilt/wasm-ast-lexer-gen.c" +yy164: ++lexer->cursor; if ((yych = *lexer->cursor) <= ':') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy159; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy165; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { if (yych <= '+') goto yy49; } else { - if (yych == '.') goto yy211; + if (yych == '.') goto yy219; goto yy49; } } @@ -1547,37 +1577,37 @@ yy158: } } } -yy159: +yy165: #line 240 "src/wasm-ast-lexer.c" { TYPE(F64); RETURN(VALUE_TYPE); } -#line 1554 "src/prebuilt/wasm-ast-lexer-gen.c" -yy160: +#line 1584 "src/prebuilt/wasm-ast-lexer-gen.c" +yy166: yych = *++lexer->cursor; - if (yych == 'c') goto yy212; + if (yych == 'c') goto yy220; goto yy50; -yy161: +yy167: yych = *++lexer->cursor; - if (yych == '_') goto yy214; + if (yych == '_') goto yy222; goto yy50; -yy162: +yy168: yych = *++lexer->cursor; - if (yych == 'w') goto yy215; + if (yych == 'w') goto yy223; goto yy50; -yy163: +yy169: ++lexer->cursor; if ((yych = *lexer->cursor) <= ':') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy164; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy170; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { if (yych <= '+') goto yy49; } else { - if (yych == '.') goto yy216; + if (yych == '.') goto yy224; goto yy49; } } @@ -1596,25 +1626,25 @@ yy163: } } } -yy164: +yy170: #line 237 "src/wasm-ast-lexer.c" { TYPE(I32); RETURN(VALUE_TYPE); } -#line 1603 "src/prebuilt/wasm-ast-lexer-gen.c" -yy165: +#line 1633 "src/prebuilt/wasm-ast-lexer-gen.c" +yy171: ++lexer->cursor; if ((yych = *lexer->cursor) <= ':') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy166; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy172; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { if (yych <= '+') goto yy49; } else { - if (yych == '.') goto yy217; + if (yych == '.') goto yy225; goto yy49; } } @@ -1633,27 +1663,27 @@ yy165: } } } -yy166: +yy172: #line 238 "src/wasm-ast-lexer.c" { TYPE(I64); RETURN(VALUE_TYPE); } -#line 1640 "src/prebuilt/wasm-ast-lexer-gen.c" -yy167: +#line 1670 "src/prebuilt/wasm-ast-lexer-gen.c" +yy173: yych = *++lexer->cursor; - if (yych == 'e') goto yy218; + if (yych == 'e') goto yy226; goto yy50; -yy168: +yy174: yych = *++lexer->cursor; - if (yych == 'o') goto yy219; + if (yych == 'o') goto yy227; goto yy50; -yy169: +yy175: ++lexer->cursor; if ((yych = *lexer->cursor) <= 'Z') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy170; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy176; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { @@ -1667,9 +1697,9 @@ yy169: if (yych <= '\\') { if (yych >= '\\') goto yy49; } else { - if (yych <= ']') goto yy170; + if (yych <= ']') goto yy176; if (yych <= 'h') goto yy49; - goto yy220; + goto yy228; } } else { if (yych <= '|') { @@ -1679,46 +1709,46 @@ yy169: } } } -yy170: +yy176: #line 226 "src/wasm-ast-lexer.c" { LITERAL(INFINITY); RETURN(FLOAT); } -#line 1686 "src/prebuilt/wasm-ast-lexer-gen.c" -yy171: +#line 1716 "src/prebuilt/wasm-ast-lexer-gen.c" +yy177: yych = *++lexer->cursor; - if (yych == 'o') goto yy221; + if (yych == 'o') goto yy229; goto yy50; -yy172: +yy178: yych = *++lexer->cursor; - if (yych == 'a') goto yy222; + if (yych == 'a') goto yy230; goto yy50; -yy173: +yy179: yych = *++lexer->cursor; - if (yych == 'p') goto yy223; + if (yych == 'p') goto yy231; goto yy50; -yy174: +yy180: yych = *++lexer->cursor; - if (yych == 'o') goto yy225; + if (yych == 'o') goto yy233; goto yy50; -yy175: +yy181: yych = *++lexer->cursor; - if (yych == 'u') goto yy226; + if (yych == 'u') goto yy234; goto yy50; -yy176: +yy182: ++lexer->cursor; if ((yych = *lexer->cursor) <= ';') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy177; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy183; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { if (yych <= '+') goto yy49; } else { if (yych <= '9') goto yy49; - if (yych <= ':') goto yy227; + if (yych <= ':') goto yy235; } } } else { @@ -1736,67 +1766,67 @@ yy176: } } } -yy177: +yy183: #line 227 "src/wasm-ast-lexer.c" { LITERAL(NAN); RETURN(FLOAT); } -#line 1743 "src/prebuilt/wasm-ast-lexer-gen.c" -yy178: +#line 1773 "src/prebuilt/wasm-ast-lexer-gen.c" +yy184: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } #line 241 "src/wasm-ast-lexer.c" { RETURN(NOP); } -#line 1751 "src/prebuilt/wasm-ast-lexer-gen.c" -yy180: +#line 1781 "src/prebuilt/wasm-ast-lexer-gen.c" +yy186: yych = *++lexer->cursor; - if (yych == 's') goto yy228; + if (yych == 's') goto yy236; goto yy50; -yy181: +yy187: yych = *++lexer->cursor; - if (yych == 'a') goto yy229; + if (yych == 'a') goto yy237; goto yy50; -yy182: +yy188: yych = *++lexer->cursor; - if (yych == 'u') goto yy230; + if (yych == 'u') goto yy238; goto yy50; -yy183: +yy189: yych = *++lexer->cursor; - if (yych == 'u') goto yy231; + if (yych == 'u') goto yy239; goto yy50; -yy184: +yy190: yych = *++lexer->cursor; - if (yych == 'm') goto yy232; + if (yych == 'm') goto yy240; goto yy50; -yy185: +yy191: yych = *++lexer->cursor; - if (yych == 'e') goto yy233; + if (yych == 'e') goto yy241; goto yy50; -yy186: +yy192: yych = *++lexer->cursor; - if (yych == '_') goto yy234; + if (yych == '_') goto yy242; goto yy50; -yy187: +yy193: yych = *++lexer->cursor; - if (yych == 'r') goto yy235; + if (yych == 'r') goto yy243; goto yy50; -yy188: +yy194: yych = *++lexer->cursor; - if (yych == 'l') goto yy236; + if (yych == 'l') goto yy244; goto yy50; -yy189: +yy195: yych = *++lexer->cursor; - if (yych == 'n') goto yy237; + if (yych == 'n') goto yy245; goto yy50; -yy190: +yy196: yych = *++lexer->cursor; - if (yych == 'e') goto yy239; + if (yych == 'e') goto yy247; goto yy50; -yy191: +yy197: yych = *++lexer->cursor; - if (yych == 'e') goto yy241; + if (yych == 'e') goto yy249; goto yy50; -yy192: +yy198: ++lexer->cursor; if ((lexer->limit - lexer->cursor) < 3) FILL(3); yych = *lexer->cursor; @@ -1804,46 +1834,46 @@ yy192: if (yych <= ',') { if (yych <= '"') { if (yych == '!') goto yy49; - goto yy93; + goto yy94; } else { - if (yych <= '&') goto yy49; - if (yych <= ')') goto yy93; + if (yych <= '\'') goto yy49; + if (yych <= ')') goto yy94; if (yych <= '+') goto yy49; - goto yy93; + goto yy94; } } else { if (yych <= '/') { if (yych != '.') goto yy49; } else { - if (yych <= '9') goto yy192; - if (yych == ';') goto yy93; + if (yych <= '9') goto yy198; + if (yych == ';') goto yy94; goto yy49; } } } else { if (yych <= 'f') { if (yych <= '[') { - if (yych <= 'F') goto yy192; + if (yych <= 'F') goto yy198; if (yych <= 'Z') goto yy49; - goto yy93; + goto yy94; } else { - if (yych == ']') goto yy93; + if (yych == ']') goto yy94; if (yych <= '`') goto yy49; - goto yy192; + goto yy198; } } else { if (yych <= '{') { - if (yych == 'p') goto yy196; + if (yych == 'p') goto yy202; if (yych <= 'z') goto yy49; - goto yy93; + goto yy94; } else { - if (yych == '}') goto yy93; + if (yych == '}') goto yy94; if (yych <= '~') goto yy49; - goto yy93; + goto yy94; } } } -yy194: +yy200: ++lexer->cursor; if ((lexer->limit - lexer->cursor) < 3) FILL(3); yych = *lexer->cursor; @@ -1853,7 +1883,7 @@ yy194: if (yych == '!') goto yy49; goto yy51; } else { - if (yych <= '&') goto yy49; + if (yych <= '\'') goto yy49; if (yych <= ')') goto yy51; goto yy49; } @@ -1861,11 +1891,11 @@ yy194: if (yych <= '9') { if (yych <= ',') goto yy51; if (yych <= '/') goto yy49; - goto yy194; + goto yy200; } else { if (yych == ';') goto yy51; if (yych <= '@') goto yy49; - goto yy194; + goto yy200; } } } else { @@ -1876,12 +1906,12 @@ yy194: } else { if (yych <= ']') goto yy51; if (yych <= '`') goto yy49; - if (yych <= 'f') goto yy194; + if (yych <= 'f') goto yy200; goto yy49; } } else { if (yych <= '{') { - if (yych <= 'p') goto yy196; + if (yych <= 'p') goto yy202; if (yych <= 'z') goto yy49; goto yy51; } else { @@ -1891,46 +1921,46 @@ yy194: } } } -yy196: +yy202: yych = *++lexer->cursor; if (yych <= ',') { - if (yych == '+') goto yy242; + if (yych == '+') goto yy250; goto yy50; } else { - if (yych <= '-') goto yy242; + if (yych <= '-') goto yy250; if (yych <= '/') goto yy50; - if (yych <= '9') goto yy243; + if (yych <= '9') goto yy251; goto yy50; } -yy197: +yy203: yych = *++lexer->cursor; - if (yych == 'n') goto yy246; + if (yych == 'n') goto yy254; goto yy50; -yy198: +yy204: yych = *++lexer->cursor; - if (yych == 'r') goto yy247; + if (yych == 'r') goto yy255; goto yy50; -yy199: +yy205: yych = *++lexer->cursor; - if (yych == 'k') goto yy248; + if (yych == 'k') goto yy256; goto yy50; -yy200: +yy206: yych = *++lexer->cursor; - if (yych == 'f') goto yy250; + if (yych == 'f') goto yy258; goto yy50; -yy201: +yy207: yych = *++lexer->cursor; - if (yych == 'a') goto yy252; + if (yych == 'a') goto yy260; goto yy50; -yy202: +yy208: ++lexer->cursor; if ((yych = *lexer->cursor) <= 'Z') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy203; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy209; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { @@ -1944,9 +1974,9 @@ yy202: if (yych <= '\\') { if (yych >= '\\') goto yy49; } else { - if (yych <= ']') goto yy203; + if (yych <= ']') goto yy209; if (yych <= '^') goto yy49; - goto yy253; + goto yy261; } } else { if (yych <= '|') { @@ -1956,225 +1986,233 @@ yy202: } } } -yy203: +yy209: #line 252 "src/wasm-ast-lexer.c" { RETURN(CALL); } -#line 1963 "src/prebuilt/wasm-ast-lexer-gen.c" -yy204: +#line 1993 "src/prebuilt/wasm-ast-lexer-gen.c" +yy210: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } #line 251 "src/wasm-ast-lexer.c" { RETURN(CASE); } -#line 1971 "src/prebuilt/wasm-ast-lexer-gen.c" -yy206: +#line 2001 "src/prebuilt/wasm-ast-lexer-gen.c" +yy212: yych = *++lexer->cursor; - if (yych == 'e') goto yy254; + if (yych == 'e') goto yy262; goto yy50; -yy207: +yy213: + ++lexer->cursor; + if (yybm[0+(yych = *lexer->cursor)] & 16) { + goto yy49; + } +#line 255 "src/wasm-ast-lexer.c" + { RETURN(DROP); } +#line 2013 "src/prebuilt/wasm-ast-lexer-gen.c" +yy215: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } #line 246 "src/wasm-ast-lexer.c" { RETURN(ELSE); } -#line 1983 "src/prebuilt/wasm-ast-lexer-gen.c" -yy209: +#line 2021 "src/prebuilt/wasm-ast-lexer-gen.c" +yy217: yych = *++lexer->cursor; - if (yych == 'r') goto yy255; + if (yych == 'r') goto yy263; goto yy50; -yy210: +yy218: yych = *++lexer->cursor; switch (yych) { - case 'a': goto yy256; - case 'c': goto yy257; - case 'd': goto yy258; - case 'e': goto yy259; - case 'f': goto yy260; - case 'g': goto yy261; - case 'l': goto yy262; - case 'm': goto yy263; - case 'n': goto yy264; - case 'r': goto yy265; - case 's': goto yy266; - case 't': goto yy267; + case 'a': goto yy264; + case 'c': goto yy265; + case 'd': goto yy266; + case 'e': goto yy267; + case 'f': goto yy268; + case 'g': goto yy269; + case 'l': goto yy270; + case 'm': goto yy271; + case 'n': goto yy272; + case 'r': goto yy273; + case 's': goto yy274; + case 't': goto yy275; default: goto yy50; } -yy211: +yy219: yych = *++lexer->cursor; switch (yych) { - case 'a': goto yy268; - case 'c': goto yy269; - case 'd': goto yy270; - case 'e': goto yy271; - case 'f': goto yy272; - case 'g': goto yy273; - case 'l': goto yy274; - case 'm': goto yy275; - case 'n': goto yy276; - case 'p': goto yy277; - case 'r': goto yy278; - case 's': goto yy279; - case 't': goto yy280; + case 'a': goto yy276; + case 'c': goto yy277; + case 'd': goto yy278; + case 'e': goto yy279; + case 'f': goto yy280; + case 'g': goto yy281; + case 'l': goto yy282; + case 'm': goto yy283; + case 'n': goto yy284; + case 'p': goto yy285; + case 'r': goto yy286; + case 's': goto yy287; + case 't': goto yy288; default: goto yy50; } -yy212: +yy220: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 415 "src/wasm-ast-lexer.c" +#line 417 "src/wasm-ast-lexer.c" { RETURN(FUNC); } -#line 2030 "src/prebuilt/wasm-ast-lexer-gen.c" -yy214: +#line 2068 "src/prebuilt/wasm-ast-lexer-gen.c" +yy222: yych = *++lexer->cursor; - if (yych == 'l') goto yy281; + if (yych == 'l') goto yy289; goto yy50; -yy215: +yy223: yych = *++lexer->cursor; - if (yych == '_') goto yy282; + if (yych == '_') goto yy290; goto yy50; -yy216: +yy224: yych = *++lexer->cursor; switch (yych) { - case 'a': goto yy283; - case 'c': goto yy284; - case 'd': goto yy285; - case 'e': goto yy286; - case 'g': goto yy287; - case 'l': goto yy288; - case 'm': goto yy289; - case 'n': goto yy290; - case 'o': goto yy291; - case 'p': goto yy292; - case 'r': goto yy293; - case 's': goto yy294; - case 't': goto yy295; - case 'w': goto yy296; - case 'x': goto yy297; + case 'a': goto yy291; + case 'c': goto yy292; + case 'd': goto yy293; + case 'e': goto yy294; + case 'g': goto yy295; + case 'l': goto yy296; + case 'm': goto yy297; + case 'n': goto yy298; + case 'o': goto yy299; + case 'p': goto yy300; + case 'r': goto yy301; + case 's': goto yy302; + case 't': goto yy303; + case 'w': goto yy304; + case 'x': goto yy305; default: goto yy50; } -yy217: +yy225: yych = *++lexer->cursor; switch (yych) { - case 'a': goto yy298; - case 'c': goto yy299; - case 'd': goto yy300; - case 'e': goto yy301; - case 'g': goto yy302; - case 'l': goto yy303; - case 'm': goto yy304; - case 'n': goto yy305; - case 'o': goto yy306; - case 'p': goto yy307; - case 'r': goto yy308; - case 's': goto yy309; - case 't': goto yy310; - case 'x': goto yy311; + case 'a': goto yy306; + case 'c': goto yy307; + case 'd': goto yy308; + case 'e': goto yy309; + case 'g': goto yy310; + case 'l': goto yy311; + case 'm': goto yy312; + case 'n': goto yy313; + case 'o': goto yy314; + case 'p': goto yy315; + case 'r': goto yy316; + case 's': goto yy317; + case 't': goto yy318; + case 'x': goto yy319; default: goto yy50; } -yy218: +yy226: yych = *++lexer->cursor; - if (yych == 'l') goto yy312; + if (yych == 'l') goto yy320; goto yy50; -yy219: +yy227: yych = *++lexer->cursor; - if (yych == 'r') goto yy313; + if (yych == 'r') goto yy321; goto yy50; -yy220: +yy228: yych = *++lexer->cursor; - if (yych == 'n') goto yy314; + if (yych == 'n') goto yy322; goto yy50; -yy221: +yy229: yych = *++lexer->cursor; - if (yych == 'k') goto yy315; + if (yych == 'k') goto yy323; goto yy50; -yy222: +yy230: yych = *++lexer->cursor; - if (yych == 'l') goto yy316; + if (yych == 'l') goto yy324; goto yy50; -yy223: +yy231: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } #line 247 "src/wasm-ast-lexer.c" { RETURN(LOOP); } -#line 2105 "src/prebuilt/wasm-ast-lexer-gen.c" -yy225: +#line 2143 "src/prebuilt/wasm-ast-lexer-gen.c" +yy233: yych = *++lexer->cursor; - if (yych == 'r') goto yy318; + if (yych == 'r') goto yy326; goto yy50; -yy226: +yy234: yych = *++lexer->cursor; - if (yych == 'l') goto yy319; + if (yych == 'l') goto yy327; goto yy50; -yy227: +yy235: yych = *++lexer->cursor; - if (yych == '0') goto yy320; + if (yych == '0') goto yy328; goto yy50; -yy228: +yy236: yych = *++lexer->cursor; - if (yych == 'e') goto yy321; + if (yych == 'e') goto yy329; goto yy50; -yy229: +yy237: yych = *++lexer->cursor; - if (yych == 'm') goto yy322; + if (yych == 'm') goto yy330; goto yy50; -yy230: +yy238: yych = *++lexer->cursor; - if (yych == 'l') goto yy324; + if (yych == 'l') goto yy332; goto yy50; -yy231: +yy239: yych = *++lexer->cursor; - if (yych == 'r') goto yy325; + if (yych == 'r') goto yy333; goto yy50; -yy232: +yy240: yych = *++lexer->cursor; - if (yych == 'e') goto yy326; + if (yych == 'e') goto yy334; goto yy50; -yy233: +yy241: yych = *++lexer->cursor; - if (yych == 'c') goto yy327; + if (yych == 'c') goto yy335; goto yy50; -yy234: +yy242: yych = *++lexer->cursor; - if (yych == 'l') goto yy328; + if (yych == 'l') goto yy336; goto yy50; -yy235: +yy243: yych = *++lexer->cursor; - if (yych == 't') goto yy329; + if (yych == 't') goto yy337; goto yy50; -yy236: +yy244: yych = *++lexer->cursor; - if (yych == 'e') goto yy331; + if (yych == 'e') goto yy339; goto yy50; -yy237: +yy245: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } #line 245 "src/wasm-ast-lexer.c" { RETURN(THEN); } -#line 2161 "src/prebuilt/wasm-ast-lexer-gen.c" -yy239: +#line 2199 "src/prebuilt/wasm-ast-lexer-gen.c" +yy247: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 414 "src/wasm-ast-lexer.c" +#line 416 "src/wasm-ast-lexer.c" { RETURN(TYPE); } -#line 2169 "src/prebuilt/wasm-ast-lexer-gen.c" -yy241: +#line 2207 "src/prebuilt/wasm-ast-lexer-gen.c" +yy249: yych = *++lexer->cursor; - if (yych == 'a') goto yy333; + if (yych == 'a') goto yy341; goto yy50; -yy242: +yy250: yych = *++lexer->cursor; if (yych <= '/') goto yy50; if (yych >= ':') goto yy50; -yy243: +yy251: ++lexer->cursor; if (lexer->limit <= lexer->cursor) FILL(1); yych = *lexer->cursor; @@ -2183,15 +2221,15 @@ yy243: if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy245; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy253; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { if (yych <= '+') goto yy49; } else { if (yych <= '/') goto yy49; - if (yych <= '9') goto yy243; + if (yych <= '9') goto yy251; goto yy49; } } @@ -2210,579 +2248,579 @@ yy243: } } } -yy245: +yy253: #line 225 "src/wasm-ast-lexer.c" { LITERAL(HEXFLOAT); RETURN(FLOAT); } -#line 2217 "src/prebuilt/wasm-ast-lexer-gen.c" -yy246: +#line 2255 "src/prebuilt/wasm-ast-lexer-gen.c" +yy254: yych = *++lexer->cursor; - if (yych == '=') goto yy334; + if (yych == '=') goto yy342; goto yy50; -yy247: +yy255: yych = *++lexer->cursor; - if (yych == 't') goto yy335; + if (yych == 't') goto yy343; goto yy50; -yy248: +yy256: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } #line 242 "src/wasm-ast-lexer.c" { RETURN(BLOCK); } -#line 2233 "src/prebuilt/wasm-ast-lexer-gen.c" -yy250: +#line 2271 "src/prebuilt/wasm-ast-lexer-gen.c" +yy258: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } #line 249 "src/wasm-ast-lexer.c" { RETURN(BR_IF); } -#line 2241 "src/prebuilt/wasm-ast-lexer-gen.c" -yy252: +#line 2279 "src/prebuilt/wasm-ast-lexer-gen.c" +yy260: yych = *++lexer->cursor; - if (yych == 'b') goto yy336; + if (yych == 'b') goto yy344; goto yy50; -yy253: +yy261: yych = *++lexer->cursor; - if (yych == 'i') goto yy337; + if (yych == 'i') goto yy345; goto yy50; -yy254: +yy262: yych = *++lexer->cursor; - if (yych == 'n') goto yy338; + if (yych == 'n') goto yy346; goto yy50; -yy255: +yy263: yych = *++lexer->cursor; - if (yych == 't') goto yy339; + if (yych == 't') goto yy347; goto yy50; -yy256: +yy264: yych = *++lexer->cursor; - if (yych == 'b') goto yy341; - if (yych == 'd') goto yy342; + if (yych == 'b') goto yy349; + if (yych == 'd') goto yy350; goto yy50; -yy257: +yy265: yych = *++lexer->cursor; - if (yych == 'e') goto yy343; - if (yych == 'o') goto yy344; + if (yych == 'e') goto yy351; + if (yych == 'o') goto yy352; goto yy50; -yy258: +yy266: yych = *++lexer->cursor; - if (yych == 'e') goto yy345; - if (yych == 'i') goto yy346; + if (yych == 'e') goto yy353; + if (yych == 'i') goto yy354; goto yy50; -yy259: +yy267: yych = *++lexer->cursor; - if (yych == 'q') goto yy347; + if (yych == 'q') goto yy355; goto yy50; -yy260: +yy268: yych = *++lexer->cursor; - if (yych == 'l') goto yy349; + if (yych == 'l') goto yy357; goto yy50; -yy261: +yy269: yych = *++lexer->cursor; - if (yych == 'e') goto yy350; - if (yych == 't') goto yy352; + if (yych == 'e') goto yy358; + if (yych == 't') goto yy360; goto yy50; -yy262: +yy270: yych = *++lexer->cursor; if (yych <= 'n') { - if (yych == 'e') goto yy354; + if (yych == 'e') goto yy362; goto yy50; } else { - if (yych <= 'o') goto yy356; - if (yych == 't') goto yy357; + if (yych <= 'o') goto yy364; + if (yych == 't') goto yy365; goto yy50; } -yy263: +yy271: yych = *++lexer->cursor; if (yych <= 'h') { - if (yych == 'a') goto yy359; + if (yych == 'a') goto yy367; goto yy50; } else { - if (yych <= 'i') goto yy360; - if (yych == 'u') goto yy361; + if (yych <= 'i') goto yy368; + if (yych == 'u') goto yy369; goto yy50; } -yy264: +yy272: yych = *++lexer->cursor; - if (yych == 'e') goto yy362; + if (yych == 'e') goto yy370; goto yy50; -yy265: +yy273: yych = *++lexer->cursor; - if (yych == 'e') goto yy364; + if (yych == 'e') goto yy372; goto yy50; -yy266: +yy274: yych = *++lexer->cursor; if (yych <= 's') { - if (yych == 'q') goto yy365; + if (yych == 'q') goto yy373; goto yy50; } else { - if (yych <= 't') goto yy366; - if (yych <= 'u') goto yy367; + if (yych <= 't') goto yy374; + if (yych <= 'u') goto yy375; goto yy50; } -yy267: +yy275: yych = *++lexer->cursor; - if (yych == 'r') goto yy368; + if (yych == 'r') goto yy376; goto yy50; -yy268: +yy276: yych = *++lexer->cursor; - if (yych == 'b') goto yy369; - if (yych == 'd') goto yy370; + if (yych == 'b') goto yy377; + if (yych == 'd') goto yy378; goto yy50; -yy269: +yy277: yych = *++lexer->cursor; - if (yych == 'e') goto yy371; - if (yych == 'o') goto yy372; + if (yych == 'e') goto yy379; + if (yych == 'o') goto yy380; goto yy50; -yy270: +yy278: yych = *++lexer->cursor; - if (yych == 'i') goto yy373; + if (yych == 'i') goto yy381; goto yy50; -yy271: +yy279: yych = *++lexer->cursor; - if (yych == 'q') goto yy374; + if (yych == 'q') goto yy382; goto yy50; -yy272: +yy280: yych = *++lexer->cursor; - if (yych == 'l') goto yy376; + if (yych == 'l') goto yy384; goto yy50; -yy273: +yy281: yych = *++lexer->cursor; - if (yych == 'e') goto yy377; - if (yych == 't') goto yy379; + if (yych == 'e') goto yy385; + if (yych == 't') goto yy387; goto yy50; -yy274: +yy282: yych = *++lexer->cursor; if (yych <= 'n') { - if (yych == 'e') goto yy381; + if (yych == 'e') goto yy389; goto yy50; } else { - if (yych <= 'o') goto yy383; - if (yych == 't') goto yy384; + if (yych <= 'o') goto yy391; + if (yych == 't') goto yy392; goto yy50; } -yy275: +yy283: yych = *++lexer->cursor; if (yych <= 'h') { - if (yych == 'a') goto yy386; + if (yych == 'a') goto yy394; goto yy50; } else { - if (yych <= 'i') goto yy387; - if (yych == 'u') goto yy388; + if (yych <= 'i') goto yy395; + if (yych == 'u') goto yy396; goto yy50; } -yy276: +yy284: yych = *++lexer->cursor; - if (yych == 'e') goto yy389; + if (yych == 'e') goto yy397; goto yy50; -yy277: +yy285: yych = *++lexer->cursor; - if (yych == 'r') goto yy391; + if (yych == 'r') goto yy399; goto yy50; -yy278: +yy286: yych = *++lexer->cursor; - if (yych == 'e') goto yy392; + if (yych == 'e') goto yy400; goto yy50; -yy279: +yy287: yych = *++lexer->cursor; if (yych <= 's') { - if (yych == 'q') goto yy393; + if (yych == 'q') goto yy401; goto yy50; } else { - if (yych <= 't') goto yy394; - if (yych <= 'u') goto yy395; + if (yych <= 't') goto yy402; + if (yych <= 'u') goto yy403; goto yy50; } -yy280: +yy288: yych = *++lexer->cursor; - if (yych == 'r') goto yy396; + if (yych == 'r') goto yy404; goto yy50; -yy281: +yy289: yych = *++lexer->cursor; - if (yych == 'o') goto yy397; + if (yych == 'o') goto yy405; goto yy50; -yy282: +yy290: yych = *++lexer->cursor; - if (yych == 'm') goto yy398; + if (yych == 'm') goto yy406; goto yy50; -yy283: +yy291: yych = *++lexer->cursor; - if (yych == 'd') goto yy399; - if (yych == 'n') goto yy400; + if (yych == 'd') goto yy407; + if (yych == 'n') goto yy408; goto yy50; -yy284: +yy292: yych = *++lexer->cursor; if (yych <= 'n') { - if (yych == 'l') goto yy401; + if (yych == 'l') goto yy409; goto yy50; } else { - if (yych <= 'o') goto yy402; - if (yych == 't') goto yy403; + if (yych <= 'o') goto yy410; + if (yych == 't') goto yy411; goto yy50; } -yy285: +yy293: yych = *++lexer->cursor; - if (yych == 'i') goto yy404; + if (yych == 'i') goto yy412; goto yy50; -yy286: +yy294: yych = *++lexer->cursor; - if (yych == 'q') goto yy405; + if (yych == 'q') goto yy413; goto yy50; -yy287: +yy295: yych = *++lexer->cursor; - if (yych == 'e') goto yy407; - if (yych == 't') goto yy408; + if (yych == 'e') goto yy415; + if (yych == 't') goto yy416; goto yy50; -yy288: +yy296: yych = *++lexer->cursor; if (yych <= 'n') { - if (yych == 'e') goto yy409; + if (yych == 'e') goto yy417; goto yy50; } else { - if (yych <= 'o') goto yy410; - if (yych == 't') goto yy411; + if (yych <= 'o') goto yy418; + if (yych == 't') goto yy419; goto yy50; } -yy289: +yy297: yych = *++lexer->cursor; - if (yych == 'u') goto yy412; + if (yych == 'u') goto yy420; goto yy50; -yy290: +yy298: yych = *++lexer->cursor; - if (yych == 'e') goto yy413; + if (yych == 'e') goto yy421; goto yy50; -yy291: +yy299: yych = *++lexer->cursor; - if (yych == 'r') goto yy415; + if (yych == 'r') goto yy423; goto yy50; -yy292: +yy300: yych = *++lexer->cursor; - if (yych == 'o') goto yy417; + if (yych == 'o') goto yy425; goto yy50; -yy293: +yy301: yych = *++lexer->cursor; - if (yych == 'e') goto yy418; - if (yych == 'o') goto yy419; + if (yych == 'e') goto yy426; + if (yych == 'o') goto yy427; goto yy50; -yy294: +yy302: yych = *++lexer->cursor; if (yych <= 's') { - if (yych == 'h') goto yy420; + if (yych == 'h') goto yy428; goto yy50; } else { - if (yych <= 't') goto yy421; - if (yych <= 'u') goto yy422; + if (yych <= 't') goto yy429; + if (yych <= 'u') goto yy430; goto yy50; } -yy295: +yy303: yych = *++lexer->cursor; - if (yych == 'r') goto yy423; + if (yych == 'r') goto yy431; goto yy50; -yy296: +yy304: yych = *++lexer->cursor; - if (yych == 'r') goto yy424; + if (yych == 'r') goto yy432; goto yy50; -yy297: +yy305: yych = *++lexer->cursor; - if (yych == 'o') goto yy425; + if (yych == 'o') goto yy433; goto yy50; -yy298: +yy306: yych = *++lexer->cursor; - if (yych == 'd') goto yy426; - if (yych == 'n') goto yy427; + if (yych == 'd') goto yy434; + if (yych == 'n') goto yy435; goto yy50; -yy299: +yy307: yych = *++lexer->cursor; if (yych <= 'n') { - if (yych == 'l') goto yy428; + if (yych == 'l') goto yy436; goto yy50; } else { - if (yych <= 'o') goto yy429; - if (yych == 't') goto yy430; + if (yych <= 'o') goto yy437; + if (yych == 't') goto yy438; goto yy50; } -yy300: +yy308: yych = *++lexer->cursor; - if (yych == 'i') goto yy431; + if (yych == 'i') goto yy439; goto yy50; -yy301: +yy309: yych = *++lexer->cursor; - if (yych == 'q') goto yy432; - if (yych == 'x') goto yy434; + if (yych == 'q') goto yy440; + if (yych == 'x') goto yy442; goto yy50; -yy302: +yy310: yych = *++lexer->cursor; - if (yych == 'e') goto yy435; - if (yych == 't') goto yy436; + if (yych == 'e') goto yy443; + if (yych == 't') goto yy444; goto yy50; -yy303: +yy311: yych = *++lexer->cursor; if (yych <= 'n') { - if (yych == 'e') goto yy437; + if (yych == 'e') goto yy445; goto yy50; } else { - if (yych <= 'o') goto yy438; - if (yych == 't') goto yy439; + if (yych <= 'o') goto yy446; + if (yych == 't') goto yy447; goto yy50; } -yy304: +yy312: yych = *++lexer->cursor; - if (yych == 'u') goto yy440; + if (yych == 'u') goto yy448; goto yy50; -yy305: +yy313: yych = *++lexer->cursor; - if (yych == 'e') goto yy441; + if (yych == 'e') goto yy449; goto yy50; -yy306: +yy314: yych = *++lexer->cursor; - if (yych == 'r') goto yy443; + if (yych == 'r') goto yy451; goto yy50; -yy307: +yy315: yych = *++lexer->cursor; - if (yych == 'o') goto yy445; + if (yych == 'o') goto yy453; goto yy50; -yy308: +yy316: yych = *++lexer->cursor; - if (yych == 'e') goto yy446; - if (yych == 'o') goto yy447; + if (yych == 'e') goto yy454; + if (yych == 'o') goto yy455; goto yy50; -yy309: +yy317: yych = *++lexer->cursor; if (yych <= 's') { - if (yych == 'h') goto yy448; + if (yych == 'h') goto yy456; goto yy50; } else { - if (yych <= 't') goto yy449; - if (yych <= 'u') goto yy450; + if (yych <= 't') goto yy457; + if (yych <= 'u') goto yy458; goto yy50; } -yy310: +yy318: yych = *++lexer->cursor; - if (yych == 'r') goto yy451; + if (yych == 'r') goto yy459; goto yy50; -yy311: +yy319: yych = *++lexer->cursor; - if (yych == 'o') goto yy452; + if (yych == 'o') goto yy460; goto yy50; -yy312: +yy320: yych = *++lexer->cursor; - if (yych == 's') goto yy453; + if (yych == 's') goto yy461; goto yy50; -yy313: +yy321: yych = *++lexer->cursor; - if (yych == 't') goto yy454; + if (yych == 't') goto yy462; goto yy50; -yy314: +yy322: yych = *++lexer->cursor; - if (yych == 'i') goto yy456; + if (yych == 'i') goto yy464; goto yy50; -yy315: +yy323: yych = *++lexer->cursor; - if (yych == 'e') goto yy457; + if (yych == 'e') goto yy465; goto yy50; -yy316: +yy324: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 418 "src/wasm-ast-lexer.c" +#line 420 "src/wasm-ast-lexer.c" { RETURN(LOCAL); } -#line 2591 "src/prebuilt/wasm-ast-lexer-gen.c" -yy318: +#line 2629 "src/prebuilt/wasm-ast-lexer-gen.c" +yy326: yych = *++lexer->cursor; - if (yych == 'y') goto yy459; + if (yych == 'y') goto yy467; goto yy50; -yy319: +yy327: yych = *++lexer->cursor; - if (yych == 'e') goto yy461; + if (yych == 'e') goto yy469; goto yy50; -yy320: +yy328: yych = *++lexer->cursor; - if (yych == 'x') goto yy463; + if (yych == 'x') goto yy471; goto yy50; -yy321: +yy329: yych = *++lexer->cursor; - if (yych == 't') goto yy464; + if (yych == 't') goto yy472; goto yy50; -yy322: +yy330: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 416 "src/wasm-ast-lexer.c" +#line 418 "src/wasm-ast-lexer.c" { RETURN(PARAM); } -#line 2615 "src/prebuilt/wasm-ast-lexer-gen.c" -yy324: +#line 2653 "src/prebuilt/wasm-ast-lexer-gen.c" +yy332: yych = *++lexer->cursor; - if (yych == 't') goto yy465; + if (yych == 't') goto yy473; goto yy50; -yy325: +yy333: yych = *++lexer->cursor; - if (yych == 'n') goto yy467; + if (yych == 'n') goto yy475; goto yy50; -yy326: +yy334: yych = *++lexer->cursor; - if (yych == 'n') goto yy469; + if (yych == 'n') goto yy477; goto yy50; -yy327: +yy335: yych = *++lexer->cursor; - if (yych == 't') goto yy470; + if (yych == 't') goto yy478; goto yy50; -yy328: +yy336: yych = *++lexer->cursor; - if (yych == 'o') goto yy472; + if (yych == 'o') goto yy480; goto yy50; -yy329: +yy337: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 422 "src/wasm-ast-lexer.c" +#line 424 "src/wasm-ast-lexer.c" { RETURN(START); } -#line 2643 "src/prebuilt/wasm-ast-lexer-gen.c" -yy331: +#line 2681 "src/prebuilt/wasm-ast-lexer-gen.c" +yy339: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 425 "src/wasm-ast-lexer.c" +#line 427 "src/wasm-ast-lexer.c" { RETURN(TABLE); } -#line 2651 "src/prebuilt/wasm-ast-lexer-gen.c" -yy333: +#line 2689 "src/prebuilt/wasm-ast-lexer-gen.c" +yy341: yych = *++lexer->cursor; - if (yych == 'c') goto yy473; + if (yych == 'c') goto yy481; goto yy50; -yy334: +yy342: yych = *++lexer->cursor; if (yych <= '/') goto yy50; - if (yych <= '9') goto yy474; + if (yych <= '9') goto yy482; goto yy50; -yy335: +yy343: yych = *++lexer->cursor; - if (yych == '_') goto yy477; + if (yych == '_') goto yy485; goto yy50; -yy336: +yy344: yych = *++lexer->cursor; - if (yych == 'l') goto yy478; + if (yych == 'l') goto yy486; goto yy50; -yy337: +yy345: yych = *++lexer->cursor; if (yych <= 'l') goto yy50; - if (yych <= 'm') goto yy479; - if (yych <= 'n') goto yy480; + if (yych <= 'm') goto yy487; + if (yych <= 'n') goto yy488; goto yy50; -yy338: +yy346: yych = *++lexer->cursor; - if (yych == 't') goto yy481; + if (yych == 't') goto yy489; goto yy50; -yy339: +yy347: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 424 "src/wasm-ast-lexer.c" +#line 426 "src/wasm-ast-lexer.c" { RETURN(EXPORT); } -#line 2686 "src/prebuilt/wasm-ast-lexer-gen.c" -yy341: +#line 2724 "src/prebuilt/wasm-ast-lexer-gen.c" +yy349: yych = *++lexer->cursor; - if (yych == 's') goto yy482; + if (yych == 's') goto yy490; goto yy50; -yy342: +yy350: yych = *++lexer->cursor; - if (yych == 'd') goto yy484; + if (yych == 'd') goto yy492; goto yy50; -yy343: +yy351: yych = *++lexer->cursor; - if (yych == 'i') goto yy486; + if (yych == 'i') goto yy494; goto yy50; -yy344: +yy352: yych = *++lexer->cursor; - if (yych == 'n') goto yy487; - if (yych == 'p') goto yy488; + if (yych == 'n') goto yy495; + if (yych == 'p') goto yy496; goto yy50; -yy345: +yy353: yych = *++lexer->cursor; - if (yych == 'm') goto yy489; + if (yych == 'm') goto yy497; goto yy50; -yy346: +yy354: yych = *++lexer->cursor; - if (yych == 'v') goto yy490; + if (yych == 'v') goto yy498; goto yy50; -yy347: +yy355: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 373 "src/wasm-ast-lexer.c" +#line 375 "src/wasm-ast-lexer.c" { OPCODE(F32_EQ); RETURN(COMPARE); } -#line 2719 "src/prebuilt/wasm-ast-lexer-gen.c" -yy349: +#line 2757 "src/prebuilt/wasm-ast-lexer-gen.c" +yy357: yych = *++lexer->cursor; - if (yych == 'o') goto yy492; + if (yych == 'o') goto yy500; goto yy50; -yy350: +yy358: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 383 "src/wasm-ast-lexer.c" +#line 385 "src/wasm-ast-lexer.c" { OPCODE(F32_GE); RETURN(COMPARE); } -#line 2731 "src/prebuilt/wasm-ast-lexer-gen.c" -yy352: +#line 2769 "src/prebuilt/wasm-ast-lexer-gen.c" +yy360: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 381 "src/wasm-ast-lexer.c" +#line 383 "src/wasm-ast-lexer.c" { OPCODE(F32_GT); RETURN(COMPARE); } -#line 2739 "src/prebuilt/wasm-ast-lexer-gen.c" -yy354: +#line 2777 "src/prebuilt/wasm-ast-lexer-gen.c" +yy362: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 379 "src/wasm-ast-lexer.c" +#line 381 "src/wasm-ast-lexer.c" { OPCODE(F32_LE); RETURN(COMPARE); } -#line 2747 "src/prebuilt/wasm-ast-lexer-gen.c" -yy356: +#line 2785 "src/prebuilt/wasm-ast-lexer-gen.c" +yy364: yych = *++lexer->cursor; - if (yych == 'a') goto yy493; + if (yych == 'a') goto yy501; goto yy50; -yy357: +yy365: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 377 "src/wasm-ast-lexer.c" +#line 379 "src/wasm-ast-lexer.c" { OPCODE(F32_LT); RETURN(COMPARE); } -#line 2759 "src/prebuilt/wasm-ast-lexer-gen.c" -yy359: +#line 2797 "src/prebuilt/wasm-ast-lexer-gen.c" +yy367: yych = *++lexer->cursor; - if (yych == 'x') goto yy494; + if (yych == 'x') goto yy502; goto yy50; -yy360: +yy368: yych = *++lexer->cursor; - if (yych == 'n') goto yy496; + if (yych == 'n') goto yy504; goto yy50; -yy361: +yy369: yych = *++lexer->cursor; - if (yych == 'l') goto yy498; + if (yych == 'l') goto yy506; goto yy50; -yy362: +yy370: ++lexer->cursor; if ((yych = *lexer->cursor) <= '[') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy363; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy371; + if (yych <= '\'') goto yy49; } } else { if (yych <= ':') { if (yych != ',') goto yy49; } else { - if (yych <= ';') goto yy363; + if (yych <= ';') goto yy371; if (yych <= 'Z') goto yy49; } } @@ -2791,9 +2829,9 @@ yy362: if (yych <= '`') { if (yych != ']') goto yy49; } else { - if (yych <= 'a') goto yy500; + if (yych <= 'a') goto yy508; if (yych <= 'f') goto yy49; - goto yy501; + goto yy509; } } else { if (yych <= '|') { @@ -2803,126 +2841,126 @@ yy362: } } } -yy363: -#line 375 "src/wasm-ast-lexer.c" +yy371: +#line 377 "src/wasm-ast-lexer.c" { OPCODE(F32_NE); RETURN(COMPARE); } -#line 2810 "src/prebuilt/wasm-ast-lexer-gen.c" -yy364: +#line 2848 "src/prebuilt/wasm-ast-lexer-gen.c" +yy372: yych = *++lexer->cursor; - if (yych == 'i') goto yy503; + if (yych == 'i') goto yy511; goto yy50; -yy365: +yy373: yych = *++lexer->cursor; - if (yych == 'r') goto yy504; + if (yych == 'r') goto yy512; goto yy50; -yy366: +yy374: yych = *++lexer->cursor; - if (yych == 'o') goto yy505; + if (yych == 'o') goto yy513; goto yy50; -yy367: +yy375: yych = *++lexer->cursor; - if (yych == 'b') goto yy506; + if (yych == 'b') goto yy514; goto yy50; -yy368: +yy376: yych = *++lexer->cursor; - if (yych == 'u') goto yy508; + if (yych == 'u') goto yy516; goto yy50; -yy369: +yy377: yych = *++lexer->cursor; - if (yych == 's') goto yy509; + if (yych == 's') goto yy517; goto yy50; -yy370: +yy378: yych = *++lexer->cursor; - if (yych == 'd') goto yy511; + if (yych == 'd') goto yy519; goto yy50; -yy371: +yy379: yych = *++lexer->cursor; - if (yych == 'i') goto yy513; + if (yych == 'i') goto yy521; goto yy50; -yy372: +yy380: yych = *++lexer->cursor; - if (yych == 'n') goto yy514; - if (yych == 'p') goto yy515; + if (yych == 'n') goto yy522; + if (yych == 'p') goto yy523; goto yy50; -yy373: +yy381: yych = *++lexer->cursor; - if (yych == 'v') goto yy516; + if (yych == 'v') goto yy524; goto yy50; -yy374: +yy382: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 374 "src/wasm-ast-lexer.c" +#line 376 "src/wasm-ast-lexer.c" { OPCODE(F64_EQ); RETURN(COMPARE); } -#line 2859 "src/prebuilt/wasm-ast-lexer-gen.c" -yy376: +#line 2897 "src/prebuilt/wasm-ast-lexer-gen.c" +yy384: yych = *++lexer->cursor; - if (yych == 'o') goto yy518; + if (yych == 'o') goto yy526; goto yy50; -yy377: +yy385: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 384 "src/wasm-ast-lexer.c" +#line 386 "src/wasm-ast-lexer.c" { OPCODE(F64_GE); RETURN(COMPARE); } -#line 2871 "src/prebuilt/wasm-ast-lexer-gen.c" -yy379: +#line 2909 "src/prebuilt/wasm-ast-lexer-gen.c" +yy387: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 382 "src/wasm-ast-lexer.c" +#line 384 "src/wasm-ast-lexer.c" { OPCODE(F64_GT); RETURN(COMPARE); } -#line 2879 "src/prebuilt/wasm-ast-lexer-gen.c" -yy381: +#line 2917 "src/prebuilt/wasm-ast-lexer-gen.c" +yy389: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 380 "src/wasm-ast-lexer.c" +#line 382 "src/wasm-ast-lexer.c" { OPCODE(F64_LE); RETURN(COMPARE); } -#line 2887 "src/prebuilt/wasm-ast-lexer-gen.c" -yy383: +#line 2925 "src/prebuilt/wasm-ast-lexer-gen.c" +yy391: yych = *++lexer->cursor; - if (yych == 'a') goto yy519; + if (yych == 'a') goto yy527; goto yy50; -yy384: +yy392: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 378 "src/wasm-ast-lexer.c" +#line 380 "src/wasm-ast-lexer.c" { OPCODE(F64_LT); RETURN(COMPARE); } -#line 2899 "src/prebuilt/wasm-ast-lexer-gen.c" -yy386: +#line 2937 "src/prebuilt/wasm-ast-lexer-gen.c" +yy394: yych = *++lexer->cursor; - if (yych == 'x') goto yy520; + if (yych == 'x') goto yy528; goto yy50; -yy387: +yy395: yych = *++lexer->cursor; - if (yych == 'n') goto yy522; + if (yych == 'n') goto yy530; goto yy50; -yy388: +yy396: yych = *++lexer->cursor; - if (yych == 'l') goto yy524; + if (yych == 'l') goto yy532; goto yy50; -yy389: +yy397: ++lexer->cursor; if ((yych = *lexer->cursor) <= '[') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy390; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy398; + if (yych <= '\'') goto yy49; } } else { if (yych <= ':') { if (yych != ',') goto yy49; } else { - if (yych <= ';') goto yy390; + if (yych <= ';') goto yy398; if (yych <= 'Z') goto yy49; } } @@ -2931,9 +2969,9 @@ yy389: if (yych <= '`') { if (yych != ']') goto yy49; } else { - if (yych <= 'a') goto yy526; + if (yych <= 'a') goto yy534; if (yych <= 'f') goto yy49; - goto yy527; + goto yy535; } } else { if (yych <= '|') { @@ -2943,75 +2981,75 @@ yy389: } } } -yy390: -#line 376 "src/wasm-ast-lexer.c" +yy398: +#line 378 "src/wasm-ast-lexer.c" { OPCODE(F64_NE); RETURN(COMPARE); } -#line 2950 "src/prebuilt/wasm-ast-lexer-gen.c" -yy391: +#line 2988 "src/prebuilt/wasm-ast-lexer-gen.c" +yy399: yych = *++lexer->cursor; - if (yych == 'o') goto yy529; + if (yych == 'o') goto yy537; goto yy50; -yy392: +yy400: yych = *++lexer->cursor; - if (yych == 'i') goto yy530; + if (yych == 'i') goto yy538; goto yy50; -yy393: +yy401: yych = *++lexer->cursor; - if (yych == 'r') goto yy531; + if (yych == 'r') goto yy539; goto yy50; -yy394: +yy402: yych = *++lexer->cursor; - if (yych == 'o') goto yy532; + if (yych == 'o') goto yy540; goto yy50; -yy395: +yy403: yych = *++lexer->cursor; - if (yych == 'b') goto yy533; + if (yych == 'b') goto yy541; goto yy50; -yy396: +yy404: yych = *++lexer->cursor; - if (yych == 'u') goto yy535; + if (yych == 'u') goto yy543; goto yy50; -yy397: +yy405: yych = *++lexer->cursor; - if (yych == 'c') goto yy536; + if (yych == 'c') goto yy544; goto yy50; -yy398: +yy406: yych = *++lexer->cursor; - if (yych == 'e') goto yy537; + if (yych == 'e') goto yy545; goto yy50; -yy399: +yy407: yych = *++lexer->cursor; - if (yych == 'd') goto yy538; + if (yych == 'd') goto yy546; goto yy50; -yy400: +yy408: yych = *++lexer->cursor; - if (yych == 'd') goto yy540; + if (yych == 'd') goto yy548; goto yy50; -yy401: +yy409: yych = *++lexer->cursor; - if (yych == 'z') goto yy542; + if (yych == 'z') goto yy550; goto yy50; -yy402: +yy410: yych = *++lexer->cursor; - if (yych == 'n') goto yy544; + if (yych == 'n') goto yy552; goto yy50; -yy403: +yy411: yych = *++lexer->cursor; - if (yych == 'z') goto yy545; + if (yych == 'z') goto yy553; goto yy50; -yy404: +yy412: yych = *++lexer->cursor; - if (yych == 'v') goto yy547; + if (yych == 'v') goto yy555; goto yy50; -yy405: +yy413: ++lexer->cursor; if ((yych = *lexer->cursor) <= 'Z') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy406; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy414; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { @@ -3025,9 +3063,9 @@ yy405: if (yych <= '\\') { if (yych >= '\\') goto yy49; } else { - if (yych <= ']') goto yy406; + if (yych <= ']') goto yy414; if (yych <= 'y') goto yy49; - goto yy548; + goto yy556; } } else { if (yych <= '|') { @@ -3037,121 +3075,121 @@ yy405: } } } -yy406: -#line 353 "src/wasm-ast-lexer.c" +yy414: +#line 355 "src/wasm-ast-lexer.c" { OPCODE(I32_EQ); RETURN(COMPARE); } -#line 3044 "src/prebuilt/wasm-ast-lexer-gen.c" -yy407: +#line 3082 "src/prebuilt/wasm-ast-lexer-gen.c" +yy415: yych = *++lexer->cursor; - if (yych == '_') goto yy550; + if (yych == '_') goto yy558; goto yy50; -yy408: +yy416: yych = *++lexer->cursor; - if (yych == '_') goto yy551; + if (yych == '_') goto yy559; goto yy50; -yy409: +yy417: yych = *++lexer->cursor; - if (yych == '_') goto yy552; + if (yych == '_') goto yy560; goto yy50; -yy410: +yy418: yych = *++lexer->cursor; - if (yych == 'a') goto yy553; + if (yych == 'a') goto yy561; goto yy50; -yy411: +yy419: yych = *++lexer->cursor; - if (yych == '_') goto yy554; + if (yych == '_') goto yy562; goto yy50; -yy412: +yy420: yych = *++lexer->cursor; - if (yych == 'l') goto yy555; + if (yych == 'l') goto yy563; goto yy50; -yy413: +yy421: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 355 "src/wasm-ast-lexer.c" +#line 357 "src/wasm-ast-lexer.c" { OPCODE(I32_NE); RETURN(COMPARE); } -#line 3076 "src/prebuilt/wasm-ast-lexer-gen.c" -yy415: +#line 3114 "src/prebuilt/wasm-ast-lexer-gen.c" +yy423: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 325 "src/wasm-ast-lexer.c" +#line 327 "src/wasm-ast-lexer.c" { OPCODE(I32_OR); RETURN(BINARY); } -#line 3084 "src/prebuilt/wasm-ast-lexer-gen.c" -yy417: +#line 3122 "src/prebuilt/wasm-ast-lexer-gen.c" +yy425: yych = *++lexer->cursor; - if (yych == 'p') goto yy557; + if (yych == 'p') goto yy565; goto yy50; -yy418: +yy426: yych = *++lexer->cursor; - if (yych == 'i') goto yy558; - if (yych == 'm') goto yy559; + if (yych == 'i') goto yy566; + if (yych == 'm') goto yy567; goto yy50; -yy419: +yy427: yych = *++lexer->cursor; - if (yych == 't') goto yy560; + if (yych == 't') goto yy568; goto yy50; -yy420: +yy428: yych = *++lexer->cursor; - if (yych == 'l') goto yy561; - if (yych == 'r') goto yy563; + if (yych == 'l') goto yy569; + if (yych == 'r') goto yy571; goto yy50; -yy421: +yy429: yych = *++lexer->cursor; - if (yych == 'o') goto yy564; + if (yych == 'o') goto yy572; goto yy50; -yy422: +yy430: yych = *++lexer->cursor; - if (yych == 'b') goto yy565; + if (yych == 'b') goto yy573; goto yy50; -yy423: +yy431: yych = *++lexer->cursor; - if (yych == 'u') goto yy567; + if (yych == 'u') goto yy575; goto yy50; -yy424: +yy432: yych = *++lexer->cursor; - if (yych == 'a') goto yy568; + if (yych == 'a') goto yy576; goto yy50; -yy425: +yy433: yych = *++lexer->cursor; - if (yych == 'r') goto yy569; + if (yych == 'r') goto yy577; goto yy50; -yy426: +yy434: yych = *++lexer->cursor; - if (yych == 'd') goto yy571; + if (yych == 'd') goto yy579; goto yy50; -yy427: +yy435: yych = *++lexer->cursor; - if (yych == 'd') goto yy573; + if (yych == 'd') goto yy581; goto yy50; -yy428: +yy436: yych = *++lexer->cursor; - if (yych == 'z') goto yy575; + if (yych == 'z') goto yy583; goto yy50; -yy429: +yy437: yych = *++lexer->cursor; - if (yych == 'n') goto yy577; + if (yych == 'n') goto yy585; goto yy50; -yy430: +yy438: yych = *++lexer->cursor; - if (yych == 'z') goto yy578; + if (yych == 'z') goto yy586; goto yy50; -yy431: +yy439: yych = *++lexer->cursor; - if (yych == 'v') goto yy580; + if (yych == 'v') goto yy588; goto yy50; -yy432: +yy440: ++lexer->cursor; if ((yych = *lexer->cursor) <= 'Z') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy433; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy441; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { @@ -3165,9 +3203,9 @@ yy432: if (yych <= '\\') { if (yych >= '\\') goto yy49; } else { - if (yych <= ']') goto yy433; + if (yych <= ']') goto yy441; if (yych <= 'y') goto yy49; - goto yy581; + goto yy589; } } else { if (yych <= '|') { @@ -3177,181 +3215,181 @@ yy432: } } } -yy433: -#line 354 "src/wasm-ast-lexer.c" +yy441: +#line 356 "src/wasm-ast-lexer.c" { OPCODE(I64_EQ); RETURN(COMPARE); } -#line 3184 "src/prebuilt/wasm-ast-lexer-gen.c" -yy434: +#line 3222 "src/prebuilt/wasm-ast-lexer-gen.c" +yy442: yych = *++lexer->cursor; - if (yych == 't') goto yy583; + if (yych == 't') goto yy591; goto yy50; -yy435: +yy443: yych = *++lexer->cursor; - if (yych == '_') goto yy584; + if (yych == '_') goto yy592; goto yy50; -yy436: +yy444: yych = *++lexer->cursor; - if (yych == '_') goto yy585; + if (yych == '_') goto yy593; goto yy50; -yy437: +yy445: yych = *++lexer->cursor; - if (yych == '_') goto yy586; + if (yych == '_') goto yy594; goto yy50; -yy438: +yy446: yych = *++lexer->cursor; - if (yych == 'a') goto yy587; + if (yych == 'a') goto yy595; goto yy50; -yy439: +yy447: yych = *++lexer->cursor; - if (yych == '_') goto yy588; + if (yych == '_') goto yy596; goto yy50; -yy440: +yy448: yych = *++lexer->cursor; - if (yych == 'l') goto yy589; + if (yych == 'l') goto yy597; goto yy50; -yy441: +yy449: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 356 "src/wasm-ast-lexer.c" +#line 358 "src/wasm-ast-lexer.c" { OPCODE(I64_NE); RETURN(COMPARE); } -#line 3220 "src/prebuilt/wasm-ast-lexer-gen.c" -yy443: +#line 3258 "src/prebuilt/wasm-ast-lexer-gen.c" +yy451: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 326 "src/wasm-ast-lexer.c" +#line 328 "src/wasm-ast-lexer.c" { OPCODE(I64_OR); RETURN(BINARY); } -#line 3228 "src/prebuilt/wasm-ast-lexer-gen.c" -yy445: +#line 3266 "src/prebuilt/wasm-ast-lexer-gen.c" +yy453: yych = *++lexer->cursor; - if (yych == 'p') goto yy591; + if (yych == 'p') goto yy599; goto yy50; -yy446: +yy454: yych = *++lexer->cursor; - if (yych == 'i') goto yy592; - if (yych == 'm') goto yy593; + if (yych == 'i') goto yy600; + if (yych == 'm') goto yy601; goto yy50; -yy447: +yy455: yych = *++lexer->cursor; - if (yych == 't') goto yy594; + if (yych == 't') goto yy602; goto yy50; -yy448: +yy456: yych = *++lexer->cursor; - if (yych == 'l') goto yy595; - if (yych == 'r') goto yy597; + if (yych == 'l') goto yy603; + if (yych == 'r') goto yy605; goto yy50; -yy449: +yy457: yych = *++lexer->cursor; - if (yych == 'o') goto yy598; + if (yych == 'o') goto yy606; goto yy50; -yy450: +yy458: yych = *++lexer->cursor; - if (yych == 'b') goto yy599; + if (yych == 'b') goto yy607; goto yy50; -yy451: +yy459: yych = *++lexer->cursor; - if (yych == 'u') goto yy601; + if (yych == 'u') goto yy609; goto yy50; -yy452: +yy460: yych = *++lexer->cursor; - if (yych == 'r') goto yy602; + if (yych == 'r') goto yy610; goto yy50; -yy453: +yy461: yych = *++lexer->cursor; - if (yych == 'e') goto yy604; + if (yych == 'e') goto yy612; goto yy50; -yy454: +yy462: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 423 "src/wasm-ast-lexer.c" +#line 425 "src/wasm-ast-lexer.c" { RETURN(IMPORT); } -#line 3274 "src/prebuilt/wasm-ast-lexer-gen.c" -yy456: +#line 3312 "src/prebuilt/wasm-ast-lexer-gen.c" +yy464: yych = *++lexer->cursor; - if (yych == 't') goto yy606; + if (yych == 't') goto yy614; goto yy50; -yy457: +yy465: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 430 "src/wasm-ast-lexer.c" +#line 432 "src/wasm-ast-lexer.c" { RETURN(INVOKE); } -#line 3286 "src/prebuilt/wasm-ast-lexer-gen.c" -yy459: +#line 3324 "src/prebuilt/wasm-ast-lexer-gen.c" +yy467: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 420 "src/wasm-ast-lexer.c" +#line 422 "src/wasm-ast-lexer.c" { RETURN(MEMORY); } -#line 3294 "src/prebuilt/wasm-ast-lexer-gen.c" -yy461: +#line 3332 "src/prebuilt/wasm-ast-lexer-gen.c" +yy469: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 419 "src/wasm-ast-lexer.c" +#line 421 "src/wasm-ast-lexer.c" { RETURN(MODULE); } -#line 3302 "src/prebuilt/wasm-ast-lexer-gen.c" -yy463: +#line 3340 "src/prebuilt/wasm-ast-lexer-gen.c" +yy471: yych = *++lexer->cursor; if (yych <= '@') { if (yych <= '/') goto yy50; - if (yych <= '9') goto yy607; + if (yych <= '9') goto yy615; goto yy50; } else { - if (yych <= 'F') goto yy607; + if (yych <= 'F') goto yy615; if (yych <= '`') goto yy50; - if (yych <= 'f') goto yy607; + if (yych <= 'f') goto yy615; goto yy50; } -yy464: +yy472: yych = *++lexer->cursor; - if (yych == '=') goto yy609; + if (yych == '=') goto yy617; goto yy50; -yy465: +yy473: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 417 "src/wasm-ast-lexer.c" +#line 419 "src/wasm-ast-lexer.c" { RETURN(RESULT); } -#line 3326 "src/prebuilt/wasm-ast-lexer-gen.c" -yy467: +#line 3364 "src/prebuilt/wasm-ast-lexer-gen.c" +yy475: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 255 "src/wasm-ast-lexer.c" +#line 257 "src/wasm-ast-lexer.c" { RETURN(RETURN); } -#line 3334 "src/prebuilt/wasm-ast-lexer-gen.c" -yy469: +#line 3372 "src/prebuilt/wasm-ast-lexer-gen.c" +yy477: yych = *++lexer->cursor; - if (yych == 't') goto yy610; + if (yych == 't') goto yy618; goto yy50; -yy470: +yy478: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 410 "src/wasm-ast-lexer.c" +#line 412 "src/wasm-ast-lexer.c" { RETURN(SELECT); } -#line 3346 "src/prebuilt/wasm-ast-lexer-gen.c" -yy472: +#line 3384 "src/prebuilt/wasm-ast-lexer-gen.c" +yy480: yych = *++lexer->cursor; - if (yych == 'c') goto yy612; + if (yych == 'c') goto yy620; goto yy50; -yy473: +yy481: yych = *++lexer->cursor; - if (yych == 'h') goto yy613; + if (yych == 'h') goto yy621; goto yy50; -yy474: +yy482: ++lexer->cursor; if (lexer->limit <= lexer->cursor) FILL(1); yych = *lexer->cursor; @@ -3360,15 +3398,15 @@ yy474: if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy476; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy484; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { if (yych <= '+') goto yy49; } else { if (yych <= '/') goto yy49; - if (yych <= '9') goto yy474; + if (yych <= '9') goto yy482; goto yy49; } } @@ -3387,549 +3425,549 @@ yy474: } } } -yy476: -#line 282 "src/wasm-ast-lexer.c" +yy484: +#line 284 "src/wasm-ast-lexer.c" { TEXT_AT(6); RETURN(ALIGN); } -#line 3394 "src/prebuilt/wasm-ast-lexer-gen.c" -yy477: +#line 3432 "src/prebuilt/wasm-ast-lexer-gen.c" +yy485: yych = *++lexer->cursor; if (yych <= 'q') { - if (yych == 'i') goto yy614; + if (yych == 'i') goto yy622; goto yy50; } else { - if (yych <= 'r') goto yy615; - if (yych == 't') goto yy616; + if (yych <= 'r') goto yy623; + if (yych == 't') goto yy624; goto yy50; } -yy478: +yy486: yych = *++lexer->cursor; - if (yych == 'e') goto yy617; + if (yych == 'e') goto yy625; goto yy50; -yy479: +yy487: yych = *++lexer->cursor; - if (yych == 'p') goto yy619; + if (yych == 'p') goto yy627; goto yy50; -yy480: +yy488: yych = *++lexer->cursor; - if (yych == 'd') goto yy620; + if (yych == 'd') goto yy628; goto yy50; -yy481: +yy489: yych = *++lexer->cursor; - if (yych == '_') goto yy621; + if (yych == '_') goto yy629; goto yy50; -yy482: +yy490: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 297 "src/wasm-ast-lexer.c" +#line 299 "src/wasm-ast-lexer.c" { OPCODE(F32_ABS); RETURN(UNARY); } -#line 3428 "src/prebuilt/wasm-ast-lexer-gen.c" -yy484: +#line 3466 "src/prebuilt/wasm-ast-lexer-gen.c" +yy492: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 339 "src/wasm-ast-lexer.c" +#line 341 "src/wasm-ast-lexer.c" { OPCODE(F32_ADD); RETURN(BINARY); } -#line 3436 "src/prebuilt/wasm-ast-lexer-gen.c" -yy486: +#line 3474 "src/prebuilt/wasm-ast-lexer-gen.c" +yy494: yych = *++lexer->cursor; - if (yych == 'l') goto yy622; + if (yych == 'l') goto yy630; goto yy50; -yy487: +yy495: yych = *++lexer->cursor; - if (yych == 's') goto yy624; - if (yych == 'v') goto yy625; + if (yych == 's') goto yy632; + if (yych == 'v') goto yy633; goto yy50; -yy488: +yy496: yych = *++lexer->cursor; - if (yych == 'y') goto yy626; + if (yych == 'y') goto yy634; goto yy50; -yy489: +yy497: yych = *++lexer->cursor; - if (yych == 'o') goto yy627; + if (yych == 'o') goto yy635; goto yy50; -yy490: +yy498: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 345 "src/wasm-ast-lexer.c" +#line 347 "src/wasm-ast-lexer.c" { OPCODE(F32_DIV); RETURN(BINARY); } -#line 3461 "src/prebuilt/wasm-ast-lexer-gen.c" -yy492: +#line 3499 "src/prebuilt/wasm-ast-lexer-gen.c" +yy500: yych = *++lexer->cursor; - if (yych == 'o') goto yy628; + if (yych == 'o') goto yy636; goto yy50; -yy493: +yy501: yych = *++lexer->cursor; - if (yych == 'd') goto yy629; + if (yych == 'd') goto yy637; goto yy50; -yy494: +yy502: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 349 "src/wasm-ast-lexer.c" +#line 351 "src/wasm-ast-lexer.c" { OPCODE(F32_MAX); RETURN(BINARY); } -#line 3477 "src/prebuilt/wasm-ast-lexer-gen.c" -yy496: +#line 3515 "src/prebuilt/wasm-ast-lexer-gen.c" +yy504: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 347 "src/wasm-ast-lexer.c" +#line 349 "src/wasm-ast-lexer.c" { OPCODE(F32_MIN); RETURN(BINARY); } -#line 3485 "src/prebuilt/wasm-ast-lexer-gen.c" -yy498: +#line 3523 "src/prebuilt/wasm-ast-lexer-gen.c" +yy506: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 343 "src/wasm-ast-lexer.c" +#line 345 "src/wasm-ast-lexer.c" { OPCODE(F32_MUL); RETURN(BINARY); } -#line 3493 "src/prebuilt/wasm-ast-lexer-gen.c" -yy500: +#line 3531 "src/prebuilt/wasm-ast-lexer-gen.c" +yy508: yych = *++lexer->cursor; - if (yych == 'r') goto yy631; + if (yych == 'r') goto yy639; goto yy50; -yy501: +yy509: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 295 "src/wasm-ast-lexer.c" +#line 297 "src/wasm-ast-lexer.c" { OPCODE(F32_NEG); RETURN(UNARY); } -#line 3505 "src/prebuilt/wasm-ast-lexer-gen.c" -yy503: +#line 3543 "src/prebuilt/wasm-ast-lexer-gen.c" +yy511: yych = *++lexer->cursor; - if (yych == 'n') goto yy632; + if (yych == 'n') goto yy640; goto yy50; -yy504: +yy512: yych = *++lexer->cursor; - if (yych == 't') goto yy633; + if (yych == 't') goto yy641; goto yy50; -yy505: +yy513: yych = *++lexer->cursor; - if (yych == 'r') goto yy635; + if (yych == 'r') goto yy643; goto yy50; -yy506: +yy514: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 341 "src/wasm-ast-lexer.c" +#line 343 "src/wasm-ast-lexer.c" { OPCODE(F32_SUB); RETURN(BINARY); } -#line 3525 "src/prebuilt/wasm-ast-lexer-gen.c" -yy508: +#line 3563 "src/prebuilt/wasm-ast-lexer-gen.c" +yy516: yych = *++lexer->cursor; - if (yych == 'n') goto yy636; + if (yych == 'n') goto yy644; goto yy50; -yy509: +yy517: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 298 "src/wasm-ast-lexer.c" +#line 300 "src/wasm-ast-lexer.c" { OPCODE(F64_ABS); RETURN(UNARY); } -#line 3537 "src/prebuilt/wasm-ast-lexer-gen.c" -yy511: +#line 3575 "src/prebuilt/wasm-ast-lexer-gen.c" +yy519: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 340 "src/wasm-ast-lexer.c" +#line 342 "src/wasm-ast-lexer.c" { OPCODE(F64_ADD); RETURN(BINARY); } -#line 3545 "src/prebuilt/wasm-ast-lexer-gen.c" -yy513: +#line 3583 "src/prebuilt/wasm-ast-lexer-gen.c" +yy521: yych = *++lexer->cursor; - if (yych == 'l') goto yy637; + if (yych == 'l') goto yy645; goto yy50; -yy514: +yy522: yych = *++lexer->cursor; - if (yych == 's') goto yy639; - if (yych == 'v') goto yy640; + if (yych == 's') goto yy647; + if (yych == 'v') goto yy648; goto yy50; -yy515: +yy523: yych = *++lexer->cursor; - if (yych == 'y') goto yy641; + if (yych == 'y') goto yy649; goto yy50; -yy516: +yy524: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 346 "src/wasm-ast-lexer.c" +#line 348 "src/wasm-ast-lexer.c" { OPCODE(F64_DIV); RETURN(BINARY); } -#line 3566 "src/prebuilt/wasm-ast-lexer-gen.c" -yy518: +#line 3604 "src/prebuilt/wasm-ast-lexer-gen.c" +yy526: yych = *++lexer->cursor; - if (yych == 'o') goto yy642; + if (yych == 'o') goto yy650; goto yy50; -yy519: +yy527: yych = *++lexer->cursor; - if (yych == 'd') goto yy643; + if (yych == 'd') goto yy651; goto yy50; -yy520: +yy528: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 350 "src/wasm-ast-lexer.c" +#line 352 "src/wasm-ast-lexer.c" { OPCODE(F64_MAX); RETURN(BINARY); } -#line 3582 "src/prebuilt/wasm-ast-lexer-gen.c" -yy522: +#line 3620 "src/prebuilt/wasm-ast-lexer-gen.c" +yy530: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 348 "src/wasm-ast-lexer.c" +#line 350 "src/wasm-ast-lexer.c" { OPCODE(F64_MIN); RETURN(BINARY); } -#line 3590 "src/prebuilt/wasm-ast-lexer-gen.c" -yy524: +#line 3628 "src/prebuilt/wasm-ast-lexer-gen.c" +yy532: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 344 "src/wasm-ast-lexer.c" +#line 346 "src/wasm-ast-lexer.c" { OPCODE(F64_MUL); RETURN(BINARY); } -#line 3598 "src/prebuilt/wasm-ast-lexer-gen.c" -yy526: +#line 3636 "src/prebuilt/wasm-ast-lexer-gen.c" +yy534: yych = *++lexer->cursor; - if (yych == 'r') goto yy645; + if (yych == 'r') goto yy653; goto yy50; -yy527: +yy535: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 296 "src/wasm-ast-lexer.c" +#line 298 "src/wasm-ast-lexer.c" { OPCODE(F64_NEG); RETURN(UNARY); } -#line 3610 "src/prebuilt/wasm-ast-lexer-gen.c" -yy529: +#line 3648 "src/prebuilt/wasm-ast-lexer-gen.c" +yy537: yych = *++lexer->cursor; - if (yych == 'm') goto yy646; + if (yych == 'm') goto yy654; goto yy50; -yy530: +yy538: yych = *++lexer->cursor; - if (yych == 'n') goto yy647; + if (yych == 'n') goto yy655; goto yy50; -yy531: +yy539: yych = *++lexer->cursor; - if (yych == 't') goto yy648; + if (yych == 't') goto yy656; goto yy50; -yy532: +yy540: yych = *++lexer->cursor; - if (yych == 'r') goto yy650; + if (yych == 'r') goto yy658; goto yy50; -yy533: +yy541: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 342 "src/wasm-ast-lexer.c" +#line 344 "src/wasm-ast-lexer.c" { OPCODE(F64_SUB); RETURN(BINARY); } -#line 3634 "src/prebuilt/wasm-ast-lexer-gen.c" -yy535: +#line 3672 "src/prebuilt/wasm-ast-lexer-gen.c" +yy543: yych = *++lexer->cursor; - if (yych == 'n') goto yy651; + if (yych == 'n') goto yy659; goto yy50; -yy536: +yy544: yych = *++lexer->cursor; - if (yych == 'a') goto yy652; + if (yych == 'a') goto yy660; goto yy50; -yy537: +yy545: yych = *++lexer->cursor; - if (yych == 'm') goto yy653; + if (yych == 'm') goto yy661; goto yy50; -yy538: +yy546: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 309 "src/wasm-ast-lexer.c" +#line 311 "src/wasm-ast-lexer.c" { OPCODE(I32_ADD); RETURN(BINARY); } -#line 3654 "src/prebuilt/wasm-ast-lexer-gen.c" -yy540: +#line 3692 "src/prebuilt/wasm-ast-lexer-gen.c" +yy548: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 323 "src/wasm-ast-lexer.c" +#line 325 "src/wasm-ast-lexer.c" { OPCODE(I32_AND); RETURN(BINARY); } -#line 3662 "src/prebuilt/wasm-ast-lexer-gen.c" -yy542: +#line 3700 "src/prebuilt/wasm-ast-lexer-gen.c" +yy550: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 289 "src/wasm-ast-lexer.c" +#line 291 "src/wasm-ast-lexer.c" { OPCODE(I32_CLZ); RETURN(UNARY); } -#line 3670 "src/prebuilt/wasm-ast-lexer-gen.c" -yy544: +#line 3708 "src/prebuilt/wasm-ast-lexer-gen.c" +yy552: yych = *++lexer->cursor; - if (yych == 's') goto yy654; + if (yych == 's') goto yy662; goto yy50; -yy545: +yy553: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 291 "src/wasm-ast-lexer.c" +#line 293 "src/wasm-ast-lexer.c" { OPCODE(I32_CTZ); RETURN(UNARY); } -#line 3682 "src/prebuilt/wasm-ast-lexer-gen.c" -yy547: +#line 3720 "src/prebuilt/wasm-ast-lexer-gen.c" +yy555: yych = *++lexer->cursor; - if (yych == '_') goto yy655; + if (yych == '_') goto yy663; goto yy50; -yy548: +yy556: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 287 "src/wasm-ast-lexer.c" +#line 289 "src/wasm-ast-lexer.c" { OPCODE(I32_EQZ); RETURN(CONVERT); } -#line 3694 "src/prebuilt/wasm-ast-lexer-gen.c" -yy550: +#line 3732 "src/prebuilt/wasm-ast-lexer-gen.c" +yy558: yych = *++lexer->cursor; - if (yych == 's') goto yy656; - if (yych == 'u') goto yy658; + if (yych == 's') goto yy664; + if (yych == 'u') goto yy666; goto yy50; -yy551: +yy559: yych = *++lexer->cursor; - if (yych == 's') goto yy660; - if (yych == 'u') goto yy662; + if (yych == 's') goto yy668; + if (yych == 'u') goto yy670; goto yy50; -yy552: +yy560: yych = *++lexer->cursor; - if (yych == 's') goto yy664; - if (yych == 'u') goto yy666; + if (yych == 's') goto yy672; + if (yych == 'u') goto yy674; goto yy50; -yy553: +yy561: yych = *++lexer->cursor; - if (yych == 'd') goto yy668; + if (yych == 'd') goto yy676; goto yy50; -yy554: +yy562: yych = *++lexer->cursor; - if (yych == 's') goto yy670; - if (yych == 'u') goto yy672; + if (yych == 's') goto yy678; + if (yych == 'u') goto yy680; goto yy50; -yy555: +yy563: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 313 "src/wasm-ast-lexer.c" +#line 315 "src/wasm-ast-lexer.c" { OPCODE(I32_MUL); RETURN(BINARY); } -#line 3726 "src/prebuilt/wasm-ast-lexer-gen.c" -yy557: +#line 3764 "src/prebuilt/wasm-ast-lexer-gen.c" +yy565: yych = *++lexer->cursor; - if (yych == 'c') goto yy674; + if (yych == 'c') goto yy682; goto yy50; -yy558: +yy566: yych = *++lexer->cursor; - if (yych == 'n') goto yy675; + if (yych == 'n') goto yy683; goto yy50; -yy559: +yy567: yych = *++lexer->cursor; - if (yych == '_') goto yy676; + if (yych == '_') goto yy684; goto yy50; -yy560: +yy568: yych = *++lexer->cursor; - if (yych == 'l') goto yy677; - if (yych == 'r') goto yy679; + if (yych == 'l') goto yy685; + if (yych == 'r') goto yy687; goto yy50; -yy561: +yy569: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 329 "src/wasm-ast-lexer.c" +#line 331 "src/wasm-ast-lexer.c" { OPCODE(I32_SHL); RETURN(BINARY); } -#line 3751 "src/prebuilt/wasm-ast-lexer-gen.c" -yy563: +#line 3789 "src/prebuilt/wasm-ast-lexer-gen.c" +yy571: yych = *++lexer->cursor; - if (yych == '_') goto yy681; + if (yych == '_') goto yy689; goto yy50; -yy564: +yy572: yych = *++lexer->cursor; - if (yych == 'r') goto yy682; + if (yych == 'r') goto yy690; goto yy50; -yy565: +yy573: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 311 "src/wasm-ast-lexer.c" +#line 313 "src/wasm-ast-lexer.c" { OPCODE(I32_SUB); RETURN(BINARY); } -#line 3767 "src/prebuilt/wasm-ast-lexer-gen.c" -yy567: +#line 3805 "src/prebuilt/wasm-ast-lexer-gen.c" +yy575: yych = *++lexer->cursor; - if (yych == 'n') goto yy683; + if (yych == 'n') goto yy691; goto yy50; -yy568: +yy576: yych = *++lexer->cursor; - if (yych == 'p') goto yy684; + if (yych == 'p') goto yy692; goto yy50; -yy569: +yy577: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 327 "src/wasm-ast-lexer.c" +#line 329 "src/wasm-ast-lexer.c" { OPCODE(I32_XOR); RETURN(BINARY); } -#line 3783 "src/prebuilt/wasm-ast-lexer-gen.c" -yy571: +#line 3821 "src/prebuilt/wasm-ast-lexer-gen.c" +yy579: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 310 "src/wasm-ast-lexer.c" +#line 312 "src/wasm-ast-lexer.c" { OPCODE(I64_ADD); RETURN(BINARY); } -#line 3791 "src/prebuilt/wasm-ast-lexer-gen.c" -yy573: +#line 3829 "src/prebuilt/wasm-ast-lexer-gen.c" +yy581: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 324 "src/wasm-ast-lexer.c" +#line 326 "src/wasm-ast-lexer.c" { OPCODE(I64_AND); RETURN(BINARY); } -#line 3799 "src/prebuilt/wasm-ast-lexer-gen.c" -yy575: +#line 3837 "src/prebuilt/wasm-ast-lexer-gen.c" +yy583: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 290 "src/wasm-ast-lexer.c" +#line 292 "src/wasm-ast-lexer.c" { OPCODE(I64_CLZ); RETURN(UNARY); } -#line 3807 "src/prebuilt/wasm-ast-lexer-gen.c" -yy577: +#line 3845 "src/prebuilt/wasm-ast-lexer-gen.c" +yy585: yych = *++lexer->cursor; - if (yych == 's') goto yy685; + if (yych == 's') goto yy693; goto yy50; -yy578: +yy586: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 292 "src/wasm-ast-lexer.c" +#line 294 "src/wasm-ast-lexer.c" { OPCODE(I64_CTZ); RETURN(UNARY); } -#line 3819 "src/prebuilt/wasm-ast-lexer-gen.c" -yy580: +#line 3857 "src/prebuilt/wasm-ast-lexer-gen.c" +yy588: yych = *++lexer->cursor; - if (yych == '_') goto yy686; + if (yych == '_') goto yy694; goto yy50; -yy581: +yy589: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 288 "src/wasm-ast-lexer.c" +#line 290 "src/wasm-ast-lexer.c" { OPCODE(I64_EQZ); RETURN(CONVERT); } -#line 3831 "src/prebuilt/wasm-ast-lexer-gen.c" -yy583: +#line 3869 "src/prebuilt/wasm-ast-lexer-gen.c" +yy591: yych = *++lexer->cursor; - if (yych == 'e') goto yy687; + if (yych == 'e') goto yy695; goto yy50; -yy584: +yy592: yych = *++lexer->cursor; - if (yych == 's') goto yy688; - if (yych == 'u') goto yy690; + if (yych == 's') goto yy696; + if (yych == 'u') goto yy698; goto yy50; -yy585: +yy593: yych = *++lexer->cursor; - if (yych == 's') goto yy692; - if (yych == 'u') goto yy694; + if (yych == 's') goto yy700; + if (yych == 'u') goto yy702; goto yy50; -yy586: +yy594: yych = *++lexer->cursor; - if (yych == 's') goto yy696; - if (yych == 'u') goto yy698; + if (yych == 's') goto yy704; + if (yych == 'u') goto yy706; goto yy50; -yy587: +yy595: yych = *++lexer->cursor; - if (yych == 'd') goto yy700; + if (yych == 'd') goto yy708; goto yy50; -yy588: +yy596: yych = *++lexer->cursor; - if (yych == 's') goto yy702; - if (yych == 'u') goto yy704; + if (yych == 's') goto yy710; + if (yych == 'u') goto yy712; goto yy50; -yy589: +yy597: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 314 "src/wasm-ast-lexer.c" +#line 316 "src/wasm-ast-lexer.c" { OPCODE(I64_MUL); RETURN(BINARY); } -#line 3867 "src/prebuilt/wasm-ast-lexer-gen.c" -yy591: +#line 3905 "src/prebuilt/wasm-ast-lexer-gen.c" +yy599: yych = *++lexer->cursor; - if (yych == 'c') goto yy706; + if (yych == 'c') goto yy714; goto yy50; -yy592: +yy600: yych = *++lexer->cursor; - if (yych == 'n') goto yy707; + if (yych == 'n') goto yy715; goto yy50; -yy593: +yy601: yych = *++lexer->cursor; - if (yych == '_') goto yy708; + if (yych == '_') goto yy716; goto yy50; -yy594: +yy602: yych = *++lexer->cursor; - if (yych == 'l') goto yy709; - if (yych == 'r') goto yy711; + if (yych == 'l') goto yy717; + if (yych == 'r') goto yy719; goto yy50; -yy595: +yy603: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 330 "src/wasm-ast-lexer.c" +#line 332 "src/wasm-ast-lexer.c" { OPCODE(I64_SHL); RETURN(BINARY); } -#line 3892 "src/prebuilt/wasm-ast-lexer-gen.c" -yy597: +#line 3930 "src/prebuilt/wasm-ast-lexer-gen.c" +yy605: yych = *++lexer->cursor; - if (yych == '_') goto yy713; + if (yych == '_') goto yy721; goto yy50; -yy598: +yy606: yych = *++lexer->cursor; - if (yych == 'r') goto yy714; + if (yych == 'r') goto yy722; goto yy50; -yy599: +yy607: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 312 "src/wasm-ast-lexer.c" +#line 314 "src/wasm-ast-lexer.c" { OPCODE(I64_SUB); RETURN(BINARY); } -#line 3908 "src/prebuilt/wasm-ast-lexer-gen.c" -yy601: +#line 3946 "src/prebuilt/wasm-ast-lexer-gen.c" +yy609: yych = *++lexer->cursor; - if (yych == 'n') goto yy715; + if (yych == 'n') goto yy723; goto yy50; -yy602: +yy610: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 328 "src/wasm-ast-lexer.c" +#line 330 "src/wasm-ast-lexer.c" { OPCODE(I64_XOR); RETURN(BINARY); } -#line 3920 "src/prebuilt/wasm-ast-lexer-gen.c" -yy604: +#line 3958 "src/prebuilt/wasm-ast-lexer-gen.c" +yy612: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } #line 244 "src/wasm-ast-lexer.c" { RETURN(IF); } -#line 3928 "src/prebuilt/wasm-ast-lexer-gen.c" -yy606: +#line 3966 "src/prebuilt/wasm-ast-lexer-gen.c" +yy614: yych = *++lexer->cursor; - if (yych == 'y') goto yy716; + if (yych == 'y') goto yy724; goto yy50; -yy607: +yy615: ++lexer->cursor; if (lexer->limit <= lexer->cursor) FILL(1); yych = *lexer->cursor; @@ -3937,299 +3975,299 @@ yy607: if (yych <= '+') { if (yych <= '"') { if (yych == '!') goto yy49; - goto yy177; + goto yy183; } else { - if (yych <= '&') goto yy49; - if (yych <= ')') goto yy177; + if (yych <= '\'') goto yy49; + if (yych <= ')') goto yy183; goto yy49; } } else { if (yych <= '9') { - if (yych <= ',') goto yy177; + if (yych <= ',') goto yy183; if (yych <= '/') goto yy49; - goto yy607; + goto yy615; } else { - if (yych == ';') goto yy177; + if (yych == ';') goto yy183; goto yy49; } } } else { if (yych <= '`') { if (yych <= '[') { - if (yych <= 'F') goto yy607; + if (yych <= 'F') goto yy615; if (yych <= 'Z') goto yy49; - goto yy177; + goto yy183; } else { - if (yych == ']') goto yy177; + if (yych == ']') goto yy183; goto yy49; } } else { if (yych <= '{') { - if (yych <= 'f') goto yy607; + if (yych <= 'f') goto yy615; if (yych <= 'z') goto yy49; - goto yy177; + goto yy183; } else { - if (yych == '}') goto yy177; + if (yych == '}') goto yy183; if (yych <= '~') goto yy49; - goto yy177; + goto yy183; } } } -yy609: +yy617: yych = *++lexer->cursor; if (yych <= '/') goto yy50; - if (yych <= '9') goto yy717; + if (yych <= '9') goto yy725; goto yy50; -yy610: +yy618: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 421 "src/wasm-ast-lexer.c" +#line 423 "src/wasm-ast-lexer.c" { RETURN(SEGMENT); } -#line 3991 "src/prebuilt/wasm-ast-lexer-gen.c" -yy612: +#line 4029 "src/prebuilt/wasm-ast-lexer-gen.c" +yy620: yych = *++lexer->cursor; - if (yych == 'a') goto yy720; + if (yych == 'a') goto yy728; goto yy50; -yy613: +yy621: yych = *++lexer->cursor; - if (yych == 'a') goto yy721; + if (yych == 'a') goto yy729; goto yy50; -yy614: +yy622: yych = *++lexer->cursor; - if (yych == 'n') goto yy722; + if (yych == 'n') goto yy730; goto yy50; -yy615: +yy623: yych = *++lexer->cursor; - if (yych == 'e') goto yy723; + if (yych == 'e') goto yy731; goto yy50; -yy616: +yy624: yych = *++lexer->cursor; - if (yych == 'r') goto yy724; + if (yych == 'r') goto yy732; goto yy50; -yy617: +yy625: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } #line 250 "src/wasm-ast-lexer.c" { RETURN(BR_TABLE); } -#line 4019 "src/prebuilt/wasm-ast-lexer-gen.c" -yy619: +#line 4057 "src/prebuilt/wasm-ast-lexer-gen.c" +yy627: yych = *++lexer->cursor; - if (yych == 'o') goto yy725; + if (yych == 'o') goto yy733; goto yy50; -yy620: +yy628: yych = *++lexer->cursor; - if (yych == 'i') goto yy726; + if (yych == 'i') goto yy734; goto yy50; -yy621: +yy629: yych = *++lexer->cursor; - if (yych == 'm') goto yy727; + if (yych == 'm') goto yy735; goto yy50; -yy622: +yy630: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 301 "src/wasm-ast-lexer.c" +#line 303 "src/wasm-ast-lexer.c" { OPCODE(F32_CEIL); RETURN(UNARY); } -#line 4039 "src/prebuilt/wasm-ast-lexer-gen.c" -yy624: +#line 4077 "src/prebuilt/wasm-ast-lexer-gen.c" +yy632: yych = *++lexer->cursor; - if (yych == 't') goto yy728; + if (yych == 't') goto yy736; goto yy50; -yy625: +yy633: yych = *++lexer->cursor; - if (yych == 'e') goto yy730; + if (yych == 'e') goto yy738; goto yy50; -yy626: +yy634: yych = *++lexer->cursor; - if (yych == 's') goto yy731; + if (yych == 's') goto yy739; goto yy50; -yy627: +yy635: yych = *++lexer->cursor; - if (yych == 't') goto yy732; + if (yych == 't') goto yy740; goto yy50; -yy628: +yy636: yych = *++lexer->cursor; - if (yych == 'r') goto yy733; + if (yych == 'r') goto yy741; goto yy50; -yy629: +yy637: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 260 "src/wasm-ast-lexer.c" +#line 262 "src/wasm-ast-lexer.c" { OPCODE(F32_LOAD); RETURN(LOAD); } -#line 4067 "src/prebuilt/wasm-ast-lexer-gen.c" -yy631: +#line 4105 "src/prebuilt/wasm-ast-lexer-gen.c" +yy639: yych = *++lexer->cursor; - if (yych == 'e') goto yy735; + if (yych == 'e') goto yy743; goto yy50; -yy632: +yy640: yych = *++lexer->cursor; - if (yych == 't') goto yy736; + if (yych == 't') goto yy744; goto yy50; -yy633: +yy641: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 299 "src/wasm-ast-lexer.c" +#line 301 "src/wasm-ast-lexer.c" { OPCODE(F32_SQRT); RETURN(UNARY); } -#line 4083 "src/prebuilt/wasm-ast-lexer-gen.c" -yy635: +#line 4121 "src/prebuilt/wasm-ast-lexer-gen.c" +yy643: yych = *++lexer->cursor; - if (yych == 'e') goto yy737; + if (yych == 'e') goto yy745; goto yy50; -yy636: +yy644: yych = *++lexer->cursor; - if (yych == 'c') goto yy739; + if (yych == 'c') goto yy747; goto yy50; -yy637: +yy645: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 302 "src/wasm-ast-lexer.c" +#line 304 "src/wasm-ast-lexer.c" { OPCODE(F64_CEIL); RETURN(UNARY); } -#line 4099 "src/prebuilt/wasm-ast-lexer-gen.c" -yy639: +#line 4137 "src/prebuilt/wasm-ast-lexer-gen.c" +yy647: yych = *++lexer->cursor; - if (yych == 't') goto yy741; + if (yych == 't') goto yy749; goto yy50; -yy640: +yy648: yych = *++lexer->cursor; - if (yych == 'e') goto yy743; + if (yych == 'e') goto yy751; goto yy50; -yy641: +yy649: yych = *++lexer->cursor; - if (yych == 's') goto yy744; + if (yych == 's') goto yy752; goto yy50; -yy642: +yy650: yych = *++lexer->cursor; - if (yych == 'r') goto yy745; + if (yych == 'r') goto yy753; goto yy50; -yy643: +yy651: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 261 "src/wasm-ast-lexer.c" +#line 263 "src/wasm-ast-lexer.c" { OPCODE(F64_LOAD); RETURN(LOAD); } -#line 4123 "src/prebuilt/wasm-ast-lexer-gen.c" -yy645: +#line 4161 "src/prebuilt/wasm-ast-lexer-gen.c" +yy653: yych = *++lexer->cursor; - if (yych == 'e') goto yy747; + if (yych == 'e') goto yy755; goto yy50; -yy646: +yy654: yych = *++lexer->cursor; - if (yych == 'o') goto yy748; + if (yych == 'o') goto yy756; goto yy50; -yy647: +yy655: yych = *++lexer->cursor; - if (yych == 't') goto yy749; + if (yych == 't') goto yy757; goto yy50; -yy648: +yy656: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 300 "src/wasm-ast-lexer.c" +#line 302 "src/wasm-ast-lexer.c" { OPCODE(F64_SQRT); RETURN(UNARY); } -#line 4143 "src/prebuilt/wasm-ast-lexer-gen.c" -yy650: +#line 4181 "src/prebuilt/wasm-ast-lexer-gen.c" +yy658: yych = *++lexer->cursor; - if (yych == 'e') goto yy750; + if (yych == 'e') goto yy758; goto yy50; -yy651: +yy659: yych = *++lexer->cursor; - if (yych == 'c') goto yy752; + if (yych == 'c') goto yy760; goto yy50; -yy652: +yy660: yych = *++lexer->cursor; - if (yych == 'l') goto yy754; + if (yych == 'l') goto yy762; goto yy50; -yy653: +yy661: yych = *++lexer->cursor; - if (yych == 'o') goto yy756; + if (yych == 'o') goto yy764; goto yy50; -yy654: +yy662: yych = *++lexer->cursor; - if (yych == 't') goto yy757; + if (yych == 't') goto yy765; goto yy50; -yy655: +yy663: yych = *++lexer->cursor; - if (yych == 's') goto yy759; - if (yych == 'u') goto yy761; + if (yych == 's') goto yy767; + if (yych == 'u') goto yy769; goto yy50; -yy656: +yy664: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 369 "src/wasm-ast-lexer.c" +#line 371 "src/wasm-ast-lexer.c" { OPCODE(I32_GE_S); RETURN(COMPARE); } -#line 4176 "src/prebuilt/wasm-ast-lexer-gen.c" -yy658: +#line 4214 "src/prebuilt/wasm-ast-lexer-gen.c" +yy666: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 371 "src/wasm-ast-lexer.c" +#line 373 "src/wasm-ast-lexer.c" { OPCODE(I32_GE_U); RETURN(COMPARE); } -#line 4184 "src/prebuilt/wasm-ast-lexer-gen.c" -yy660: +#line 4222 "src/prebuilt/wasm-ast-lexer-gen.c" +yy668: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 365 "src/wasm-ast-lexer.c" +#line 367 "src/wasm-ast-lexer.c" { OPCODE(I32_GT_S); RETURN(COMPARE); } -#line 4192 "src/prebuilt/wasm-ast-lexer-gen.c" -yy662: +#line 4230 "src/prebuilt/wasm-ast-lexer-gen.c" +yy670: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 367 "src/wasm-ast-lexer.c" +#line 369 "src/wasm-ast-lexer.c" { OPCODE(I32_GT_U); RETURN(COMPARE); } -#line 4200 "src/prebuilt/wasm-ast-lexer-gen.c" -yy664: +#line 4238 "src/prebuilt/wasm-ast-lexer-gen.c" +yy672: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 361 "src/wasm-ast-lexer.c" +#line 363 "src/wasm-ast-lexer.c" { OPCODE(I32_LE_S); RETURN(COMPARE); } -#line 4208 "src/prebuilt/wasm-ast-lexer-gen.c" -yy666: +#line 4246 "src/prebuilt/wasm-ast-lexer-gen.c" +yy674: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 363 "src/wasm-ast-lexer.c" +#line 365 "src/wasm-ast-lexer.c" { OPCODE(I32_LE_U); RETURN(COMPARE); } -#line 4216 "src/prebuilt/wasm-ast-lexer-gen.c" -yy668: +#line 4254 "src/prebuilt/wasm-ast-lexer-gen.c" +yy676: ++lexer->cursor; if ((yych = *lexer->cursor) <= '8') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy669; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy677; + if (yych <= '\'') goto yy49; } } else { if (yych <= '0') { if (yych != ',') goto yy49; } else { - if (yych <= '1') goto yy763; + if (yych <= '1') goto yy771; if (yych <= '7') goto yy49; - goto yy764; + goto yy772; } } } else { @@ -4247,240 +4285,240 @@ yy668: } } } -yy669: -#line 258 "src/wasm-ast-lexer.c" +yy677: +#line 260 "src/wasm-ast-lexer.c" { OPCODE(I32_LOAD); RETURN(LOAD); } -#line 4254 "src/prebuilt/wasm-ast-lexer-gen.c" -yy670: +#line 4292 "src/prebuilt/wasm-ast-lexer-gen.c" +yy678: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 357 "src/wasm-ast-lexer.c" +#line 359 "src/wasm-ast-lexer.c" { OPCODE(I32_LT_S); RETURN(COMPARE); } -#line 4262 "src/prebuilt/wasm-ast-lexer-gen.c" -yy672: +#line 4300 "src/prebuilt/wasm-ast-lexer-gen.c" +yy680: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 359 "src/wasm-ast-lexer.c" +#line 361 "src/wasm-ast-lexer.c" { OPCODE(I32_LT_U); RETURN(COMPARE); } -#line 4270 "src/prebuilt/wasm-ast-lexer-gen.c" -yy674: +#line 4308 "src/prebuilt/wasm-ast-lexer-gen.c" +yy682: yych = *++lexer->cursor; - if (yych == 'n') goto yy765; + if (yych == 'n') goto yy773; goto yy50; -yy675: +yy683: yych = *++lexer->cursor; - if (yych == 't') goto yy766; + if (yych == 't') goto yy774; goto yy50; -yy676: +yy684: yych = *++lexer->cursor; - if (yych == 's') goto yy767; - if (yych == 'u') goto yy769; + if (yych == 's') goto yy775; + if (yych == 'u') goto yy777; goto yy50; -yy677: +yy685: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 335 "src/wasm-ast-lexer.c" +#line 337 "src/wasm-ast-lexer.c" { OPCODE(I32_ROTL); RETURN(BINARY); } -#line 4291 "src/prebuilt/wasm-ast-lexer-gen.c" -yy679: +#line 4329 "src/prebuilt/wasm-ast-lexer-gen.c" +yy687: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 337 "src/wasm-ast-lexer.c" +#line 339 "src/wasm-ast-lexer.c" { OPCODE(I32_ROTR); RETURN(BINARY); } -#line 4299 "src/prebuilt/wasm-ast-lexer-gen.c" -yy681: +#line 4337 "src/prebuilt/wasm-ast-lexer-gen.c" +yy689: yych = *++lexer->cursor; - if (yych == 's') goto yy771; - if (yych == 'u') goto yy773; + if (yych == 's') goto yy779; + if (yych == 'u') goto yy781; goto yy50; -yy682: +yy690: yych = *++lexer->cursor; - if (yych == 'e') goto yy775; + if (yych == 'e') goto yy783; goto yy50; -yy683: +yy691: yych = *++lexer->cursor; - if (yych == 'c') goto yy777; + if (yych == 'c') goto yy785; goto yy50; -yy684: +yy692: yych = *++lexer->cursor; - if (yych == '/') goto yy778; + if (yych == '/') goto yy786; goto yy50; -yy685: +yy693: yych = *++lexer->cursor; - if (yych == 't') goto yy779; + if (yych == 't') goto yy787; goto yy50; -yy686: +yy694: yych = *++lexer->cursor; - if (yych == 's') goto yy781; - if (yych == 'u') goto yy783; + if (yych == 's') goto yy789; + if (yych == 'u') goto yy791; goto yy50; -yy687: +yy695: yych = *++lexer->cursor; - if (yych == 'n') goto yy785; + if (yych == 'n') goto yy793; goto yy50; -yy688: +yy696: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 370 "src/wasm-ast-lexer.c" +#line 372 "src/wasm-ast-lexer.c" { OPCODE(I64_GE_S); RETURN(COMPARE); } -#line 4337 "src/prebuilt/wasm-ast-lexer-gen.c" -yy690: +#line 4375 "src/prebuilt/wasm-ast-lexer-gen.c" +yy698: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 372 "src/wasm-ast-lexer.c" +#line 374 "src/wasm-ast-lexer.c" { OPCODE(I64_GE_U); RETURN(COMPARE); } -#line 4345 "src/prebuilt/wasm-ast-lexer-gen.c" -yy692: +#line 4383 "src/prebuilt/wasm-ast-lexer-gen.c" +yy700: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 366 "src/wasm-ast-lexer.c" +#line 368 "src/wasm-ast-lexer.c" { OPCODE(I64_GT_S); RETURN(COMPARE); } -#line 4353 "src/prebuilt/wasm-ast-lexer-gen.c" -yy694: +#line 4391 "src/prebuilt/wasm-ast-lexer-gen.c" +yy702: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 368 "src/wasm-ast-lexer.c" +#line 370 "src/wasm-ast-lexer.c" { OPCODE(I64_GT_U); RETURN(COMPARE); } -#line 4361 "src/prebuilt/wasm-ast-lexer-gen.c" -yy696: +#line 4399 "src/prebuilt/wasm-ast-lexer-gen.c" +yy704: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 362 "src/wasm-ast-lexer.c" +#line 364 "src/wasm-ast-lexer.c" { OPCODE(I64_LE_S); RETURN(COMPARE); } -#line 4369 "src/prebuilt/wasm-ast-lexer-gen.c" -yy698: +#line 4407 "src/prebuilt/wasm-ast-lexer-gen.c" +yy706: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 364 "src/wasm-ast-lexer.c" +#line 366 "src/wasm-ast-lexer.c" { OPCODE(I64_LE_U); RETURN(COMPARE); } -#line 4377 "src/prebuilt/wasm-ast-lexer-gen.c" -yy700: +#line 4415 "src/prebuilt/wasm-ast-lexer-gen.c" +yy708: ++lexer->cursor; if ((yych = *lexer->cursor) <= '7') { if (yych <= '+') { if (yych <= '"') { if (yych == '!') goto yy49; } else { - if (yych <= '&') goto yy49; + if (yych <= '\'') goto yy49; if (yych >= '*') goto yy49; } } else { if (yych <= '1') { - if (yych <= ',') goto yy701; + if (yych <= ',') goto yy709; if (yych <= '0') goto yy49; - goto yy786; + goto yy794; } else { - if (yych == '3') goto yy787; + if (yych == '3') goto yy795; goto yy49; } } } else { if (yych <= '\\') { if (yych <= ';') { - if (yych <= '8') goto yy788; + if (yych <= '8') goto yy796; if (yych <= ':') goto yy49; } else { if (yych != '[') goto yy49; } } else { if (yych <= '{') { - if (yych <= ']') goto yy701; + if (yych <= ']') goto yy709; if (yych <= 'z') goto yy49; } else { - if (yych == '}') goto yy701; + if (yych == '}') goto yy709; if (yych <= '~') goto yy49; } } } -yy701: -#line 259 "src/wasm-ast-lexer.c" +yy709: +#line 261 "src/wasm-ast-lexer.c" { OPCODE(I64_LOAD); RETURN(LOAD); } -#line 4419 "src/prebuilt/wasm-ast-lexer-gen.c" -yy702: +#line 4457 "src/prebuilt/wasm-ast-lexer-gen.c" +yy710: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 358 "src/wasm-ast-lexer.c" +#line 360 "src/wasm-ast-lexer.c" { OPCODE(I64_LT_S); RETURN(COMPARE); } -#line 4427 "src/prebuilt/wasm-ast-lexer-gen.c" -yy704: +#line 4465 "src/prebuilt/wasm-ast-lexer-gen.c" +yy712: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 360 "src/wasm-ast-lexer.c" +#line 362 "src/wasm-ast-lexer.c" { OPCODE(I64_LT_U); RETURN(COMPARE); } -#line 4435 "src/prebuilt/wasm-ast-lexer-gen.c" -yy706: +#line 4473 "src/prebuilt/wasm-ast-lexer-gen.c" +yy714: yych = *++lexer->cursor; - if (yych == 'n') goto yy789; + if (yych == 'n') goto yy797; goto yy50; -yy707: +yy715: yych = *++lexer->cursor; - if (yych == 't') goto yy790; + if (yych == 't') goto yy798; goto yy50; -yy708: +yy716: yych = *++lexer->cursor; - if (yych == 's') goto yy791; - if (yych == 'u') goto yy793; + if (yych == 's') goto yy799; + if (yych == 'u') goto yy801; goto yy50; -yy709: +yy717: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 336 "src/wasm-ast-lexer.c" +#line 338 "src/wasm-ast-lexer.c" { OPCODE(I64_ROTL); RETURN(BINARY); } -#line 4456 "src/prebuilt/wasm-ast-lexer-gen.c" -yy711: +#line 4494 "src/prebuilt/wasm-ast-lexer-gen.c" +yy719: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 338 "src/wasm-ast-lexer.c" +#line 340 "src/wasm-ast-lexer.c" { OPCODE(I64_ROTR); RETURN(BINARY); } -#line 4464 "src/prebuilt/wasm-ast-lexer-gen.c" -yy713: +#line 4502 "src/prebuilt/wasm-ast-lexer-gen.c" +yy721: yych = *++lexer->cursor; - if (yych == 's') goto yy795; - if (yych == 'u') goto yy797; + if (yych == 's') goto yy803; + if (yych == 'u') goto yy805; goto yy50; -yy714: +yy722: yych = *++lexer->cursor; - if (yych == 'e') goto yy799; + if (yych == 'e') goto yy807; goto yy50; -yy715: +yy723: yych = *++lexer->cursor; - if (yych == 'c') goto yy801; + if (yych == 'c') goto yy809; goto yy50; -yy716: +yy724: yych = *++lexer->cursor; if (yybm[0+yych] & 16) { goto yy49; } - goto yy170; -yy717: + goto yy176; +yy725: ++lexer->cursor; if (lexer->limit <= lexer->cursor) FILL(1); yych = *lexer->cursor; @@ -4489,15 +4527,15 @@ yy717: if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy719; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy727; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { if (yych <= '+') goto yy49; } else { if (yych <= '/') goto yy49; - if (yych <= '9') goto yy717; + if (yych <= '9') goto yy725; goto yy49; } } @@ -4516,247 +4554,247 @@ yy717: } } } -yy719: -#line 281 "src/wasm-ast-lexer.c" +yy727: +#line 283 "src/wasm-ast-lexer.c" { TEXT_AT(7); RETURN(OFFSET); } -#line 4523 "src/prebuilt/wasm-ast-lexer-gen.c" -yy720: +#line 4561 "src/prebuilt/wasm-ast-lexer-gen.c" +yy728: yych = *++lexer->cursor; - if (yych == 'l') goto yy802; + if (yych == 'l') goto yy810; goto yy50; -yy721: +yy729: yych = *++lexer->cursor; - if (yych == 'b') goto yy804; + if (yych == 'b') goto yy812; goto yy50; -yy722: +yy730: yych = *++lexer->cursor; - if (yych == 'v') goto yy805; + if (yych == 'v') goto yy813; goto yy50; -yy723: +yy731: yych = *++lexer->cursor; - if (yych == 't') goto yy806; + if (yych == 't') goto yy814; goto yy50; -yy724: +yy732: yych = *++lexer->cursor; - if (yych == 'a') goto yy807; + if (yych == 'a') goto yy815; goto yy50; -yy725: +yy733: yych = *++lexer->cursor; - if (yych == 'r') goto yy808; + if (yych == 'r') goto yy816; goto yy50; -yy726: +yy734: yych = *++lexer->cursor; - if (yych == 'r') goto yy809; + if (yych == 'r') goto yy817; goto yy50; -yy727: +yy735: yych = *++lexer->cursor; - if (yych == 'e') goto yy810; + if (yych == 'e') goto yy818; goto yy50; -yy728: +yy736: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 285 "src/wasm-ast-lexer.c" +#line 287 "src/wasm-ast-lexer.c" { TYPE(F32); RETURN(CONST); } -#line 4563 "src/prebuilt/wasm-ast-lexer-gen.c" -yy730: +#line 4601 "src/prebuilt/wasm-ast-lexer-gen.c" +yy738: yych = *++lexer->cursor; - if (yych == 'r') goto yy811; + if (yych == 'r') goto yy819; goto yy50; -yy731: +yy739: yych = *++lexer->cursor; - if (yych == 'i') goto yy812; + if (yych == 'i') goto yy820; goto yy50; -yy732: +yy740: yych = *++lexer->cursor; - if (yych == 'e') goto yy813; + if (yych == 'e') goto yy821; goto yy50; -yy733: +yy741: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 303 "src/wasm-ast-lexer.c" +#line 305 "src/wasm-ast-lexer.c" { OPCODE(F32_FLOOR); RETURN(UNARY); } -#line 4583 "src/prebuilt/wasm-ast-lexer-gen.c" -yy735: +#line 4621 "src/prebuilt/wasm-ast-lexer-gen.c" +yy743: yych = *++lexer->cursor; - if (yych == 's') goto yy814; + if (yych == 's') goto yy822; goto yy50; -yy736: +yy744: yych = *++lexer->cursor; - if (yych == 'e') goto yy815; + if (yych == 'e') goto yy823; goto yy50; -yy737: +yy745: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 264 "src/wasm-ast-lexer.c" +#line 266 "src/wasm-ast-lexer.c" { OPCODE(F32_STORE); RETURN(STORE); } -#line 4599 "src/prebuilt/wasm-ast-lexer-gen.c" -yy739: +#line 4637 "src/prebuilt/wasm-ast-lexer-gen.c" +yy747: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 305 "src/wasm-ast-lexer.c" +#line 307 "src/wasm-ast-lexer.c" { OPCODE(F32_TRUNC); RETURN(UNARY); } -#line 4607 "src/prebuilt/wasm-ast-lexer-gen.c" -yy741: +#line 4645 "src/prebuilt/wasm-ast-lexer-gen.c" +yy749: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 286 "src/wasm-ast-lexer.c" +#line 288 "src/wasm-ast-lexer.c" { TYPE(F64); RETURN(CONST); } -#line 4615 "src/prebuilt/wasm-ast-lexer-gen.c" -yy743: +#line 4653 "src/prebuilt/wasm-ast-lexer-gen.c" +yy751: yych = *++lexer->cursor; - if (yych == 'r') goto yy816; + if (yych == 'r') goto yy824; goto yy50; -yy744: +yy752: yych = *++lexer->cursor; - if (yych == 'i') goto yy817; + if (yych == 'i') goto yy825; goto yy50; -yy745: +yy753: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 304 "src/wasm-ast-lexer.c" +#line 306 "src/wasm-ast-lexer.c" { OPCODE(F64_FLOOR); RETURN(UNARY); } -#line 4631 "src/prebuilt/wasm-ast-lexer-gen.c" -yy747: +#line 4669 "src/prebuilt/wasm-ast-lexer-gen.c" +yy755: yych = *++lexer->cursor; - if (yych == 's') goto yy818; + if (yych == 's') goto yy826; goto yy50; -yy748: +yy756: yych = *++lexer->cursor; - if (yych == 't') goto yy819; + if (yych == 't') goto yy827; goto yy50; -yy749: +yy757: yych = *++lexer->cursor; - if (yych == 'e') goto yy820; + if (yych == 'e') goto yy828; goto yy50; -yy750: +yy758: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 265 "src/wasm-ast-lexer.c" +#line 267 "src/wasm-ast-lexer.c" { OPCODE(F64_STORE); RETURN(STORE); } -#line 4651 "src/prebuilt/wasm-ast-lexer-gen.c" -yy752: +#line 4689 "src/prebuilt/wasm-ast-lexer-gen.c" +yy760: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 306 "src/wasm-ast-lexer.c" +#line 308 "src/wasm-ast-lexer.c" { OPCODE(F64_TRUNC); RETURN(UNARY); } -#line 4659 "src/prebuilt/wasm-ast-lexer-gen.c" -yy754: +#line 4697 "src/prebuilt/wasm-ast-lexer-gen.c" +yy762: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 256 "src/wasm-ast-lexer.c" +#line 258 "src/wasm-ast-lexer.c" { RETURN(GET_LOCAL); } -#line 4667 "src/prebuilt/wasm-ast-lexer-gen.c" -yy756: +#line 4705 "src/prebuilt/wasm-ast-lexer-gen.c" +yy764: yych = *++lexer->cursor; - if (yych == 'r') goto yy821; + if (yych == 'r') goto yy829; goto yy50; -yy757: +yy765: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 283 "src/wasm-ast-lexer.c" +#line 285 "src/wasm-ast-lexer.c" { TYPE(I32); RETURN(CONST); } -#line 4679 "src/prebuilt/wasm-ast-lexer-gen.c" -yy759: +#line 4717 "src/prebuilt/wasm-ast-lexer-gen.c" +yy767: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 315 "src/wasm-ast-lexer.c" +#line 317 "src/wasm-ast-lexer.c" { OPCODE(I32_DIV_S); RETURN(BINARY); } -#line 4687 "src/prebuilt/wasm-ast-lexer-gen.c" -yy761: +#line 4725 "src/prebuilt/wasm-ast-lexer-gen.c" +yy769: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 317 "src/wasm-ast-lexer.c" +#line 319 "src/wasm-ast-lexer.c" { OPCODE(I32_DIV_U); RETURN(BINARY); } -#line 4695 "src/prebuilt/wasm-ast-lexer-gen.c" -yy763: +#line 4733 "src/prebuilt/wasm-ast-lexer-gen.c" +yy771: yych = *++lexer->cursor; - if (yych == '6') goto yy822; + if (yych == '6') goto yy830; goto yy50; -yy764: +yy772: yych = *++lexer->cursor; - if (yych == '_') goto yy823; + if (yych == '_') goto yy831; goto yy50; -yy765: +yy773: yych = *++lexer->cursor; - if (yych == 't') goto yy824; + if (yych == 't') goto yy832; goto yy50; -yy766: +yy774: yych = *++lexer->cursor; - if (yych == 'e') goto yy826; + if (yych == 'e') goto yy834; goto yy50; -yy767: +yy775: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 319 "src/wasm-ast-lexer.c" +#line 321 "src/wasm-ast-lexer.c" { OPCODE(I32_REM_S); RETURN(BINARY); } -#line 4719 "src/prebuilt/wasm-ast-lexer-gen.c" -yy769: +#line 4757 "src/prebuilt/wasm-ast-lexer-gen.c" +yy777: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 321 "src/wasm-ast-lexer.c" +#line 323 "src/wasm-ast-lexer.c" { OPCODE(I32_REM_U); RETURN(BINARY); } -#line 4727 "src/prebuilt/wasm-ast-lexer-gen.c" -yy771: +#line 4765 "src/prebuilt/wasm-ast-lexer-gen.c" +yy779: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 331 "src/wasm-ast-lexer.c" +#line 333 "src/wasm-ast-lexer.c" { OPCODE(I32_SHR_S); RETURN(BINARY); } -#line 4735 "src/prebuilt/wasm-ast-lexer-gen.c" -yy773: +#line 4773 "src/prebuilt/wasm-ast-lexer-gen.c" +yy781: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 333 "src/wasm-ast-lexer.c" +#line 335 "src/wasm-ast-lexer.c" { OPCODE(I32_SHR_U); RETURN(BINARY); } -#line 4743 "src/prebuilt/wasm-ast-lexer-gen.c" -yy775: +#line 4781 "src/prebuilt/wasm-ast-lexer-gen.c" +yy783: ++lexer->cursor; if ((yych = *lexer->cursor) <= '8') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy776; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy784; + if (yych <= '\'') goto yy49; } } else { if (yych <= '0') { if (yych != ',') goto yy49; } else { - if (yych <= '1') goto yy827; + if (yych <= '1') goto yy835; if (yych <= '7') goto yy49; - goto yy828; + goto yy836; } } } else { @@ -4774,679 +4812,679 @@ yy775: } } } -yy776: -#line 262 "src/wasm-ast-lexer.c" +yy784: +#line 264 "src/wasm-ast-lexer.c" { OPCODE(I32_STORE); RETURN(STORE); } -#line 4781 "src/prebuilt/wasm-ast-lexer-gen.c" -yy777: +#line 4819 "src/prebuilt/wasm-ast-lexer-gen.c" +yy785: yych = *++lexer->cursor; - if (yych == '_') goto yy830; + if (yych == '_') goto yy838; goto yy50; -yy778: +yy786: yych = *++lexer->cursor; - if (yych == 'i') goto yy831; + if (yych == 'i') goto yy839; goto yy50; -yy779: +yy787: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 284 "src/wasm-ast-lexer.c" +#line 286 "src/wasm-ast-lexer.c" { TYPE(I64); RETURN(CONST); } -#line 4797 "src/prebuilt/wasm-ast-lexer-gen.c" -yy781: +#line 4835 "src/prebuilt/wasm-ast-lexer-gen.c" +yy789: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 316 "src/wasm-ast-lexer.c" +#line 318 "src/wasm-ast-lexer.c" { OPCODE(I64_DIV_S); RETURN(BINARY); } -#line 4805 "src/prebuilt/wasm-ast-lexer-gen.c" -yy783: +#line 4843 "src/prebuilt/wasm-ast-lexer-gen.c" +yy791: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 318 "src/wasm-ast-lexer.c" +#line 320 "src/wasm-ast-lexer.c" { OPCODE(I64_DIV_U); RETURN(BINARY); } -#line 4813 "src/prebuilt/wasm-ast-lexer-gen.c" -yy785: +#line 4851 "src/prebuilt/wasm-ast-lexer-gen.c" +yy793: yych = *++lexer->cursor; - if (yych == 'd') goto yy832; + if (yych == 'd') goto yy840; goto yy50; -yy786: +yy794: yych = *++lexer->cursor; - if (yych == '6') goto yy833; + if (yych == '6') goto yy841; goto yy50; -yy787: +yy795: yych = *++lexer->cursor; - if (yych == '2') goto yy834; + if (yych == '2') goto yy842; goto yy50; -yy788: +yy796: yych = *++lexer->cursor; - if (yych == '_') goto yy835; + if (yych == '_') goto yy843; goto yy50; -yy789: +yy797: yych = *++lexer->cursor; - if (yych == 't') goto yy836; + if (yych == 't') goto yy844; goto yy50; -yy790: +yy798: yych = *++lexer->cursor; - if (yych == 'e') goto yy838; + if (yych == 'e') goto yy846; goto yy50; -yy791: +yy799: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 320 "src/wasm-ast-lexer.c" +#line 322 "src/wasm-ast-lexer.c" { OPCODE(I64_REM_S); RETURN(BINARY); } -#line 4845 "src/prebuilt/wasm-ast-lexer-gen.c" -yy793: +#line 4883 "src/prebuilt/wasm-ast-lexer-gen.c" +yy801: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 322 "src/wasm-ast-lexer.c" +#line 324 "src/wasm-ast-lexer.c" { OPCODE(I64_REM_U); RETURN(BINARY); } -#line 4853 "src/prebuilt/wasm-ast-lexer-gen.c" -yy795: +#line 4891 "src/prebuilt/wasm-ast-lexer-gen.c" +yy803: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 332 "src/wasm-ast-lexer.c" +#line 334 "src/wasm-ast-lexer.c" { OPCODE(I64_SHR_S); RETURN(BINARY); } -#line 4861 "src/prebuilt/wasm-ast-lexer-gen.c" -yy797: +#line 4899 "src/prebuilt/wasm-ast-lexer-gen.c" +yy805: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 334 "src/wasm-ast-lexer.c" +#line 336 "src/wasm-ast-lexer.c" { OPCODE(I64_SHR_U); RETURN(BINARY); } -#line 4869 "src/prebuilt/wasm-ast-lexer-gen.c" -yy799: +#line 4907 "src/prebuilt/wasm-ast-lexer-gen.c" +yy807: ++lexer->cursor; if ((yych = *lexer->cursor) <= '7') { if (yych <= '+') { if (yych <= '"') { if (yych == '!') goto yy49; } else { - if (yych <= '&') goto yy49; + if (yych <= '\'') goto yy49; if (yych >= '*') goto yy49; } } else { if (yych <= '1') { - if (yych <= ',') goto yy800; + if (yych <= ',') goto yy808; if (yych <= '0') goto yy49; - goto yy839; + goto yy847; } else { - if (yych == '3') goto yy840; + if (yych == '3') goto yy848; goto yy49; } } } else { if (yych <= '\\') { if (yych <= ';') { - if (yych <= '8') goto yy841; + if (yych <= '8') goto yy849; if (yych <= ':') goto yy49; } else { if (yych != '[') goto yy49; } } else { if (yych <= '{') { - if (yych <= ']') goto yy800; + if (yych <= ']') goto yy808; if (yych <= 'z') goto yy49; } else { - if (yych == '}') goto yy800; + if (yych == '}') goto yy808; if (yych <= '~') goto yy49; } } } -yy800: -#line 263 "src/wasm-ast-lexer.c" +yy808: +#line 265 "src/wasm-ast-lexer.c" { OPCODE(I64_STORE); RETURN(STORE); } -#line 4911 "src/prebuilt/wasm-ast-lexer-gen.c" -yy801: +#line 4949 "src/prebuilt/wasm-ast-lexer-gen.c" +yy809: yych = *++lexer->cursor; - if (yych == '_') goto yy843; + if (yych == '_') goto yy851; goto yy50; -yy802: +yy810: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 257 "src/wasm-ast-lexer.c" +#line 259 "src/wasm-ast-lexer.c" { RETURN(SET_LOCAL); } -#line 4923 "src/prebuilt/wasm-ast-lexer-gen.c" -yy804: +#line 4961 "src/prebuilt/wasm-ast-lexer-gen.c" +yy812: yych = *++lexer->cursor; - if (yych == 'l') goto yy844; + if (yych == 'l') goto yy852; goto yy50; -yy805: +yy813: yych = *++lexer->cursor; - if (yych == 'a') goto yy845; + if (yych == 'a') goto yy853; goto yy50; -yy806: +yy814: yych = *++lexer->cursor; - if (yych == 'u') goto yy846; + if (yych == 'u') goto yy854; goto yy50; -yy807: +yy815: yych = *++lexer->cursor; - if (yych == 'p') goto yy847; + if (yych == 'p') goto yy855; goto yy50; -yy808: +yy816: yych = *++lexer->cursor; - if (yych == 't') goto yy849; + if (yych == 't') goto yy857; goto yy50; -yy809: +yy817: yych = *++lexer->cursor; - if (yych == 'e') goto yy851; + if (yych == 'e') goto yy859; goto yy50; -yy810: +yy818: yych = *++lexer->cursor; - if (yych == 'm') goto yy852; + if (yych == 'm') goto yy860; goto yy50; -yy811: +yy819: yych = *++lexer->cursor; - if (yych == 't') goto yy853; + if (yych == 't') goto yy861; goto yy50; -yy812: +yy820: yych = *++lexer->cursor; - if (yych == 'g') goto yy854; + if (yych == 'g') goto yy862; goto yy50; -yy813: +yy821: yych = *++lexer->cursor; - if (yych == '/') goto yy855; + if (yych == '/') goto yy863; goto yy50; -yy814: +yy822: yych = *++lexer->cursor; - if (yych == 't') goto yy856; + if (yych == 't') goto yy864; goto yy50; -yy815: +yy823: yych = *++lexer->cursor; - if (yych == 'r') goto yy858; + if (yych == 'r') goto yy866; goto yy50; -yy816: +yy824: yych = *++lexer->cursor; - if (yych == 't') goto yy859; + if (yych == 't') goto yy867; goto yy50; -yy817: +yy825: yych = *++lexer->cursor; - if (yych == 'g') goto yy860; + if (yych == 'g') goto yy868; goto yy50; -yy818: +yy826: yych = *++lexer->cursor; - if (yych == 't') goto yy861; + if (yych == 't') goto yy869; goto yy50; -yy819: +yy827: yych = *++lexer->cursor; - if (yych == 'e') goto yy863; + if (yych == 'e') goto yy871; goto yy50; -yy820: +yy828: yych = *++lexer->cursor; - if (yych == 'r') goto yy864; + if (yych == 'r') goto yy872; goto yy50; -yy821: +yy829: yych = *++lexer->cursor; - if (yych == 'y') goto yy865; + if (yych == 'y') goto yy873; goto yy50; -yy822: +yy830: yych = *++lexer->cursor; - if (yych == '_') goto yy867; + if (yych == '_') goto yy875; goto yy50; -yy823: +yy831: yych = *++lexer->cursor; - if (yych == 's') goto yy868; - if (yych == 'u') goto yy870; + if (yych == 's') goto yy876; + if (yych == 'u') goto yy878; goto yy50; -yy824: +yy832: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 293 "src/wasm-ast-lexer.c" +#line 295 "src/wasm-ast-lexer.c" { OPCODE(I32_POPCNT); RETURN(UNARY); } -#line 5012 "src/prebuilt/wasm-ast-lexer-gen.c" -yy826: +#line 5050 "src/prebuilt/wasm-ast-lexer-gen.c" +yy834: yych = *++lexer->cursor; - if (yych == 'r') goto yy872; + if (yych == 'r') goto yy880; goto yy50; -yy827: +yy835: yych = *++lexer->cursor; - if (yych == '6') goto yy873; + if (yych == '6') goto yy881; goto yy50; -yy828: +yy836: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 276 "src/wasm-ast-lexer.c" +#line 278 "src/wasm-ast-lexer.c" { OPCODE(I32_STORE8); RETURN(STORE); } -#line 5028 "src/prebuilt/wasm-ast-lexer-gen.c" -yy830: +#line 5066 "src/prebuilt/wasm-ast-lexer-gen.c" +yy838: yych = *++lexer->cursor; - if (yych == 's') goto yy875; - if (yych == 'u') goto yy876; + if (yych == 's') goto yy883; + if (yych == 'u') goto yy884; goto yy50; -yy831: +yy839: yych = *++lexer->cursor; - if (yych == '6') goto yy877; + if (yych == '6') goto yy885; goto yy50; -yy832: +yy840: yych = *++lexer->cursor; - if (yych == '_') goto yy878; + if (yych == '_') goto yy886; goto yy50; -yy833: +yy841: yych = *++lexer->cursor; - if (yych == '_') goto yy879; + if (yych == '_') goto yy887; goto yy50; -yy834: +yy842: yych = *++lexer->cursor; - if (yych == '_') goto yy880; + if (yych == '_') goto yy888; goto yy50; -yy835: +yy843: yych = *++lexer->cursor; - if (yych == 's') goto yy881; - if (yych == 'u') goto yy883; + if (yych == 's') goto yy889; + if (yych == 'u') goto yy891; goto yy50; -yy836: +yy844: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 294 "src/wasm-ast-lexer.c" +#line 296 "src/wasm-ast-lexer.c" { OPCODE(I64_POPCNT); RETURN(UNARY); } -#line 5062 "src/prebuilt/wasm-ast-lexer-gen.c" -yy838: +#line 5100 "src/prebuilt/wasm-ast-lexer-gen.c" +yy846: yych = *++lexer->cursor; - if (yych == 'r') goto yy885; + if (yych == 'r') goto yy893; goto yy50; -yy839: +yy847: yych = *++lexer->cursor; - if (yych == '6') goto yy886; + if (yych == '6') goto yy894; goto yy50; -yy840: +yy848: yych = *++lexer->cursor; - if (yych == '2') goto yy888; + if (yych == '2') goto yy896; goto yy50; -yy841: +yy849: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 277 "src/wasm-ast-lexer.c" +#line 279 "src/wasm-ast-lexer.c" { OPCODE(I64_STORE8); RETURN(STORE); } -#line 5082 "src/prebuilt/wasm-ast-lexer-gen.c" -yy843: +#line 5120 "src/prebuilt/wasm-ast-lexer-gen.c" +yy851: yych = *++lexer->cursor; - if (yych == 's') goto yy890; - if (yych == 'u') goto yy891; + if (yych == 's') goto yy898; + if (yych == 'u') goto yy899; goto yy50; -yy844: +yy852: yych = *++lexer->cursor; - if (yych == 'e') goto yy892; + if (yych == 'e') goto yy900; goto yy50; -yy845: +yy853: yych = *++lexer->cursor; - if (yych == 'l') goto yy894; + if (yych == 'l') goto yy902; goto yy50; -yy846: +yy854: yych = *++lexer->cursor; - if (yych == 'r') goto yy895; + if (yych == 'r') goto yy903; goto yy50; -yy847: +yy855: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 429 "src/wasm-ast-lexer.c" +#line 431 "src/wasm-ast-lexer.c" { RETURN(ASSERT_TRAP); } -#line 5107 "src/prebuilt/wasm-ast-lexer-gen.c" -yy849: +#line 5145 "src/prebuilt/wasm-ast-lexer-gen.c" +yy857: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } #line 253 "src/wasm-ast-lexer.c" { RETURN(CALL_IMPORT); } -#line 5115 "src/prebuilt/wasm-ast-lexer-gen.c" -yy851: +#line 5153 "src/prebuilt/wasm-ast-lexer-gen.c" +yy859: yych = *++lexer->cursor; - if (yych == 'c') goto yy896; + if (yych == 'c') goto yy904; goto yy50; -yy852: +yy860: yych = *++lexer->cursor; - if (yych == 'o') goto yy897; + if (yych == 'o') goto yy905; goto yy50; -yy853: +yy861: yych = *++lexer->cursor; - if (yych == '_') goto yy898; + if (yych == '_') goto yy906; goto yy50; -yy854: +yy862: yych = *++lexer->cursor; - if (yych == 'n') goto yy899; + if (yych == 'n') goto yy907; goto yy50; -yy855: +yy863: yych = *++lexer->cursor; - if (yych == 'f') goto yy901; + if (yych == 'f') goto yy909; goto yy50; -yy856: +yy864: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 307 "src/wasm-ast-lexer.c" +#line 309 "src/wasm-ast-lexer.c" { OPCODE(F32_NEAREST); RETURN(UNARY); } -#line 5143 "src/prebuilt/wasm-ast-lexer-gen.c" -yy858: +#line 5181 "src/prebuilt/wasm-ast-lexer-gen.c" +yy866: yych = *++lexer->cursor; - if (yych == 'p') goto yy902; + if (yych == 'p') goto yy910; goto yy50; -yy859: +yy867: yych = *++lexer->cursor; - if (yych == '_') goto yy903; + if (yych == '_') goto yy911; goto yy50; -yy860: +yy868: yych = *++lexer->cursor; - if (yych == 'n') goto yy904; + if (yych == 'n') goto yy912; goto yy50; -yy861: +yy869: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 308 "src/wasm-ast-lexer.c" +#line 310 "src/wasm-ast-lexer.c" { OPCODE(F64_NEAREST); RETURN(UNARY); } -#line 5163 "src/prebuilt/wasm-ast-lexer-gen.c" -yy863: +#line 5201 "src/prebuilt/wasm-ast-lexer-gen.c" +yy871: yych = *++lexer->cursor; - if (yych == '/') goto yy906; + if (yych == '/') goto yy914; goto yy50; -yy864: +yy872: yych = *++lexer->cursor; - if (yych == 'p') goto yy907; + if (yych == 'p') goto yy915; goto yy50; -yy865: +yy873: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 413 "src/wasm-ast-lexer.c" +#line 415 "src/wasm-ast-lexer.c" { RETURN(GROW_MEMORY); } -#line 5179 "src/prebuilt/wasm-ast-lexer-gen.c" -yy867: +#line 5217 "src/prebuilt/wasm-ast-lexer-gen.c" +yy875: yych = *++lexer->cursor; - if (yych == 's') goto yy908; - if (yych == 'u') goto yy910; + if (yych == 's') goto yy916; + if (yych == 'u') goto yy918; goto yy50; -yy868: +yy876: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 266 "src/wasm-ast-lexer.c" +#line 268 "src/wasm-ast-lexer.c" { OPCODE(I32_LOAD8_S); RETURN(LOAD); } -#line 5192 "src/prebuilt/wasm-ast-lexer-gen.c" -yy870: +#line 5230 "src/prebuilt/wasm-ast-lexer-gen.c" +yy878: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 268 "src/wasm-ast-lexer.c" +#line 270 "src/wasm-ast-lexer.c" { OPCODE(I32_LOAD8_U); RETURN(LOAD); } -#line 5200 "src/prebuilt/wasm-ast-lexer-gen.c" -yy872: +#line 5238 "src/prebuilt/wasm-ast-lexer-gen.c" +yy880: yych = *++lexer->cursor; - if (yych == 'p') goto yy912; + if (yych == 'p') goto yy920; goto yy50; -yy873: +yy881: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 278 "src/wasm-ast-lexer.c" +#line 280 "src/wasm-ast-lexer.c" { OPCODE(I32_STORE16); RETURN(STORE); } -#line 5212 "src/prebuilt/wasm-ast-lexer-gen.c" -yy875: +#line 5250 "src/prebuilt/wasm-ast-lexer-gen.c" +yy883: yych = *++lexer->cursor; - if (yych == '/') goto yy913; + if (yych == '/') goto yy921; goto yy50; -yy876: +yy884: yych = *++lexer->cursor; - if (yych == '/') goto yy914; + if (yych == '/') goto yy922; goto yy50; -yy877: +yy885: yych = *++lexer->cursor; - if (yych == '4') goto yy915; + if (yych == '4') goto yy923; goto yy50; -yy878: +yy886: yych = *++lexer->cursor; - if (yych == 's') goto yy917; - if (yych == 'u') goto yy918; + if (yych == 's') goto yy925; + if (yych == 'u') goto yy926; goto yy50; -yy879: +yy887: yych = *++lexer->cursor; - if (yych == 's') goto yy919; - if (yych == 'u') goto yy921; + if (yych == 's') goto yy927; + if (yych == 'u') goto yy929; goto yy50; -yy880: +yy888: yych = *++lexer->cursor; - if (yych == 's') goto yy923; - if (yych == 'u') goto yy925; + if (yych == 's') goto yy931; + if (yych == 'u') goto yy933; goto yy50; -yy881: +yy889: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 267 "src/wasm-ast-lexer.c" +#line 269 "src/wasm-ast-lexer.c" { OPCODE(I64_LOAD8_S); RETURN(LOAD); } -#line 5247 "src/prebuilt/wasm-ast-lexer-gen.c" -yy883: +#line 5285 "src/prebuilt/wasm-ast-lexer-gen.c" +yy891: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 269 "src/wasm-ast-lexer.c" +#line 271 "src/wasm-ast-lexer.c" { OPCODE(I64_LOAD8_U); RETURN(LOAD); } -#line 5255 "src/prebuilt/wasm-ast-lexer-gen.c" -yy885: +#line 5293 "src/prebuilt/wasm-ast-lexer-gen.c" +yy893: yych = *++lexer->cursor; - if (yych == 'p') goto yy927; + if (yych == 'p') goto yy935; goto yy50; -yy886: +yy894: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 279 "src/wasm-ast-lexer.c" +#line 281 "src/wasm-ast-lexer.c" { OPCODE(I64_STORE16); RETURN(STORE); } -#line 5267 "src/prebuilt/wasm-ast-lexer-gen.c" -yy888: +#line 5305 "src/prebuilt/wasm-ast-lexer-gen.c" +yy896: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 280 "src/wasm-ast-lexer.c" +#line 282 "src/wasm-ast-lexer.c" { OPCODE(I64_STORE32); RETURN(STORE); } -#line 5275 "src/prebuilt/wasm-ast-lexer-gen.c" -yy890: +#line 5313 "src/prebuilt/wasm-ast-lexer-gen.c" +yy898: yych = *++lexer->cursor; - if (yych == '/') goto yy928; + if (yych == '/') goto yy936; goto yy50; -yy891: +yy899: yych = *++lexer->cursor; - if (yych == '/') goto yy929; + if (yych == '/') goto yy937; goto yy50; -yy892: +yy900: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 411 "src/wasm-ast-lexer.c" +#line 413 "src/wasm-ast-lexer.c" { RETURN(UNREACHABLE); } -#line 5291 "src/prebuilt/wasm-ast-lexer-gen.c" -yy894: +#line 5329 "src/prebuilt/wasm-ast-lexer-gen.c" +yy902: yych = *++lexer->cursor; - if (yych == 'i') goto yy930; + if (yych == 'i') goto yy938; goto yy50; -yy895: +yy903: yych = *++lexer->cursor; - if (yych == 'n') goto yy931; + if (yych == 'n') goto yy939; goto yy50; -yy896: +yy904: yych = *++lexer->cursor; - if (yych == 't') goto yy933; + if (yych == 't') goto yy941; goto yy50; -yy897: +yy905: yych = *++lexer->cursor; - if (yych == 'r') goto yy935; + if (yych == 'r') goto yy943; goto yy50; -yy898: +yy906: yych = *++lexer->cursor; - if (yych == 's') goto yy936; - if (yych == 'u') goto yy937; + if (yych == 's') goto yy944; + if (yych == 'u') goto yy945; goto yy50; -yy899: +yy907: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 351 "src/wasm-ast-lexer.c" +#line 353 "src/wasm-ast-lexer.c" { OPCODE(F32_COPYSIGN); RETURN(BINARY); } -#line 5320 "src/prebuilt/wasm-ast-lexer-gen.c" -yy901: +#line 5358 "src/prebuilt/wasm-ast-lexer-gen.c" +yy909: yych = *++lexer->cursor; - if (yych == '6') goto yy938; + if (yych == '6') goto yy946; goto yy50; -yy902: +yy910: yych = *++lexer->cursor; - if (yych == 'r') goto yy939; + if (yych == 'r') goto yy947; goto yy50; -yy903: +yy911: yych = *++lexer->cursor; - if (yych == 's') goto yy940; - if (yych == 'u') goto yy941; + if (yych == 's') goto yy948; + if (yych == 'u') goto yy949; goto yy50; -yy904: +yy912: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 352 "src/wasm-ast-lexer.c" +#line 354 "src/wasm-ast-lexer.c" { OPCODE(F64_COPYSIGN); RETURN(BINARY); } -#line 5341 "src/prebuilt/wasm-ast-lexer-gen.c" -yy906: +#line 5379 "src/prebuilt/wasm-ast-lexer-gen.c" +yy914: yych = *++lexer->cursor; - if (yych == 'f') goto yy942; + if (yych == 'f') goto yy950; goto yy50; -yy907: +yy915: yych = *++lexer->cursor; - if (yych == 'r') goto yy943; + if (yych == 'r') goto yy951; goto yy50; -yy908: +yy916: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 270 "src/wasm-ast-lexer.c" +#line 272 "src/wasm-ast-lexer.c" { OPCODE(I32_LOAD16_S); RETURN(LOAD); } -#line 5357 "src/prebuilt/wasm-ast-lexer-gen.c" -yy910: +#line 5395 "src/prebuilt/wasm-ast-lexer-gen.c" +yy918: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 272 "src/wasm-ast-lexer.c" +#line 274 "src/wasm-ast-lexer.c" { OPCODE(I32_LOAD16_U); RETURN(LOAD); } -#line 5365 "src/prebuilt/wasm-ast-lexer-gen.c" -yy912: +#line 5403 "src/prebuilt/wasm-ast-lexer-gen.c" +yy920: yych = *++lexer->cursor; - if (yych == 'r') goto yy944; + if (yych == 'r') goto yy952; goto yy50; -yy913: +yy921: yych = *++lexer->cursor; - if (yych == 'f') goto yy945; + if (yych == 'f') goto yy953; goto yy50; -yy914: +yy922: yych = *++lexer->cursor; - if (yych == 'f') goto yy946; + if (yych == 'f') goto yy954; goto yy50; -yy915: +yy923: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 387 "src/wasm-ast-lexer.c" +#line 389 "src/wasm-ast-lexer.c" { OPCODE(I32_WRAP_I64); RETURN(CONVERT); } -#line 5385 "src/prebuilt/wasm-ast-lexer-gen.c" -yy917: +#line 5423 "src/prebuilt/wasm-ast-lexer-gen.c" +yy925: yych = *++lexer->cursor; - if (yych == '/') goto yy947; + if (yych == '/') goto yy955; goto yy50; -yy918: +yy926: yych = *++lexer->cursor; - if (yych == '/') goto yy948; + if (yych == '/') goto yy956; goto yy50; -yy919: +yy927: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 271 "src/wasm-ast-lexer.c" +#line 273 "src/wasm-ast-lexer.c" { OPCODE(I64_LOAD16_S); RETURN(LOAD); } -#line 5401 "src/prebuilt/wasm-ast-lexer-gen.c" -yy921: +#line 5439 "src/prebuilt/wasm-ast-lexer-gen.c" +yy929: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 273 "src/wasm-ast-lexer.c" +#line 275 "src/wasm-ast-lexer.c" { OPCODE(I64_LOAD16_U); RETURN(LOAD); } -#line 5409 "src/prebuilt/wasm-ast-lexer-gen.c" -yy923: +#line 5447 "src/prebuilt/wasm-ast-lexer-gen.c" +yy931: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 274 "src/wasm-ast-lexer.c" +#line 276 "src/wasm-ast-lexer.c" { OPCODE(I64_LOAD32_S); RETURN(LOAD); } -#line 5417 "src/prebuilt/wasm-ast-lexer-gen.c" -yy925: +#line 5455 "src/prebuilt/wasm-ast-lexer-gen.c" +yy933: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 275 "src/wasm-ast-lexer.c" +#line 277 "src/wasm-ast-lexer.c" { OPCODE(I64_LOAD32_U); RETURN(LOAD); } -#line 5425 "src/prebuilt/wasm-ast-lexer-gen.c" -yy927: +#line 5463 "src/prebuilt/wasm-ast-lexer-gen.c" +yy935: yych = *++lexer->cursor; - if (yych == 'r') goto yy949; + if (yych == 'r') goto yy957; goto yy50; -yy928: +yy936: yych = *++lexer->cursor; - if (yych == 'f') goto yy950; + if (yych == 'f') goto yy958; goto yy50; -yy929: +yy937: yych = *++lexer->cursor; - if (yych == 'f') goto yy951; + if (yych == 'f') goto yy959; goto yy50; -yy930: +yy938: yych = *++lexer->cursor; - if (yych == 'd') goto yy952; + if (yych == 'd') goto yy960; goto yy50; -yy931: +yy939: ++lexer->cursor; if ((yych = *lexer->cursor) <= 'Z') { if (yych <= ')') { if (yych <= '!') { if (yych >= '!') goto yy49; } else { - if (yych <= '"') goto yy932; - if (yych <= '&') goto yy49; + if (yych <= '"') goto yy940; + if (yych <= '\'') goto yy49; } } else { if (yych <= ',') { @@ -5460,9 +5498,9 @@ yy931: if (yych <= '\\') { if (yych >= '\\') goto yy49; } else { - if (yych <= ']') goto yy932; + if (yych <= ']') goto yy940; if (yych <= '^') goto yy49; - goto yy954; + goto yy962; } } else { if (yych <= '|') { @@ -5472,521 +5510,521 @@ yy931: } } } -yy932: -#line 427 "src/wasm-ast-lexer.c" +yy940: +#line 429 "src/wasm-ast-lexer.c" { RETURN(ASSERT_RETURN); } -#line 5479 "src/prebuilt/wasm-ast-lexer-gen.c" -yy933: +#line 5517 "src/prebuilt/wasm-ast-lexer-gen.c" +yy941: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } #line 254 "src/wasm-ast-lexer.c" { RETURN(CALL_INDIRECT); } -#line 5487 "src/prebuilt/wasm-ast-lexer-gen.c" -yy935: +#line 5525 "src/prebuilt/wasm-ast-lexer-gen.c" +yy943: yych = *++lexer->cursor; - if (yych == 'y') goto yy955; + if (yych == 'y') goto yy963; goto yy50; -yy936: +yy944: yych = *++lexer->cursor; - if (yych == '/') goto yy957; + if (yych == '/') goto yy965; goto yy50; -yy937: +yy945: yych = *++lexer->cursor; - if (yych == '/') goto yy958; + if (yych == '/') goto yy966; goto yy50; -yy938: +yy946: yych = *++lexer->cursor; - if (yych == '4') goto yy959; + if (yych == '4') goto yy967; goto yy50; -yy939: +yy947: yych = *++lexer->cursor; - if (yych == 'e') goto yy961; + if (yych == 'e') goto yy969; goto yy50; -yy940: +yy948: yych = *++lexer->cursor; - if (yych == '/') goto yy962; + if (yych == '/') goto yy970; goto yy50; -yy941: +yy949: yych = *++lexer->cursor; - if (yych == '/') goto yy963; + if (yych == '/') goto yy971; goto yy50; -yy942: +yy950: yych = *++lexer->cursor; - if (yych == '3') goto yy964; + if (yych == '3') goto yy972; goto yy50; -yy943: +yy951: yych = *++lexer->cursor; - if (yych == 'e') goto yy965; + if (yych == 'e') goto yy973; goto yy50; -yy944: +yy952: yych = *++lexer->cursor; - if (yych == 'e') goto yy966; + if (yych == 'e') goto yy974; goto yy50; -yy945: +yy953: yych = *++lexer->cursor; - if (yych == '3') goto yy967; - if (yych == '6') goto yy968; + if (yych == '3') goto yy975; + if (yych == '6') goto yy976; goto yy50; -yy946: +yy954: yych = *++lexer->cursor; - if (yych == '3') goto yy969; - if (yych == '6') goto yy970; + if (yych == '3') goto yy977; + if (yych == '6') goto yy978; goto yy50; -yy947: +yy955: yych = *++lexer->cursor; - if (yych == 'i') goto yy971; + if (yych == 'i') goto yy979; goto yy50; -yy948: +yy956: yych = *++lexer->cursor; - if (yych == 'i') goto yy972; + if (yych == 'i') goto yy980; goto yy50; -yy949: +yy957: yych = *++lexer->cursor; - if (yych == 'e') goto yy973; + if (yych == 'e') goto yy981; goto yy50; -yy950: +yy958: yych = *++lexer->cursor; - if (yych == '3') goto yy974; - if (yych == '6') goto yy975; + if (yych == '3') goto yy982; + if (yych == '6') goto yy983; goto yy50; -yy951: +yy959: yych = *++lexer->cursor; - if (yych == '3') goto yy976; - if (yych == '6') goto yy977; + if (yych == '3') goto yy984; + if (yych == '6') goto yy985; goto yy50; -yy952: +yy960: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 426 "src/wasm-ast-lexer.c" +#line 428 "src/wasm-ast-lexer.c" { RETURN(ASSERT_INVALID); } -#line 5567 "src/prebuilt/wasm-ast-lexer-gen.c" -yy954: +#line 5605 "src/prebuilt/wasm-ast-lexer-gen.c" +yy962: yych = *++lexer->cursor; - if (yych == 'n') goto yy978; + if (yych == 'n') goto yy986; goto yy50; -yy955: +yy963: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 412 "src/wasm-ast-lexer.c" +#line 414 "src/wasm-ast-lexer.c" { RETURN(CURRENT_MEMORY); } -#line 5579 "src/prebuilt/wasm-ast-lexer-gen.c" -yy957: +#line 5617 "src/prebuilt/wasm-ast-lexer-gen.c" +yy965: yych = *++lexer->cursor; - if (yych == 'i') goto yy979; + if (yych == 'i') goto yy987; goto yy50; -yy958: +yy966: yych = *++lexer->cursor; - if (yych == 'i') goto yy980; + if (yych == 'i') goto yy988; goto yy50; -yy959: +yy967: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 405 "src/wasm-ast-lexer.c" +#line 407 "src/wasm-ast-lexer.c" { OPCODE(F32_DEMOTE_F64); RETURN(CONVERT); } -#line 5595 "src/prebuilt/wasm-ast-lexer-gen.c" -yy961: - yych = *++lexer->cursor; - if (yych == 't') goto yy981; - goto yy50; -yy962: - yych = *++lexer->cursor; - if (yych == 'i') goto yy982; - goto yy50; -yy963: - yych = *++lexer->cursor; - if (yych == 'i') goto yy983; - goto yy50; -yy964: - yych = *++lexer->cursor; - if (yych == '2') goto yy984; - goto yy50; -yy965: - yych = *++lexer->cursor; - if (yych == 't') goto yy986; - goto yy50; -yy966: - yych = *++lexer->cursor; - if (yych == 't') goto yy987; - goto yy50; -yy967: - yych = *++lexer->cursor; - if (yych == '2') goto yy988; - goto yy50; -yy968: - yych = *++lexer->cursor; - if (yych == '4') goto yy990; - goto yy50; +#line 5633 "src/prebuilt/wasm-ast-lexer-gen.c" yy969: yych = *++lexer->cursor; - if (yych == '2') goto yy992; + if (yych == 't') goto yy989; goto yy50; yy970: yych = *++lexer->cursor; - if (yych == '4') goto yy994; + if (yych == 'i') goto yy990; goto yy50; yy971: yych = *++lexer->cursor; - if (yych == '3') goto yy996; + if (yych == 'i') goto yy991; goto yy50; yy972: yych = *++lexer->cursor; - if (yych == '3') goto yy997; + if (yych == '2') goto yy992; goto yy50; yy973: yych = *++lexer->cursor; - if (yych == 't') goto yy998; + if (yych == 't') goto yy994; goto yy50; yy974: yych = *++lexer->cursor; - if (yych == '2') goto yy999; + if (yych == 't') goto yy995; goto yy50; yy975: yych = *++lexer->cursor; - if (yych == '4') goto yy1001; + if (yych == '2') goto yy996; goto yy50; yy976: yych = *++lexer->cursor; - if (yych == '2') goto yy1003; + if (yych == '4') goto yy998; goto yy50; yy977: yych = *++lexer->cursor; - if (yych == '4') goto yy1005; + if (yych == '2') goto yy1000; goto yy50; yy978: yych = *++lexer->cursor; - if (yych == 'a') goto yy1007; + if (yych == '4') goto yy1002; goto yy50; yy979: yych = *++lexer->cursor; - if (yych == '3') goto yy1008; - if (yych == '6') goto yy1009; + if (yych == '3') goto yy1004; goto yy50; yy980: yych = *++lexer->cursor; - if (yych == '3') goto yy1010; - if (yych == '6') goto yy1011; + if (yych == '3') goto yy1005; goto yy50; yy981: yych = *++lexer->cursor; - if (yych == '/') goto yy1012; + if (yych == 't') goto yy1006; goto yy50; yy982: yych = *++lexer->cursor; - if (yych == '3') goto yy1013; - if (yych == '6') goto yy1014; + if (yych == '2') goto yy1007; goto yy50; yy983: yych = *++lexer->cursor; - if (yych == '3') goto yy1015; - if (yych == '6') goto yy1016; + if (yych == '4') goto yy1009; goto yy50; yy984: + yych = *++lexer->cursor; + if (yych == '2') goto yy1011; + goto yy50; +yy985: + yych = *++lexer->cursor; + if (yych == '4') goto yy1013; + goto yy50; +yy986: + yych = *++lexer->cursor; + if (yych == 'a') goto yy1015; + goto yy50; +yy987: + yych = *++lexer->cursor; + if (yych == '3') goto yy1016; + if (yych == '6') goto yy1017; + goto yy50; +yy988: + yych = *++lexer->cursor; + if (yych == '3') goto yy1018; + if (yych == '6') goto yy1019; + goto yy50; +yy989: + yych = *++lexer->cursor; + if (yych == '/') goto yy1020; + goto yy50; +yy990: + yych = *++lexer->cursor; + if (yych == '3') goto yy1021; + if (yych == '6') goto yy1022; + goto yy50; +yy991: + yych = *++lexer->cursor; + if (yych == '3') goto yy1023; + if (yych == '6') goto yy1024; + goto yy50; +yy992: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 404 "src/wasm-ast-lexer.c" +#line 406 "src/wasm-ast-lexer.c" { OPCODE(F64_PROMOTE_F32); RETURN(CONVERT); } -#line 5699 "src/prebuilt/wasm-ast-lexer-gen.c" -yy986: +#line 5737 "src/prebuilt/wasm-ast-lexer-gen.c" +yy994: yych = *++lexer->cursor; - if (yych == '/') goto yy1017; + if (yych == '/') goto yy1025; goto yy50; -yy987: +yy995: yych = *++lexer->cursor; - if (yych == '/') goto yy1018; + if (yych == '/') goto yy1026; goto yy50; -yy988: +yy996: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 388 "src/wasm-ast-lexer.c" +#line 390 "src/wasm-ast-lexer.c" { OPCODE(I32_TRUNC_S_F32); RETURN(CONVERT); } -#line 5715 "src/prebuilt/wasm-ast-lexer-gen.c" -yy990: +#line 5753 "src/prebuilt/wasm-ast-lexer-gen.c" +yy998: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 390 "src/wasm-ast-lexer.c" +#line 392 "src/wasm-ast-lexer.c" { OPCODE(I32_TRUNC_S_F64); RETURN(CONVERT); } -#line 5723 "src/prebuilt/wasm-ast-lexer-gen.c" -yy992: +#line 5761 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1000: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 392 "src/wasm-ast-lexer.c" +#line 394 "src/wasm-ast-lexer.c" { OPCODE(I32_TRUNC_U_F32); RETURN(CONVERT); } -#line 5731 "src/prebuilt/wasm-ast-lexer-gen.c" -yy994: +#line 5769 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1002: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 394 "src/wasm-ast-lexer.c" +#line 396 "src/wasm-ast-lexer.c" { OPCODE(I32_TRUNC_U_F64); RETURN(CONVERT); } -#line 5739 "src/prebuilt/wasm-ast-lexer-gen.c" -yy996: +#line 5777 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1004: yych = *++lexer->cursor; - if (yych == '2') goto yy1019; + if (yych == '2') goto yy1027; goto yy50; -yy997: +yy1005: yych = *++lexer->cursor; - if (yych == '2') goto yy1021; + if (yych == '2') goto yy1029; goto yy50; -yy998: +yy1006: yych = *++lexer->cursor; - if (yych == '/') goto yy1023; + if (yych == '/') goto yy1031; goto yy50; -yy999: +yy1007: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 389 "src/wasm-ast-lexer.c" +#line 391 "src/wasm-ast-lexer.c" { OPCODE(I64_TRUNC_S_F32); RETURN(CONVERT); } -#line 5759 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1001: +#line 5797 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1009: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 391 "src/wasm-ast-lexer.c" +#line 393 "src/wasm-ast-lexer.c" { OPCODE(I64_TRUNC_S_F64); RETURN(CONVERT); } -#line 5767 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1003: +#line 5805 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1011: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 393 "src/wasm-ast-lexer.c" +#line 395 "src/wasm-ast-lexer.c" { OPCODE(I64_TRUNC_U_F32); RETURN(CONVERT); } -#line 5775 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1005: +#line 5813 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1013: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 395 "src/wasm-ast-lexer.c" +#line 397 "src/wasm-ast-lexer.c" { OPCODE(I64_TRUNC_U_F64); RETURN(CONVERT); } -#line 5783 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1007: +#line 5821 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1015: yych = *++lexer->cursor; - if (yych == 'n') goto yy1024; + if (yych == 'n') goto yy1032; goto yy50; -yy1008: +yy1016: yych = *++lexer->cursor; - if (yych == '2') goto yy1026; + if (yych == '2') goto yy1034; goto yy50; -yy1009: +yy1017: yych = *++lexer->cursor; - if (yych == '4') goto yy1028; + if (yych == '4') goto yy1036; goto yy50; -yy1010: +yy1018: yych = *++lexer->cursor; - if (yych == '2') goto yy1030; + if (yych == '2') goto yy1038; goto yy50; -yy1011: +yy1019: yych = *++lexer->cursor; - if (yych == '4') goto yy1032; + if (yych == '4') goto yy1040; goto yy50; -yy1012: +yy1020: yych = *++lexer->cursor; - if (yych == 'i') goto yy1034; + if (yych == 'i') goto yy1042; goto yy50; -yy1013: +yy1021: yych = *++lexer->cursor; - if (yych == '2') goto yy1035; + if (yych == '2') goto yy1043; goto yy50; -yy1014: +yy1022: yych = *++lexer->cursor; - if (yych == '4') goto yy1037; + if (yych == '4') goto yy1045; goto yy50; -yy1015: +yy1023: yych = *++lexer->cursor; - if (yych == '2') goto yy1039; + if (yych == '2') goto yy1047; goto yy50; -yy1016: +yy1024: yych = *++lexer->cursor; - if (yych == '4') goto yy1041; + if (yych == '4') goto yy1049; goto yy50; -yy1017: +yy1025: yych = *++lexer->cursor; - if (yych == 'i') goto yy1043; + if (yych == 'i') goto yy1051; goto yy50; -yy1018: +yy1026: yych = *++lexer->cursor; - if (yych == 'f') goto yy1044; + if (yych == 'f') goto yy1052; goto yy50; -yy1019: +yy1027: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 385 "src/wasm-ast-lexer.c" +#line 387 "src/wasm-ast-lexer.c" { OPCODE(I64_EXTEND_S_I32); RETURN(CONVERT); } -#line 5839 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1021: +#line 5877 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1029: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 386 "src/wasm-ast-lexer.c" +#line 388 "src/wasm-ast-lexer.c" { OPCODE(I64_EXTEND_U_I32); RETURN(CONVERT); } -#line 5847 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1023: +#line 5885 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1031: yych = *++lexer->cursor; - if (yych == 'f') goto yy1045; + if (yych == 'f') goto yy1053; goto yy50; -yy1024: +yy1032: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 428 "src/wasm-ast-lexer.c" +#line 430 "src/wasm-ast-lexer.c" { RETURN(ASSERT_RETURN_NAN); } -#line 5859 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1026: +#line 5897 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1034: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 396 "src/wasm-ast-lexer.c" +#line 398 "src/wasm-ast-lexer.c" { OPCODE(F32_CONVERT_S_I32); RETURN(CONVERT); } -#line 5867 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1028: +#line 5905 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1036: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 398 "src/wasm-ast-lexer.c" +#line 400 "src/wasm-ast-lexer.c" { OPCODE(F32_CONVERT_S_I64); RETURN(CONVERT); } -#line 5875 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1030: +#line 5913 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1038: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 400 "src/wasm-ast-lexer.c" +#line 402 "src/wasm-ast-lexer.c" { OPCODE(F32_CONVERT_U_I32); RETURN(CONVERT); } -#line 5883 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1032: +#line 5921 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1040: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 402 "src/wasm-ast-lexer.c" +#line 404 "src/wasm-ast-lexer.c" { OPCODE(F32_CONVERT_U_I64); RETURN(CONVERT); } -#line 5891 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1034: +#line 5929 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1042: yych = *++lexer->cursor; - if (yych == '3') goto yy1046; + if (yych == '3') goto yy1054; goto yy50; -yy1035: +yy1043: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 397 "src/wasm-ast-lexer.c" +#line 399 "src/wasm-ast-lexer.c" { OPCODE(F64_CONVERT_S_I32); RETURN(CONVERT); } -#line 5903 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1037: +#line 5941 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1045: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 399 "src/wasm-ast-lexer.c" +#line 401 "src/wasm-ast-lexer.c" { OPCODE(F64_CONVERT_S_I64); RETURN(CONVERT); } -#line 5911 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1039: +#line 5949 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1047: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 401 "src/wasm-ast-lexer.c" +#line 403 "src/wasm-ast-lexer.c" { OPCODE(F64_CONVERT_U_I32); RETURN(CONVERT); } -#line 5919 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1041: +#line 5957 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1049: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 403 "src/wasm-ast-lexer.c" +#line 405 "src/wasm-ast-lexer.c" { OPCODE(F64_CONVERT_U_I64); RETURN(CONVERT); } -#line 5927 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1043: +#line 5965 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1051: yych = *++lexer->cursor; - if (yych == '6') goto yy1047; + if (yych == '6') goto yy1055; goto yy50; -yy1044: +yy1052: yych = *++lexer->cursor; - if (yych == '3') goto yy1048; + if (yych == '3') goto yy1056; goto yy50; -yy1045: +yy1053: yych = *++lexer->cursor; - if (yych == '6') goto yy1049; + if (yych == '6') goto yy1057; goto yy50; -yy1046: +yy1054: yych = *++lexer->cursor; - if (yych == '2') goto yy1050; + if (yych == '2') goto yy1058; goto yy50; -yy1047: +yy1055: yych = *++lexer->cursor; - if (yych == '4') goto yy1052; + if (yych == '4') goto yy1060; goto yy50; -yy1048: +yy1056: yych = *++lexer->cursor; - if (yych == '2') goto yy1054; + if (yych == '2') goto yy1062; goto yy50; -yy1049: +yy1057: yych = *++lexer->cursor; - if (yych == '4') goto yy1056; + if (yych == '4') goto yy1064; goto yy50; -yy1050: +yy1058: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 406 "src/wasm-ast-lexer.c" +#line 408 "src/wasm-ast-lexer.c" { OPCODE(F32_REINTERPRET_I32); RETURN(CONVERT); } -#line 5963 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1052: +#line 6001 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1060: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 408 "src/wasm-ast-lexer.c" +#line 410 "src/wasm-ast-lexer.c" { OPCODE(F64_REINTERPRET_I64); RETURN(CONVERT); } -#line 5971 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1054: +#line 6009 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1062: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 407 "src/wasm-ast-lexer.c" +#line 409 "src/wasm-ast-lexer.c" { OPCODE(I32_REINTERPRET_F32); RETURN(CONVERT); } -#line 5979 "src/prebuilt/wasm-ast-lexer-gen.c" -yy1056: +#line 6017 "src/prebuilt/wasm-ast-lexer-gen.c" +yy1064: ++lexer->cursor; if (yybm[0+(yych = *lexer->cursor)] & 16) { goto yy49; } -#line 409 "src/wasm-ast-lexer.c" +#line 411 "src/wasm-ast-lexer.c" { OPCODE(I64_REINTERPRET_F64); RETURN(CONVERT); } -#line 5987 "src/prebuilt/wasm-ast-lexer-gen.c" +#line 6025 "src/prebuilt/wasm-ast-lexer-gen.c" } } -#line 451 "src/wasm-ast-lexer.c" +#line 453 "src/wasm-ast-lexer.c" } } diff --git a/src/prebuilt/wasm-ast-parser-gen.c b/src/prebuilt/wasm-ast-parser-gen.c index 503ffd57..a87794b2 100644 --- a/src/prebuilt/wasm-ast-parser-gen.c +++ b/src/prebuilt/wasm-ast-parser-gen.c @@ -119,6 +119,15 @@ #define USE_NATURAL_ALIGNMENT (~0) +static WasmExprList join_exprs1(WasmLocation* loc, WasmExpr* expr1); +static WasmExprList join_exprs2(WasmLocation* loc, WasmExprList* expr1, + WasmExpr* expr2); +static WasmExprList join_exprs3(WasmLocation* loc, WasmExprList* expr1, + WasmExprList* expr2, WasmExpr* expr3); +static WasmExprList join_exprs4(WasmLocation* loc, WasmExprList* expr1, + WasmExprList* expr2, WasmExprList* expr3, + WasmExpr* expr4); + static WasmFuncField* new_func_field(WasmAllocator* allocator) { return wasm_alloc_zero(allocator, sizeof(WasmFuncField), WASM_DEFAULT_ALIGN); } @@ -166,7 +175,7 @@ static void on_read_binary_error(uint32_t offset, const char* error, #define wasm_ast_parser_lex wasm_ast_lexer_lex -#line 170 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:339 */ +#line 179 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -219,52 +228,54 @@ extern int wasm_ast_parser_debug; WASM_TOKEN_TYPE_VAR = 264, WASM_TOKEN_TYPE_VALUE_TYPE = 265, WASM_TOKEN_TYPE_NOP = 266, - WASM_TOKEN_TYPE_BLOCK = 267, - WASM_TOKEN_TYPE_IF = 268, - WASM_TOKEN_TYPE_THEN = 269, - WASM_TOKEN_TYPE_ELSE = 270, - WASM_TOKEN_TYPE_LOOP = 271, - WASM_TOKEN_TYPE_BR = 272, - WASM_TOKEN_TYPE_BR_IF = 273, - WASM_TOKEN_TYPE_BR_TABLE = 274, - WASM_TOKEN_TYPE_CASE = 275, - WASM_TOKEN_TYPE_CALL = 276, - WASM_TOKEN_TYPE_CALL_IMPORT = 277, - WASM_TOKEN_TYPE_CALL_INDIRECT = 278, - WASM_TOKEN_TYPE_RETURN = 279, - WASM_TOKEN_TYPE_GET_LOCAL = 280, - WASM_TOKEN_TYPE_SET_LOCAL = 281, - WASM_TOKEN_TYPE_LOAD = 282, - WASM_TOKEN_TYPE_STORE = 283, - WASM_TOKEN_TYPE_OFFSET = 284, - WASM_TOKEN_TYPE_ALIGN = 285, - WASM_TOKEN_TYPE_CONST = 286, - WASM_TOKEN_TYPE_UNARY = 287, - WASM_TOKEN_TYPE_BINARY = 288, - WASM_TOKEN_TYPE_COMPARE = 289, - WASM_TOKEN_TYPE_CONVERT = 290, - WASM_TOKEN_TYPE_SELECT = 291, - WASM_TOKEN_TYPE_FUNC = 292, - WASM_TOKEN_TYPE_START = 293, - WASM_TOKEN_TYPE_TYPE = 294, - WASM_TOKEN_TYPE_PARAM = 295, - WASM_TOKEN_TYPE_RESULT = 296, - WASM_TOKEN_TYPE_LOCAL = 297, - WASM_TOKEN_TYPE_MODULE = 298, - WASM_TOKEN_TYPE_MEMORY = 299, - WASM_TOKEN_TYPE_SEGMENT = 300, - WASM_TOKEN_TYPE_IMPORT = 301, - WASM_TOKEN_TYPE_EXPORT = 302, - WASM_TOKEN_TYPE_TABLE = 303, - WASM_TOKEN_TYPE_UNREACHABLE = 304, - WASM_TOKEN_TYPE_CURRENT_MEMORY = 305, - WASM_TOKEN_TYPE_GROW_MEMORY = 306, - WASM_TOKEN_TYPE_ASSERT_INVALID = 307, - WASM_TOKEN_TYPE_ASSERT_RETURN = 308, - WASM_TOKEN_TYPE_ASSERT_RETURN_NAN = 309, - WASM_TOKEN_TYPE_ASSERT_TRAP = 310, - WASM_TOKEN_TYPE_INVOKE = 311, - WASM_TOKEN_TYPE_LOW = 312 + WASM_TOKEN_TYPE_DROP = 267, + WASM_TOKEN_TYPE_BLOCK = 268, + WASM_TOKEN_TYPE_END = 269, + WASM_TOKEN_TYPE_IF = 270, + WASM_TOKEN_TYPE_THEN = 271, + WASM_TOKEN_TYPE_ELSE = 272, + WASM_TOKEN_TYPE_LOOP = 273, + WASM_TOKEN_TYPE_BR = 274, + WASM_TOKEN_TYPE_BR_IF = 275, + WASM_TOKEN_TYPE_BR_TABLE = 276, + WASM_TOKEN_TYPE_CALL = 277, + WASM_TOKEN_TYPE_CALL_IMPORT = 278, + WASM_TOKEN_TYPE_CALL_INDIRECT = 279, + WASM_TOKEN_TYPE_RETURN = 280, + WASM_TOKEN_TYPE_GET_LOCAL = 281, + WASM_TOKEN_TYPE_SET_LOCAL = 282, + WASM_TOKEN_TYPE_TEE_LOCAL = 283, + WASM_TOKEN_TYPE_LOAD = 284, + WASM_TOKEN_TYPE_STORE = 285, + WASM_TOKEN_TYPE_OFFSET = 286, + WASM_TOKEN_TYPE_ALIGN = 287, + WASM_TOKEN_TYPE_CONST = 288, + WASM_TOKEN_TYPE_UNARY = 289, + WASM_TOKEN_TYPE_BINARY = 290, + WASM_TOKEN_TYPE_COMPARE = 291, + WASM_TOKEN_TYPE_CONVERT = 292, + WASM_TOKEN_TYPE_SELECT = 293, + WASM_TOKEN_TYPE_UNREACHABLE = 294, + WASM_TOKEN_TYPE_CURRENT_MEMORY = 295, + WASM_TOKEN_TYPE_GROW_MEMORY = 296, + WASM_TOKEN_TYPE_FUNC = 297, + WASM_TOKEN_TYPE_START = 298, + WASM_TOKEN_TYPE_TYPE = 299, + WASM_TOKEN_TYPE_PARAM = 300, + WASM_TOKEN_TYPE_RESULT = 301, + WASM_TOKEN_TYPE_LOCAL = 302, + WASM_TOKEN_TYPE_MODULE = 303, + WASM_TOKEN_TYPE_MEMORY = 304, + WASM_TOKEN_TYPE_SEGMENT = 305, + WASM_TOKEN_TYPE_IMPORT = 306, + WASM_TOKEN_TYPE_EXPORT = 307, + WASM_TOKEN_TYPE_TABLE = 308, + WASM_TOKEN_TYPE_ASSERT_INVALID = 309, + WASM_TOKEN_TYPE_ASSERT_RETURN = 310, + WASM_TOKEN_TYPE_ASSERT_RETURN_NAN = 311, + WASM_TOKEN_TYPE_ASSERT_TRAP = 312, + WASM_TOKEN_TYPE_INVOKE = 313, + WASM_TOKEN_TYPE_LOW = 314 }; #endif @@ -297,7 +308,7 @@ int wasm_ast_parser_parse (WasmAstLexer* lexer, WasmAstParser* parser); /* Copy the second part of user declarations. */ -#line 301 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:358 */ +#line 312 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:358 */ #ifdef short # undef short @@ -541,21 +552,21 @@ union yyalloc /* YYFINAL -- State number of the termination state. */ #define YYFINAL 8 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 373 +#define YYLAST 689 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 58 +#define YYNTOKENS 60 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 46 +#define YYNNTS 47 /* YYNRULES -- Number of rules. */ -#define YYNRULES 122 +#define YYNRULES 154 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 274 +#define YYNSTATES 344 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 -#define YYMAXUTOK 312 +#define YYMAXUTOK 314 #define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) @@ -595,26 +606,29 @@ static const yytype_uint8 yytranslate[] = 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57 + 55, 56, 57, 58, 59 }; #if WASM_AST_PARSER_DEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 203, 203, 209, 222, 223, 229, 230, 234, 238, - 245, 249, 253, 260, 272, 279, 280, 286, 290, 306, - 313, 314, 318, 319, 329, 330, 341, 344, 347, 352, - 357, 363, 369, 377, 382, 388, 394, 400, 405, 409, - 416, 423, 429, 435, 442, 446, 451, 458, 466, 478, - 483, 489, 495, 501, 506, 509, 513, 519, 520, 523, - 527, 535, 536, 541, 542, 548, 554, 564, 570, 576, - 586, 589, 644, 653, 663, 670, 681, 682, 689, 693, - 706, 714, 715, 722, 734, 745, 751, 760, 764, 771, - 775, 782, 790, 796, 806, 813, 819, 822, 861, 882, - 899, 907, 915, 933, 941, 952, 986, 995, 1019, 1025, - 1032, 1038, 1046, 1053, 1063, 1064, 1072, 1084, 1085, 1088, - 1089, 1096, 1105 + 0, 212, 212, 218, 231, 232, 238, 239, 243, 247, + 254, 265, 269, 273, 280, 292, 299, 300, 306, 310, + 326, 333, 334, 336, 339, 340, 350, 351, 362, 363, + 366, 369, 372, 375, 380, 385, 394, 399, 404, 410, + 413, 418, 425, 428, 432, 436, 440, 444, 448, 452, + 458, 464, 476, 480, 484, 488, 492, 495, 500, 503, + 506, 509, 515, 521, 531, 537, 543, 549, 555, 562, + 569, 573, 577, 582, 588, 594, 602, 608, 612, 617, + 622, 627, 632, 637, 642, 649, 656, 669, 674, 679, + 684, 689, 693, 699, 700, 710, 711, 717, 723, 733, + 739, 745, 755, 758, 813, 822, 832, 839, 850, 851, + 858, 862, 875, 883, 884, 891, 903, 914, 920, 929, + 933, 940, 944, 951, 959, 965, 975, 982, 988, 991, + 1030, 1051, 1068, 1076, 1084, 1102, 1110, 1121, 1155, 1164, + 1188, 1194, 1201, 1207, 1215, 1222, 1232, 1233, 1241, 1253, + 1254, 1257, 1258, 1265, 1274 }; #endif @@ -624,23 +638,23 @@ static const yytype_uint16 yyrline[] = static const char *const yytname[] = { "\"EOF\"", "error", "$undefined", "\"(\"", "\")\"", "NAT", "INT", - "FLOAT", "TEXT", "VAR", "VALUE_TYPE", "NOP", "BLOCK", "IF", "THEN", - "ELSE", "LOOP", "BR", "BR_IF", "BR_TABLE", "CASE", "CALL", "CALL_IMPORT", - "CALL_INDIRECT", "RETURN", "GET_LOCAL", "SET_LOCAL", "LOAD", "STORE", - "OFFSET", "ALIGN", "CONST", "UNARY", "BINARY", "COMPARE", "CONVERT", - "SELECT", "FUNC", "START", "TYPE", "PARAM", "RESULT", "LOCAL", "MODULE", - "MEMORY", "SEGMENT", "IMPORT", "EXPORT", "TABLE", "UNREACHABLE", - "CURRENT_MEMORY", "GROW_MEMORY", "ASSERT_INVALID", "ASSERT_RETURN", - "ASSERT_RETURN_NAN", "ASSERT_TRAP", "INVOKE", "LOW", "$accept", - "text_list", "value_type_list", "func_type", "literal", "var", - "var_list", "bind_var", "quoted_text", "segment_contents", "labeling", - "offset", "align", "expr", "expr1", "expr_opt", "non_empty_expr_list", - "expr_list", "func_fields", "func_body", "type_use", "func_info", "func", - "export_opt", "start", "segment_address", "segment", "segment_list", - "initial_pages", "max_pages", "memory", "type_def", "table", "import", - "export", "export_memory", "module_fields", "raw_module", "module", - "cmd", "cmd_list", "const", "const_opt", "const_list", "script", - "script_start", YY_NULLPTR + "FLOAT", "TEXT", "VAR", "VALUE_TYPE", "NOP", "DROP", "BLOCK", "END", + "IF", "THEN", "ELSE", "LOOP", "BR", "BR_IF", "BR_TABLE", "CALL", + "CALL_IMPORT", "CALL_INDIRECT", "RETURN", "GET_LOCAL", "SET_LOCAL", + "TEE_LOCAL", "LOAD", "STORE", "OFFSET", "ALIGN", "CONST", "UNARY", + "BINARY", "COMPARE", "CONVERT", "SELECT", "UNREACHABLE", + "CURRENT_MEMORY", "GROW_MEMORY", "FUNC", "START", "TYPE", "PARAM", + "RESULT", "LOCAL", "MODULE", "MEMORY", "SEGMENT", "IMPORT", "EXPORT", + "TABLE", "ASSERT_INVALID", "ASSERT_RETURN", "ASSERT_RETURN_NAN", + "ASSERT_TRAP", "INVOKE", "LOW", "$accept", "text_list", + "value_type_list", "func_type", "nat", "literal", "var", "var_list", + "bind_var", "quoted_text", "segment_contents", "labeling", "labeling1", + "offset", "align", "expr", "op", "expr1", "expr_list", "func_fields", + "func_body", "type_use", "func_info", "func", "export_opt", "start", + "segment_address", "segment", "segment_list", "initial_pages", + "max_pages", "memory", "type_def", "table", "import", "export", + "export_memory", "module_fields", "raw_module", "module", "cmd", + "cmd_list", "const", "const_opt", "const_list", "script", "script_start", YY_NULLPTR }; #endif @@ -654,16 +668,16 @@ static const yytype_uint16 yytoknum[] = 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, - 305, 306, 307, 308, 309, 310, 311, 312 + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314 }; # endif -#define YYPACT_NINF -210 +#define YYPACT_NINF -257 #define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-210))) + (!!((Yystate) == (-257))) -#define YYTABLE_NINF -1 +#define YYTABLE_NINF -94 #define yytable_value_is_error(Yytable_value) \ 0 @@ -672,34 +686,41 @@ static const yytype_uint16 yytoknum[] = STATE-NUM. */ static const yytype_int16 yypact[] = { - -210, 7, -210, 18, 53, -210, -210, -210, -210, 38, - 33, 48, 67, 87, 68, -210, 75, 91, 13, 68, - 36, 45, 47, -210, -210, -210, -210, 76, -210, -210, - -210, -210, -210, -210, -210, -210, -210, 106, 68, 68, - 68, 94, 68, 82, 23, 107, 108, 68, -210, -210, - -210, -210, -210, 88, -210, -210, -210, 28, -210, -210, - 130, 117, -210, 152, -210, 151, 68, 68, 19, 73, - 138, 141, 143, 120, 158, 154, -210, 155, -210, -210, - -210, 156, 157, -210, 159, 123, -210, 145, -210, 68, - 160, 161, 162, -210, -210, 169, 174, 68, -210, -210, - -210, 183, -210, 164, 155, 164, 82, 82, -210, 82, - 82, 82, 155, 82, 82, 166, 166, 120, 155, 155, - 155, 155, 155, 82, 164, 178, 164, -210, -210, 155, - 192, 156, 197, 322, -210, 199, 198, -210, 110, 200, - 159, 168, -210, -210, 149, 160, 90, 201, 202, -210, - -210, -210, 210, -210, 215, -210, -210, 155, 225, 164, - 155, 155, 155, 82, 155, 155, 155, -210, -210, -210, - 155, -210, 173, 173, -210, -210, 155, 155, -210, 155, - 232, 29, 219, 233, 30, 228, -210, -210, 238, -210, - -210, -210, 234, 239, 241, 242, -210, 251, 256, -210, - -210, -210, -210, -210, 240, 155, 155, -210, -210, 155, - 155, -210, -210, 155, -210, -210, 155, 155, -210, -210, - 155, -210, 156, -210, 265, 243, 243, 266, -210, 64, - 273, -210, 274, -210, 38, -210, -210, 164, -210, -210, - -210, 155, -210, -210, 155, -210, -210, 156, 281, -210, - -210, 243, 276, -210, -210, 272, 277, 155, -210, -210, - -210, -210, 244, -210, 278, 285, 280, 282, 269, -210, - 164, 155, 283, -210 + -257, 30, -257, 40, 64, -257, -257, -257, -257, 68, + 45, 92, 94, 101, 80, -257, 49, 15, 77, 80, + 58, 71, 97, -257, -257, -257, -257, -7, -257, -257, + -257, -257, -257, -257, -257, -257, -257, 148, 80, 80, + 80, 52, 80, 85, 29, 133, 125, 80, -257, -257, + -257, -257, -257, 132, -257, -257, -257, 245, -257, -257, + 158, 128, -257, 184, -257, 183, 80, 80, 21, 131, + 155, 157, 170, 76, 510, -257, -257, 180, 180, 180, + 185, 185, 185, 85, 85, 85, -257, 85, 85, 85, + 160, 160, 76, -257, -257, -257, -257, -257, -257, -257, + -257, 323, 362, -257, -257, -257, -257, 401, 188, -257, + 190, 152, -257, 174, -257, 80, 194, 195, 196, -257, + -257, 198, 200, 80, -257, -257, -257, 201, -257, 362, + 180, 362, 180, 85, 85, -257, 85, 85, 85, 362, + 85, 85, 85, 160, 160, 76, 362, 362, 362, 362, + 362, -257, -257, 362, 85, 180, 197, 180, 202, -257, + 362, -257, 362, 362, 180, -257, 85, 85, -257, -257, + -257, -257, -257, -257, -257, -257, 166, 166, -257, 401, + 204, 648, -257, 547, 205, -257, 134, 206, 190, 162, + -257, -257, 179, 194, 65, 209, 210, -257, -257, -257, + 211, -257, 212, -257, -257, 362, 440, 203, 362, 180, + 362, 362, 85, 362, 362, 362, -257, -257, 362, 362, + 166, 166, -257, -257, 362, 362, -257, 362, -257, 213, + 37, 216, 215, 39, 217, -257, 207, 137, 208, 362, + -257, -257, 85, -257, -257, -257, 219, -257, -257, -257, + 218, 225, 226, 228, -257, 227, 230, -257, -257, -257, + -257, -257, 617, 284, 362, -257, 362, -257, 362, 362, + -257, -257, 362, -257, -257, 362, 362, -257, -257, 362, + -257, 401, -257, 231, 479, 479, 232, -257, -257, 180, + -257, 223, 98, -257, 62, 234, -257, 235, -257, 68, + -257, -257, 180, 284, -257, -257, -257, 362, -257, -257, + 362, -257, -257, 401, 584, -257, -257, 479, 362, -257, + 237, -257, -257, 238, 239, 362, -257, -257, -257, -257, + 233, 199, -257, 246, -257, 241, 250, 251, 242, -257, + 180, 362, 257, -257 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -707,211 +728,293 @@ static const yytype_int16 yypact[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 114, 121, 122, 0, 0, 107, 108, 115, 1, 96, + 146, 153, 154, 0, 0, 139, 140, 147, 1, 128, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, - 0, 0, 0, 18, 119, 106, 3, 0, 105, 97, - 104, 103, 102, 101, 98, 99, 100, 0, 0, 0, - 0, 0, 76, 0, 0, 0, 0, 0, 15, 110, - 119, 119, 119, 0, 109, 120, 77, 61, 13, 14, - 0, 0, 17, 0, 83, 81, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 61, 59, 62, 67, 71, - 63, 61, 0, 78, 6, 0, 84, 0, 81, 0, - 6, 0, 0, 89, 16, 117, 0, 0, 11, 10, - 12, 0, 27, 20, 0, 20, 0, 0, 15, 0, - 0, 0, 57, 0, 0, 22, 22, 0, 0, 0, - 0, 0, 0, 0, 4, 0, 4, 54, 55, 0, - 0, 61, 0, 0, 60, 0, 0, 74, 0, 0, - 6, 0, 86, 82, 0, 6, 0, 0, 0, 95, - 94, 118, 0, 112, 0, 116, 21, 61, 0, 21, - 61, 57, 0, 0, 61, 61, 0, 58, 38, 44, - 0, 23, 24, 24, 48, 49, 0, 0, 53, 0, - 0, 0, 0, 0, 0, 0, 56, 26, 0, 75, - 72, 4, 0, 0, 0, 0, 85, 0, 0, 92, - 90, 111, 113, 28, 0, 29, 61, 35, 37, 33, - 16, 41, 42, 61, 45, 25, 0, 0, 50, 52, - 0, 70, 61, 5, 0, 61, 61, 0, 73, 0, - 0, 87, 0, 79, 0, 93, 91, 20, 31, 36, - 34, 39, 43, 46, 0, 51, 65, 61, 0, 64, - 68, 61, 7, 9, 88, 19, 0, 61, 40, 47, - 66, 69, 0, 80, 0, 0, 30, 0, 0, 8, - 20, 61, 0, 32 + 0, 0, 0, 19, 151, 138, 3, 0, 137, 129, + 136, 135, 134, 133, 130, 131, 132, 0, 0, 0, + 0, 0, 108, 0, 0, 0, 0, 0, 16, 142, + 151, 151, 151, 0, 141, 152, 109, 93, 14, 15, + 0, 0, 18, 0, 115, 113, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 31, 32, 21, 21, 21, + 0, 0, 0, 0, 0, 0, 39, 0, 0, 0, + 24, 24, 0, 52, 53, 54, 55, 42, 30, 56, + 57, 93, 93, 28, 99, 103, 95, 93, 0, 110, + 6, 0, 116, 0, 113, 0, 6, 0, 0, 121, + 17, 149, 0, 0, 11, 12, 13, 0, 59, 0, + 21, 93, 21, 0, 0, 16, 0, 0, 0, 70, + 0, 0, 0, 24, 24, 0, 0, 0, 0, 0, + 0, 58, 91, 0, 0, 4, 0, 4, 0, 23, + 93, 22, 93, 93, 22, 10, 0, 0, 16, 43, + 44, 45, 46, 47, 48, 25, 26, 26, 51, 93, + 0, 0, 94, 0, 0, 106, 0, 0, 6, 0, + 118, 114, 0, 6, 0, 0, 0, 127, 126, 150, + 0, 144, 0, 148, 60, 93, 93, 0, 93, 22, + 64, 0, 0, 93, 93, 0, 71, 81, 0, 0, + 26, 26, 86, 87, 0, 0, 90, 0, 92, 0, + 0, 0, 0, 0, 0, 29, 0, 0, 0, 93, + 36, 37, 0, 27, 49, 50, 0, 107, 104, 4, + 0, 0, 0, 0, 117, 0, 0, 124, 122, 143, + 145, 61, 0, 72, 93, 62, 93, 65, 66, 17, + 78, 79, 93, 82, 83, 0, 0, 88, 89, 0, + 102, 93, 5, 0, 93, 93, 0, 33, 40, 21, + 34, 0, 38, 105, 0, 0, 119, 0, 111, 0, + 125, 123, 21, 73, 76, 63, 67, 68, 80, 84, + 0, 77, 97, 93, 0, 96, 100, 93, 93, 35, + 7, 9, 120, 20, 0, 93, 69, 85, 98, 101, + 0, 0, 112, 0, 41, 0, 74, 0, 0, 8, + 21, 93, 0, 75 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -210, 54, -125, -76, 179, -52, 193, -38, -17, -210, - -102, 194, 146, -77, -210, 150, -210, -153, -209, -178, - -70, -66, -210, -210, -210, -210, -210, 230, -210, -210, - -210, -210, -210, -210, -210, -210, -210, 310, -210, -210, - -210, 226, -210, 86, -210, -210 + -257, -57, -149, -102, 104, -80, -10, -101, -40, 129, + -257, -78, -68, -75, -170, -126, -257, -257, -100, -242, + -256, -91, -92, -257, -257, -257, -257, -257, 135, -257, + -257, -257, -257, -257, -257, -257, -257, -257, 266, -257, + -257, -257, 156, -257, 95, -257, -257 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 16, 181, 139, 101, 60, 69, 156, 24, 256, - 157, 172, 216, 76, 130, 168, 77, 78, 79, 80, - 81, 82, 29, 57, 30, 234, 143, 87, 65, 88, - 31, 32, 33, 34, 35, 36, 17, 5, 6, 7, - 1, 55, 152, 41, 2, 3 + -1, 16, 230, 187, 166, 127, 60, 69, 159, 24, + 324, 160, 161, 176, 244, 102, 103, 158, 104, 105, + 106, 107, 108, 29, 57, 30, 299, 191, 113, 65, + 114, 31, 32, 33, 34, 35, 36, 17, 5, 6, + 7, 1, 55, 200, 41, 2, 3 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_uint16 yytable[] = +static const yytype_int16 yytable[] = { - 134, 184, 37, 160, 203, 131, 63, 207, 66, 132, - 4, 211, 212, 246, 147, 136, 92, 94, 8, 75, - 148, 50, 51, 52, 58, 56, 61, 158, 59, 67, - 68, 74, 62, 222, 226, 167, 18, 62, 260, 223, - 223, 175, 176, 177, 178, 179, 15, 249, 250, 89, - 90, 20, 186, 239, 161, 162, 9, 164, 165, 166, - 242, 169, 170, 91, 194, 188, 229, 159, 252, 197, - 21, 180, 145, 261, 223, 198, 23, 93, 58, 25, - 154, 205, 59, 26, 167, 209, 182, 58, 185, 213, - 22, 59, 38, 214, 27, 28, 9, 53, 54, 218, - 219, 39, 220, 40, 264, 10, 11, 12, 13, 14, - 49, 210, 64, 42, 43, 44, 23, 62, 272, 73, - 45, 206, 46, 47, 48, 98, 99, 100, 238, 123, - 191, 192, 240, 241, 83, 257, 70, 71, 72, 243, - 244, 53, 95, 245, 53, 96, 53, 97, 141, 142, - 191, 192, 141, 196, 84, 85, 86, 74, 133, 135, - 140, 137, 138, 146, 258, 149, 150, 259, 271, 102, - 103, 104, 53, 62, 105, 106, 107, 108, 153, 109, - 110, 111, 112, 113, 114, 115, 116, 155, 183, 117, - 118, 119, 120, 121, 122, 171, 187, 123, 124, 125, - 126, 189, 190, 215, 193, 199, 200, 127, 128, 129, - 102, 103, 104, 195, 201, 105, 106, 107, 108, 202, - 109, 110, 111, 112, 113, 114, 115, 116, 204, 224, - 117, 118, 119, 120, 121, 122, 221, 225, 227, 124, - 125, 126, 228, 231, 230, 232, 248, 233, 127, 128, - 129, 102, 103, 104, 237, 235, 105, 106, 107, 108, - 236, 109, 110, 111, 112, 113, 114, 115, 116, 247, - 251, 117, 118, 119, 120, 121, 122, 253, 254, 262, - 26, 263, 266, 268, 270, 265, 269, 273, 255, 127, - 128, 129, 102, 103, 104, 267, 174, 105, 106, 107, - 108, 163, 109, 110, 111, 112, 113, 114, 115, 116, - 173, 208, 117, 118, 119, 120, 121, 122, 144, 217, - 19, 151, 0, 126, 0, 0, 0, 0, 0, 0, - 127, 128, 129, 102, 103, 104, 0, 0, 105, 106, - 107, 108, 0, 109, 110, 111, 112, 113, 114, 115, - 116, 0, 0, 117, 118, 119, 120, 121, 122, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 127, 128, 129 + 162, 163, 182, 204, 63, 206, 66, 245, 233, 180, + 179, 164, 178, 216, 195, 184, 177, 101, 27, 28, + 223, 224, 225, 226, 227, 196, 58, 228, 315, 316, + 59, 207, 61, 4, 212, 42, 43, 44, 62, 312, + 8, 281, 45, 285, 46, 47, 48, 282, 18, 282, + 275, 276, 205, 25, 208, 53, 54, 26, 118, 120, + 236, 329, 237, 238, 209, 222, 320, 242, 220, 221, + 117, 328, 282, 169, 170, 171, 15, 172, 173, 174, + 263, 124, 125, 126, 267, 268, 252, 246, 23, 272, + 58, 255, 273, 274, 59, 20, 239, 21, 277, 278, + 294, 279, 256, -17, 22, 261, 182, -17, 265, 154, + 249, 250, 9, 270, 271, 231, 38, 234, 10, 11, + 12, 13, 14, 210, 211, 9, 213, 214, 215, 39, + 217, 218, 219, 23, 62, 119, 58, 303, 64, 291, + 59, 266, 306, 307, 229, 70, 71, 72, 37, 309, + 310, 288, 49, 311, 289, 40, 240, 241, 53, 121, + 53, 122, 109, 182, 304, 73, 305, 50, 51, 52, + 110, 56, 308, 53, 123, 67, 68, 189, 190, 249, + 250, 326, 189, 254, 327, 167, 168, 111, 112, 62, + 165, 175, 185, 186, 188, 115, 116, 194, 243, 197, + 198, 53, 269, 182, 201, 203, 235, 232, 247, 248, + 251, 318, 253, 257, 258, 259, 260, 280, 330, 284, + 264, 287, 290, 293, 325, 333, 283, 286, 295, 296, + 297, 300, 292, 298, 301, 313, 317, 319, 321, 322, + 331, 342, 323, 332, 193, 335, 26, 334, 74, 192, + 336, 337, 202, 338, 62, 339, 75, 76, 77, 340, + 78, 343, 341, 79, 80, 81, 82, 83, 84, 85, + 86, 87, 88, 89, 90, 91, 19, 199, 92, 93, + 94, 95, 96, 97, 98, 99, 100, 181, 0, 0, + 0, 0, 0, 0, 0, 75, 76, 77, 0, 78, + 0, -93, 79, 80, 81, 82, 83, 84, 85, 86, + 87, 88, 89, 90, 91, 0, 0, 92, 93, 94, + 95, 96, 97, 98, 99, 100, 74, 0, 0, 0, + 0, 0, 0, 0, 75, 76, 77, 0, 78, 0, + 0, 79, 80, 81, 82, 83, 84, 85, 86, 87, + 88, 89, 90, 91, 0, 0, 92, 93, 94, 95, + 96, 97, 98, 99, 100, 181, 0, 0, 0, 0, + 0, 0, 0, 75, 76, 77, 0, 78, 0, 0, + 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, + 89, 90, 91, 0, 0, 92, 93, 94, 95, 96, + 97, 98, 99, 100, 183, 0, 0, 0, 0, 0, + 0, 0, 75, 76, 77, 0, 78, 0, 0, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 0, 0, 92, 93, 94, 95, 96, 97, + 98, 99, 100, 262, 0, 0, 0, 0, 0, 0, + 0, 75, 76, 77, 0, 78, 0, 0, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, + 91, 0, 0, 92, 93, 94, 95, 96, 97, 98, + 99, 100, 314, 0, 0, 0, 0, 0, 0, 0, + 75, 76, 77, 0, 78, 0, 0, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, + 0, 0, 92, 93, 94, 95, 96, 97, 98, 99, + 100, 128, 129, 130, 0, 131, 0, 0, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, + 144, 0, 0, 145, 146, 147, 148, 149, 150, 151, + 152, 153, 0, 0, 154, 155, 156, 157, 128, 129, + 130, 0, 131, 0, 0, 132, 133, 134, 135, 136, + 137, 138, 139, 140, 141, 142, 143, 144, 0, 0, + 145, 146, 147, 148, 149, 150, 151, 152, 153, 0, + 0, 0, 155, 156, 157, 128, 129, 130, 0, 131, + 0, 0, 132, 133, 134, 135, 136, 137, 138, 139, + 140, 141, 142, 143, 144, 0, 0, 145, 146, 147, + 148, 149, 150, 151, 152, 153, 0, 0, 128, 129, + 130, 157, 131, 302, 0, 132, 133, 134, 135, 136, + 137, 138, 139, 140, 141, 142, 143, 144, 0, 0, + 145, 146, 147, 148, 149, 150, 151, 152, 153, 128, + 129, 130, 0, 131, 0, 0, 132, 133, 134, 135, + 136, 137, 138, 139, 140, 141, 142, 143, 144, 0, + 0, 145, 146, 147, 148, 149, 150, 151, 152, 153 }; static const yytype_int16 yycheck[] = { - 77, 126, 19, 105, 157, 75, 44, 160, 46, 75, - 3, 164, 165, 222, 90, 81, 68, 69, 0, 57, - 90, 38, 39, 40, 5, 42, 3, 104, 9, 46, - 47, 3, 9, 4, 4, 112, 3, 9, 247, 10, - 10, 118, 119, 120, 121, 122, 8, 225, 226, 66, - 67, 3, 129, 206, 106, 107, 43, 109, 110, 111, - 213, 113, 114, 44, 140, 131, 191, 105, 4, 145, - 3, 123, 89, 251, 10, 145, 8, 4, 5, 4, - 97, 158, 9, 8, 161, 162, 124, 5, 126, 166, - 3, 9, 56, 170, 3, 4, 43, 3, 4, 176, - 177, 56, 179, 56, 257, 52, 53, 54, 55, 56, - 4, 163, 5, 37, 38, 39, 8, 9, 271, 31, - 44, 159, 46, 47, 48, 5, 6, 7, 205, 39, - 40, 41, 209, 210, 4, 237, 50, 51, 52, 216, - 217, 3, 4, 220, 3, 4, 3, 4, 3, 4, - 40, 41, 3, 4, 37, 3, 5, 3, 3, 3, - 37, 4, 3, 3, 241, 4, 4, 244, 270, 11, - 12, 13, 3, 9, 16, 17, 18, 19, 4, 21, - 22, 23, 24, 25, 26, 27, 28, 4, 10, 31, - 32, 33, 34, 35, 36, 29, 4, 39, 40, 41, - 42, 4, 4, 30, 4, 4, 4, 49, 50, 51, - 11, 12, 13, 45, 4, 16, 17, 18, 19, 4, - 21, 22, 23, 24, 25, 26, 27, 28, 3, 10, - 31, 32, 33, 34, 35, 36, 4, 4, 10, 40, - 41, 42, 4, 4, 10, 4, 3, 5, 49, 50, - 51, 11, 12, 13, 14, 4, 16, 17, 18, 19, - 4, 21, 22, 23, 24, 25, 26, 27, 28, 4, - 4, 31, 32, 33, 34, 35, 36, 4, 4, 3, - 8, 4, 4, 3, 15, 41, 4, 4, 234, 49, - 50, 51, 11, 12, 13, 10, 117, 16, 17, 18, - 19, 108, 21, 22, 23, 24, 25, 26, 27, 28, - 116, 161, 31, 32, 33, 34, 35, 36, 88, 173, - 10, 95, -1, 42, -1, -1, -1, -1, -1, -1, - 49, 50, 51, 11, 12, 13, -1, -1, 16, 17, - 18, 19, -1, 21, 22, 23, 24, 25, 26, 27, - 28, -1, -1, 31, 32, 33, 34, 35, 36, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 49, 50, 51 + 78, 79, 102, 129, 44, 131, 46, 177, 157, 101, + 101, 79, 92, 139, 116, 107, 91, 57, 3, 4, + 146, 147, 148, 149, 150, 116, 5, 153, 284, 285, + 9, 131, 3, 3, 135, 42, 43, 44, 9, 281, + 0, 4, 49, 4, 51, 52, 53, 10, 3, 10, + 220, 221, 130, 4, 132, 3, 4, 8, 68, 69, + 160, 317, 162, 163, 132, 145, 4, 168, 143, 144, + 49, 313, 10, 83, 84, 85, 8, 87, 88, 89, + 206, 5, 6, 7, 210, 211, 188, 179, 8, 215, + 5, 193, 218, 219, 9, 3, 164, 3, 224, 225, + 249, 227, 193, 5, 3, 205, 206, 9, 208, 44, + 45, 46, 48, 213, 214, 155, 58, 157, 54, 55, + 56, 57, 58, 133, 134, 48, 136, 137, 138, 58, + 140, 141, 142, 8, 9, 4, 5, 263, 5, 239, + 9, 209, 268, 269, 154, 50, 51, 52, 19, 275, + 276, 14, 4, 279, 17, 58, 166, 167, 3, 4, + 3, 4, 4, 263, 264, 33, 266, 38, 39, 40, + 42, 42, 272, 3, 4, 46, 47, 3, 4, 45, + 46, 307, 3, 4, 310, 81, 82, 3, 5, 9, + 5, 31, 4, 3, 42, 66, 67, 3, 32, 4, + 4, 3, 212, 303, 4, 4, 4, 10, 4, 4, + 4, 289, 50, 4, 4, 4, 4, 4, 318, 4, + 17, 14, 14, 4, 302, 325, 10, 10, 10, 4, + 4, 4, 242, 5, 4, 4, 4, 14, 4, 4, + 3, 341, 299, 4, 115, 46, 8, 14, 3, 114, + 4, 10, 123, 3, 9, 4, 11, 12, 13, 17, + 15, 4, 340, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 10, 121, 33, 34, + 35, 36, 37, 38, 39, 40, 41, 3, -1, -1, + -1, -1, -1, -1, -1, 11, 12, 13, -1, 15, + -1, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, -1, -1, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 3, -1, -1, -1, + -1, -1, -1, -1, 11, 12, 13, -1, 15, -1, + -1, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, -1, -1, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 3, -1, -1, -1, -1, + -1, -1, -1, 11, 12, 13, -1, 15, -1, -1, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, -1, -1, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 3, -1, -1, -1, -1, -1, + -1, -1, 11, 12, 13, -1, 15, -1, -1, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, -1, -1, 33, 34, 35, 36, 37, 38, + 39, 40, 41, 3, -1, -1, -1, -1, -1, -1, + -1, 11, 12, 13, -1, 15, -1, -1, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, -1, -1, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 3, -1, -1, -1, -1, -1, -1, -1, + 11, 12, 13, -1, 15, -1, -1, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + -1, -1, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 11, 12, 13, -1, 15, -1, -1, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, -1, -1, 33, 34, 35, 36, 37, 38, 39, + 40, 41, -1, -1, 44, 45, 46, 47, 11, 12, + 13, -1, 15, -1, -1, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, -1, -1, + 33, 34, 35, 36, 37, 38, 39, 40, 41, -1, + -1, -1, 45, 46, 47, 11, 12, 13, -1, 15, + -1, -1, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, -1, -1, 33, 34, 35, + 36, 37, 38, 39, 40, 41, -1, -1, 11, 12, + 13, 47, 15, 16, -1, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, -1, -1, + 33, 34, 35, 36, 37, 38, 39, 40, 41, 11, + 12, 13, -1, 15, -1, -1, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, -1, + -1, 33, 34, 35, 36, 37, 38, 39, 40, 41 }; /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 98, 102, 103, 3, 95, 96, 97, 0, 43, - 52, 53, 54, 55, 56, 8, 59, 94, 3, 95, - 3, 3, 3, 8, 66, 4, 8, 3, 4, 80, - 82, 88, 89, 90, 91, 92, 93, 66, 56, 56, - 56, 101, 37, 38, 39, 44, 46, 47, 48, 4, - 66, 66, 66, 3, 4, 99, 66, 81, 5, 9, - 63, 3, 9, 65, 5, 86, 65, 66, 66, 64, - 101, 101, 101, 31, 3, 65, 71, 74, 75, 76, - 77, 78, 79, 4, 37, 3, 5, 85, 87, 66, - 66, 44, 63, 4, 63, 4, 4, 4, 5, 6, - 7, 62, 11, 12, 13, 16, 17, 18, 19, 21, - 22, 23, 24, 25, 26, 27, 28, 31, 32, 33, - 34, 35, 36, 39, 40, 41, 42, 49, 50, 51, - 72, 78, 79, 3, 71, 3, 79, 4, 3, 61, - 37, 3, 4, 84, 85, 66, 3, 61, 78, 4, - 4, 99, 100, 4, 66, 4, 65, 68, 71, 65, - 68, 63, 63, 64, 63, 63, 63, 71, 73, 63, - 63, 29, 69, 69, 62, 71, 71, 71, 71, 71, - 63, 60, 65, 10, 60, 65, 71, 4, 79, 4, - 4, 40, 41, 4, 61, 45, 4, 61, 78, 4, - 4, 4, 4, 75, 3, 71, 65, 75, 73, 71, - 63, 75, 75, 71, 71, 30, 70, 70, 71, 71, - 71, 4, 4, 10, 10, 4, 4, 10, 4, 60, - 10, 4, 4, 5, 83, 4, 4, 14, 71, 75, - 71, 71, 75, 71, 71, 71, 76, 4, 3, 77, - 77, 4, 4, 4, 4, 59, 67, 68, 71, 71, - 76, 77, 3, 4, 75, 41, 4, 10, 3, 4, - 15, 68, 75, 4 + 0, 101, 105, 106, 3, 98, 99, 100, 0, 48, + 54, 55, 56, 57, 58, 8, 61, 97, 3, 98, + 3, 3, 3, 8, 69, 4, 8, 3, 4, 83, + 85, 91, 92, 93, 94, 95, 96, 69, 58, 58, + 58, 104, 42, 43, 44, 49, 51, 52, 53, 4, + 69, 69, 69, 3, 4, 102, 69, 84, 5, 9, + 66, 3, 9, 68, 5, 89, 68, 69, 69, 67, + 104, 104, 104, 33, 3, 11, 12, 13, 15, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 68, 75, 76, 78, 79, 80, 81, 82, 4, + 42, 3, 5, 88, 90, 69, 69, 49, 66, 4, + 66, 4, 4, 4, 5, 6, 7, 65, 11, 12, + 13, 15, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 44, 45, 46, 47, 77, 68, + 71, 72, 71, 71, 72, 5, 64, 64, 64, 66, + 66, 66, 66, 66, 66, 31, 73, 73, 65, 81, + 82, 3, 78, 3, 82, 4, 3, 63, 42, 3, + 4, 87, 88, 69, 3, 63, 81, 4, 4, 102, + 103, 4, 69, 4, 75, 71, 75, 78, 71, 72, + 66, 66, 67, 66, 66, 66, 75, 66, 66, 66, + 73, 73, 65, 75, 75, 75, 75, 75, 75, 66, + 62, 68, 10, 62, 68, 4, 78, 78, 78, 72, + 66, 66, 67, 32, 74, 74, 82, 4, 4, 45, + 46, 4, 63, 50, 4, 63, 81, 4, 4, 4, + 4, 78, 3, 75, 17, 78, 72, 75, 75, 66, + 78, 78, 75, 75, 75, 74, 74, 75, 75, 75, + 4, 4, 10, 10, 4, 4, 10, 14, 14, 17, + 14, 78, 66, 4, 62, 10, 4, 4, 5, 86, + 4, 4, 16, 75, 78, 78, 75, 75, 78, 75, + 75, 75, 79, 4, 3, 80, 80, 4, 71, 14, + 4, 4, 4, 61, 70, 71, 75, 75, 79, 80, + 78, 3, 4, 78, 14, 46, 4, 10, 3, 4, + 17, 71, 78, 4 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 58, 59, 59, 60, 60, 61, 61, 61, 61, - 62, 62, 62, 63, 63, 64, 64, 65, 66, 67, - 68, 68, 69, 69, 70, 70, 71, 72, 72, 72, - 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, - 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, - 72, 72, 72, 72, 72, 72, 72, 73, 73, 74, - 74, 75, 75, 76, 76, 76, 76, 77, 77, 77, - 78, 79, 80, 80, 80, 80, 81, 81, 82, 83, - 84, 85, 85, 86, 87, 88, 88, 89, 89, 90, - 91, 91, 91, 91, 92, 93, 94, 94, 94, 94, - 94, 94, 94, 94, 94, 95, 95, 96, 97, 97, - 97, 97, 97, 97, 98, 98, 99, 100, 100, 101, - 101, 102, 103 + 0, 60, 61, 61, 62, 62, 63, 63, 63, 63, + 64, 65, 65, 65, 66, 66, 67, 67, 68, 69, + 70, 71, 71, 72, 73, 73, 74, 74, 75, 75, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 76, 76, + 76, 76, 76, 76, 76, 76, 76, 76, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 78, 78, 79, 79, 79, 79, 80, + 80, 80, 81, 82, 83, 83, 83, 83, 84, 84, + 85, 86, 87, 88, 88, 89, 90, 91, 91, 92, + 92, 93, 94, 94, 94, 94, 95, 96, 97, 97, + 97, 97, 97, 97, 97, 97, 97, 98, 98, 99, + 100, 100, 100, 100, 100, 100, 101, 101, 102, 103, + 103, 104, 104, 105, 106 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 1, 2, 0, 2, 0, 4, 8, 4, - 1, 1, 1, 1, 1, 0, 2, 1, 1, 1, - 0, 1, 0, 1, 0, 1, 3, 1, 3, 3, - 7, 4, 12, 3, 4, 3, 4, 3, 2, 4, - 5, 3, 3, 4, 2, 3, 4, 5, 2, 2, - 3, 4, 3, 2, 1, 1, 2, 0, 1, 1, - 2, 0, 1, 1, 5, 5, 6, 1, 5, 6, - 4, 1, 6, 7, 5, 6, 0, 1, 4, 1, - 5, 0, 2, 1, 1, 6, 5, 7, 8, 4, - 6, 7, 6, 7, 5, 5, 0, 2, 2, 2, - 2, 2, 2, 2, 2, 4, 4, 1, 1, 5, - 5, 9, 8, 9, 0, 2, 4, 0, 1, 0, - 2, 1, 1 + 1, 1, 1, 1, 1, 1, 0, 2, 1, 1, + 1, 0, 1, 1, 0, 1, 0, 1, 1, 3, + 1, 1, 1, 4, 4, 5, 3, 3, 4, 1, + 4, 7, 1, 2, 2, 2, 2, 2, 2, 3, + 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 3, 3, 4, 2, 3, 3, 4, 4, 5, + 1, 2, 3, 4, 7, 12, 4, 4, 3, 3, + 4, 2, 3, 3, 4, 5, 2, 2, 3, 3, + 2, 1, 2, 0, 2, 1, 5, 5, 6, 1, + 5, 6, 4, 1, 6, 7, 5, 6, 0, 1, + 4, 1, 5, 0, 2, 1, 1, 6, 5, 7, + 8, 4, 6, 7, 6, 7, 5, 5, 0, 2, + 2, 2, 2, 2, 2, 2, 2, 4, 4, 1, + 1, 5, 5, 9, 8, 9, 0, 2, 4, 0, + 1, 0, 2, 1, 1 }; @@ -1407,202 +1510,202 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN switch (yytype) { - case 59: /* text_list */ -#line 170 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 61: /* text_list */ +#line 179 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_text_list(parser->allocator, &((*yyvaluep).text_list)); } -#line 1414 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1517 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 60: /* value_type_list */ -#line 173 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 62: /* value_type_list */ +#line 182 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_type_vector(parser->allocator, &((*yyvaluep).types)); } -#line 1420 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1523 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 61: /* func_type */ -#line 183 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 63: /* func_type */ +#line 192 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_func_signature(parser->allocator, &((*yyvaluep).func_sig)); } -#line 1426 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1529 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 62: /* literal */ -#line 172 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 65: /* literal */ +#line 181 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).literal).text); } -#line 1432 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1535 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 63: /* var */ -#line 174 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 66: /* var */ +#line 183 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_var(parser->allocator, &((*yyvaluep).var)); } -#line 1438 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1541 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 64: /* var_list */ -#line 175 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 67: /* var_list */ +#line 184 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_var_vector_and_elements(parser->allocator, &((*yyvaluep).vars)); } -#line 1444 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1547 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 65: /* bind_var */ -#line 171 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 68: /* bind_var */ +#line 180 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); } -#line 1450 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1553 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 66: /* quoted_text */ -#line 171 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 69: /* quoted_text */ +#line 180 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); } -#line 1456 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1559 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 67: /* segment_contents */ -#line 180 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 70: /* segment_contents */ +#line 189 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_segment(parser->allocator, &((*yyvaluep).segment)); } -#line 1462 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1565 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 68: /* labeling */ -#line 171 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 71: /* labeling */ +#line 180 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); } -#line 1468 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1571 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 71: /* expr */ -#line 176 "src/wasm-ast-parser.y" /* yacc.c:1257 */ - { wasm_destroy_expr(parser->allocator, ((*yyvaluep).expr)); } -#line 1474 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ + case 72: /* labeling1 */ +#line 180 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); } +#line 1577 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 72: /* expr1 */ -#line 176 "src/wasm-ast-parser.y" /* yacc.c:1257 */ - { wasm_destroy_expr(parser->allocator, ((*yyvaluep).expr)); } -#line 1480 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ + case 75: /* expr */ +#line 186 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + { wasm_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); } +#line 1583 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 73: /* expr_opt */ -#line 176 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 76: /* op */ +#line 185 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_expr(parser->allocator, ((*yyvaluep).expr)); } -#line 1486 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1589 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 74: /* non_empty_expr_list */ -#line 177 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 77: /* expr1 */ +#line 186 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); } -#line 1492 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1595 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 75: /* expr_list */ -#line 177 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 78: /* expr_list */ +#line 186 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); } -#line 1498 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1601 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 76: /* func_fields */ -#line 178 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 79: /* func_fields */ +#line 187 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_func_fields(parser->allocator, ((*yyvaluep).func_fields)); } -#line 1504 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1607 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 77: /* func_body */ -#line 178 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 80: /* func_body */ +#line 187 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_func_fields(parser->allocator, ((*yyvaluep).func_fields)); } -#line 1510 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1613 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 79: /* func_info */ -#line 179 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 82: /* func_info */ +#line 188 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_func(parser->allocator, ((*yyvaluep).func)); wasm_free(parser->allocator, ((*yyvaluep).func)); } -#line 1516 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1619 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 80: /* func */ -#line 187 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 83: /* func */ +#line 196 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_exported_func(parser->allocator, &((*yyvaluep).exported_func)); } -#line 1522 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1625 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 84: /* segment */ -#line 180 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 87: /* segment */ +#line 189 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_segment(parser->allocator, &((*yyvaluep).segment)); } -#line 1528 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1631 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 85: /* segment_list */ -#line 181 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 88: /* segment_list */ +#line 190 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_segment_vector_and_elements(parser->allocator, &((*yyvaluep).segments)); } -#line 1534 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1637 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 88: /* memory */ -#line 182 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 91: /* memory */ +#line 191 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_memory(parser->allocator, &((*yyvaluep).memory)); } -#line 1540 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1643 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 89: /* type_def */ -#line 184 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 92: /* type_def */ +#line 193 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_func_type(parser->allocator, &((*yyvaluep).func_type)); } -#line 1546 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1649 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 90: /* table */ -#line 175 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 93: /* table */ +#line 184 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_var_vector_and_elements(parser->allocator, &((*yyvaluep).vars)); } -#line 1552 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1655 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 91: /* import */ -#line 185 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 94: /* import */ +#line 194 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_import(parser->allocator, ((*yyvaluep).import)); wasm_free(parser->allocator, ((*yyvaluep).import)); } -#line 1558 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1661 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 92: /* export */ -#line 186 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 95: /* export */ +#line 195 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_export(parser->allocator, &((*yyvaluep).export_)); } -#line 1564 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1667 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 94: /* module_fields */ -#line 188 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 97: /* module_fields */ +#line 197 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_module(parser->allocator, ((*yyvaluep).module)); wasm_free(parser->allocator, ((*yyvaluep).module)); } -#line 1570 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1673 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 95: /* raw_module */ -#line 189 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 98: /* raw_module */ +#line 198 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_raw_module(parser->allocator, &((*yyvaluep).raw_module)); } -#line 1576 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1679 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 96: /* module */ -#line 188 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 99: /* module */ +#line 197 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_module(parser->allocator, ((*yyvaluep).module)); wasm_free(parser->allocator, ((*yyvaluep).module)); } -#line 1582 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1685 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 97: /* cmd */ -#line 191 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 100: /* cmd */ +#line 200 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_command(parser->allocator, ((*yyvaluep).command)); wasm_free(parser->allocator, ((*yyvaluep).command)); } -#line 1588 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1691 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 98: /* cmd_list */ -#line 192 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 101: /* cmd_list */ +#line 201 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_command_vector_and_elements(parser->allocator, &((*yyvaluep).commands)); } -#line 1594 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1697 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 101: /* const_list */ -#line 190 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 104: /* const_list */ +#line 199 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_const_vector(parser->allocator, &((*yyvaluep).consts)); } -#line 1600 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1703 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 102: /* script */ -#line 193 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 105: /* script */ +#line 202 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_script(&((*yyvaluep).script)); } -#line 1606 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1709 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; @@ -1894,18 +1997,18 @@ yyreduce: switch (yyn) { case 2: -#line 203 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 212 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WasmTextListNode* node = new_text_list_node(parser->allocator); DUPTEXT(node->text, (yyvsp[0].text)); node->next = NULL; (yyval.text_list).first = (yyval.text_list).last = node; } -#line 1905 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2008 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 3: -#line 209 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 218 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.text_list) = (yyvsp[-1].text_list); WasmTextListNode* node = new_text_list_node(parser->allocator); @@ -1914,83 +2017,96 @@ yyreduce: (yyval.text_list).last->next = node; (yyval.text_list).last = node; } -#line 1918 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2021 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 4: -#line 222 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 231 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.types)); } -#line 1924 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2027 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 5: -#line 223 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 232 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.types) = (yyvsp[-1].types); wasm_append_type_value(parser->allocator, &(yyval.types), &(yyvsp[0].type)); } -#line 1933 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2036 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 6: -#line 229 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 238 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.func_sig)); } -#line 1939 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2042 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 7: -#line 230 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 239 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func_sig).result_type = WASM_TYPE_VOID; (yyval.func_sig).param_types = (yyvsp[-1].types); } -#line 1948 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2051 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 8: -#line 234 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 243 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func_sig).result_type = (yyvsp[-1].type); (yyval.func_sig).param_types = (yyvsp[-5].types); } -#line 1957 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2060 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 9: -#line 238 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 247 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.func_sig)); (yyval.func_sig).result_type = (yyvsp[-1].type); } -#line 1963 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2066 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 10: -#line 245 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 254 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.literal).type = (yyvsp[0].literal).type; - DUPTEXT((yyval.literal).text, (yyvsp[0].literal).text); + if (WASM_FAILED(wasm_parse_int32((yyvsp[0].literal).text.start, + (yyvsp[0].literal).text.start + (yyvsp[0].literal).text.length, &(yyval.u32), + WASM_PARSE_UNSIGNED_ONLY))) { + wasm_ast_parser_error(&(yylsp[0]), lexer, parser, "invalid int " PRIstringslice, + WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].literal).text)); + } } -#line 1972 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2079 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 11: -#line 249 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 265 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.literal).type = (yyvsp[0].literal).type; DUPTEXT((yyval.literal).text, (yyvsp[0].literal).text); } -#line 1981 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2088 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 12: -#line 253 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 269 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.literal).type = (yyvsp[0].literal).type; DUPTEXT((yyval.literal).text, (yyvsp[0].literal).text); } -#line 1990 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2097 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 13: -#line 260 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 273 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + (yyval.literal).type = (yyvsp[0].literal).type; + DUPTEXT((yyval.literal).text, (yyvsp[0].literal).text); + } +#line 2106 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 14: +#line 280 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.var).loc = (yylsp[0]); (yyval.var).type = WASM_VAR_TYPE_INDEX; @@ -2003,42 +2119,42 @@ yyreduce: } (yyval.var).index = index; } -#line 2007 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2123 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 14: -#line 272 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 15: +#line 292 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.var).loc = (yylsp[0]); (yyval.var).type = WASM_VAR_TYPE_NAME; DUPTEXT((yyval.var).name, (yyvsp[0].text)); } -#line 2017 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2133 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 15: -#line 279 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 16: +#line 299 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.vars)); } -#line 2023 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2139 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 16: -#line 280 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 17: +#line 300 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.vars) = (yyvsp[-1].vars); wasm_append_var_value(parser->allocator, &(yyval.vars), &(yyvsp[0].var)); } -#line 2032 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2148 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 17: -#line 286 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 18: +#line 306 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { DUPTEXT((yyval.text), (yyvsp[0].text)); } -#line 2038 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2154 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 18: -#line 290 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 19: +#line 310 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WasmTextListNode node; node.text = (yyvsp[0].text); @@ -2052,38 +2168,32 @@ yyreduce: (yyval.text).start = data; (yyval.text).length = size; } -#line 2056 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2172 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 19: -#line 306 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 20: +#line 326 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { dup_text_list(parser->allocator, &(yyvsp[0].text_list), &(yyval.segment).data, &(yyval.segment).size); wasm_destroy_text_list(parser->allocator, &(yyvsp[0].text_list)); } -#line 2065 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ - break; - - case 20: -#line 313 "src/wasm-ast-parser.y" /* yacc.c:1646 */ - { WASM_ZERO_MEMORY((yyval.text)); } -#line 2071 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2181 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 21: -#line 314 "src/wasm-ast-parser.y" /* yacc.c:1646 */ - { (yyval.text) = (yyvsp[0].text); } -#line 2077 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 333 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { WASM_ZERO_MEMORY((yyval.text)); } +#line 2187 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 22: -#line 318 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 24: +#line 339 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.u64) = 0; } -#line 2083 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2193 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 23: -#line 319 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 25: +#line 340 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { if (WASM_FAILED(wasm_parse_int64((yyvsp[0].text).start, (yyvsp[0].text).start + (yyvsp[0].text).length, &(yyval.u64), WASM_PARSE_SIGNED_AND_UNSIGNED))) { @@ -2092,17 +2202,17 @@ yyreduce: WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].text))); } } -#line 2096 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2206 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 24: -#line 329 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 26: +#line 350 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.u32) = USE_NATURAL_ALIGNMENT; } -#line 2102 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2212 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 25: -#line 330 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 27: +#line 351 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { if (WASM_FAILED(wasm_parse_int32((yyvsp[0].text).start, (yyvsp[0].text).start + (yyvsp[0].text).length, &(yyval.u32), WASM_PARSE_UNSIGNED_ONLY))) { @@ -2111,244 +2221,226 @@ yyreduce: WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].text))); } } -#line 2115 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ - break; - - case 26: -#line 341 "src/wasm-ast-parser.y" /* yacc.c:1646 */ - { (yyval.expr) = (yyvsp[-1].expr); (yyval.expr)->loc = (yylsp[-2]); } -#line 2121 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ - break; - - case 27: -#line 344 "src/wasm-ast-parser.y" /* yacc.c:1646 */ - { - (yyval.expr) = wasm_new_empty_expr(parser->allocator, WASM_EXPR_TYPE_NOP); - } -#line 2129 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2225 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 28: -#line 347 "src/wasm-ast-parser.y" /* yacc.c:1646 */ - { - (yyval.expr) = wasm_new_block_expr(parser->allocator); - (yyval.expr)->block.label = (yyvsp[-1].text); - (yyval.expr)->block.first = (yyvsp[0].expr_list).first; - } -#line 2139 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 362 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { (yyval.expr_list) = join_exprs1(&(yylsp[0]), (yyvsp[0].expr)); } +#line 2231 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 29: -#line 352 "src/wasm-ast-parser.y" /* yacc.c:1646 */ - { - (yyval.expr) = wasm_new_if_expr(parser->allocator); - (yyval.expr)->if_.cond = (yyvsp[-1].expr); - (yyval.expr)->if_.true_.first = (yyvsp[0].expr); - } -#line 2149 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 363 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { (yyval.expr_list) = (yyvsp[-1].expr_list); } +#line 2237 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 30: -#line 357 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 366 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_if_expr(parser->allocator); - (yyval.expr)->if_.cond = (yyvsp[-5].expr); - (yyval.expr)->if_.true_.label = (yyvsp[-2].text); - (yyval.expr)->if_.true_.first = (yyvsp[-1].expr_list).first; + (yyval.expr) = wasm_new_unreachable_expr(parser->allocator); } -#line 2160 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2245 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 31: -#line 363 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 369 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_if_else_expr(parser->allocator); - (yyval.expr)->if_else.cond = (yyvsp[-2].expr); - (yyval.expr)->if_else.true_.first = (yyvsp[-1].expr); - (yyval.expr)->if_else.false_.first = (yyvsp[0].expr); + (yyval.expr) = wasm_new_nop_expr(parser->allocator); } -#line 2171 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2253 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 32: -#line 369 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 372 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_if_else_expr(parser->allocator); - (yyval.expr)->if_else.cond = (yyvsp[-10].expr); - (yyval.expr)->if_else.true_.label = (yyvsp[-7].text); - (yyval.expr)->if_else.true_.first = (yyvsp[-6].expr_list).first; - (yyval.expr)->if_else.false_.label = (yyvsp[-2].text); - (yyval.expr)->if_else.false_.first = (yyvsp[-1].expr_list).first; + (yyval.expr) = wasm_new_drop_expr(parser->allocator); } -#line 2184 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2261 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 33: -#line 377 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 375 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_br_if_expr(parser->allocator); - (yyval.expr)->br_if.var = (yyvsp[-1].var); - (yyval.expr)->br_if.cond = (yyvsp[0].expr); + (yyval.expr) = wasm_new_block_expr(parser->allocator); + (yyval.expr)->block.label = (yyvsp[-2].text); + (yyval.expr)->block.first = (yyvsp[-1].expr_list).first; } -#line 2194 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2271 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 34: -#line 382 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 380 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_br_if_expr(parser->allocator); - (yyval.expr)->br_if.var = (yyvsp[-2].var); - (yyval.expr)->br_if.expr = (yyvsp[-1].expr); - (yyval.expr)->br_if.cond = (yyvsp[0].expr); + (yyval.expr) = wasm_new_loop_expr(parser->allocator); + (yyval.expr)->loop.label = (yyvsp[-2].text); + (yyval.expr)->loop.first = (yyvsp[-1].expr_list).first; } -#line 2205 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2281 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 35: -#line 388 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 385 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_loop_expr(parser->allocator); - WASM_ZERO_MEMORY((yyval.expr)->loop.outer); - (yyval.expr)->loop.inner = (yyvsp[-1].text); - (yyval.expr)->loop.first = (yyvsp[0].expr_list).first; + (yyval.expr) = wasm_new_block_expr(parser->allocator); + (yyval.expr)->block.label = (yyvsp[-3].text); + WasmExpr* loop = wasm_new_loop_expr(parser->allocator); + loop->loc = (yylsp[-4]); + loop->loop.label = (yyvsp[-2].text); + loop->loop.first = (yyvsp[-1].expr_list).first; + (yyval.expr)->block.first = loop; } -#line 2216 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2295 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 36: #line 394 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_loop_expr(parser->allocator); - (yyval.expr)->loop.outer = (yyvsp[-2].text); - (yyval.expr)->loop.inner = (yyvsp[-1].text); - (yyval.expr)->loop.first = (yyvsp[0].expr_list).first; + (yyval.expr) = wasm_new_br_expr(parser->allocator); + (yyval.expr)->br.arity = (yyvsp[-1].u32); + (yyval.expr)->br.var = (yyvsp[0].var); } -#line 2227 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2305 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 37: -#line 400 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 399 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_br_expr(parser->allocator); - (yyval.expr)->br.var = (yyvsp[-1].var); - (yyval.expr)->br.expr = (yyvsp[0].expr); + (yyval.expr) = wasm_new_br_if_expr(parser->allocator); + (yyval.expr)->br_if.arity = (yyvsp[-1].u32); + (yyval.expr)->br_if.var = (yyvsp[0].var); } -#line 2237 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2315 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 38: -#line 405 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 404 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_return_expr(parser->allocator); - (yyval.expr)->return_.expr = (yyvsp[0].expr); + (yyval.expr) = wasm_new_br_table_expr(parser->allocator); + (yyval.expr)->br_table.arity = (yyvsp[-2].u32); + (yyval.expr)->br_table.targets = (yyvsp[-1].vars); + (yyval.expr)->br_table.default_target = (yyvsp[0].var); } -#line 2246 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2326 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 39: -#line 409 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 410 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_br_table_expr(parser->allocator); - (yyval.expr)->br_table.key = (yyvsp[0].expr); - (yyval.expr)->br_table.expr = NULL; - (yyval.expr)->br_table.targets = (yyvsp[-2].vars); - (yyval.expr)->br_table.default_target = (yyvsp[-1].var); + (yyval.expr) = wasm_new_return_expr(parser->allocator); } -#line 2258 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2334 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 40: -#line 416 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 413 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_br_table_expr(parser->allocator); - (yyval.expr)->br_table.key = (yyvsp[0].expr); - (yyval.expr)->br_table.expr = (yyvsp[-1].expr); - (yyval.expr)->br_table.targets = (yyvsp[-3].vars); - (yyval.expr)->br_table.default_target = (yyvsp[-2].var); + (yyval.expr) = wasm_new_if_expr(parser->allocator); + (yyval.expr)->if_.true_.label = (yyvsp[-2].text); + (yyval.expr)->if_.true_.first = (yyvsp[-1].expr_list).first; } -#line 2270 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2344 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 41: -#line 423 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 418 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_call_expr(parser->allocator); - (yyval.expr)->call.var = (yyvsp[-1].var); - (yyval.expr)->call.first_arg = (yyvsp[0].expr_list).first; - (yyval.expr)->call.num_args = (yyvsp[0].expr_list).size; + (yyval.expr) = wasm_new_if_else_expr(parser->allocator); + (yyval.expr)->if_else.true_.label = (yyvsp[-5].text); + (yyval.expr)->if_else.true_.first = (yyvsp[-4].expr_list).first; + (yyval.expr)->if_else.false_.label = (yyvsp[-2].text); + (yyval.expr)->if_else.false_.first = (yyvsp[-1].expr_list).first; } -#line 2281 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2356 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 42: -#line 429 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 425 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_call_import_expr(parser->allocator); - (yyval.expr)->call.var = (yyvsp[-1].var); - (yyval.expr)->call.first_arg = (yyvsp[0].expr_list).first; - (yyval.expr)->call.num_args = (yyvsp[0].expr_list).size; + (yyval.expr) = wasm_new_select_expr(parser->allocator); } -#line 2292 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2364 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 43: -#line 435 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 428 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_call_indirect_expr(parser->allocator); - (yyval.expr)->call_indirect.var = (yyvsp[-2].var); - (yyval.expr)->call_indirect.expr = (yyvsp[-1].expr); - (yyval.expr)->call_indirect.first_arg = (yyvsp[0].expr_list).first; - (yyval.expr)->call_indirect.num_args = (yyvsp[0].expr_list).size; + (yyval.expr) = wasm_new_call_expr(parser->allocator); + (yyval.expr)->call.var = (yyvsp[0].var); } -#line 2304 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2373 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 44: -#line 442 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 432 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + (yyval.expr) = wasm_new_call_expr(parser->allocator); + (yyval.expr)->call_import.var = (yyvsp[0].var); + } +#line 2382 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 45: +#line 436 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + (yyval.expr) = wasm_new_call_indirect_expr(parser->allocator); + (yyval.expr)->call_indirect.var = (yyvsp[0].var); + } +#line 2391 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 46: +#line 440 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_get_local_expr(parser->allocator); (yyval.expr)->get_local.var = (yyvsp[0].var); } -#line 2313 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2400 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 45: -#line 446 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 47: +#line 444 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_set_local_expr(parser->allocator); - (yyval.expr)->set_local.var = (yyvsp[-1].var); - (yyval.expr)->set_local.expr = (yyvsp[0].expr); + (yyval.expr)->set_local.var = (yyvsp[0].var); } -#line 2323 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2409 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 46: -#line 451 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 48: +#line 448 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + (yyval.expr) = wasm_new_tee_local_expr(parser->allocator); + (yyval.expr)->tee_local.var = (yyvsp[0].var); + } +#line 2418 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 49: +#line 452 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_load_expr(parser->allocator); - (yyval.expr)->load.opcode = (yyvsp[-3].opcode); - (yyval.expr)->load.offset = (yyvsp[-2].u64); - (yyval.expr)->load.align = (yyvsp[-1].u32); - (yyval.expr)->load.addr = (yyvsp[0].expr); + (yyval.expr)->load.opcode = (yyvsp[-2].opcode); + (yyval.expr)->load.offset = (yyvsp[-1].u64); + (yyval.expr)->load.align = (yyvsp[0].u32); } -#line 2335 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2429 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 47: + case 50: #line 458 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_store_expr(parser->allocator); - (yyval.expr)->store.opcode = (yyvsp[-4].opcode); - (yyval.expr)->store.offset = (yyvsp[-3].u64); - (yyval.expr)->store.align = (yyvsp[-2].u32); - (yyval.expr)->store.addr = (yyvsp[-1].expr); - (yyval.expr)->store.value = (yyvsp[0].expr); + (yyval.expr) = wasm_new_load_expr(parser->allocator); + (yyval.expr)->store.opcode = (yyvsp[-2].opcode); + (yyval.expr)->store.offset = (yyvsp[-1].u64); + (yyval.expr)->store.align = (yyvsp[0].u32); } -#line 2348 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2440 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 48: -#line 466 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 51: +#line 464 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_const_expr(parser->allocator); (yyval.expr)->const_.loc = (yylsp[-1]); @@ -2361,144 +2453,474 @@ yyreduce: } wasm_free(parser->allocator, (char*)(yyvsp[0].literal).text.start); } -#line 2365 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2457 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 49: -#line 478 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 52: +#line 476 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_unary_expr(parser->allocator); - (yyval.expr)->unary.opcode = (yyvsp[-1].opcode); - (yyval.expr)->unary.expr = (yyvsp[0].expr); + (yyval.expr)->unary.opcode = (yyvsp[0].opcode); } -#line 2375 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2466 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 50: -#line 483 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 53: +#line 480 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_binary_expr(parser->allocator); - (yyval.expr)->binary.opcode = (yyvsp[-2].opcode); - (yyval.expr)->binary.left = (yyvsp[-1].expr); - (yyval.expr)->binary.right = (yyvsp[0].expr); + (yyval.expr)->binary.opcode = (yyvsp[0].opcode); } -#line 2386 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2475 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 51: -#line 489 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 54: +#line 484 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_select_expr(parser->allocator); - (yyval.expr)->select.true_ = (yyvsp[-2].expr); - (yyval.expr)->select.false_ = (yyvsp[-1].expr); - (yyval.expr)->select.cond = (yyvsp[0].expr); + (yyval.expr) = wasm_new_compare_expr(parser->allocator); + (yyval.expr)->compare.opcode = (yyvsp[0].opcode); } -#line 2397 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2484 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 52: + case 55: +#line 488 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + (yyval.expr) = wasm_new_convert_expr(parser->allocator); + (yyval.expr)->convert.opcode = (yyvsp[0].opcode); + } +#line 2493 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 56: +#line 492 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + (yyval.expr) = wasm_new_current_memory_expr(parser->allocator); + } +#line 2501 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 57: #line 495 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_compare_expr(parser->allocator); - (yyval.expr)->compare.opcode = (yyvsp[-2].opcode); - (yyval.expr)->compare.left = (yyvsp[-1].expr); - (yyval.expr)->compare.right = (yyvsp[0].expr); + (yyval.expr) = wasm_new_grow_memory_expr(parser->allocator); } -#line 2408 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2509 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 53: -#line 501 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 58: +#line 500 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_convert_expr(parser->allocator); - (yyval.expr)->convert.opcode = (yyvsp[-1].opcode); - (yyval.expr)->convert.expr = (yyvsp[0].expr); + (yyval.expr_list) = join_exprs1(&(yylsp[0]), wasm_new_unreachable_expr(parser->allocator)); } -#line 2418 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2517 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 54: + case 59: +#line 503 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + (yyval.expr_list) = join_exprs1(&(yylsp[0]), wasm_new_nop_expr(parser->allocator)); + } +#line 2525 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 60: #line 506 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_empty_expr(parser->allocator, WASM_EXPR_TYPE_UNREACHABLE); + (yyval.expr_list) = join_exprs2(&(yylsp[-1]), &(yyvsp[0].expr_list), wasm_new_drop_expr(parser->allocator)); } -#line 2426 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2533 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 55: + case 61: #line 509 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_empty_expr(parser->allocator, - WASM_EXPR_TYPE_CURRENT_MEMORY); + WasmExpr* expr = wasm_new_block_expr(parser->allocator); + expr->block.label = (yyvsp[-1].text); + expr->block.first = (yyvsp[0].expr_list).first; + (yyval.expr_list) = join_exprs1(&(yylsp[-2]), expr); } -#line 2435 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2544 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 56: -#line 513 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 62: +#line 515 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr) = wasm_new_grow_memory_expr(parser->allocator); - (yyval.expr)->grow_memory.expr = (yyvsp[0].expr); + WasmExpr* expr = wasm_new_loop_expr(parser->allocator); + expr->loop.label = (yyvsp[-1].text); + expr->loop.first = (yyvsp[0].expr_list).first; + (yyval.expr_list) = join_exprs1(&(yylsp[-2]), expr); } -#line 2444 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2555 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 57: -#line 519 "src/wasm-ast-parser.y" /* yacc.c:1646 */ - { (yyval.expr) = NULL; } -#line 2450 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + case 63: +#line 521 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* block = wasm_new_block_expr(parser->allocator); + block->block.label = (yyvsp[-2].text); + WasmExpr* loop = wasm_new_loop_expr(parser->allocator); + loop->loc = (yylsp[-3]); + loop->loop.label = (yyvsp[-1].text); + loop->loop.first = (yyvsp[0].expr_list).first; + block->block.first = loop; + (yyval.expr_list) = join_exprs1(&(yylsp[-3]), block); + } +#line 2570 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 59: -#line 523 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 64: +#line 531 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr_list).first = (yyval.expr_list).last = (yyvsp[0].expr); - (yyval.expr_list).size = 1; + WasmExpr* expr = wasm_new_br_expr(parser->allocator); + expr->br.arity = 0; + expr->br.var = (yyvsp[0].var); + (yyval.expr_list) = join_exprs1(&(yylsp[-1]), expr); } -#line 2459 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2581 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 60: -#line 527 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 65: +#line 537 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - (yyval.expr_list) = (yyvsp[-1].expr_list); - (yyval.expr_list).last->next = (yyvsp[0].expr); - (yyval.expr_list).last = (yyvsp[0].expr); - (yyval.expr_list).size++; + WasmExpr* expr = wasm_new_br_expr(parser->allocator); + expr->br.arity = 1; + expr->br.var = (yyvsp[-1].var); + (yyval.expr_list) = join_exprs2(&(yylsp[-2]), &(yyvsp[0].expr_list), expr); } -#line 2470 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2592 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 61: -#line 535 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 66: +#line 543 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_br_if_expr(parser->allocator); + expr->br_if.arity = 0; + expr->br_if.var = (yyvsp[-1].var); + (yyval.expr_list) = join_exprs2(&(yylsp[-2]), &(yyvsp[0].expr_list), expr); + } +#line 2603 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 67: +#line 549 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_br_if_expr(parser->allocator); + expr->br_if.arity = 1; + expr->br_if.var = (yyvsp[-2].var); + (yyval.expr_list) = join_exprs3(&(yylsp[-3]), &(yyvsp[-1].expr_list), &(yyvsp[0].expr_list), expr); + } +#line 2614 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 68: +#line 555 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_br_table_expr(parser->allocator); + expr->br_table.arity = 0; + expr->br_table.targets = (yyvsp[-2].vars); + expr->br_table.default_target = (yyvsp[-1].var); + (yyval.expr_list) = join_exprs2(&(yylsp[-3]), &(yyvsp[0].expr_list), expr); + } +#line 2626 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 69: +#line 562 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_br_table_expr(parser->allocator); + expr->br_table.arity = 1; + expr->br_table.targets = (yyvsp[-3].vars); + expr->br_table.default_target = (yyvsp[-2].var); + (yyval.expr_list) = join_exprs3(&(yylsp[-4]), &(yyvsp[-1].expr_list), &(yyvsp[0].expr_list), expr); + } +#line 2638 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 70: +#line 569 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_return_expr(parser->allocator); + (yyval.expr_list) = join_exprs1(&(yylsp[0]), expr); + } +#line 2647 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 71: +#line 573 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_return_expr(parser->allocator); + (yyval.expr_list) = join_exprs2(&(yylsp[-1]), &(yyvsp[0].expr_list), expr); + } +#line 2656 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 72: +#line 577 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_if_expr(parser->allocator); + expr->if_.true_.first = (yyvsp[0].expr_list).first; + (yyval.expr_list) = join_exprs2(&(yylsp[-2]), &(yyvsp[-1].expr_list), expr); + } +#line 2666 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 73: +#line 582 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_if_else_expr(parser->allocator); + expr->if_else.true_.first = (yyvsp[-1].expr_list).first; + expr->if_else.false_.first = (yyvsp[0].expr_list).first; + (yyval.expr_list) = join_exprs2(&(yylsp[-3]), &(yyvsp[-2].expr_list), expr); + } +#line 2677 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 74: +#line 588 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_if_expr(parser->allocator); + expr->if_.true_.label = (yyvsp[-2].text); + expr->if_.true_.first = (yyvsp[-1].expr_list).first; + (yyval.expr_list) = join_exprs2(&(yylsp[-6]), &(yyvsp[-5].expr_list), expr); + } +#line 2688 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 75: +#line 594 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_if_else_expr(parser->allocator); + expr->if_else.true_.label = (yyvsp[-7].text); + expr->if_else.true_.first = (yyvsp[-6].expr_list).first; + expr->if_else.false_.label = (yyvsp[-2].text); + expr->if_else.false_.first = (yyvsp[-1].expr_list).first; + (yyval.expr_list) = join_exprs2(&(yylsp[-11]), &(yyvsp[-10].expr_list), expr); + } +#line 2701 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 76: +#line 602 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_if_else_expr(parser->allocator); + expr->if_else.true_.first = (yyvsp[-2].expr_list).first; + expr->if_else.false_.first = (yyvsp[0].expr_list).first; + (yyval.expr_list) = join_exprs1(&(yylsp[-3]), expr); + } +#line 2712 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 77: +#line 608 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + (yyval.expr_list) = join_exprs4(&(yylsp[-3]), &(yyvsp[-2].expr_list), &(yyvsp[-1].expr_list), &(yyvsp[0].expr_list), + wasm_new_select_expr(parser->allocator)); + } +#line 2721 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 78: +#line 612 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_call_expr(parser->allocator); + expr->call.var = (yyvsp[-1].var); + (yyval.expr_list) = join_exprs2(&(yylsp[-2]), &(yyvsp[0].expr_list), expr); + } +#line 2731 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 79: +#line 617 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_call_import_expr(parser->allocator); + expr->call_import.var = (yyvsp[-1].var); + (yyval.expr_list) = join_exprs2(&(yylsp[-2]), &(yyvsp[0].expr_list), expr); + } +#line 2741 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 80: +#line 622 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_call_indirect_expr(parser->allocator); + expr->call_indirect.var = (yyvsp[-2].var); + (yyval.expr_list) = join_exprs3(&(yylsp[-3]), &(yyvsp[-1].expr_list), &(yyvsp[0].expr_list), expr); + } +#line 2751 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 81: +#line 627 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_get_local_expr(parser->allocator); + expr->get_local.var = (yyvsp[0].var); + (yyval.expr_list) = join_exprs1(&(yylsp[-1]), expr); + } +#line 2761 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 82: +#line 632 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_set_local_expr(parser->allocator); + expr->set_local.var = (yyvsp[-1].var); + (yyval.expr_list) = join_exprs2(&(yylsp[-2]), &(yyvsp[0].expr_list), expr); + } +#line 2771 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 83: +#line 637 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_tee_local_expr(parser->allocator); + expr->tee_local.var = (yyvsp[-1].var); + (yyval.expr_list) = join_exprs2(&(yylsp[-2]), &(yyvsp[0].expr_list), expr); + } +#line 2781 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 84: +#line 642 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_load_expr(parser->allocator); + expr->load.opcode = (yyvsp[-3].opcode); + expr->load.offset = (yyvsp[-2].u64); + expr->load.align = (yyvsp[-1].u32); + (yyval.expr_list) = join_exprs2(&(yylsp[-3]), &(yyvsp[0].expr_list), expr); + } +#line 2793 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 85: +#line 649 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_store_expr(parser->allocator); + expr->store.opcode = (yyvsp[-4].opcode); + expr->store.offset = (yyvsp[-3].u64); + expr->store.align = (yyvsp[-2].u32); + (yyval.expr_list) = join_exprs3(&(yylsp[-4]), &(yyvsp[-1].expr_list), &(yyvsp[0].expr_list), expr); + } +#line 2805 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 86: +#line 656 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_const_expr(parser->allocator); + expr->const_.loc = (yylsp[-1]); + if (WASM_FAILED(parse_const((yyvsp[-1].type), (yyvsp[0].literal).type, (yyvsp[0].literal).text.start, + (yyvsp[0].literal).text.start + (yyvsp[0].literal).text.length, + &expr->const_))) { + wasm_ast_parser_error(&(yylsp[0]), lexer, parser, + "invalid literal \"" PRIstringslice "\"", + WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].literal).text)); + } + wasm_free(parser->allocator, (char*)(yyvsp[0].literal).text.start); + (yyval.expr_list) = join_exprs1(&(yylsp[-1]), expr); + } +#line 2823 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 87: +#line 669 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_unary_expr(parser->allocator); + expr->unary.opcode = (yyvsp[-1].opcode); + (yyval.expr_list) = join_exprs2(&(yylsp[-1]), &(yyvsp[0].expr_list), expr); + } +#line 2833 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 88: +#line 674 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_binary_expr(parser->allocator); + expr->binary.opcode = (yyvsp[-2].opcode); + (yyval.expr_list) = join_exprs3(&(yylsp[-2]), &(yyvsp[-1].expr_list), &(yyvsp[0].expr_list), expr); + } +#line 2843 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 89: +#line 679 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_compare_expr(parser->allocator); + expr->compare.opcode = (yyvsp[-2].opcode); + (yyval.expr_list) = join_exprs3(&(yylsp[-2]), &(yyvsp[-1].expr_list), &(yyvsp[0].expr_list), expr); + } +#line 2853 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 90: +#line 684 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_convert_expr(parser->allocator); + expr->convert.opcode = (yyvsp[-1].opcode); + (yyval.expr_list) = join_exprs2(&(yylsp[-1]), &(yyvsp[0].expr_list), expr); + } +#line 2863 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 91: +#line 689 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_current_memory_expr(parser->allocator); + (yyval.expr_list) = join_exprs1(&(yylsp[0]), expr); + } +#line 2872 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 92: +#line 693 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmExpr* expr = wasm_new_grow_memory_expr(parser->allocator); + (yyval.expr_list) = join_exprs2(&(yylsp[-1]), &(yyvsp[0].expr_list), expr); + } +#line 2881 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 93: +#line 699 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.expr_list)); } -#line 2476 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2887 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 64: -#line 542 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 94: +#line 700 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + (yyval.expr_list).first = (yyvsp[-1].expr_list).first; + (yyvsp[-1].expr_list).last->next = (yyvsp[0].expr_list).first; + (yyval.expr_list).last = (yyvsp[0].expr_list).last ? (yyvsp[0].expr_list).last : (yyvsp[-1].expr_list).first; + (yyval.expr_list).size = (yyvsp[-1].expr_list).size + (yyvsp[0].expr_list).size; + } +#line 2898 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 96: +#line 711 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func_fields) = new_func_field(parser->allocator); (yyval.func_fields)->type = WASM_FUNC_FIELD_TYPE_RESULT_TYPE; (yyval.func_fields)->result_type = (yyvsp[-2].type); (yyval.func_fields)->next = (yyvsp[0].func_fields); } -#line 2487 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2909 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 65: -#line 548 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 97: +#line 717 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func_fields) = new_func_field(parser->allocator); (yyval.func_fields)->type = WASM_FUNC_FIELD_TYPE_PARAM_TYPES; (yyval.func_fields)->types = (yyvsp[-2].types); (yyval.func_fields)->next = (yyvsp[0].func_fields); } -#line 2498 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2920 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 66: -#line 554 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 98: +#line 723 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func_fields) = new_func_field(parser->allocator); (yyval.func_fields)->type = WASM_FUNC_FIELD_TYPE_BOUND_PARAM; @@ -2507,33 +2929,33 @@ yyreduce: (yyval.func_fields)->bound_type.type = (yyvsp[-2].type); (yyval.func_fields)->next = (yyvsp[0].func_fields); } -#line 2511 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2933 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 67: -#line 564 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 99: +#line 733 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func_fields) = new_func_field(parser->allocator); (yyval.func_fields)->type = WASM_FUNC_FIELD_TYPE_EXPRS; (yyval.func_fields)->first_expr = (yyvsp[0].expr_list).first; (yyval.func_fields)->next = NULL; } -#line 2522 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2944 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 68: -#line 570 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 100: +#line 739 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func_fields) = new_func_field(parser->allocator); (yyval.func_fields)->type = WASM_FUNC_FIELD_TYPE_LOCAL_TYPES; (yyval.func_fields)->types = (yyvsp[-2].types); (yyval.func_fields)->next = (yyvsp[0].func_fields); } -#line 2533 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2955 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 69: -#line 576 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 101: +#line 745 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func_fields) = new_func_field(parser->allocator); (yyval.func_fields)->type = WASM_FUNC_FIELD_TYPE_BOUND_LOCAL; @@ -2542,17 +2964,17 @@ yyreduce: (yyval.func_fields)->bound_type.type = (yyvsp[-2].type); (yyval.func_fields)->next = (yyvsp[0].func_fields); } -#line 2546 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2968 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 70: -#line 586 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 102: +#line 755 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.var) = (yyvsp[-1].var); } -#line 2552 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2974 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 71: -#line 589 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 103: +#line 758 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func) = new_func(parser->allocator); WasmFuncField* field = (yyvsp[0].func_fields); @@ -2606,11 +3028,11 @@ yyreduce: field = next; } } -#line 2610 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3032 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 72: -#line 644 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 104: +#line 813 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.exported_func).func = (yyvsp[-1].func); (yyval.exported_func).func->loc = (yylsp[-4]); @@ -2620,11 +3042,11 @@ yyreduce: (yyval.exported_func).export_.var.type = WASM_VAR_TYPE_INDEX; (yyval.exported_func).export_.var.index = -1; } -#line 2624 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3046 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 73: -#line 653 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 105: +#line 822 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.exported_func).func = (yyvsp[-1].func); (yyval.exported_func).func->loc = (yylsp[-5]); @@ -2635,11 +3057,11 @@ yyreduce: (yyval.exported_func).export_.var.type = WASM_VAR_TYPE_INDEX; (yyval.exported_func).export_.var.index = -1; } -#line 2639 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3061 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 74: -#line 663 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 106: +#line 832 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.exported_func).func = (yyvsp[-1].func); (yyval.exported_func).func->loc = (yylsp[-3]); @@ -2647,11 +3069,11 @@ yyreduce: (yyval.exported_func).export_.var.type = WASM_VAR_TYPE_INDEX; (yyval.exported_func).export_.var.index = -1; } -#line 2651 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3073 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 75: -#line 670 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 107: +#line 839 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.exported_func).func = (yyvsp[-1].func); (yyval.exported_func).func->loc = (yylsp[-4]); @@ -2660,23 +3082,23 @@ yyreduce: (yyval.exported_func).export_.var.type = WASM_VAR_TYPE_INDEX; (yyval.exported_func).export_.var.index = -1; } -#line 2664 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3086 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 76: -#line 681 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 108: +#line 850 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.text)); } -#line 2670 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3092 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 78: -#line 689 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 110: +#line 858 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.var) = (yyvsp[-1].var); } -#line 2676 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3098 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 79: -#line 693 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 111: +#line 862 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { if (WASM_FAILED(wasm_parse_int32((yyvsp[0].literal).text.start, (yyvsp[0].literal).text.start + (yyvsp[0].literal).text.length, &(yyval.u32), @@ -2687,37 +3109,37 @@ yyreduce: WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].literal).text)); } } -#line 2691 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3113 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 80: -#line 706 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 112: +#line 875 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.segment).loc = (yylsp[-3]); (yyval.segment).data = (yyvsp[-1].segment).data; (yyval.segment).size = (yyvsp[-1].segment).size; (yyval.segment).addr = (yyvsp[-2].u32); } -#line 2702 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3124 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 81: -#line 714 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 113: +#line 883 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.segments)); } -#line 2708 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3130 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 82: -#line 715 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 114: +#line 884 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.segments) = (yyvsp[-1].segments); wasm_append_segment_value(parser->allocator, &(yyval.segments), &(yyvsp[0].segment)); } -#line 2717 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3139 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 83: -#line 722 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 115: +#line 891 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { if (WASM_FAILED(wasm_parse_uint64((yyvsp[0].literal).text.start, (yyvsp[0].literal).text.start + (yyvsp[0].literal).text.length, &(yyval.u64)))) { @@ -2727,11 +3149,11 @@ yyreduce: WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].literal).text)); } } -#line 2731 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3153 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 84: -#line 734 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 116: +#line 903 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { if (WASM_FAILED(wasm_parse_uint64((yyvsp[0].literal).text.start, (yyvsp[0].literal).text.start + (yyvsp[0].literal).text.length, &(yyval.u64)))) { @@ -2740,57 +3162,57 @@ yyreduce: WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].literal).text)); } } -#line 2744 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3166 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 85: -#line 745 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 117: +#line 914 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.memory).loc = (yylsp[-4]); (yyval.memory).initial_pages = (yyvsp[-3].u64); (yyval.memory).max_pages = (yyvsp[-2].u64); (yyval.memory).segments = (yyvsp[-1].segments); } -#line 2755 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3177 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 86: -#line 751 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 118: +#line 920 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.memory).loc = (yylsp[-3]); (yyval.memory).initial_pages = (yyvsp[-2].u64); (yyval.memory).max_pages = (yyval.memory).initial_pages; (yyval.memory).segments = (yyvsp[-1].segments); } -#line 2766 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3188 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 87: -#line 760 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 119: +#line 929 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.func_type)); (yyval.func_type).sig = (yyvsp[-2].func_sig); } -#line 2775 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3197 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 88: -#line 764 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 120: +#line 933 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func_type).name = (yyvsp[-5].text); (yyval.func_type).sig = (yyvsp[-2].func_sig); } -#line 2784 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3206 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 89: -#line 771 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 121: +#line 940 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.vars) = (yyvsp[-1].vars); } -#line 2790 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3212 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 90: -#line 775 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 122: +#line 944 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.import) = new_import(parser->allocator); (yyval.import)->module_name = (yyvsp[-3].text); @@ -2798,11 +3220,11 @@ yyreduce: (yyval.import)->decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE; (yyval.import)->decl.type_var = (yyvsp[-1].var); } -#line 2802 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3224 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 91: -#line 782 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 123: +#line 951 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.import) = new_import(parser->allocator); (yyval.import)->name = (yyvsp[-4].text); @@ -2811,22 +3233,22 @@ yyreduce: (yyval.import)->decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE; (yyval.import)->decl.type_var = (yyvsp[-1].var); } -#line 2815 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3237 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 92: -#line 790 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 124: +#line 959 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.import) = new_import(parser->allocator); (yyval.import)->module_name = (yyvsp[-3].text); (yyval.import)->func_name = (yyvsp[-2].text); (yyval.import)->decl.sig = (yyvsp[-1].func_sig); } -#line 2826 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3248 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 93: -#line 796 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 125: +#line 965 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.import) = new_import(parser->allocator); (yyval.import)->name = (yyvsp[-4].text); @@ -2834,36 +3256,36 @@ yyreduce: (yyval.import)->func_name = (yyvsp[-2].text); (yyval.import)->decl.sig = (yyvsp[-1].func_sig); } -#line 2838 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3260 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 94: -#line 806 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 126: +#line 975 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.export_).name = (yyvsp[-2].text); (yyval.export_).var = (yyvsp[-1].var); } -#line 2847 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3269 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 95: -#line 813 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 127: +#line 982 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.export_memory).name = (yyvsp[-2].text); } -#line 2855 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3277 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 96: -#line 819 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 128: +#line 988 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = new_module(parser->allocator); } -#line 2863 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3285 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 97: -#line 822 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 129: +#line 991 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -2903,11 +3325,11 @@ yyreduce: binding->index = (yyval.module)->exports.size - 1; } } -#line 2907 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3329 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 98: -#line 861 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 130: +#line 1030 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -2929,11 +3351,11 @@ yyreduce: binding->index = (yyval.module)->imports.size - 1; } } -#line 2933 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3355 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 99: -#line 882 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 131: +#line 1051 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -2951,11 +3373,11 @@ yyreduce: binding->index = (yyval.module)->exports.size - 1; } } -#line 2955 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3377 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 100: -#line 899 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 132: +#line 1068 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -2964,11 +3386,11 @@ yyreduce: field->export_memory = (yyvsp[0].export_memory); (yyval.module)->export_memory = &field->export_memory; } -#line 2968 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3390 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 101: -#line 907 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 133: +#line 1076 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -2977,11 +3399,11 @@ yyreduce: field->table = (yyvsp[0].vars); (yyval.module)->table = &field->table; } -#line 2981 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3403 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 102: -#line 915 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 134: +#line 1084 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -3000,11 +3422,11 @@ yyreduce: binding->index = (yyval.module)->func_types.size - 1; } } -#line 3004 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3426 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 103: -#line 933 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 135: +#line 1102 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -3013,11 +3435,11 @@ yyreduce: field->memory = (yyvsp[0].memory); (yyval.module)->memory = &field->memory; } -#line 3017 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3439 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 104: -#line 941 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 136: +#line 1110 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -3026,11 +3448,11 @@ yyreduce: field->start = (yyvsp[0].var); (yyval.module)->start = &field->start; } -#line 3030 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3452 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 105: -#line 952 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 137: +#line 1121 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.raw_module).type = WASM_RAW_MODULE_TYPE_TEXT; (yyval.raw_module).text = (yyvsp[-1].module); @@ -3065,22 +3487,22 @@ yyreduce: } } } -#line 3069 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3491 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 106: -#line 986 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 138: +#line 1155 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.raw_module).type = WASM_RAW_MODULE_TYPE_BINARY; (yyval.raw_module).loc = (yylsp[-2]); dup_text_list(parser->allocator, &(yyvsp[-1].text_list), &(yyval.raw_module).binary.data, &(yyval.raw_module).binary.size); wasm_destroy_text_list(parser->allocator, &(yyvsp[-1].text_list)); } -#line 3080 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3502 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 107: -#line 995 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 139: +#line 1164 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { if ((yyvsp[0].raw_module).type == WASM_RAW_MODULE_TYPE_TEXT) { (yyval.module) = (yyvsp[0].raw_module).text; @@ -3100,22 +3522,22 @@ yyreduce: wasm_free(parser->allocator, (yyvsp[0].raw_module).binary.data); } } -#line 3104 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3526 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 108: -#line 1019 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 140: +#line 1188 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.command) = new_command(parser->allocator); (yyval.command)->type = WASM_COMMAND_TYPE_MODULE; (yyval.command)->module = *(yyvsp[0].module); wasm_free(parser->allocator, (yyvsp[0].module)); } -#line 3115 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3537 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 109: -#line 1025 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 141: +#line 1194 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.command) = new_command(parser->allocator); (yyval.command)->type = WASM_COMMAND_TYPE_INVOKE; @@ -3123,22 +3545,22 @@ yyreduce: (yyval.command)->invoke.name = (yyvsp[-2].text); (yyval.command)->invoke.args = (yyvsp[-1].consts); } -#line 3127 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3549 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 110: -#line 1032 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 142: +#line 1201 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.command) = new_command(parser->allocator); (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_INVALID; (yyval.command)->assert_invalid.module = (yyvsp[-2].raw_module); (yyval.command)->assert_invalid.text = (yyvsp[-1].text); } -#line 3138 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3560 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 111: -#line 1038 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 143: +#line 1207 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.command) = new_command(parser->allocator); (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_RETURN; @@ -3147,11 +3569,11 @@ yyreduce: (yyval.command)->assert_return.invoke.args = (yyvsp[-3].consts); (yyval.command)->assert_return.expected = (yyvsp[-1].const_); } -#line 3151 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3573 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 112: -#line 1046 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 144: +#line 1215 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.command) = new_command(parser->allocator); (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_RETURN_NAN; @@ -3159,11 +3581,11 @@ yyreduce: (yyval.command)->assert_return_nan.invoke.name = (yyvsp[-3].text); (yyval.command)->assert_return_nan.invoke.args = (yyvsp[-2].consts); } -#line 3163 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3585 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 113: -#line 1053 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 145: +#line 1222 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.command) = new_command(parser->allocator); (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_TRAP; @@ -3172,27 +3594,27 @@ yyreduce: (yyval.command)->assert_trap.invoke.args = (yyvsp[-3].consts); (yyval.command)->assert_trap.text = (yyvsp[-1].text); } -#line 3176 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3598 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 114: -#line 1063 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 146: +#line 1232 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.commands)); } -#line 3182 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3604 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 115: -#line 1064 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 147: +#line 1233 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.commands) = (yyvsp[-1].commands); wasm_append_command_value(parser->allocator, &(yyval.commands), (yyvsp[0].command)); wasm_free(parser->allocator, (yyvsp[0].command)); } -#line 3192 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3614 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 116: -#line 1072 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 148: +#line 1241 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.const_).loc = (yylsp[-2]); if (WASM_FAILED(parse_const((yyvsp[-2].type), (yyvsp[-1].literal).type, (yyvsp[-1].literal).text.start, @@ -3203,41 +3625,41 @@ yyreduce: } wasm_free(parser->allocator, (char*)(yyvsp[-1].literal).text.start); } -#line 3207 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3629 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 117: -#line 1084 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 149: +#line 1253 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.const_).type = WASM_TYPE_VOID; } -#line 3213 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3635 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 119: -#line 1088 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 151: +#line 1257 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.consts)); } -#line 3219 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3641 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 120: -#line 1089 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 152: +#line 1258 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.consts) = (yyvsp[-1].consts); wasm_append_const_value(parser->allocator, &(yyval.consts), &(yyvsp[0].const_)); } -#line 3228 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3650 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 121: -#line 1096 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 153: +#line 1265 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.script).commands = (yyvsp[0].commands); parser->script = (yyval.script); } -#line 3237 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3659 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; -#line 3241 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3663 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -3472,9 +3894,71 @@ yyreturn: #endif return yyresult; } -#line 1108 "src/wasm-ast-parser.y" /* yacc.c:1906 */ +#line 1277 "src/wasm-ast-parser.y" /* yacc.c:1906 */ +static void append_expr_list(WasmExprList* expr_list, WasmExprList* expr) { + if (!expr->first) + return; + if (expr_list->last) + expr_list->last->next = expr->first; + else + expr_list->first = expr->first; + expr_list->last = expr->last; + expr_list->size += expr->size; +} + +static void append_expr(WasmExprList* expr_list, WasmExpr* expr) { + if (expr_list->last) + expr_list->last->next = expr; + else + expr_list->first = expr; + expr_list->last = expr; + expr_list->size++; +} + +static WasmExprList join_exprs1(WasmLocation* loc, WasmExpr* expr1) { + WasmExprList result; + WASM_ZERO_MEMORY(result); + append_expr(&result, expr1); + expr1->loc = *loc; + return result; +} + +static WasmExprList join_exprs2(WasmLocation* loc, WasmExprList* expr1, + WasmExpr* expr2) { + WasmExprList result; + WASM_ZERO_MEMORY(result); + append_expr_list(&result, expr1); + append_expr(&result, expr2); + expr2->loc = *loc; + return result; +} + +static WasmExprList join_exprs3(WasmLocation* loc, WasmExprList* expr1, + WasmExprList* expr2, WasmExpr* expr3) { + WasmExprList result; + WASM_ZERO_MEMORY(result); + append_expr_list(&result, expr1); + append_expr_list(&result, expr2); + append_expr(&result, expr3); + expr3->loc = *loc; + return result; +} + +static WasmExprList join_exprs4(WasmLocation* loc, WasmExprList* expr1, + WasmExprList* expr2, WasmExprList* expr3, + WasmExpr* expr4) { + WasmExprList result; + WASM_ZERO_MEMORY(result); + append_expr_list(&result, expr1); + append_expr_list(&result, expr2); + append_expr_list(&result, expr3); + append_expr(&result, expr4); + expr4->loc = *loc; + return result; +} + static WasmResult parse_const(WasmType type, WasmLiteralType literal_type, const char* s, diff --git a/src/prebuilt/wasm-ast-parser-gen.h b/src/prebuilt/wasm-ast-parser-gen.h index 45a2a725..38111fc0 100644 --- a/src/prebuilt/wasm-ast-parser-gen.h +++ b/src/prebuilt/wasm-ast-parser-gen.h @@ -63,52 +63,54 @@ extern int wasm_ast_parser_debug; WASM_TOKEN_TYPE_VAR = 264, WASM_TOKEN_TYPE_VALUE_TYPE = 265, WASM_TOKEN_TYPE_NOP = 266, - WASM_TOKEN_TYPE_BLOCK = 267, - WASM_TOKEN_TYPE_IF = 268, - WASM_TOKEN_TYPE_THEN = 269, - WASM_TOKEN_TYPE_ELSE = 270, - WASM_TOKEN_TYPE_LOOP = 271, - WASM_TOKEN_TYPE_BR = 272, - WASM_TOKEN_TYPE_BR_IF = 273, - WASM_TOKEN_TYPE_BR_TABLE = 274, - WASM_TOKEN_TYPE_CASE = 275, - WASM_TOKEN_TYPE_CALL = 276, - WASM_TOKEN_TYPE_CALL_IMPORT = 277, - WASM_TOKEN_TYPE_CALL_INDIRECT = 278, - WASM_TOKEN_TYPE_RETURN = 279, - WASM_TOKEN_TYPE_GET_LOCAL = 280, - WASM_TOKEN_TYPE_SET_LOCAL = 281, - WASM_TOKEN_TYPE_LOAD = 282, - WASM_TOKEN_TYPE_STORE = 283, - WASM_TOKEN_TYPE_OFFSET = 284, - WASM_TOKEN_TYPE_ALIGN = 285, - WASM_TOKEN_TYPE_CONST = 286, - WASM_TOKEN_TYPE_UNARY = 287, - WASM_TOKEN_TYPE_BINARY = 288, - WASM_TOKEN_TYPE_COMPARE = 289, - WASM_TOKEN_TYPE_CONVERT = 290, - WASM_TOKEN_TYPE_SELECT = 291, - WASM_TOKEN_TYPE_FUNC = 292, - WASM_TOKEN_TYPE_START = 293, - WASM_TOKEN_TYPE_TYPE = 294, - WASM_TOKEN_TYPE_PARAM = 295, - WASM_TOKEN_TYPE_RESULT = 296, - WASM_TOKEN_TYPE_LOCAL = 297, - WASM_TOKEN_TYPE_MODULE = 298, - WASM_TOKEN_TYPE_MEMORY = 299, - WASM_TOKEN_TYPE_SEGMENT = 300, - WASM_TOKEN_TYPE_IMPORT = 301, - WASM_TOKEN_TYPE_EXPORT = 302, - WASM_TOKEN_TYPE_TABLE = 303, - WASM_TOKEN_TYPE_UNREACHABLE = 304, - WASM_TOKEN_TYPE_CURRENT_MEMORY = 305, - WASM_TOKEN_TYPE_GROW_MEMORY = 306, - WASM_TOKEN_TYPE_ASSERT_INVALID = 307, - WASM_TOKEN_TYPE_ASSERT_RETURN = 308, - WASM_TOKEN_TYPE_ASSERT_RETURN_NAN = 309, - WASM_TOKEN_TYPE_ASSERT_TRAP = 310, - WASM_TOKEN_TYPE_INVOKE = 311, - WASM_TOKEN_TYPE_LOW = 312 + WASM_TOKEN_TYPE_DROP = 267, + WASM_TOKEN_TYPE_BLOCK = 268, + WASM_TOKEN_TYPE_END = 269, + WASM_TOKEN_TYPE_IF = 270, + WASM_TOKEN_TYPE_THEN = 271, + WASM_TOKEN_TYPE_ELSE = 272, + WASM_TOKEN_TYPE_LOOP = 273, + WASM_TOKEN_TYPE_BR = 274, + WASM_TOKEN_TYPE_BR_IF = 275, + WASM_TOKEN_TYPE_BR_TABLE = 276, + WASM_TOKEN_TYPE_CALL = 277, + WASM_TOKEN_TYPE_CALL_IMPORT = 278, + WASM_TOKEN_TYPE_CALL_INDIRECT = 279, + WASM_TOKEN_TYPE_RETURN = 280, + WASM_TOKEN_TYPE_GET_LOCAL = 281, + WASM_TOKEN_TYPE_SET_LOCAL = 282, + WASM_TOKEN_TYPE_TEE_LOCAL = 283, + WASM_TOKEN_TYPE_LOAD = 284, + WASM_TOKEN_TYPE_STORE = 285, + WASM_TOKEN_TYPE_OFFSET = 286, + WASM_TOKEN_TYPE_ALIGN = 287, + WASM_TOKEN_TYPE_CONST = 288, + WASM_TOKEN_TYPE_UNARY = 289, + WASM_TOKEN_TYPE_BINARY = 290, + WASM_TOKEN_TYPE_COMPARE = 291, + WASM_TOKEN_TYPE_CONVERT = 292, + WASM_TOKEN_TYPE_SELECT = 293, + WASM_TOKEN_TYPE_UNREACHABLE = 294, + WASM_TOKEN_TYPE_CURRENT_MEMORY = 295, + WASM_TOKEN_TYPE_GROW_MEMORY = 296, + WASM_TOKEN_TYPE_FUNC = 297, + WASM_TOKEN_TYPE_START = 298, + WASM_TOKEN_TYPE_TYPE = 299, + WASM_TOKEN_TYPE_PARAM = 300, + WASM_TOKEN_TYPE_RESULT = 301, + WASM_TOKEN_TYPE_LOCAL = 302, + WASM_TOKEN_TYPE_MODULE = 303, + WASM_TOKEN_TYPE_MEMORY = 304, + WASM_TOKEN_TYPE_SEGMENT = 305, + WASM_TOKEN_TYPE_IMPORT = 306, + WASM_TOKEN_TYPE_EXPORT = 307, + WASM_TOKEN_TYPE_TABLE = 308, + WASM_TOKEN_TYPE_ASSERT_INVALID = 309, + WASM_TOKEN_TYPE_ASSERT_RETURN = 310, + WASM_TOKEN_TYPE_ASSERT_RETURN_NAN = 311, + WASM_TOKEN_TYPE_ASSERT_TRAP = 312, + WASM_TOKEN_TYPE_INVOKE = 313, + WASM_TOKEN_TYPE_LOW = 314 }; #endif diff --git a/src/wasm-apply-names.c b/src/wasm-apply-names.c index f21abd63..f8287984 100644 --- a/src/wasm-apply-names.c +++ b/src/wasm-apply-names.c @@ -158,8 +158,7 @@ static WasmResult end_block_expr(WasmExpr* expr, void* user_data) { static WasmResult begin_loop_expr(WasmExpr* expr, void* user_data) { Context* ctx = user_data; - push_label(ctx, &expr->loop.outer); - push_label(ctx, &expr->loop.inner); + push_label(ctx, &expr->loop.label); return WASM_OK; } @@ -170,21 +169,21 @@ static WasmResult end_loop_expr(WasmExpr* expr, void* user_data) { return WASM_OK; } -static WasmResult begin_br_expr(WasmExpr* expr, void* user_data) { +static WasmResult on_br_expr(WasmExpr* expr, void* user_data) { Context* ctx = user_data; WasmLabel* label = find_label_by_var(ctx, &expr->br.var); use_name_for_var(ctx->allocator, label, &expr->br.var); return WASM_OK; } -static WasmResult begin_br_if_expr(WasmExpr* expr, void* user_data) { +static WasmResult on_br_if_expr(WasmExpr* expr, void* user_data) { Context* ctx = user_data; WasmLabel* label = find_label_by_var(ctx, &expr->br_if.var); use_name_for_var(ctx->allocator, label, &expr->br_if.var); return WASM_OK; } -static WasmResult begin_br_table_expr(WasmExpr* expr, void* user_data) { +static WasmResult on_br_table_expr(WasmExpr* expr, void* user_data) { Context* ctx = user_data; size_t i; WasmVarVector* targets = &expr->br_table.targets; @@ -199,24 +198,24 @@ static WasmResult begin_br_table_expr(WasmExpr* expr, void* user_data) { return WASM_OK; } -static WasmResult begin_call_expr(WasmExpr* expr, void* user_data) { +static WasmResult on_call_expr(WasmExpr* expr, void* user_data) { Context* ctx = user_data; CHECK_RESULT( use_name_for_func_var(ctx->allocator, ctx->module, &expr->call.var)); return WASM_OK; } -static WasmResult begin_call_import_expr(WasmExpr* expr, void* user_data) { +static WasmResult on_call_import_expr(WasmExpr* expr, void* user_data) { Context* ctx = user_data; CHECK_RESULT( use_name_for_import_var(ctx->allocator, ctx->module, &expr->call.var)); return WASM_OK; } -static WasmResult begin_call_indirect_expr(WasmExpr* expr, void* user_data) { +static WasmResult on_call_indirect_expr(WasmExpr* expr, void* user_data) { Context* ctx = user_data; - CHECK_RESULT(use_name_for_func_type_var(ctx->allocator, ctx->module, - &expr->call_indirect.var)); + CHECK_RESULT( + use_name_for_func_type_var(ctx->allocator, ctx->module, &expr->call.var)); return WASM_OK; } @@ -227,7 +226,7 @@ static WasmResult on_get_local_expr(WasmExpr* expr, void* user_data) { return WASM_OK; } -static WasmResult after_if_cond_expr(WasmExpr* expr, void* user_data) { +static WasmResult begin_if_expr(WasmExpr* expr, void* user_data) { Context* ctx = user_data; push_label(ctx, &expr->if_.true_.label); return WASM_OK; @@ -239,7 +238,7 @@ static WasmResult end_if_expr(WasmExpr* expr, void* user_data) { return WASM_OK; } -static WasmResult after_if_else_cond_expr(WasmExpr* expr, void* user_data) { +static WasmResult begin_if_else_expr(WasmExpr* expr, void* user_data) { Context* ctx = user_data; push_label(ctx, &expr->if_else.true_.label); return WASM_OK; @@ -258,7 +257,7 @@ static WasmResult end_if_else_expr(WasmExpr* expr, void* user_data) { return WASM_OK; } -static WasmResult begin_set_local_expr(WasmExpr* expr, void* user_data) { +static WasmResult on_set_local_expr(WasmExpr* expr, void* user_data) { Context* ctx = user_data; CHECK_RESULT(use_name_for_param_and_local_var(ctx, ctx->current_func, &expr->set_local.var)); @@ -331,19 +330,19 @@ WasmResult wasm_apply_names(WasmAllocator* allocator, WasmModule* module) { ctx.visitor.end_block_expr = end_block_expr; ctx.visitor.begin_loop_expr = begin_loop_expr; ctx.visitor.end_loop_expr = end_loop_expr; - ctx.visitor.begin_br_expr = begin_br_expr; - ctx.visitor.begin_br_if_expr = begin_br_if_expr; - ctx.visitor.begin_br_table_expr = begin_br_table_expr; - ctx.visitor.begin_call_expr = begin_call_expr; - ctx.visitor.begin_call_import_expr = begin_call_import_expr; - ctx.visitor.begin_call_indirect_expr = begin_call_indirect_expr; + ctx.visitor.on_br_expr = on_br_expr; + ctx.visitor.on_br_if_expr = on_br_if_expr; + ctx.visitor.on_br_table_expr = on_br_table_expr; + ctx.visitor.on_call_expr = on_call_expr; + ctx.visitor.on_call_import_expr = on_call_import_expr; + ctx.visitor.on_call_indirect_expr = on_call_indirect_expr; ctx.visitor.on_get_local_expr = on_get_local_expr; - ctx.visitor.after_if_cond_expr = after_if_cond_expr; + ctx.visitor.begin_if_expr = begin_if_expr; ctx.visitor.end_if_expr = end_if_expr; - ctx.visitor.after_if_else_cond_expr = after_if_else_cond_expr; + ctx.visitor.begin_if_else_expr = begin_if_else_expr; ctx.visitor.after_if_else_true_expr = after_if_else_true_expr; ctx.visitor.end_if_else_expr = end_if_else_expr; - ctx.visitor.begin_set_local_expr = begin_set_local_expr; + ctx.visitor.on_set_local_expr = on_set_local_expr; WasmResult result = visit_module(&ctx, module); wasm_destroy_string_slice_vector(allocator, &ctx.param_index_to_name); wasm_destroy_string_slice_vector(allocator, &ctx.local_index_to_name); diff --git a/src/wasm-ast-checker.c b/src/wasm-ast-checker.c index b940d621..2d0ca5b6 100644 --- a/src/wasm-ast-checker.c +++ b/src/wasm-ast-checker.c @@ -28,91 +28,71 @@ #include "wasm-binary-reader-ast.h" #include "wasm-binary-reader.h" -static const char* s_type_names[] = { - "void", "i32", "i64", "f32", "f64", -}; -WASM_STATIC_ASSERT(WASM_ARRAY_SIZE(s_type_names) == WASM_NUM_TYPES); - -typedef enum TypeSet { - WASM_TYPE_SET_VOID = 0, - WASM_TYPE_SET_I32 = 1 << 0, - WASM_TYPE_SET_I64 = 1 << 1, - WASM_TYPE_SET_F32 = 1 << 2, - WASM_TYPE_SET_F64 = 1 << 3, - WASM_TYPE_SET_ALL = (1 << 4) - 1, -} TypeSet; - -static const char* s_type_set_names[] = { - "void", - "i32", - "i64", - "i32 or i64", - "f32", - "i32 or f32", - "i64 or f32", - "i32, i64 or f32", - "f64", - "i32 or f64", - "i64 or f64", - "i32, i64 or f64", - "f32 or f64", - "i32, f32 or f64", - "i64, f32 or f64", - "i32, i64, f32 or f64", -}; -WASM_STATIC_ASSERT(WASM_ARRAY_SIZE(s_type_set_names) == WASM_TYPE_SET_ALL + 1); -WASM_STATIC_ASSERT((1 << (WASM_TYPE_I32 - 1)) == WASM_TYPE_SET_I32); -WASM_STATIC_ASSERT((1 << (WASM_TYPE_I64 - 1)) == WASM_TYPE_SET_I64); -WASM_STATIC_ASSERT((1 << (WASM_TYPE_F32 - 1)) == WASM_TYPE_SET_F32); -WASM_STATIC_ASSERT((1 << (WASM_TYPE_F64 - 1)) == WASM_TYPE_SET_F64); - -#define TYPE_TO_TYPE_SET(type) ((type) ? 1 << ((type)-1) : 0) +typedef enum WasmCheckType { + WASM_CHECK_TYPE_VOID = WASM_TYPE_VOID, + WASM_CHECK_TYPE_I32 = WASM_TYPE_I32, + WASM_CHECK_TYPE_I64 = WASM_TYPE_I64, + WASM_CHECK_TYPE_F32 = WASM_TYPE_F32, + WASM_CHECK_TYPE_F64 = WASM_TYPE_F64, + WASM_CHECK_TYPE_ANY = WASM_NUM_TYPES, + WASM_NUM_CHECK_TYPES, + WASM_CHECK_TYPE____ = WASM_CHECK_TYPE_VOID, /* see table in wasm-common.h */ +} WasmCheckType; +WASM_DEFINE_VECTOR(check_type, WasmCheckType); + +static const char* s_type_names[] = {"void", "i32", "i64", "f32", "f64", "any"}; +WASM_STATIC_ASSERT(WASM_ARRAY_SIZE(s_type_names) == WASM_NUM_CHECK_TYPES); #define V(rtype, type1, type2, mem_size, code, NAME, text) \ - [code] = WASM_TYPE_##rtype, -static WasmType s_opcode_rtype[] = {WASM_FOREACH_OPCODE(V)}; + [code] = WASM_CHECK_TYPE_##rtype, +static WasmCheckType s_opcode_rtype[] = {WASM_FOREACH_OPCODE(V)}; #undef V #define V(rtype, type1, type2, mem_size, code, NAME, text) \ - [code] = WASM_TYPE_##type1, -static WasmType s_opcode_type1[] = {WASM_FOREACH_OPCODE(V)}; + [code] = WASM_CHECK_TYPE_##type1, +static WasmCheckType s_opcode_type1[] = {WASM_FOREACH_OPCODE(V)}; #undef V #define V(rtype, type1, type2, mem_size, code, NAME, text) \ - [code] = WASM_TYPE_##type2, -static WasmType s_opcode_type2[] = {WASM_FOREACH_OPCODE(V)}; + [code] = WASM_CHECK_TYPE_##type2, +static WasmCheckType s_opcode_type2[] = {WASM_FOREACH_OPCODE(V)}; #undef V -typedef enum CheckType { - CHECK_TYPE_NAME, - CHECK_TYPE_FULL, -} CheckType; +typedef size_t WasmSizeT; +WASM_DEFINE_VECTOR(size_t, WasmSizeT); + +typedef enum CheckStyle { + CHECK_STYLE_NAME, + CHECK_STYLE_FULL, +} CheckStyle; typedef struct LabelNode { const WasmLabel* label; - WasmType expected_type; + WasmCheckType type; const char* desc; struct LabelNode* next; } LabelNode; typedef struct Context { - CheckType check_type; + CheckStyle check_style; WasmSourceErrorHandler* error_handler; WasmAllocator* allocator; WasmAstLexer* lexer; const WasmModule* current_module; const WasmFunc* current_func; + WasmSizeTVector type_stack_limit; + WasmCheckTypeVector type_stack; LabelNode* top_label; int max_depth; WasmResult result; } Context; static void WASM_PRINTF_FORMAT(4, 5) print_error(Context* ctx, - CheckType check_type, + CheckStyle check_style, const WasmLocation* loc, const char* fmt, ...) { - if (check_type <= ctx->check_type) { + if (check_style <= ctx->check_style) { ctx->result = WASM_ERROR; va_list args; va_start(args, fmt); @@ -147,7 +127,7 @@ static void check_duplicate_bindings(Context* ctx, WasmLocation* a_loc = &a->binding.loc; WasmLocation* b_loc = &b->binding.loc; WasmLocation* loc = a_loc->line > b_loc->line ? a_loc : b_loc; - print_error(ctx, CHECK_TYPE_NAME, loc, + print_error(ctx, CHECK_STYLE_NAME, loc, "redefinition of %s \"" PRIstringslice "\"", desc, WASM_PRINTF_STRING_SLICE_ARG(a->binding.name)); } @@ -169,11 +149,11 @@ static WasmResult check_var(Context* ctx, return WASM_OK; } if (var->type == WASM_VAR_TYPE_NAME) { - print_error(ctx, CHECK_TYPE_NAME, &var->loc, + print_error(ctx, CHECK_STYLE_NAME, &var->loc, "undefined %s variable \"" PRIstringslice "\"", desc, WASM_PRINTF_STRING_SLICE_ARG(var->name)); } else { - print_error(ctx, CHECK_TYPE_NAME, &var->loc, + print_error(ctx, CHECK_STYLE_NAME, &var->loc, "%s variable out of range (max %d)", desc, max_index); } return WASM_ERROR; @@ -226,7 +206,7 @@ static WasmResult check_func_type_var(Context* ctx, static WasmResult check_local_var(Context* ctx, const WasmVar* var, - WasmType* out_type) { + WasmCheckType* out_type) { const WasmModule* module = ctx->current_module; const WasmFunc* func = ctx->current_func; int max_index = wasm_get_num_params_and_locals(module, func); @@ -244,11 +224,11 @@ static WasmResult check_local_var(Context* ctx, } if (var->type == WASM_VAR_TYPE_NAME) { - print_error(ctx, CHECK_TYPE_NAME, &var->loc, + print_error(ctx, CHECK_STYLE_NAME, &var->loc, "undefined local variable \"" PRIstringslice "\"", WASM_PRINTF_STRING_SLICE_ARG(var->name)); } else { - print_error(ctx, CHECK_TYPE_NAME, &var->loc, + print_error(ctx, CHECK_STYLE_NAME, &var->loc, "local variable out of range (max %d)", max_index); } return WASM_ERROR; @@ -258,68 +238,18 @@ static void check_align(Context* ctx, const WasmLocation* loc, uint32_t alignment) { if (alignment != WASM_USE_NATURAL_ALIGNMENT && !is_power_of_two(alignment)) - print_error(ctx, CHECK_TYPE_FULL, loc, "alignment must be power-of-two"); + print_error(ctx, CHECK_STYLE_FULL, loc, "alignment must be power-of-two"); } static void check_offset(Context* ctx, const WasmLocation* loc, uint64_t offset) { if (offset > UINT32_MAX) { - print_error(ctx, CHECK_TYPE_FULL, loc, + print_error(ctx, CHECK_STYLE_FULL, loc, "offset must be less than or equal to 0xffffffff"); } } -static void check_type(Context* ctx, - const WasmLocation* loc, - WasmType actual, - WasmType expected, - const char* desc) { - if (expected != WASM_TYPE_VOID && actual != expected) { - print_error(ctx, CHECK_TYPE_FULL, loc, - "type mismatch%s. got %s, expected %s", desc, - s_type_names[actual], s_type_names[expected]); - } -} - -static void check_type_set(Context* ctx, - const WasmLocation* loc, - WasmType actual, - TypeSet expected, - const char* desc) { - if (expected != WASM_TYPE_SET_VOID && - (TYPE_TO_TYPE_SET(actual) & expected) == 0) { - print_error(ctx, CHECK_TYPE_FULL, loc, - "type mismatch%s. got %s, expected %s", desc, - s_type_names[actual], s_type_set_names[expected]); - } -} - -static void check_type_exact(Context* ctx, - const WasmLocation* loc, - WasmType actual, - WasmType expected, - const char* desc) { - if (actual != expected) { - print_error(ctx, CHECK_TYPE_FULL, loc, - "type mismatch%s. got %s, expected %s", desc, - s_type_names[actual], s_type_names[expected]); - } -} - -static void check_type_arg_exact(Context* ctx, - const WasmLocation* loc, - WasmType actual, - WasmType expected, - const char* desc, - int arg_index) { - if (actual != expected) { - print_error(ctx, CHECK_TYPE_FULL, loc, - "type mismatch for argument %d of %s. got %s, expected %s", - arg_index, desc, s_type_names[actual], s_type_names[expected]); - } -} - static LabelNode* find_label_by_name(LabelNode* top_label, const WasmStringSlice* name) { LabelNode* node = top_label; @@ -356,11 +286,11 @@ static WasmResult check_label_var(Context* ctx, } if (var->type == WASM_VAR_TYPE_NAME) { - print_error(ctx, CHECK_TYPE_NAME, &var->loc, + print_error(ctx, CHECK_STYLE_NAME, &var->loc, "undefined label variable \"" PRIstringslice "\"", WASM_PRINTF_STRING_SLICE_ARG(var->name)); } else { - print_error(ctx, CHECK_TYPE_NAME, &var->loc, + print_error(ctx, CHECK_STYLE_NAME, &var->loc, "label variable out of range (max %d)", ctx->max_depth); } @@ -371,11 +301,11 @@ static void push_label(Context* ctx, const WasmLocation* loc, LabelNode* node, const WasmLabel* label, - WasmType expected_type, + WasmCheckType type, const char* desc) { node->label = label; node->next = ctx->top_label; - node->expected_type = expected_type; + node->type = type; node->desc = desc; ctx->top_label = node; ctx->max_depth++; @@ -386,131 +316,298 @@ static void pop_label(Context* ctx) { ctx->top_label = ctx->top_label->next; } -static void check_expr(Context* ctx, - const WasmExpr* expr, - WasmType expected_type, - const char* desc); +static size_t type_stack_limit(Context* ctx) { + return ctx->type_stack_limit.data[ctx->type_stack_limit.size - 1]; +} + +static size_t push_type_stack_limit(Context* ctx) { + size_t limit = ctx->type_stack.size; + wasm_append_size_t_value(ctx->allocator, &ctx->type_stack_limit, &limit); + return limit; +} + +static void pop_type_stack_limit(Context* ctx) { + assert(ctx->type_stack_limit.size > 0); + ctx->type_stack_limit.size--; +} + +static void push_type(Context* ctx, WasmCheckType type) { + if (type != WASM_CHECK_TYPE_VOID) + wasm_append_check_type_value(ctx->allocator, &ctx->type_stack, &type); +} + +static WasmCheckType peek_type(Context* ctx, size_t depth, int arity) { + if (arity > 0) { + if (depth < ctx->type_stack.size - type_stack_limit(ctx)) { + return ctx->type_stack.data[ctx->type_stack.size - depth - 1]; + } else { + /* return any type to allow type-checking to continue; the caller should + * have already raised an error about the stack underflow. */ + return WASM_CHECK_TYPE_I32; + } + } else { + return WASM_CHECK_TYPE_VOID; + } +} + +static WasmCheckType top_type(Context* ctx) { + return peek_type(ctx, 0, 1); +} + +static WasmCheckType pop_type(Context* ctx) { + WasmCheckType result = top_type(ctx); + if (ctx->type_stack.size > type_stack_limit(ctx)) + ctx->type_stack.size--; + return result; +} + +static void check_type(Context* ctx, + const WasmLocation* loc, + WasmCheckType actual, + WasmCheckType expected, + const char* desc) { + if (actual != expected) { + print_error(ctx, CHECK_STYLE_FULL, loc, + "type mismatch at %s. got %s, expected %s", desc, + s_type_names[actual], s_type_names[expected]); + } +} -static void check_expr_opt(Context* ctx, +static void check_type_arg(Context* ctx, const WasmLocation* loc, - const WasmExpr* expr, - WasmType expected_type, - const char* desc) { - if (expr) - check_expr(ctx, expr, expected_type, desc); - else - check_type(ctx, loc, WASM_TYPE_VOID, expected_type, desc); + WasmCheckType actual, + WasmCheckType expected, + const char* desc, + int arg_index) { + if (actual != expected) { + print_error(ctx, CHECK_STYLE_FULL, loc, + "type mismatch for argument %d of %s. got %s, expected %s", + arg_index, desc, s_type_names[actual], s_type_names[expected]); + } +} + +static void check_assert_return_nan_type(Context* ctx, + const WasmLocation* loc, + WasmCheckType actual, + const char* desc) { + /* when using assert_return_nan, the result can be either a f32 or f64 type + * so we special case it here. */ + if (actual != WASM_CHECK_TYPE_F32 && actual != WASM_CHECK_TYPE_F64) { + print_error(ctx, CHECK_STYLE_FULL, loc, + "type mismatch at %s. got %s, expected f32 or f64", desc, + s_type_names[actual]); + } +} + +static WasmCheckType join_type(Context* ctx, + const WasmLocation* loc, + WasmCheckType t1, + WasmCheckType t2, + const char* desc) { + if (t1 == WASM_CHECK_TYPE_ANY) { + return t2; + } else if (t2 == WASM_CHECK_TYPE_ANY) { + return t1; + } else if (t1 == t2) { + return t1; + } else { + print_error(ctx, CHECK_STYLE_FULL, loc, + "type mismatch at %s. got %s, expected %s", desc, + s_type_names[t1], s_type_names[t2]); + return t1; + } +} + +static void unify_label_type(Context* ctx, + const WasmLocation* loc, + LabelNode* node, + WasmCheckType type, + const char* desc) { + if (node->type == WASM_CHECK_TYPE_ANY) { + node->type = type; + } else if (type != WASM_CHECK_TYPE_ANY && node->type != type) { + print_error(ctx, CHECK_STYLE_FULL, loc, + "type mismatch at %s. got %s, expected %s", desc, + s_type_names[type], s_type_names[node->type]); + } +} + +static void transform_stack(Context* ctx, + const WasmLocation* loc, + const char* desc, + size_t before_size, + size_t after_size, + ...) { + size_t i; + va_list args; + va_start(args, after_size); + size_t limit = type_stack_limit(ctx); + size_t avail = ctx->type_stack.size - limit; + if (before_size <= avail) { + for (i = 0; i < before_size; ++i) { + WasmCheckType actual = + ctx->type_stack.data[ctx->type_stack.size - before_size + i]; + WasmCheckType expected = va_arg(args, WasmCheckType); + /* TODO(binji): could give a better location for the error by storing the + * location in the type stack; i.e. where this type was added to the + * stack */ + check_type(ctx, loc, actual, expected, desc); + } + ctx->type_stack.size -= before_size; + } else { + print_error(ctx, CHECK_STYLE_FULL, loc, + "type stack size too small at %s. got %" PRIzd + ", expected at least %" PRIzd, + desc, avail, before_size); + ctx->type_stack.size = limit; + } + assert(after_size <= 1); + if (after_size > 0) + push_type(ctx, va_arg(args, WasmCheckType)); + va_end(args); } static void check_br(Context* ctx, const WasmLocation* loc, const WasmVar* var, - const WasmExpr* expr, + WasmCheckType type, const char* desc) { LabelNode* node; - if (WASM_FAILED(check_label_var(ctx, ctx->top_label, var, &node))) - return; - - check_expr_opt(ctx, loc, expr, node->expected_type, desc); + if (WASM_SUCCEEDED(check_label_var(ctx, ctx->top_label, var, &node))) { + unify_label_type(ctx, loc, node, type, desc); + } } static void check_call(Context* ctx, const WasmLocation* loc, const WasmStringSlice* callee_name, const WasmFuncSignature* sig, - const WasmExpr* first_arg, - size_t num_args, - WasmType expected_type, const char* desc) { size_t expected_args = sig->param_types.size; - if (expected_args == num_args) { - char buffer[100]; - wasm_snprintf(buffer, 100, " of %s result", desc); - check_type(ctx, loc, sig->result_type, expected_type, buffer); - const WasmExpr* arg; + size_t limit = type_stack_limit(ctx); + size_t avail = ctx->type_stack.size - limit; + if (expected_args <= avail) { size_t i; - for (i = 0, arg = first_arg; i < num_args; ++i, arg = arg->next) { - wasm_snprintf(buffer, 100, " of argument %" PRIzd " of %s", i, desc); - check_expr(ctx, arg, sig->param_types.data[i], buffer); + for (i = 0; i < sig->param_types.size; ++i) { + WasmCheckType actual = + ctx->type_stack.data[ctx->type_stack.size - expected_args + i]; + WasmCheckType expected = sig->param_types.data[i]; + check_type_arg(ctx, loc, actual, expected, desc, i); } + ctx->type_stack.size -= expected_args; } else { - char* callee_name_str = ""; - if (callee_name && callee_name->start) { - size_t length = callee_name->length + 10; - callee_name_str = alloca(length); - wasm_snprintf(callee_name_str, length, " \"" PRIstringslice "\"", - WASM_PRINTF_STRING_SLICE_ARG(*callee_name)); - } - print_error(ctx, CHECK_TYPE_FULL, loc, - "too %s parameters to function%s in %s. got %" PRIzd - ", expected %" PRIzd, - num_args > expected_args ? "many" : "few", callee_name_str, - desc, num_args, expected_args); + print_error(ctx, CHECK_STYLE_FULL, loc, + "type stack size too small at %s. got %" PRIzd + ", expected at least %" PRIzd, + desc, avail, expected_args); + ctx->type_stack.size = limit; } + push_type(ctx, sig->result_type); } -static void check_expr_list(Context* ctx, - const WasmLocation* loc, - const WasmExpr* first, - WasmType expected_type, - const char* desc) { +static void check_expr(Context* ctx, const WasmExpr* expr); + +static WasmCheckType check_block(Context* ctx, + const WasmLocation* loc, + const WasmExpr* first, + const char* desc) { if (first) { + size_t limit = push_type_stack_limit(ctx); const WasmExpr* expr; for (expr = first; expr; expr = expr->next) { - if (expr->next) - check_expr(ctx, expr, WASM_TYPE_VOID, ""); - else - check_expr(ctx, expr, expected_type, desc); + check_expr(ctx, expr); + /* stop typechecking if we hit unreachable code */ + if (top_type(ctx) == WASM_CHECK_TYPE_ANY) + break; } + WasmCheckType result = top_type(ctx); + if (result != WASM_CHECK_TYPE_ANY) { + size_t result_arity = ctx->type_stack.size - limit; + if (result_arity > 1) { + print_error(ctx, CHECK_STYLE_FULL, loc, + "maximum arity for %s is 1, got %" PRIzd, desc, + result_arity); + } else if (result_arity == 0) { + result = WASM_CHECK_TYPE_VOID; + } + } + ctx->type_stack.size = limit; + pop_type_stack_limit(ctx); + return result; } else { - check_type(ctx, loc, WASM_TYPE_VOID, expected_type, desc); + return WASM_CHECK_TYPE_VOID; } } -static void check_expr(Context* ctx, - const WasmExpr* expr, - WasmType expected_type, - const char* desc) { +static void check_expr(Context* ctx, const WasmExpr* expr) { switch (expr->type) { case WASM_EXPR_TYPE_BINARY: { - WasmType rtype = s_opcode_rtype[expr->binary.opcode]; - WasmType type1 = s_opcode_type1[expr->binary.opcode]; - WasmType type2 = s_opcode_type2[expr->binary.opcode]; - check_type(ctx, &expr->loc, rtype, expected_type, desc); - check_expr(ctx, expr->binary.left, type1, " of argument 0 of binary op"); - check_expr(ctx, expr->binary.right, type2, " of argument 1 of binary op"); + WasmCheckType rtype = s_opcode_rtype[expr->binary.opcode]; + WasmCheckType type1 = s_opcode_type1[expr->binary.opcode]; + WasmCheckType type2 = s_opcode_type2[expr->binary.opcode]; + transform_stack(ctx, &expr->loc, "binary", 2, 1, type1, type2, rtype); break; } case WASM_EXPR_TYPE_BLOCK: { LabelNode node; - push_label(ctx, &expr->loc, &node, &expr->block.label, expected_type, - "block"); - check_expr_list(ctx, &expr->loc, expr->block.first, expected_type, - " of block"); + push_label(ctx, &expr->loc, &node, &expr->block.label, + WASM_CHECK_TYPE_ANY, "block"); + WasmCheckType rtype = + check_block(ctx, &expr->loc, expr->block.first, "block"); + rtype = join_type(ctx, &expr->loc, node.type, rtype, "block"); pop_label(ctx); + push_type(ctx, rtype); break; } case WASM_EXPR_TYPE_BR: { - check_br(ctx, &expr->loc, &expr->br.var, expr->br.expr, " of br value"); + WasmCheckType type = peek_type(ctx, 0, expr->br.arity); + check_br(ctx, &expr->loc, &expr->br.var, type, "br value"); + if (expr->br.arity > 0) { + transform_stack(ctx, &expr->loc, "br", 1, 1, type, WASM_CHECK_TYPE_ANY); + } else { + transform_stack(ctx, &expr->loc, "br", 0, 1, WASM_CHECK_TYPE_ANY); + } break; } case WASM_EXPR_TYPE_BR_IF: { - check_type(ctx, &expr->loc, WASM_TYPE_VOID, expected_type, desc); - check_br(ctx, &expr->loc, &expr->br_if.var, expr->br_if.expr, - " of br_if value"); - check_expr(ctx, expr->br_if.cond, WASM_TYPE_I32, " of br_if condition"); + WasmCheckType type = peek_type(ctx, 1, expr->br_if.arity); + check_br(ctx, &expr->loc, &expr->br_if.var, type, "br_if value"); + if (expr->br_if.arity > 0) { + transform_stack(ctx, &expr->loc, "br_if", 2, 1, type, + WASM_CHECK_TYPE_I32, WASM_CHECK_TYPE_VOID); + } else { + transform_stack(ctx, &expr->loc, "br_if", 1, 1, WASM_CHECK_TYPE_I32, + WASM_CHECK_TYPE_VOID); + } + break; + } + + case WASM_EXPR_TYPE_BR_TABLE: { + WasmCheckType type = peek_type(ctx, 1, expr->br_table.arity); + size_t i; + for (i = 0; i < expr->br_table.targets.size; ++i) { + check_br(ctx, &expr->loc, &expr->br_table.targets.data[i], type, + "br_table target"); + } + check_br(ctx, &expr->loc, &expr->br_table.default_target, type, + "br_table default target"); + if (expr->br_table.arity > 0) { + transform_stack(ctx, &expr->loc, "br_table", 2, 1, type, + WASM_CHECK_TYPE_I32, WASM_CHECK_TYPE_ANY); + } else { + transform_stack(ctx, &expr->loc, "br_table", 1, 1, WASM_CHECK_TYPE_I32, + WASM_CHECK_TYPE_ANY); + } break; } case WASM_EXPR_TYPE_CALL: { const WasmFunc* callee; if (WASM_SUCCEEDED(check_func_var(ctx, &expr->call.var, &callee))) { - check_call(ctx, &expr->loc, &callee->name, &callee->decl.sig, - expr->call.first_arg, expr->call.num_args, expected_type, - "call"); + check_call(ctx, &expr->loc, &callee->name, &callee->decl.sig, "call"); } break; } @@ -519,182 +616,172 @@ static void check_expr(Context* ctx, const WasmImport* import; if (WASM_SUCCEEDED(check_import_var(ctx, &expr->call.var, &import))) { check_call(ctx, &expr->loc, &import->name, &import->decl.sig, - expr->call.first_arg, expr->call.num_args, expected_type, "call_import"); } break; } case WASM_EXPR_TYPE_CALL_INDIRECT: { - check_expr(ctx, expr->call_indirect.expr, WASM_TYPE_I32, - " of function index"); const WasmFuncType* func_type; if (WASM_SUCCEEDED( - check_func_type_var(ctx, &expr->call_indirect.var, &func_type))) { - check_call(ctx, &expr->loc, NULL, &func_type->sig, - expr->call_indirect.first_arg, expr->call_indirect.num_args, - expected_type, "call_indirect"); + check_func_type_var(ctx, &expr->call.var, &func_type))) { + WasmCheckType type = pop_type(ctx); + check_type(ctx, &expr->loc, type, WASM_CHECK_TYPE_I32, + "function index"); + check_call(ctx, &expr->loc, NULL, &func_type->sig, "call_indirect"); } break; } case WASM_EXPR_TYPE_COMPARE: { - WasmType rtype = s_opcode_rtype[expr->compare.opcode]; - WasmType type1 = s_opcode_type1[expr->compare.opcode]; - WasmType type2 = s_opcode_type2[expr->compare.opcode]; - check_type(ctx, &expr->loc, rtype, expected_type, desc); - check_expr(ctx, expr->compare.left, type1, - " of argument 0 of compare op"); - check_expr(ctx, expr->compare.right, type2, - " of argument 1 of compare op"); + WasmCheckType rtype = s_opcode_rtype[expr->compare.opcode]; + WasmCheckType type1 = s_opcode_type1[expr->compare.opcode]; + WasmCheckType type2 = s_opcode_type2[expr->compare.opcode]; + transform_stack(ctx, &expr->loc, "compare", 2, 1, type1, type2, rtype); break; } case WASM_EXPR_TYPE_CONST: - check_type(ctx, &expr->loc, expr->const_.type, expected_type, desc); + push_type(ctx, expr->const_.type); break; case WASM_EXPR_TYPE_CONVERT: { - WasmType rtype = s_opcode_rtype[expr->convert.opcode]; - WasmType type1 = s_opcode_type1[expr->convert.opcode]; - check_type(ctx, &expr->loc, rtype, expected_type, desc); - check_expr(ctx, expr->convert.expr, type1, " of convert op"); + WasmCheckType rtype = s_opcode_rtype[expr->convert.opcode]; + WasmCheckType type1 = s_opcode_type1[expr->convert.opcode]; + transform_stack(ctx, &expr->loc, "convert", 1, 1, type1, rtype); + break; + } + + case WASM_EXPR_TYPE_DROP: { + WasmType type = top_type(ctx); + transform_stack(ctx, &expr->loc, "drop", 1, 0, type); break; } case WASM_EXPR_TYPE_GET_LOCAL: { - WasmType type; + WasmCheckType type; if (WASM_SUCCEEDED(check_local_var(ctx, &expr->get_local.var, &type))) { - check_type(ctx, &expr->loc, type, expected_type, desc); + push_type(ctx, type); } break; } case WASM_EXPR_TYPE_GROW_MEMORY: - check_type(ctx, &expr->loc, WASM_TYPE_I32, expected_type, - " in grow_memory"); - check_expr(ctx, expr->grow_memory.expr, WASM_TYPE_I32, " of grow_memory"); + transform_stack(ctx, &expr->loc, "grow_memory", 1, 1, WASM_CHECK_TYPE_I32, + WASM_CHECK_TYPE_I32); break; case WASM_EXPR_TYPE_IF: { LabelNode node; - check_expr(ctx, expr->if_.cond, WASM_TYPE_I32, " of condition"); - push_label(ctx, &expr->loc, &node, &expr->if_.true_.label, expected_type, - "if branch"); - check_expr_list(ctx, &expr->loc, expr->if_.true_.first, expected_type, - " of if branch"); + push_label(ctx, &expr->loc, &node, &expr->if_.true_.label, + WASM_CHECK_TYPE_ANY, "if branch"); + WasmCheckType rtype = + check_block(ctx, &expr->loc, expr->if_.true_.first, "if expression"); + rtype = join_type(ctx, &expr->loc, rtype, WASM_CHECK_TYPE_VOID, + "if expression"); pop_label(ctx); - check_type(ctx, &expr->loc, WASM_TYPE_VOID, expected_type, desc); + transform_stack(ctx, &expr->loc, "if expression", 1, 1, + WASM_CHECK_TYPE_I32, rtype); break; } case WASM_EXPR_TYPE_IF_ELSE: { LabelNode node; - check_expr(ctx, expr->if_else.cond, WASM_TYPE_I32, " of condition"); push_label(ctx, &expr->loc, &node, &expr->if_else.true_.label, - expected_type, "if true branch"); - check_expr_list(ctx, &expr->loc, expr->if_else.true_.first, expected_type, - " of if branch"); + WASM_CHECK_TYPE_ANY, "if true branch"); + WasmCheckType rtype1 = check_block( + ctx, &expr->loc, expr->if_else.true_.first, "if true branch"); pop_label(ctx); push_label(ctx, &expr->loc, &node, &expr->if_else.false_.label, - expected_type, "if false branch"); - check_expr_list(ctx, &expr->loc, expr->if_else.false_.first, - expected_type, " of if branch"); + WASM_CHECK_TYPE_ANY, "if false branch"); + WasmCheckType rtype2 = check_block( + ctx, &expr->loc, expr->if_else.false_.first, "if false branch"); pop_label(ctx); + WasmCheckType rtype = + join_type(ctx, &expr->loc, rtype1, rtype2, "of if expression"); + transform_stack(ctx, &expr->loc, "if expression", 1, 1, + WASM_CHECK_TYPE_I32, rtype); break; } case WASM_EXPR_TYPE_LOAD: { - WasmType rtype = s_opcode_rtype[expr->load.opcode]; - WasmType type1 = s_opcode_type1[expr->load.opcode]; + WasmCheckType rtype = s_opcode_rtype[expr->load.opcode]; + WasmCheckType type1 = s_opcode_type1[expr->load.opcode]; check_align(ctx, &expr->loc, expr->load.align); check_offset(ctx, &expr->loc, expr->load.offset); - check_type(ctx, &expr->loc, rtype, expected_type, desc); - check_expr(ctx, expr->load.addr, type1, " of load index"); + transform_stack(ctx, &expr->loc, "load", 1, 1, type1, rtype); break; } case WASM_EXPR_TYPE_LOOP: { - LabelNode outer_node; - LabelNode inner_node; - push_label(ctx, &expr->loc, &outer_node, &expr->loop.outer, expected_type, - "loop outer label"); - push_label(ctx, &expr->loc, &inner_node, &expr->loop.inner, - WASM_TYPE_VOID, "loop inner label"); - check_expr_list(ctx, &expr->loc, expr->loop.first, expected_type, - " of loop"); - pop_label(ctx); + LabelNode node; + push_label(ctx, &expr->loc, &node, &expr->loop.label, + WASM_CHECK_TYPE_VOID, "loop label"); + WasmCheckType rtype = + check_block(ctx, &expr->loc, expr->loop.first, "loop"); pop_label(ctx); + push_type(ctx, rtype); break; } case WASM_EXPR_TYPE_CURRENT_MEMORY: - check_type(ctx, &expr->loc, WASM_TYPE_I32, expected_type, - " in current_memory"); + push_type(ctx, WASM_CHECK_TYPE_I32); break; case WASM_EXPR_TYPE_NOP: - check_type(ctx, &expr->loc, WASM_TYPE_VOID, expected_type, " in nop"); break; case WASM_EXPR_TYPE_RETURN: { - WasmType result_type = + WasmCheckType result_type = wasm_get_result_type(ctx->current_module, ctx->current_func); - check_expr_opt(ctx, &expr->loc, expr->return_.expr, result_type, - " of return"); + if (result_type != WASM_TYPE_VOID) { + transform_stack(ctx, &expr->loc, "return", 1, 1, result_type, + WASM_CHECK_TYPE_ANY); + } else { + transform_stack(ctx, &expr->loc, "return", 0, 1, WASM_CHECK_TYPE_ANY); + } break; } - case WASM_EXPR_TYPE_SELECT: - check_expr(ctx, expr->select.cond, WASM_TYPE_I32, " of condition"); - check_expr(ctx, expr->select.true_, expected_type, - " of argument 0 of select op"); - check_expr(ctx, expr->select.false_, expected_type, - " of argment 1 of select op"); + case WASM_EXPR_TYPE_SELECT: { + WasmCheckType type = peek_type(ctx, 1, 1); + transform_stack(ctx, &expr->loc, "select", 3, 1, type, type, + WASM_CHECK_TYPE_I32, type); break; + } case WASM_EXPR_TYPE_SET_LOCAL: { - WasmType type; - if (WASM_SUCCEEDED(check_local_var(ctx, &expr->set_local.var, &type))) { - check_type(ctx, &expr->loc, type, expected_type, desc); - check_expr(ctx, expr->set_local.expr, type, " of set_local"); - } + WasmCheckType type = WASM_TYPE_I32; + check_local_var(ctx, &expr->set_local.var, &type); + transform_stack(ctx, &expr->loc, "set_local", 1, 0, type); break; } case WASM_EXPR_TYPE_STORE: { - WasmType rtype = s_opcode_rtype[expr->store.opcode]; - WasmType type1 = s_opcode_type1[expr->store.opcode]; - WasmType type2 = s_opcode_type2[expr->store.opcode]; + WasmCheckType type1 = s_opcode_type1[expr->store.opcode]; + WasmCheckType type2 = s_opcode_type2[expr->store.opcode]; check_align(ctx, &expr->loc, expr->store.align); check_offset(ctx, &expr->loc, expr->store.offset); - check_type(ctx, &expr->loc, rtype, expected_type, desc); - check_expr(ctx, expr->store.addr, type1, " of store index"); - check_expr(ctx, expr->store.value, type2, " of store value"); + transform_stack(ctx, &expr->loc, "store", 2, 0, type1, type2); break; } - case WASM_EXPR_TYPE_BR_TABLE: { - check_expr(ctx, expr->br_table.key, WASM_TYPE_I32, " of key"); - size_t i; - for (i = 0; i < expr->br_table.targets.size; ++i) { - check_br(ctx, &expr->loc, &expr->br_table.targets.data[i], - expr->br_table.expr, " of br_table target"); - } - check_br(ctx, &expr->loc, &expr->br_table.default_target, - expr->br_table.expr, " of br_table default target"); + case WASM_EXPR_TYPE_TEE_LOCAL: { + WasmCheckType type = WASM_TYPE_I32; + check_local_var(ctx, &expr->tee_local.var, &type); + transform_stack(ctx, &expr->loc, "tee_local", 1, 1, type, type); break; } case WASM_EXPR_TYPE_UNARY: { - WasmType rtype = s_opcode_rtype[expr->unary.opcode]; - WasmType type1 = s_opcode_type1[expr->unary.opcode]; - check_type(ctx, &expr->loc, rtype, expected_type, desc); - check_expr(ctx, expr->unary.expr, type1, " of unary op"); + WasmCheckType rtype = s_opcode_rtype[expr->unary.opcode]; + WasmCheckType type1 = s_opcode_type1[expr->unary.opcode]; + transform_stack(ctx, &expr->loc, "unary", 1, 1, type1, rtype); break; } case WASM_EXPR_TYPE_UNREACHABLE: + push_type(ctx, WASM_CHECK_TYPE_ANY); break; } } @@ -705,18 +792,25 @@ static void check_func_signature_matches_func_type( const WasmFuncSignature* sig, const WasmFuncType* func_type) { size_t num_params = sig->param_types.size; - check_type_exact(ctx, loc, sig->result_type, - wasm_get_func_type_result_type(func_type), - " between function result and function type result"); + /* special case this check to give a better error message */ + WasmCheckType func_type_result_type = + wasm_get_func_type_result_type(func_type); + if (sig->result_type != func_type_result_type) { + print_error( + ctx, CHECK_STYLE_FULL, loc, + "type mismatch between function result type (%s) and function type " + "result type (%s)\n", + s_type_names[sig->result_type], s_type_names[func_type_result_type]); + } if (num_params == wasm_get_func_type_num_params(func_type)) { size_t i; for (i = 0; i < num_params; ++i) { - check_type_arg_exact(ctx, loc, sig->param_types.data[i], - wasm_get_func_type_param_type(func_type, i), - "function", i); + check_type_arg(ctx, loc, sig->param_types.data[i], + wasm_get_func_type_param_type(func_type, i), "function", + i); } } else { - print_error(ctx, CHECK_TYPE_FULL, loc, + print_error(ctx, CHECK_STYLE_FULL, loc, "expected %" PRIzd " parameters, got %" PRIzd, wasm_get_func_type_num_params(func_type), num_params); } @@ -743,8 +837,10 @@ static void check_func(Context* ctx, WasmLabel label = wasm_empty_string_slice(); push_label(ctx, &func->loc, &node, &label, func->decl.sig.result_type, "func"); - check_expr_list(ctx, &func->loc, func->first_expr, func->decl.sig.result_type, - " of function result"); + WasmCheckType rtype = + check_block(ctx, &func->loc, func->first_expr, "function result"); + join_type(ctx, &func->loc, rtype, func->decl.sig.result_type, + "function result"); pop_label(ctx); ctx->current_func = NULL; } @@ -768,19 +864,19 @@ static void check_table(Context* ctx, const WasmVarVector* table) { static void check_memory(Context* ctx, const WasmMemory* memory) { if (memory->initial_pages > WASM_MAX_PAGES) { - print_error(ctx, CHECK_TYPE_FULL, &memory->loc, + print_error(ctx, CHECK_STYLE_FULL, &memory->loc, "initial pages (%" PRIu64 ") must be <= (%u)", memory->initial_pages, WASM_MAX_PAGES); } if (memory->max_pages > WASM_MAX_PAGES) { - print_error(ctx, CHECK_TYPE_FULL, &memory->loc, + print_error(ctx, CHECK_STYLE_FULL, &memory->loc, "max pages (%" PRIu64 ") must be <= (%u)", memory->max_pages, WASM_MAX_PAGES); } if (memory->max_pages < memory->initial_pages) { - print_error(ctx, CHECK_TYPE_FULL, &memory->loc, + print_error(ctx, CHECK_STYLE_FULL, &memory->loc, "max pages (%" PRIu64 ") must be >= initial pages (%" PRIu64 ")", memory->max_pages, memory->initial_pages); @@ -791,17 +887,17 @@ static void check_memory(Context* ctx, const WasmMemory* memory) { for (i = 0; i < memory->segments.size; ++i) { const WasmSegment* segment = &memory->segments.data[i]; if (segment->addr < last_end) { - print_error(ctx, CHECK_TYPE_FULL, &segment->loc, + print_error(ctx, CHECK_STYLE_FULL, &segment->loc, "address (%u) less than end of previous segment (%u)", segment->addr, last_end); } if (segment->addr > memory->initial_pages * WASM_PAGE_SIZE) { - print_error(ctx, CHECK_TYPE_FULL, &segment->loc, + print_error(ctx, CHECK_STYLE_FULL, &segment->loc, "address (%u) greater than initial memory size (%" PRIu64 ")", segment->addr, memory->initial_pages * WASM_PAGE_SIZE); } else if (segment->addr + segment->size > memory->initial_pages * WASM_PAGE_SIZE) { - print_error(ctx, CHECK_TYPE_FULL, &segment->loc, + print_error(ctx, CHECK_STYLE_FULL, &segment->loc, "segment ends past the end of initial memory size (%" PRIu64 ")", memory->initial_pages * WASM_PAGE_SIZE); @@ -841,7 +937,7 @@ static void check_module(Context* ctx, const WasmModule* module) { case WASM_MODULE_FIELD_TYPE_TABLE: if (seen_table) { - print_error(ctx, CHECK_TYPE_FULL, &field->loc, + print_error(ctx, CHECK_STYLE_FULL, &field->loc, "only one table allowed"); } check_table(ctx, &field->table); @@ -850,7 +946,7 @@ static void check_module(Context* ctx, const WasmModule* module) { case WASM_MODULE_FIELD_TYPE_MEMORY: if (seen_memory) { - print_error(ctx, CHECK_TYPE_FULL, &field->loc, + print_error(ctx, CHECK_STYLE_FULL, &field->loc, "only one memory block allowed"); } check_memory(ctx, &field->memory); @@ -862,7 +958,7 @@ static void check_module(Context* ctx, const WasmModule* module) { case WASM_MODULE_FIELD_TYPE_START: { if (seen_start) { - print_error(ctx, CHECK_TYPE_FULL, &field->loc, + print_error(ctx, CHECK_STYLE_FULL, &field->loc, "only one start function allowed"); } @@ -870,13 +966,13 @@ static void check_module(Context* ctx, const WasmModule* module) { check_func_var(ctx, &field->start, &start_func); if (start_func) { if (wasm_get_num_params(ctx->current_module, start_func) != 0) { - print_error(ctx, CHECK_TYPE_FULL, &field->loc, + print_error(ctx, CHECK_STYLE_FULL, &field->loc, "start function must be nullary"); } if (wasm_get_result_type(ctx->current_module, start_func) != WASM_TYPE_VOID) { - print_error(ctx, CHECK_TYPE_FULL, &field->loc, + print_error(ctx, CHECK_STYLE_FULL, &field->loc, "start function must not return anything"); } } @@ -887,7 +983,8 @@ static void check_module(Context* ctx, const WasmModule* module) { } if (seen_export_memory && !seen_memory) { - print_error(ctx, CHECK_TYPE_FULL, export_memory_loc, "no memory to export"); + print_error(ctx, CHECK_STYLE_FULL, export_memory_loc, + "no memory to export"); } check_duplicate_bindings(ctx, &module->func_bindings, "function"); @@ -906,10 +1003,10 @@ static void on_read_binary_error(uint32_t offset, void* user_data) { BinaryErrorCallbackData* data = user_data; if (offset == WASM_UNKNOWN_OFFSET) { - print_error(data->ctx, CHECK_TYPE_FULL, data->loc, + print_error(data->ctx, CHECK_STYLE_FULL, data->loc, "error in binary module: %s", error); } else { - print_error(data->ctx, CHECK_TYPE_FULL, data->loc, + print_error(data->ctx, CHECK_STYLE_FULL, data->loc, "error in binary module: @0x%08x: %s", offset, error); } } @@ -938,49 +1035,50 @@ static void check_raw_module(Context* ctx, WasmRawModule* raw) { } } -static void check_invoke(Context* ctx, - const WasmCommandInvoke* invoke, - TypeSet return_type) { +/* returns the result type of the invoked function, checked by the caller; + * returning WASM_CHECK_TYPE_ANY means that another error occured first, so the + * result type should be ignored. */ +static WasmCheckType check_invoke(Context* ctx, + const WasmCommandInvoke* invoke) { const WasmModule* module = ctx->current_module; if (!module) { - print_error(ctx, CHECK_TYPE_FULL, &invoke->loc, + print_error(ctx, CHECK_STYLE_FULL, &invoke->loc, "invoke must occur after a module definition"); - return; + return WASM_CHECK_TYPE_ANY; } - WasmExport* export = - wasm_get_export_by_name(module, &invoke->name); + WasmExport* export = wasm_get_export_by_name(module, &invoke->name); if (!export) { - print_error(ctx, CHECK_TYPE_NAME, &invoke->loc, + print_error(ctx, CHECK_STYLE_NAME, &invoke->loc, "unknown function export \"" PRIstringslice "\"", WASM_PRINTF_STRING_SLICE_ARG(invoke->name)); - return; + return WASM_CHECK_TYPE_ANY; } WasmFunc* func = wasm_get_func_by_var(module, &export->var); if (!func) { /* this error will have already been reported, just skip it */ - return; + return WASM_CHECK_TYPE_ANY; } size_t actual_args = invoke->args.size; size_t expected_args = wasm_get_num_params(module, func); if (expected_args != actual_args) { - print_error(ctx, CHECK_TYPE_FULL, &invoke->loc, + print_error(ctx, CHECK_STYLE_FULL, &invoke->loc, "too %s parameters to function. got %" PRIzd ", expected %" PRIzd, actual_args > expected_args ? "many" : "few", actual_args, expected_args); - return; + return WASM_CHECK_TYPE_ANY; } - check_type_set(ctx, &invoke->loc, wasm_get_result_type(module, func), - return_type, ""); size_t i; for (i = 0; i < actual_args; ++i) { WasmConst* const_ = &invoke->args.data[i]; - check_type_arg_exact(ctx, &const_->loc, const_->type, - wasm_get_param_type(module, func, i), "invoke", i); + check_type_arg(ctx, &const_->loc, const_->type, + wasm_get_param_type(module, func, i), "invoke", i); } + + return wasm_get_result_type(module, func); } static void check_command(Context* ctx, const WasmCommand* command) { @@ -990,25 +1088,36 @@ static void check_command(Context* ctx, const WasmCommand* command) { break; case WASM_COMMAND_TYPE_INVOKE: - check_invoke(ctx, &command->invoke, WASM_TYPE_SET_VOID); + /* ignore result type */ + check_invoke(ctx, &command->invoke); break; case WASM_COMMAND_TYPE_ASSERT_INVALID: /* ignore */ break; - case WASM_COMMAND_TYPE_ASSERT_RETURN: - check_invoke(ctx, &command->assert_return.invoke, - TYPE_TO_TYPE_SET(command->assert_return.expected.type)); + case WASM_COMMAND_TYPE_ASSERT_RETURN: { + const WasmCommandInvoke* invoke = &command->assert_return.invoke; + WasmCheckType result_type = check_invoke(ctx, invoke); + if (result_type != WASM_CHECK_TYPE_ANY) { + check_type(ctx, &invoke->loc, result_type, + command->assert_return.expected.type, "invoke"); + } break; + } - case WASM_COMMAND_TYPE_ASSERT_RETURN_NAN: - check_invoke(ctx, &command->assert_return_nan.invoke, - WASM_TYPE_SET_F32 | WASM_TYPE_SET_F64); + case WASM_COMMAND_TYPE_ASSERT_RETURN_NAN: { + const WasmCommandInvoke* invoke = &command->assert_return_nan.invoke; + WasmCheckType result_type = check_invoke(ctx, invoke); + if (result_type != WASM_CHECK_TYPE_ANY) { + check_assert_return_nan_type(ctx, &invoke->loc, result_type, "invoke"); + } break; + } case WASM_COMMAND_TYPE_ASSERT_TRAP: - check_invoke(ctx, &command->assert_trap.invoke, WASM_TYPE_SET_VOID); + /* ignore result type */ + check_invoke(ctx, &command->assert_trap.invoke); break; default: @@ -1016,12 +1125,14 @@ static void check_command(Context* ctx, const WasmCommand* command) { } } -WasmResult wasm_check_names(WasmAstLexer* lexer, +WasmResult wasm_check_names(WasmAllocator* allocator, + WasmAstLexer* lexer, const struct WasmScript* script, WasmSourceErrorHandler* error_handler) { Context ctx; WASM_ZERO_MEMORY(ctx); - ctx.check_type = CHECK_TYPE_NAME; + ctx.check_style = CHECK_STYLE_NAME; + ctx.allocator = allocator; ctx.lexer = lexer; ctx.error_handler = error_handler; ctx.result = WASM_OK; @@ -1031,12 +1142,14 @@ WasmResult wasm_check_names(WasmAstLexer* lexer, return ctx.result; } -WasmResult wasm_check_ast(WasmAstLexer* lexer, +WasmResult wasm_check_ast(WasmAllocator* allocator, + WasmAstLexer* lexer, const struct WasmScript* script, WasmSourceErrorHandler* error_handler) { Context ctx; WASM_ZERO_MEMORY(ctx); - ctx.check_type = CHECK_TYPE_FULL; + ctx.check_style = CHECK_STYLE_FULL; + ctx.allocator = allocator; ctx.lexer = lexer; ctx.error_handler = error_handler; ctx.result = WASM_OK; @@ -1054,7 +1167,7 @@ WasmResult wasm_check_assert_invalid( WasmSourceErrorHandler* error_handler) { Context ctx; WASM_ZERO_MEMORY(ctx); - ctx.check_type = CHECK_TYPE_FULL; + ctx.check_style = CHECK_STYLE_FULL; ctx.allocator = allocator; ctx.lexer = lexer; ctx.error_handler = error_handler; @@ -1068,7 +1181,7 @@ WasmResult wasm_check_assert_invalid( Context ai_ctx; WASM_ZERO_MEMORY(ai_ctx); - ai_ctx.check_type = CHECK_TYPE_FULL; + ai_ctx.check_style = CHECK_STYLE_FULL; ai_ctx.allocator = allocator; ai_ctx.lexer = lexer; ai_ctx.error_handler = assert_invalid_error_handler; @@ -1076,7 +1189,7 @@ WasmResult wasm_check_assert_invalid( check_raw_module(&ai_ctx, &command->assert_invalid.module); if (WASM_SUCCEEDED(ai_ctx.result)) { - print_error(&ctx, CHECK_TYPE_FULL, &command->assert_invalid.module.loc, + print_error(&ctx, CHECK_STYLE_FULL, &command->assert_invalid.module.loc, "expected module to be invalid"); } } diff --git a/src/wasm-ast-checker.h b/src/wasm-ast-checker.h index 9e6ade1a..2e9b6375 100644 --- a/src/wasm-ast-checker.h +++ b/src/wasm-ast-checker.h @@ -27,13 +27,15 @@ struct WasmScript; WASM_EXTERN_C_BEGIN /* Only check that names are valid; this is useful if you want to generate * invalid binaries (so they can be validated by the consumer). */ -WasmResult wasm_check_names(WasmAstLexer*, +WasmResult wasm_check_names(struct WasmAllocator*, + WasmAstLexer*, const struct WasmScript*, WasmSourceErrorHandler*); /* perform all checks on the AST; the module is valid if and only if this * function succeeds. */ -WasmResult wasm_check_ast(WasmAstLexer*, +WasmResult wasm_check_ast(struct WasmAllocator*, + WasmAstLexer*, const struct WasmScript*, WasmSourceErrorHandler*); diff --git a/src/wasm-ast-lexer.c b/src/wasm-ast-lexer.c index a5824bfd..9c570061 100644 --- a/src/wasm-ast-lexer.c +++ b/src/wasm-ast-lexer.c @@ -198,7 +198,7 @@ int wasm_ast_lexer_lex(WASM_AST_PARSER_STYPE* lval, hexdigit = [0-9a-fA-F]; letter = [a-zA-Z]; symbol = [+\-*\/\\\^~=<>!?@#$%&|:`.]; - tick = "`"; + tick = "'"; escape = [nt\\'"]; character = [^"\\\x00-\x1f\x7f] | "\\" escape | "\\" hexdigit hexdigit; sign = [+-]; @@ -248,13 +248,15 @@ int wasm_ast_lexer_lex(WASM_AST_PARSER_STYPE* lval, <i> "br" { RETURN(BR); } <i> "br_if" { RETURN(BR_IF); } <i> "br_table" { RETURN(BR_TABLE); } - <i> "case" { RETURN(CASE); } <i> "call" { RETURN(CALL); } <i> "call_import" { RETURN(CALL_IMPORT); } <i> "call_indirect" { RETURN(CALL_INDIRECT); } + <i> "drop" { RETURN(DROP); } + <i> "end" { RETURN(END); } <i> "return" { RETURN(RETURN); } <i> "get_local" { RETURN(GET_LOCAL); } <i> "set_local" { RETURN(SET_LOCAL); } + <i> "tee_local" { RETURN(TEE_LOCAL); } <i> "i32.load" { OPCODE(I32_LOAD); RETURN(LOAD); } <i> "i64.load" { OPCODE(I64_LOAD); RETURN(LOAD); } <i> "f32.load" { OPCODE(F32_LOAD); RETURN(LOAD); } diff --git a/src/wasm-ast-parser.y b/src/wasm-ast-parser.y index 78321a49..23415a30 100644 --- a/src/wasm-ast-parser.y +++ b/src/wasm-ast-parser.y @@ -62,6 +62,15 @@ #define USE_NATURAL_ALIGNMENT (~0) +static WasmExprList join_exprs1(WasmLocation* loc, WasmExpr* expr1); +static WasmExprList join_exprs2(WasmLocation* loc, WasmExprList* expr1, + WasmExpr* expr2); +static WasmExprList join_exprs3(WasmLocation* loc, WasmExprList* expr1, + WasmExprList* expr2, WasmExpr* expr3); +static WasmExprList join_exprs4(WasmLocation* loc, WasmExprList* expr1, + WasmExprList* expr2, WasmExprList* expr3, + WasmExpr* expr4); + static WasmFuncField* new_func_field(WasmAllocator* allocator) { return wasm_alloc_zero(allocator, sizeof(WasmFuncField), WASM_DEFAULT_ALIGN); } @@ -122,13 +131,13 @@ static void on_read_binary_error(uint32_t offset, const char* error, %token LPAR "(" %token RPAR ")" %token NAT INT FLOAT TEXT VAR VALUE_TYPE -%token NOP BLOCK IF THEN ELSE LOOP BR BR_IF BR_TABLE CASE +%token NOP DROP BLOCK END IF THEN ELSE LOOP BR BR_IF BR_TABLE %token CALL CALL_IMPORT CALL_INDIRECT RETURN -%token GET_LOCAL SET_LOCAL LOAD STORE OFFSET ALIGN +%token GET_LOCAL SET_LOCAL TEE_LOCAL LOAD STORE OFFSET ALIGN %token CONST UNARY BINARY COMPARE CONVERT SELECT +%token UNREACHABLE CURRENT_MEMORY GROW_MEMORY %token FUNC START TYPE PARAM RESULT LOCAL %token MODULE MEMORY SEGMENT IMPORT EXPORT TABLE -%token UNREACHABLE CURRENT_MEMORY GROW_MEMORY %token ASSERT_INVALID ASSERT_RETURN ASSERT_RETURN_NAN ASSERT_TRAP INVOKE %token EOF 0 "EOF" @@ -145,8 +154,8 @@ static void on_read_binary_error(uint32_t offset, const char* error, %type<export_> export %type<export_memory> export_memory %type<exported_func> func -%type<expr> expr expr1 expr_opt -%type<expr_list> expr_list non_empty_expr_list +%type<expr> op +%type<expr_list> expr expr1 expr_list %type<func_fields> func_fields func_body %type<func> func_info %type<func_sig> func_type @@ -159,22 +168,22 @@ static void on_read_binary_error(uint32_t offset, const char* error, %type<script> script %type<segment> segment segment_contents %type<segments> segment_list -%type<text> bind_var labeling quoted_text export_opt +%type<text> bind_var labeling labeling1 quoted_text export_opt %type<text_list> text_list %type<types> value_type_list -%type<u32> align segment_address +%type<u32> nat align segment_address %type<u64> offset initial_pages max_pages %type<vars> table var_list %type<var> start type_use var %destructor { wasm_destroy_text_list(parser->allocator, &$$); } text_list -%destructor { wasm_destroy_string_slice(parser->allocator, &$$); } bind_var labeling quoted_text +%destructor { wasm_destroy_string_slice(parser->allocator, &$$); } bind_var labeling labeling1 quoted_text %destructor { wasm_destroy_string_slice(parser->allocator, &$$.text); } literal %destructor { wasm_destroy_type_vector(parser->allocator, &$$); } value_type_list %destructor { wasm_destroy_var(parser->allocator, &$$); } var %destructor { wasm_destroy_var_vector_and_elements(parser->allocator, &$$); } table var_list -%destructor { wasm_destroy_expr(parser->allocator, $$); } expr expr1 expr_opt -%destructor { wasm_destroy_expr_list(parser->allocator, $$.first); } expr_list non_empty_expr_list +%destructor { wasm_destroy_expr(parser->allocator, $$); } op +%destructor { wasm_destroy_expr_list(parser->allocator, $$.first); } expr expr1 expr_list %destructor { wasm_destroy_func_fields(parser->allocator, $$); } func_fields func_body %destructor { wasm_destroy_func(parser->allocator, $$); wasm_free(parser->allocator, $$); } func_info %destructor { wasm_destroy_segment(parser->allocator, &$$); } segment segment_contents @@ -241,12 +250,23 @@ func_type : /* Expressions */ +nat : + NAT { + if (WASM_FAILED(wasm_parse_int32($1.text.start, + $1.text.start + $1.text.length, &$$, + WASM_PARSE_UNSIGNED_ONLY))) { + wasm_ast_parser_error(&@1, lexer, parser, "invalid int " PRIstringslice, + WASM_PRINTF_STRING_SLICE_ARG($1.text)); + } + } +; + literal : - INT { + NAT { $$.type = $1.type; DUPTEXT($$.text, $1.text); } - | NAT { + | INT { $$.type = $1.type; DUPTEXT($$.text, $1.text); } @@ -311,8 +331,9 @@ segment_contents : labeling : /* empty */ %prec LOW { WASM_ZERO_MEMORY($$); } - | bind_var { $$ = $1; } + | labeling1 ; +labeling1 : bind_var ; offset : /* empty */ { $$ = 0; } @@ -338,130 +359,107 @@ align : ; expr : - LPAR expr1 RPAR { $$ = $2; $$->loc = @1; } + op { $$ = join_exprs1(&@1, $1); } + | LPAR expr1 RPAR { $$ = $2; } ; -expr1 : - NOP { - $$ = wasm_new_empty_expr(parser->allocator, WASM_EXPR_TYPE_NOP); +op : + UNREACHABLE { + $$ = wasm_new_unreachable_expr(parser->allocator); } - | BLOCK labeling expr_list { + | NOP { + $$ = wasm_new_nop_expr(parser->allocator); + } + | DROP { + $$ = wasm_new_drop_expr(parser->allocator); + } + | BLOCK labeling expr_list END { $$ = wasm_new_block_expr(parser->allocator); $$->block.label = $2; $$->block.first = $3.first; } - | IF expr expr { - $$ = wasm_new_if_expr(parser->allocator); - $$->if_.cond = $2; - $$->if_.true_.first = $3; - } - | IF expr LPAR THEN labeling expr_list RPAR { - $$ = wasm_new_if_expr(parser->allocator); - $$->if_.cond = $2; - $$->if_.true_.label = $5; - $$->if_.true_.first = $6.first; - } - | IF expr expr expr { - $$ = wasm_new_if_else_expr(parser->allocator); - $$->if_else.cond = $2; - $$->if_else.true_.first = $3; - $$->if_else.false_.first = $4; - } - | IF expr LPAR THEN labeling expr_list RPAR LPAR ELSE labeling expr_list RPAR { - $$ = wasm_new_if_else_expr(parser->allocator); - $$->if_else.cond = $2; - $$->if_else.true_.label = $5; - $$->if_else.true_.first = $6.first; - $$->if_else.false_.label = $10; - $$->if_else.false_.first = $11.first; - } - | BR_IF var expr { - $$ = wasm_new_br_if_expr(parser->allocator); - $$->br_if.var = $2; - $$->br_if.cond = $3; - } - | BR_IF var expr expr { - $$ = wasm_new_br_if_expr(parser->allocator); - $$->br_if.var = $2; - $$->br_if.expr = $3; - $$->br_if.cond = $4; - } - | LOOP labeling expr_list { + | LOOP labeling expr_list END { $$ = wasm_new_loop_expr(parser->allocator); - WASM_ZERO_MEMORY($$->loop.outer); - $$->loop.inner = $2; + $$->loop.label = $2; $$->loop.first = $3.first; } - | LOOP bind_var bind_var expr_list { - $$ = wasm_new_loop_expr(parser->allocator); - $$->loop.outer = $2; - $$->loop.inner = $3; - $$->loop.first = $4.first; + | LOOP labeling1 labeling1 expr_list END { + $$ = wasm_new_block_expr(parser->allocator); + $$->block.label = $2; + WasmExpr* loop = wasm_new_loop_expr(parser->allocator); + loop->loc = @1; + loop->loop.label = $3; + loop->loop.first = $4.first; + $$->block.first = loop; } - | BR var expr_opt { + | BR nat var { $$ = wasm_new_br_expr(parser->allocator); - $$->br.var = $2; - $$->br.expr = $3; + $$->br.arity = $2; + $$->br.var = $3; } - | RETURN expr_opt { - $$ = wasm_new_return_expr(parser->allocator); - $$->return_.expr = $2; + | BR_IF nat var { + $$ = wasm_new_br_if_expr(parser->allocator); + $$->br_if.arity = $2; + $$->br_if.var = $3; } - | BR_TABLE var_list var expr { + | BR_TABLE nat var_list var { $$ = wasm_new_br_table_expr(parser->allocator); - $$->br_table.key = $4; - $$->br_table.expr = NULL; - $$->br_table.targets = $2; - $$->br_table.default_target = $3; + $$->br_table.arity = $2; + $$->br_table.targets = $3; + $$->br_table.default_target = $4; } - | BR_TABLE var_list var expr expr { - $$ = wasm_new_br_table_expr(parser->allocator); - $$->br_table.key = $5; - $$->br_table.expr = $4; - $$->br_table.targets = $2; - $$->br_table.default_target = $3; + | RETURN { + $$ = wasm_new_return_expr(parser->allocator); } - | CALL var expr_list { + | IF labeling expr_list END { + $$ = wasm_new_if_expr(parser->allocator); + $$->if_.true_.label = $2; + $$->if_.true_.first = $3.first; + } + | IF labeling expr_list ELSE labeling expr_list END { + $$ = wasm_new_if_else_expr(parser->allocator); + $$->if_else.true_.label = $2; + $$->if_else.true_.first = $3.first; + $$->if_else.false_.label = $5; + $$->if_else.false_.first = $6.first; + } + | SELECT { + $$ = wasm_new_select_expr(parser->allocator); + } + | CALL var { $$ = wasm_new_call_expr(parser->allocator); $$->call.var = $2; - $$->call.first_arg = $3.first; - $$->call.num_args = $3.size; } - | CALL_IMPORT var expr_list { - $$ = wasm_new_call_import_expr(parser->allocator); - $$->call.var = $2; - $$->call.first_arg = $3.first; - $$->call.num_args = $3.size; + | CALL_IMPORT var { + $$ = wasm_new_call_expr(parser->allocator); + $$->call_import.var = $2; } - | CALL_INDIRECT var expr expr_list { + | CALL_INDIRECT var { $$ = wasm_new_call_indirect_expr(parser->allocator); $$->call_indirect.var = $2; - $$->call_indirect.expr = $3; - $$->call_indirect.first_arg = $4.first; - $$->call_indirect.num_args = $4.size; } | GET_LOCAL var { $$ = wasm_new_get_local_expr(parser->allocator); $$->get_local.var = $2; } - | SET_LOCAL var expr { + | SET_LOCAL var { $$ = wasm_new_set_local_expr(parser->allocator); $$->set_local.var = $2; - $$->set_local.expr = $3; } - | LOAD offset align expr { + | TEE_LOCAL var { + $$ = wasm_new_tee_local_expr(parser->allocator); + $$->tee_local.var = $2; + } + | LOAD offset align { $$ = wasm_new_load_expr(parser->allocator); $$->load.opcode = $1; $$->load.offset = $2; $$->load.align = $3; - $$->load.addr = $4; } - | STORE offset align expr expr { - $$ = wasm_new_store_expr(parser->allocator); + | STORE offset align { + $$ = wasm_new_load_expr(parser->allocator); $$->store.opcode = $1; $$->store.offset = $2; $$->store.align = $3; - $$->store.addr = $4; - $$->store.value = $5; } | CONST literal { $$ = wasm_new_const_expr(parser->allocator); @@ -475,65 +473,236 @@ expr1 : } wasm_free(parser->allocator, (char*)$2.text.start); } - | UNARY expr { + | UNARY { $$ = wasm_new_unary_expr(parser->allocator); $$->unary.opcode = $1; - $$->unary.expr = $2; } - | BINARY expr expr { + | BINARY { $$ = wasm_new_binary_expr(parser->allocator); $$->binary.opcode = $1; - $$->binary.left = $2; - $$->binary.right = $3; - } - | SELECT expr expr expr { - $$ = wasm_new_select_expr(parser->allocator); - $$->select.true_ = $2; - $$->select.false_ = $3; - $$->select.cond = $4; } - | COMPARE expr expr { + | COMPARE { $$ = wasm_new_compare_expr(parser->allocator); $$->compare.opcode = $1; - $$->compare.left = $2; - $$->compare.right = $3; } - | CONVERT expr { + | CONVERT { $$ = wasm_new_convert_expr(parser->allocator); $$->convert.opcode = $1; - $$->convert.expr = $2; - } - | UNREACHABLE { - $$ = wasm_new_empty_expr(parser->allocator, WASM_EXPR_TYPE_UNREACHABLE); } | CURRENT_MEMORY { - $$ = wasm_new_empty_expr(parser->allocator, - WASM_EXPR_TYPE_CURRENT_MEMORY); + $$ = wasm_new_current_memory_expr(parser->allocator); } - | GROW_MEMORY expr { + | GROW_MEMORY { $$ = wasm_new_grow_memory_expr(parser->allocator); - $$->grow_memory.expr = $2; } ; -expr_opt : - /* empty */ { $$ = NULL; } - | expr -; -non_empty_expr_list : - expr { - $$.first = $$.last = $1; - $$.size = 1; +expr1 : + UNREACHABLE { + $$ = join_exprs1(&@1, wasm_new_unreachable_expr(parser->allocator)); } - | non_empty_expr_list expr { - $$ = $1; - $$.last->next = $2; - $$.last = $2; - $$.size++; + | NOP { + $$ = join_exprs1(&@1, wasm_new_nop_expr(parser->allocator)); + } + | DROP expr { + $$ = join_exprs2(&@1, &$2, wasm_new_drop_expr(parser->allocator)); + } + | BLOCK labeling expr_list { + WasmExpr* expr = wasm_new_block_expr(parser->allocator); + expr->block.label = $2; + expr->block.first = $3.first; + $$ = join_exprs1(&@1, expr); + } + | LOOP labeling expr_list { + WasmExpr* expr = wasm_new_loop_expr(parser->allocator); + expr->loop.label = $2; + expr->loop.first = $3.first; + $$ = join_exprs1(&@1, expr); + } + | LOOP labeling1 labeling1 expr_list { + WasmExpr* block = wasm_new_block_expr(parser->allocator); + block->block.label = $2; + WasmExpr* loop = wasm_new_loop_expr(parser->allocator); + loop->loc = @1; + loop->loop.label = $3; + loop->loop.first = $4.first; + block->block.first = loop; + $$ = join_exprs1(&@1, block); + } + | BR var { + WasmExpr* expr = wasm_new_br_expr(parser->allocator); + expr->br.arity = 0; + expr->br.var = $2; + $$ = join_exprs1(&@1, expr); + } + | BR var expr { + WasmExpr* expr = wasm_new_br_expr(parser->allocator); + expr->br.arity = 1; + expr->br.var = $2; + $$ = join_exprs2(&@1, &$3, expr); + } + | BR_IF var expr { + WasmExpr* expr = wasm_new_br_if_expr(parser->allocator); + expr->br_if.arity = 0; + expr->br_if.var = $2; + $$ = join_exprs2(&@1, &$3, expr); + } + | BR_IF var expr expr { + WasmExpr* expr = wasm_new_br_if_expr(parser->allocator); + expr->br_if.arity = 1; + expr->br_if.var = $2; + $$ = join_exprs3(&@1, &$3, &$4, expr); + } + | BR_TABLE var_list var expr { + WasmExpr* expr = wasm_new_br_table_expr(parser->allocator); + expr->br_table.arity = 0; + expr->br_table.targets = $2; + expr->br_table.default_target = $3; + $$ = join_exprs2(&@1, &$4, expr); + } + | BR_TABLE var_list var expr expr { + WasmExpr* expr = wasm_new_br_table_expr(parser->allocator); + expr->br_table.arity = 1; + expr->br_table.targets = $2; + expr->br_table.default_target = $3; + $$ = join_exprs3(&@1, &$4, &$5, expr); + } + | RETURN { + WasmExpr* expr = wasm_new_return_expr(parser->allocator); + $$ = join_exprs1(&@1, expr); + } + | RETURN expr { + WasmExpr* expr = wasm_new_return_expr(parser->allocator); + $$ = join_exprs2(&@1, &$2, expr); + } + | IF expr expr { + WasmExpr* expr = wasm_new_if_expr(parser->allocator); + expr->if_.true_.first = $3.first; + $$ = join_exprs2(&@1, &$2, expr); + } + | IF expr expr expr { + WasmExpr* expr = wasm_new_if_else_expr(parser->allocator); + expr->if_else.true_.first = $3.first; + expr->if_else.false_.first = $4.first; + $$ = join_exprs2(&@1, &$2, expr); + } + | IF expr LPAR THEN labeling expr_list RPAR { + WasmExpr* expr = wasm_new_if_expr(parser->allocator); + expr->if_.true_.label = $5; + expr->if_.true_.first = $6.first; + $$ = join_exprs2(&@1, &$2, expr); + } + | IF expr LPAR THEN labeling expr_list RPAR LPAR ELSE labeling expr_list RPAR { + WasmExpr* expr = wasm_new_if_else_expr(parser->allocator); + expr->if_else.true_.label = $5; + expr->if_else.true_.first = $6.first; + expr->if_else.false_.label = $10; + expr->if_else.false_.first = $11.first; + $$ = join_exprs2(&@1, &$2, expr); + } + | IF expr_list ELSE expr_list { + WasmExpr* expr = wasm_new_if_else_expr(parser->allocator); + expr->if_else.true_.first = $2.first; + expr->if_else.false_.first = $4.first; + $$ = join_exprs1(&@1, expr); + } + | SELECT expr expr expr { + $$ = join_exprs4(&@1, &$2, &$3, &$4, + wasm_new_select_expr(parser->allocator)); + } + | CALL var expr_list { + WasmExpr* expr = wasm_new_call_expr(parser->allocator); + expr->call.var = $2; + $$ = join_exprs2(&@1, &$3, expr); + } + | CALL_IMPORT var expr_list { + WasmExpr* expr = wasm_new_call_import_expr(parser->allocator); + expr->call_import.var = $2; + $$ = join_exprs2(&@1, &$3, expr); + } + | CALL_INDIRECT var expr expr_list { + WasmExpr* expr = wasm_new_call_indirect_expr(parser->allocator); + expr->call_indirect.var = $2; + $$ = join_exprs3(&@1, &$3, &$4, expr); + } + | GET_LOCAL var { + WasmExpr* expr = wasm_new_get_local_expr(parser->allocator); + expr->get_local.var = $2; + $$ = join_exprs1(&@1, expr); + } + | SET_LOCAL var expr { + WasmExpr* expr = wasm_new_set_local_expr(parser->allocator); + expr->set_local.var = $2; + $$ = join_exprs2(&@1, &$3, expr); + } + | TEE_LOCAL var expr { + WasmExpr* expr = wasm_new_tee_local_expr(parser->allocator); + expr->tee_local.var = $2; + $$ = join_exprs2(&@1, &$3, expr); + } + | LOAD offset align expr { + WasmExpr* expr = wasm_new_load_expr(parser->allocator); + expr->load.opcode = $1; + expr->load.offset = $2; + expr->load.align = $3; + $$ = join_exprs2(&@1, &$4, expr); + } + | STORE offset align expr expr { + WasmExpr* expr = wasm_new_store_expr(parser->allocator); + expr->store.opcode = $1; + expr->store.offset = $2; + expr->store.align = $3; + $$ = join_exprs3(&@1, &$4, &$5, expr); + } + | CONST literal { + WasmExpr* expr = wasm_new_const_expr(parser->allocator); + expr->const_.loc = @1; + if (WASM_FAILED(parse_const($1, $2.type, $2.text.start, + $2.text.start + $2.text.length, + &expr->const_))) { + wasm_ast_parser_error(&@2, lexer, parser, + "invalid literal \"" PRIstringslice "\"", + WASM_PRINTF_STRING_SLICE_ARG($2.text)); + } + wasm_free(parser->allocator, (char*)$2.text.start); + $$ = join_exprs1(&@1, expr); + } + | UNARY expr { + WasmExpr* expr = wasm_new_unary_expr(parser->allocator); + expr->unary.opcode = $1; + $$ = join_exprs2(&@1, &$2, expr); + } + | BINARY expr expr { + WasmExpr* expr = wasm_new_binary_expr(parser->allocator); + expr->binary.opcode = $1; + $$ = join_exprs3(&@1, &$2, &$3, expr); + } + | COMPARE expr expr { + WasmExpr* expr = wasm_new_compare_expr(parser->allocator); + expr->compare.opcode = $1; + $$ = join_exprs3(&@1, &$2, &$3, expr); + } + | CONVERT expr { + WasmExpr* expr = wasm_new_convert_expr(parser->allocator); + expr->convert.opcode = $1; + $$ = join_exprs2(&@1, &$2, expr); + } + | CURRENT_MEMORY { + WasmExpr* expr = wasm_new_current_memory_expr(parser->allocator); + $$ = join_exprs1(&@1, expr); + } + | GROW_MEMORY expr { + WasmExpr* expr = wasm_new_grow_memory_expr(parser->allocator); + $$ = join_exprs2(&@1, &$2, expr); } ; expr_list : /* empty */ { WASM_ZERO_MEMORY($$); } - | non_empty_expr_list + | expr expr_list { + $$.first = $1.first; + $1.last->next = $2.first; + $$.last = $2.last ? $2.last : $1.first; + $$.size = $1.size + $2.size; + } ; /* Functions */ @@ -1107,6 +1276,68 @@ script_start : %% +static void append_expr_list(WasmExprList* expr_list, WasmExprList* expr) { + if (!expr->first) + return; + if (expr_list->last) + expr_list->last->next = expr->first; + else + expr_list->first = expr->first; + expr_list->last = expr->last; + expr_list->size += expr->size; +} + +static void append_expr(WasmExprList* expr_list, WasmExpr* expr) { + if (expr_list->last) + expr_list->last->next = expr; + else + expr_list->first = expr; + expr_list->last = expr; + expr_list->size++; +} + +static WasmExprList join_exprs1(WasmLocation* loc, WasmExpr* expr1) { + WasmExprList result; + WASM_ZERO_MEMORY(result); + append_expr(&result, expr1); + expr1->loc = *loc; + return result; +} + +static WasmExprList join_exprs2(WasmLocation* loc, WasmExprList* expr1, + WasmExpr* expr2) { + WasmExprList result; + WASM_ZERO_MEMORY(result); + append_expr_list(&result, expr1); + append_expr(&result, expr2); + expr2->loc = *loc; + return result; +} + +static WasmExprList join_exprs3(WasmLocation* loc, WasmExprList* expr1, + WasmExprList* expr2, WasmExpr* expr3) { + WasmExprList result; + WASM_ZERO_MEMORY(result); + append_expr_list(&result, expr1); + append_expr_list(&result, expr2); + append_expr(&result, expr3); + expr3->loc = *loc; + return result; +} + +static WasmExprList join_exprs4(WasmLocation* loc, WasmExprList* expr1, + WasmExprList* expr2, WasmExprList* expr3, + WasmExpr* expr4) { + WasmExprList result; + WASM_ZERO_MEMORY(result); + append_expr_list(&result, expr1); + append_expr_list(&result, expr2); + append_expr_list(&result, expr3); + append_expr(&result, expr4); + expr4->loc = *loc; + return result; +} + static WasmResult parse_const(WasmType type, WasmLiteralType literal_type, const char* s, diff --git a/src/wasm-ast-writer.c b/src/wasm-ast-writer.c index e5c45685..43c28763 100644 --- a/src/wasm-ast-writer.c +++ b/src/wasm-ast-writer.c @@ -139,6 +139,10 @@ static void write_puts_space(Context* ctx, const char* s) { write_puts(ctx, s, NEXT_CHAR_SPACE); } +static void write_puts_newline(Context* ctx, const char* s) { + write_puts(ctx, s, NEXT_CHAR_NEWLINE); +} + static void write_newline(Context* ctx, WasmBool force) { if (ctx->next_char == NEXT_CHAR_FORCE_NEWLINE) write_next_char(ctx); @@ -274,15 +278,18 @@ static void write_expr(Context* ctx, const WasmExpr* expr); static void write_block(Context* ctx, const WasmBlock* block, - const char* text) { - write_open_space(ctx, text); + const char* start_text, + const char* end_text) { + if (start_text) + write_puts_space(ctx, start_text); if (!write_string_slice_opt(ctx, &block->label, NEXT_CHAR_SPACE)) writef(ctx, " ;; exit = @%d", ctx->depth); write_newline(ctx, FORCE_NEWLINE); ctx->depth++; write_expr_list(ctx, block->first); ctx->depth--; - write_close_newline(ctx); + if (end_text) + write_puts_newline(ctx, end_text); } static void write_const(Context* ctx, const WasmConst* const_) { @@ -326,76 +333,53 @@ static void write_const(Context* ctx, const WasmConst* const_) { static void write_expr(Context* ctx, const WasmExpr* expr) { switch (expr->type) { case WASM_EXPR_TYPE_BINARY: - write_open_newline(ctx, s_opcode_name[expr->binary.opcode]); - write_expr(ctx, expr->binary.left); - write_expr(ctx, expr->binary.right); - write_close_newline(ctx); + write_puts_newline(ctx, s_opcode_name[expr->binary.opcode]); break; case WASM_EXPR_TYPE_BLOCK: - write_block(ctx, &expr->block, s_opcode_name[WASM_OPCODE_BLOCK]); + write_block(ctx, &expr->block, s_opcode_name[WASM_OPCODE_BLOCK], + s_opcode_name[WASM_OPCODE_END]); break; case WASM_EXPR_TYPE_BR: - write_open_space(ctx, s_opcode_name[WASM_OPCODE_BR]); + write_puts_space(ctx, s_opcode_name[WASM_OPCODE_BR]); + writef(ctx, "%d", expr->br.arity); write_br_var(ctx, &expr->br.var, NEXT_CHAR_NEWLINE); - if (expr->br.expr) - write_expr(ctx, expr->br.expr); - write_close_newline(ctx); break; case WASM_EXPR_TYPE_BR_IF: - write_open_space(ctx, s_opcode_name[WASM_OPCODE_BR_IF]); + write_puts_space(ctx, s_opcode_name[WASM_OPCODE_BR_IF]); + writef(ctx, "%d", expr->br_if.arity); write_br_var(ctx, &expr->br_if.var, NEXT_CHAR_NEWLINE); - if (expr->br_if.expr) - write_expr(ctx, expr->br_if.expr); - write_expr(ctx, expr->br_if.cond); - write_close_newline(ctx); break; case WASM_EXPR_TYPE_BR_TABLE: { - write_open_newline(ctx, s_opcode_name[WASM_OPCODE_BR_TABLE]); + write_puts_space(ctx, s_opcode_name[WASM_OPCODE_BR_TABLE]); + writef(ctx, "%d", expr->br_table.arity); size_t i; for (i = 0; i < expr->br_table.targets.size; ++i) write_br_var(ctx, &expr->br_table.targets.data[i], NEXT_CHAR_SPACE); write_br_var(ctx, &expr->br_table.default_target, NEXT_CHAR_NEWLINE); - if (expr->br_table.expr) - write_expr(ctx, expr->br_table.expr); - write_expr(ctx, expr->br_table.key); - write_close_newline(ctx); break; } - case WASM_EXPR_TYPE_CALL: { - write_open_space(ctx, s_opcode_name[WASM_OPCODE_CALL_FUNCTION]); + case WASM_EXPR_TYPE_CALL: + write_puts_space(ctx, s_opcode_name[WASM_OPCODE_CALL_FUNCTION]); write_var(ctx, &expr->call.var, NEXT_CHAR_NEWLINE); - write_expr_list(ctx, expr->call.first_arg); - write_close_newline(ctx); break; - } - case WASM_EXPR_TYPE_CALL_IMPORT: { - write_open_space(ctx, s_opcode_name[WASM_OPCODE_CALL_IMPORT]); - write_var(ctx, &expr->call.var, NEXT_CHAR_NEWLINE); - write_expr_list(ctx, expr->call.first_arg); - write_close_newline(ctx); + case WASM_EXPR_TYPE_CALL_IMPORT: + write_puts_space(ctx, s_opcode_name[WASM_OPCODE_CALL_IMPORT]); + write_var(ctx, &expr->call_import.var, NEXT_CHAR_NEWLINE); break; - } - case WASM_EXPR_TYPE_CALL_INDIRECT: { - write_open_space(ctx, s_opcode_name[WASM_OPCODE_CALL_INDIRECT]); + case WASM_EXPR_TYPE_CALL_INDIRECT: + write_puts_space(ctx, s_opcode_name[WASM_OPCODE_CALL_INDIRECT]); write_var(ctx, &expr->call_indirect.var, NEXT_CHAR_NEWLINE); - write_expr(ctx, expr->call_indirect.expr); - write_expr_list(ctx, expr->call_indirect.first_arg); - write_close_newline(ctx); break; - } case WASM_EXPR_TYPE_COMPARE: - write_open_newline(ctx, s_opcode_name[expr->compare.opcode]); - write_expr(ctx, expr->compare.left); - write_expr(ctx, expr->compare.right); - write_close_newline(ctx); + write_puts_newline(ctx, s_opcode_name[expr->compare.opcode]); break; case WASM_EXPR_TYPE_CONST: @@ -403,126 +387,89 @@ static void write_expr(Context* ctx, const WasmExpr* expr) { break; case WASM_EXPR_TYPE_CONVERT: - write_open_newline(ctx, s_opcode_name[expr->convert.opcode]); - write_expr(ctx, expr->convert.expr); - write_close_newline(ctx); + write_puts_newline(ctx, s_opcode_name[expr->convert.opcode]); + break; + + case WASM_EXPR_TYPE_DROP: + write_puts_newline(ctx, s_opcode_name[WASM_OPCODE_DROP]); break; case WASM_EXPR_TYPE_GET_LOCAL: - write_open_space(ctx, s_opcode_name[WASM_OPCODE_GET_LOCAL]); - write_var(ctx, &expr->get_local.var, NEXT_CHAR_NONE); - write_close_newline(ctx); + write_puts_newline(ctx, s_opcode_name[WASM_OPCODE_GET_LOCAL]); + write_var(ctx, &expr->get_local.var, NEXT_CHAR_NEWLINE); break; case WASM_EXPR_TYPE_GROW_MEMORY: - write_open_newline(ctx, s_opcode_name[WASM_OPCODE_GROW_MEMORY]); - write_expr(ctx, expr->grow_memory.expr); - write_close_newline(ctx); + write_puts_newline(ctx, s_opcode_name[WASM_OPCODE_GROW_MEMORY]); break; - case WASM_EXPR_TYPE_IF: { - write_open_newline(ctx, s_opcode_name[WASM_OPCODE_IF]); - write_expr(ctx, expr->if_.cond); - write_block(ctx, &expr->if_.true_, "then"); - write_close_newline(ctx); + case WASM_EXPR_TYPE_IF: + write_block(ctx, &expr->if_.true_, s_opcode_name[WASM_OPCODE_IF], + s_opcode_name[WASM_OPCODE_ELSE]); break; - } - case WASM_EXPR_TYPE_IF_ELSE: { - write_open_newline(ctx, s_opcode_name[WASM_OPCODE_IF]); - write_expr(ctx, expr->if_else.cond); - write_block(ctx, &expr->if_else.true_, "then"); - write_block(ctx, &expr->if_else.false_, "else"); - write_close_newline(ctx); + case WASM_EXPR_TYPE_IF_ELSE: + write_block(ctx, &expr->if_else.true_, s_opcode_name[WASM_OPCODE_IF], + s_opcode_name[WASM_OPCODE_ELSE]); + write_block(ctx, &expr->if_else.false_, NULL, + s_opcode_name[WASM_OPCODE_END]); break; - } case WASM_EXPR_TYPE_LOAD: - write_open_space(ctx, s_opcode_name[expr->load.opcode]); + write_puts_space(ctx, s_opcode_name[expr->load.opcode]); if (expr->load.offset) writef(ctx, "offset=%" PRIu64, expr->load.offset); if (!wasm_is_naturally_aligned(expr->load.opcode, expr->load.align)) writef(ctx, "align=%u", expr->load.align); - write_newline(ctx, NO_FORCE_NEWLINE); - write_expr(ctx, expr->load.addr); - write_close_newline(ctx); + write_newline(ctx, FORCE_NEWLINE); break; - case WASM_EXPR_TYPE_LOOP: { - write_open_space(ctx, s_opcode_name[WASM_OPCODE_LOOP]); - WasmBool has_outer_name = - write_string_slice_opt(ctx, &expr->loop.outer, NEXT_CHAR_SPACE); - WasmBool has_inner_name = - write_string_slice_opt(ctx, &expr->loop.inner, NEXT_CHAR_SPACE); - if (!has_outer_name || !has_inner_name) { - writef(ctx, " ;;"); - if (!has_outer_name) - writef(ctx, "exit = @%d", ctx->depth); - if (!has_inner_name) { - writef(ctx, "cont = @%d", ctx->depth + 1); - } - } - write_newline(ctx, FORCE_NEWLINE); - ctx->depth += 2; - write_expr_list(ctx, expr->loop.first); - ctx->depth -= 2; - write_close_newline(ctx); + case WASM_EXPR_TYPE_LOOP: + write_block(ctx, &expr->loop, s_opcode_name[WASM_OPCODE_LOOP], + s_opcode_name[WASM_OPCODE_END]); break; - } case WASM_EXPR_TYPE_CURRENT_MEMORY: - write_open_space(ctx, s_opcode_name[WASM_OPCODE_CURRENT_MEMORY]); - write_close_newline(ctx); + write_puts_newline(ctx, s_opcode_name[WASM_OPCODE_CURRENT_MEMORY]); break; case WASM_EXPR_TYPE_NOP: - write_open_space(ctx, s_opcode_name[WASM_OPCODE_NOP]); - write_close_newline(ctx); + write_puts_newline(ctx, s_opcode_name[WASM_OPCODE_NOP]); break; case WASM_EXPR_TYPE_RETURN: - write_open_newline(ctx, s_opcode_name[WASM_OPCODE_RETURN]); - if (expr->return_.expr) - write_expr(ctx, expr->return_.expr); - write_close_newline(ctx); + write_puts_newline(ctx, s_opcode_name[WASM_OPCODE_RETURN]); break; case WASM_EXPR_TYPE_SELECT: - write_open_newline(ctx, s_opcode_name[WASM_OPCODE_SELECT]); - write_expr(ctx, expr->select.true_); - write_expr(ctx, expr->select.false_); - write_expr(ctx, expr->select.cond); - write_close_newline(ctx); + write_puts_newline(ctx, s_opcode_name[WASM_OPCODE_SELECT]); break; case WASM_EXPR_TYPE_SET_LOCAL: - write_open_space(ctx, s_opcode_name[WASM_OPCODE_SET_LOCAL]); + write_puts_space(ctx, s_opcode_name[WASM_OPCODE_SET_LOCAL]); write_var(ctx, &expr->set_local.var, NEXT_CHAR_NEWLINE); - write_expr(ctx, expr->set_local.expr); - write_close_newline(ctx); break; case WASM_EXPR_TYPE_STORE: - write_open_space(ctx, s_opcode_name[expr->store.opcode]); + write_puts_space(ctx, s_opcode_name[expr->store.opcode]); if (expr->store.offset) writef(ctx, "offset=%" PRIu64, expr->store.offset); if (!wasm_is_naturally_aligned(expr->store.opcode, expr->store.align)) writef(ctx, "align=%u", expr->store.align); - write_newline(ctx, NO_FORCE_NEWLINE); - write_expr(ctx, expr->store.addr); - write_expr(ctx, expr->store.value); - write_close_newline(ctx); + write_newline(ctx, FORCE_NEWLINE); + break; + + case WASM_EXPR_TYPE_TEE_LOCAL: + write_puts_space(ctx, s_opcode_name[WASM_OPCODE_TEE_LOCAL]); + write_var(ctx, &expr->tee_local.var, NEXT_CHAR_NEWLINE); break; case WASM_EXPR_TYPE_UNARY: - write_open_newline(ctx, s_opcode_name[expr->unary.opcode]); - write_expr(ctx, expr->unary.expr); - write_close_newline(ctx); + write_puts_newline(ctx, s_opcode_name[expr->unary.opcode]); break; case WASM_EXPR_TYPE_UNREACHABLE: - write_open_space(ctx, s_opcode_name[WASM_OPCODE_UNREACHABLE]); - write_close_newline(ctx); + write_puts_newline(ctx, s_opcode_name[WASM_OPCODE_UNREACHABLE]); break; default: diff --git a/src/wasm-ast.c b/src/wasm-ast.c index 4510ddb8..00d56ccf 100644 --- a/src/wasm-ast.c +++ b/src/wasm-ast.c @@ -310,21 +310,19 @@ WasmFuncType* wasm_append_implicit_func_type(struct WasmAllocator* allocator, V(WASM_EXPR_TYPE_BR_IF, br_if, br_if) \ V(WASM_EXPR_TYPE_BR_TABLE, br_table, br_table) \ V(WASM_EXPR_TYPE_CALL, call, call) \ - V(WASM_EXPR_TYPE_CALL_IMPORT, call_import, call) \ + V(WASM_EXPR_TYPE_CALL_IMPORT, call_import, call_import) \ V(WASM_EXPR_TYPE_CALL_INDIRECT, call_indirect, call_indirect) \ V(WASM_EXPR_TYPE_COMPARE, compare, compare) \ V(WASM_EXPR_TYPE_CONST, const, const_) \ V(WASM_EXPR_TYPE_CONVERT, convert, convert) \ V(WASM_EXPR_TYPE_GET_LOCAL, get_local, get_local) \ - V(WASM_EXPR_TYPE_GROW_MEMORY, grow_memory, grow_memory) \ - V(WASM_EXPR_TYPE_IF_ELSE, if_else, if_else) \ V(WASM_EXPR_TYPE_IF, if, if_) \ + V(WASM_EXPR_TYPE_IF_ELSE, if_else, if_else) \ V(WASM_EXPR_TYPE_LOAD, load, load) \ V(WASM_EXPR_TYPE_LOOP, loop, loop) \ - V(WASM_EXPR_TYPE_RETURN, return, return_) \ - V(WASM_EXPR_TYPE_SELECT, select, select) \ V(WASM_EXPR_TYPE_SET_LOCAL, set_local, set_local) \ V(WASM_EXPR_TYPE_STORE, store, store) \ + V(WASM_EXPR_TYPE_TEE_LOCAL, tee_local, tee_local) \ V(WASM_EXPR_TYPE_UNARY, unary, unary) #define DEFINE_NEW_EXPR(type_, name, member) \ @@ -336,6 +334,24 @@ WasmFuncType* wasm_append_implicit_func_type(struct WasmAllocator* allocator, FOREACH_EXPR_TYPE(DEFINE_NEW_EXPR) #undef DEFINE_NEW_EXPR +#define FOREACH_EMPTY_EXPR_TYPE(V) \ + V(WASM_EXPR_TYPE_CURRENT_MEMORY, current_memory) \ + V(WASM_EXPR_TYPE_DROP, drop) \ + V(WASM_EXPR_TYPE_GROW_MEMORY, grow_memory) \ + V(WASM_EXPR_TYPE_NOP, nop) \ + V(WASM_EXPR_TYPE_RETURN, return ) \ + V(WASM_EXPR_TYPE_SELECT, select) \ + V(WASM_EXPR_TYPE_UNREACHABLE, unreachable) + +#define DEFINE_NEW_EMPTY_EXPR(type_, name) \ + WasmExpr* wasm_new_##name##_expr(WasmAllocator* allocator) { \ + WasmExpr* result = ALLOC_EXPR_TYPE_ZERO(allocator, next); \ + result->type = type_; \ + return result; \ + } +FOREACH_EMPTY_EXPR_TYPE(DEFINE_NEW_EMPTY_EXPR) +#undef DEFINE_NEW_EMPTY_EXPR + WasmExpr* wasm_new_empty_expr(struct WasmAllocator* allocator, WasmExprType type) { WasmExpr* result = ALLOC_EXPR_TYPE_ZERO(allocator, next); @@ -389,96 +405,58 @@ void wasm_destroy_block(WasmAllocator* allocator, WasmBlock* block) { void wasm_destroy_expr(WasmAllocator* allocator, WasmExpr* expr) { switch (expr->type) { - case WASM_EXPR_TYPE_BINARY: - wasm_destroy_expr(allocator, expr->binary.left); - wasm_destroy_expr(allocator, expr->binary.right); - break; case WASM_EXPR_TYPE_BLOCK: wasm_destroy_block(allocator, &expr->block); break; case WASM_EXPR_TYPE_BR: wasm_destroy_var(allocator, &expr->br.var); - if (expr->br.expr) - wasm_destroy_expr(allocator, expr->br.expr); break; case WASM_EXPR_TYPE_BR_IF: wasm_destroy_var(allocator, &expr->br_if.var); - wasm_destroy_expr(allocator, expr->br_if.cond); - if (expr->br_if.expr) - wasm_destroy_expr(allocator, expr->br_if.expr); + break; + case WASM_EXPR_TYPE_BR_TABLE: + WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, expr->br_table.targets, var); + wasm_destroy_var(allocator, &expr->br_table.default_target); break; case WASM_EXPR_TYPE_CALL: case WASM_EXPR_TYPE_CALL_IMPORT: - wasm_destroy_var(allocator, &expr->call.var); - wasm_destroy_expr_list(allocator, expr->call.first_arg); - break; case WASM_EXPR_TYPE_CALL_INDIRECT: - wasm_destroy_var(allocator, &expr->call_indirect.var); - wasm_destroy_expr(allocator, expr->call_indirect.expr); - wasm_destroy_expr_list(allocator, expr->call_indirect.first_arg); - break; - case WASM_EXPR_TYPE_COMPARE: - wasm_destroy_expr(allocator, expr->compare.left); - wasm_destroy_expr(allocator, expr->compare.right); - break; - case WASM_EXPR_TYPE_CONVERT: - wasm_destroy_expr(allocator, expr->convert.expr); + wasm_destroy_var(allocator, &expr->call.var); break; case WASM_EXPR_TYPE_GET_LOCAL: wasm_destroy_var(allocator, &expr->get_local.var); break; - case WASM_EXPR_TYPE_GROW_MEMORY: - wasm_destroy_expr(allocator, expr->grow_memory.expr); - break; case WASM_EXPR_TYPE_IF: - wasm_destroy_expr(allocator, expr->if_.cond); wasm_destroy_block(allocator, &expr->if_.true_); break; case WASM_EXPR_TYPE_IF_ELSE: - wasm_destroy_expr(allocator, expr->if_else.cond); wasm_destroy_block(allocator, &expr->if_else.true_); wasm_destroy_block(allocator, &expr->if_else.false_); break; - case WASM_EXPR_TYPE_LOAD: - wasm_destroy_expr(allocator, expr->load.addr); - break; case WASM_EXPR_TYPE_LOOP: - wasm_destroy_string_slice(allocator, &expr->loop.inner); - wasm_destroy_string_slice(allocator, &expr->loop.outer); - wasm_destroy_expr_list(allocator, expr->loop.first); - break; - case WASM_EXPR_TYPE_RETURN: - if (expr->return_.expr) - wasm_destroy_expr(allocator, expr->return_.expr); - break; - case WASM_EXPR_TYPE_SELECT: - wasm_destroy_expr(allocator, expr->select.cond); - wasm_destroy_expr(allocator, expr->select.true_); - wasm_destroy_expr(allocator, expr->select.false_); + wasm_destroy_block(allocator, &expr->loop); break; case WASM_EXPR_TYPE_SET_LOCAL: wasm_destroy_var(allocator, &expr->set_local.var); - wasm_destroy_expr(allocator, expr->set_local.expr); break; - case WASM_EXPR_TYPE_STORE: - wasm_destroy_expr(allocator, expr->store.addr); - wasm_destroy_expr(allocator, expr->store.value); - break; - case WASM_EXPR_TYPE_BR_TABLE: - wasm_destroy_expr(allocator, expr->br_table.key); - if (expr->br_table.expr) - wasm_destroy_expr(allocator, expr->br_table.expr); - WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, expr->br_table.targets, var); - wasm_destroy_var(allocator, &expr->br_table.default_target); - break; - case WASM_EXPR_TYPE_UNARY: - wasm_destroy_expr(allocator, expr->unary.expr); + case WASM_EXPR_TYPE_TEE_LOCAL: + wasm_destroy_var(allocator, &expr->tee_local.var); break; - case WASM_EXPR_TYPE_UNREACHABLE: + case WASM_EXPR_TYPE_BINARY: + case WASM_EXPR_TYPE_COMPARE: case WASM_EXPR_TYPE_CONST: + case WASM_EXPR_TYPE_CONVERT: + case WASM_EXPR_TYPE_DROP: case WASM_EXPR_TYPE_CURRENT_MEMORY: + case WASM_EXPR_TYPE_GROW_MEMORY: + case WASM_EXPR_TYPE_LOAD: case WASM_EXPR_TYPE_NOP: + case WASM_EXPR_TYPE_RETURN: + case WASM_EXPR_TYPE_SELECT: + case WASM_EXPR_TYPE_STORE: + case WASM_EXPR_TYPE_UNARY: + case WASM_EXPR_TYPE_UNREACHABLE: break; } wasm_free(allocator, expr); @@ -661,10 +639,7 @@ static WasmResult visit_expr_list(WasmExpr* first, WasmExprVisitor* visitor) { static WasmResult visit_expr(WasmExpr* expr, WasmExprVisitor* visitor) { switch (expr->type) { case WASM_EXPR_TYPE_BINARY: - CALLBACK(begin_binary_expr); - CHECK_RESULT(visit_expr(expr->binary.left, visitor)); - CHECK_RESULT(visit_expr(expr->binary.right, visitor)); - CALLBACK(end_binary_expr); + CALLBACK(on_binary_expr); break; case WASM_EXPR_TYPE_BLOCK: @@ -674,44 +649,31 @@ static WasmResult visit_expr(WasmExpr* expr, WasmExprVisitor* visitor) { break; case WASM_EXPR_TYPE_BR: - CALLBACK(begin_br_expr); - if (expr->br.expr) - CHECK_RESULT(visit_expr(expr->br.expr, visitor)); - CALLBACK(end_br_expr); + CALLBACK(on_br_expr); break; case WASM_EXPR_TYPE_BR_IF: - CALLBACK(begin_br_if_expr); - if (expr->br_if.expr) - CHECK_RESULT(visit_expr(expr->br_if.expr, visitor)); - CHECK_RESULT(visit_expr(expr->br_if.cond, visitor)); - CALLBACK(end_br_if_expr); + CALLBACK(on_br_if_expr); + break; + + case WASM_EXPR_TYPE_BR_TABLE: + CALLBACK(on_br_table_expr); break; case WASM_EXPR_TYPE_CALL: - CALLBACK(begin_call_expr); - CHECK_RESULT(visit_expr_list(expr->call.first_arg, visitor)); - CALLBACK(end_call_expr); + CALLBACK(on_call_expr); break; case WASM_EXPR_TYPE_CALL_IMPORT: - CALLBACK(begin_call_import_expr); - CHECK_RESULT(visit_expr_list(expr->call.first_arg, visitor)); - CALLBACK(end_call_import_expr); + CALLBACK(on_call_import_expr); break; case WASM_EXPR_TYPE_CALL_INDIRECT: - CALLBACK(begin_call_indirect_expr); - CHECK_RESULT(visit_expr(expr->call_indirect.expr, visitor)); - CHECK_RESULT(visit_expr_list(expr->call_indirect.first_arg, visitor)); - CALLBACK(end_call_indirect_expr); + CALLBACK(on_call_indirect_expr); break; case WASM_EXPR_TYPE_COMPARE: - CALLBACK(begin_compare_expr); - CHECK_RESULT(visit_expr(expr->compare.left, visitor)); - CHECK_RESULT(visit_expr(expr->compare.right, visitor)); - CALLBACK(end_compare_expr); + CALLBACK(on_compare_expr); break; case WASM_EXPR_TYPE_CONST: @@ -719,9 +681,15 @@ static WasmResult visit_expr(WasmExpr* expr, WasmExprVisitor* visitor) { break; case WASM_EXPR_TYPE_CONVERT: - CALLBACK(begin_convert_expr); - CHECK_RESULT(visit_expr(expr->convert.expr, visitor)); - CALLBACK(end_convert_expr); + CALLBACK(on_convert_expr); + break; + + case WASM_EXPR_TYPE_CURRENT_MEMORY: + CALLBACK(on_current_memory_expr); + break; + + case WASM_EXPR_TYPE_DROP: + CALLBACK(on_drop_expr); break; case WASM_EXPR_TYPE_GET_LOCAL: @@ -729,23 +697,17 @@ static WasmResult visit_expr(WasmExpr* expr, WasmExprVisitor* visitor) { break; case WASM_EXPR_TYPE_GROW_MEMORY: - CALLBACK(begin_grow_memory_expr); - CHECK_RESULT(visit_expr(expr->grow_memory.expr, visitor)); - CALLBACK(end_grow_memory_expr); + CALLBACK(on_grow_memory_expr); break; case WASM_EXPR_TYPE_IF: CALLBACK(begin_if_expr); - CHECK_RESULT(visit_expr(expr->if_.cond, visitor)); - CALLBACK(after_if_cond_expr); CHECK_RESULT(visit_expr_list(expr->if_.true_.first, visitor)); CALLBACK(end_if_expr); break; case WASM_EXPR_TYPE_IF_ELSE: CALLBACK(begin_if_else_expr); - CHECK_RESULT(visit_expr(expr->if_else.cond, visitor)); - CALLBACK(after_if_else_cond_expr); CHECK_RESULT(visit_expr_list(expr->if_else.true_.first, visitor)); CALLBACK(after_if_else_true_expr); CHECK_RESULT(visit_expr_list(expr->if_else.false_.first, visitor)); @@ -753,9 +715,7 @@ static WasmResult visit_expr(WasmExpr* expr, WasmExprVisitor* visitor) { break; case WASM_EXPR_TYPE_LOAD: - CALLBACK(begin_load_expr); - CHECK_RESULT(visit_expr(expr->load.addr, visitor)); - CALLBACK(end_load_expr); + CALLBACK(on_load_expr); break; case WASM_EXPR_TYPE_LOOP: @@ -764,54 +724,32 @@ static WasmResult visit_expr(WasmExpr* expr, WasmExprVisitor* visitor) { CALLBACK(end_loop_expr); break; - case WASM_EXPR_TYPE_CURRENT_MEMORY: - CALLBACK(on_current_memory_expr); - break; - case WASM_EXPR_TYPE_NOP: CALLBACK(on_nop_expr); break; case WASM_EXPR_TYPE_RETURN: - CALLBACK(begin_return_expr); - if (expr->return_.expr) - CHECK_RESULT(visit_expr(expr->return_.expr, visitor)); - CALLBACK(end_return_expr); + CALLBACK(on_return_expr); break; case WASM_EXPR_TYPE_SELECT: - CALLBACK(begin_select_expr); - CHECK_RESULT(visit_expr(expr->select.true_, visitor)); - CHECK_RESULT(visit_expr(expr->select.false_, visitor)); - CHECK_RESULT(visit_expr(expr->select.cond, visitor)); - CALLBACK(end_select_expr); + CALLBACK(on_select_expr); break; case WASM_EXPR_TYPE_SET_LOCAL: - CALLBACK(begin_set_local_expr); - CHECK_RESULT(visit_expr(expr->set_local.expr, visitor)); - CALLBACK(end_set_local_expr); + CALLBACK(on_set_local_expr); break; case WASM_EXPR_TYPE_STORE: - CALLBACK(begin_store_expr); - CHECK_RESULT(visit_expr(expr->store.addr, visitor)); - CHECK_RESULT(visit_expr(expr->store.value, visitor)); - CALLBACK(end_store_expr); + CALLBACK(on_store_expr); break; - case WASM_EXPR_TYPE_BR_TABLE: - CALLBACK(begin_br_table_expr); - CHECK_RESULT(visit_expr(expr->br_table.key, visitor)); - if (expr->br_table.expr) - CHECK_RESULT(visit_expr(expr->br_table.expr, visitor)); - CALLBACK(end_br_table_expr); + case WASM_EXPR_TYPE_TEE_LOCAL: + CALLBACK(on_tee_local_expr); break; case WASM_EXPR_TYPE_UNARY: - CALLBACK(begin_unary_expr); - CHECK_RESULT(visit_expr(expr->unary.expr, visitor)); - CALLBACK(end_unary_expr); + CALLBACK(on_unary_expr); break; case WASM_EXPR_TYPE_UNREACHABLE: diff --git a/src/wasm-ast.h b/src/wasm-ast.h index 3c8f270c..0f4fc2ac 100644 --- a/src/wasm-ast.h +++ b/src/wasm-ast.h @@ -68,6 +68,7 @@ typedef enum WasmExprType { WASM_EXPR_TYPE_CONST, WASM_EXPR_TYPE_CONVERT, WASM_EXPR_TYPE_CURRENT_MEMORY, + WASM_EXPR_TYPE_DROP, WASM_EXPR_TYPE_GET_LOCAL, WASM_EXPR_TYPE_GROW_MEMORY, WASM_EXPR_TYPE_IF, @@ -79,6 +80,7 @@ typedef enum WasmExprType { WASM_EXPR_TYPE_SELECT, WASM_EXPR_TYPE_SET_LOCAL, WASM_EXPR_TYPE_STORE, + WASM_EXPR_TYPE_TEE_LOCAL, WASM_EXPR_TYPE_UNARY, WASM_EXPR_TYPE_UNREACHABLE, } WasmExprType; @@ -112,50 +114,20 @@ struct WasmExpr { WasmExprType type; WasmExpr* next; union { - WasmBlock block; - struct { WasmExpr* cond; WasmBlock true_, false_; } if_else; - struct { WasmExpr* cond; WasmBlock true_; } if_; - struct { WasmVar var; WasmExpr *cond, *expr; } br_if; + struct { WasmOpcode opcode; } binary, compare, convert, unary; + WasmBlock block, loop; + struct { WasmVar var; uint8_t arity; } br, br_if; struct { - WasmLabel inner, outer; - WasmExpr* first; - } loop; - struct { WasmVar var; WasmExpr* expr; } br; - struct { WasmExpr* expr; } return_; - struct { - WasmExpr* key; - WasmExpr* expr; WasmVarVector targets; WasmVar default_target; + uint8_t arity; } br_table; - struct { WasmVar var; WasmExpr* first_arg; size_t num_args; } call; - struct { - WasmVar var; - WasmExpr* expr; - WasmExpr* first_arg; - size_t num_args; - } call_indirect; - struct { WasmVar var; } get_local; - struct { WasmVar var; WasmExpr* expr; } set_local; - struct { - WasmOpcode opcode; - uint32_t align; - uint64_t offset; - WasmExpr* addr; - } load; - struct { - WasmOpcode opcode; - uint32_t align; - uint64_t offset; - WasmExpr *addr, *value; - } store; + struct { WasmVar var; } call, call_import, call_indirect; WasmConst const_; - struct { WasmOpcode opcode; WasmExpr* expr; } unary; - struct { WasmOpcode opcode; WasmExpr *left, *right; } binary; - struct { WasmExpr *cond, *true_, *false_; } select; - struct { WasmOpcode opcode; WasmExpr *left, *right; } compare; - struct { WasmOpcode opcode; WasmExpr *expr; } convert; - struct { WasmExpr* expr; } grow_memory; + struct { WasmVar var; } get_local, set_local, tee_local; + struct { WasmBlock true_; } if_; + struct { WasmBlock true_, false_; } if_else; + struct { WasmOpcode opcode; uint32_t align; uint64_t offset; } load, store; }; }; @@ -343,53 +315,37 @@ typedef struct WasmScript { typedef struct WasmExprVisitor { void* user_data; - WasmResult (*begin_binary_expr)(WasmExpr*, void* user_data); - WasmResult (*end_binary_expr)(WasmExpr*, void* user_data); + WasmResult (*on_binary_expr)(WasmExpr*, void* user_data); WasmResult (*begin_block_expr)(WasmExpr*, void* user_data); WasmResult (*end_block_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_br_expr)(WasmExpr*, void* user_data); - WasmResult (*end_br_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_br_if_expr)(WasmExpr*, void* user_data); - WasmResult (*end_br_if_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_br_table_expr)(WasmExpr*, void* user_data); - WasmResult (*end_br_table_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_call_expr)(WasmExpr*, void* user_data); - WasmResult (*end_call_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_call_import_expr)(WasmExpr*, void* user_data); - WasmResult (*end_call_import_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_call_indirect_expr)(WasmExpr*, void* user_data); - WasmResult (*end_call_indirect_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_compare_expr)(WasmExpr*, void* user_data); - WasmResult (*end_compare_expr)(WasmExpr*, void* user_data); + WasmResult (*on_br_expr)(WasmExpr*, void* user_data); + WasmResult (*on_br_if_expr)(WasmExpr*, void* user_data); + WasmResult (*on_br_table_expr)(WasmExpr*, void* user_data); + WasmResult (*on_call_expr)(WasmExpr*, void* user_data); + WasmResult (*on_call_import_expr)(WasmExpr*, void* user_data); + WasmResult (*on_call_indirect_expr)(WasmExpr*, void* user_data); + WasmResult (*on_compare_expr)(WasmExpr*, void* user_data); WasmResult (*on_const_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_convert_expr)(WasmExpr*, void* user_data); - WasmResult (*end_convert_expr)(WasmExpr*, void* user_data); + WasmResult (*on_convert_expr)(WasmExpr*, void* user_data); WasmResult (*on_current_memory_expr)(WasmExpr*, void* user_data); + WasmResult (*on_drop_expr)(WasmExpr*, void* user_data); WasmResult (*on_get_local_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_grow_memory_expr)(WasmExpr*, void* user_data); - WasmResult (*end_grow_memory_expr)(WasmExpr*, void* user_data); + WasmResult (*on_grow_memory_expr)(WasmExpr*, void* user_data); WasmResult (*begin_if_expr)(WasmExpr*, void* user_data); - WasmResult (*after_if_cond_expr)(WasmExpr*, void* user_data); WasmResult (*end_if_expr)(WasmExpr*, void* user_data); WasmResult (*begin_if_else_expr)(WasmExpr*, void* user_data); - WasmResult (*after_if_else_cond_expr)(WasmExpr*, void* user_data); WasmResult (*after_if_else_true_expr)(WasmExpr*, void* user_data); WasmResult (*end_if_else_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_load_expr)(WasmExpr*, void* user_data); - WasmResult (*end_load_expr)(WasmExpr*, void* user_data); + WasmResult (*on_load_expr)(WasmExpr*, void* user_data); WasmResult (*begin_loop_expr)(WasmExpr*, void* user_data); WasmResult (*end_loop_expr)(WasmExpr*, void* user_data); WasmResult (*on_nop_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_return_expr)(WasmExpr*, void* user_data); - WasmResult (*end_return_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_select_expr)(WasmExpr*, void* user_data); - WasmResult (*end_select_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_set_local_expr)(WasmExpr*, void* user_data); - WasmResult (*end_set_local_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_store_expr)(WasmExpr*, void* user_data); - WasmResult (*end_store_expr)(WasmExpr*, void* user_data); - WasmResult (*begin_unary_expr)(WasmExpr*, void* user_data); - WasmResult (*end_unary_expr)(WasmExpr*, void* user_data); + WasmResult (*on_return_expr)(WasmExpr*, void* user_data); + WasmResult (*on_select_expr)(WasmExpr*, void* user_data); + WasmResult (*on_set_local_expr)(WasmExpr*, void* user_data); + WasmResult (*on_store_expr)(WasmExpr*, void* user_data); + WasmResult (*on_tee_local_expr)(WasmExpr*, void* user_data); + WasmResult (*on_unary_expr)(WasmExpr*, void* user_data); WasmResult (*on_unreachable_expr)(WasmExpr*, void* user_data); } WasmExprVisitor; @@ -418,19 +374,22 @@ WasmExpr* wasm_new_call_indirect_expr(struct WasmAllocator*); WasmExpr* wasm_new_compare_expr(struct WasmAllocator*); WasmExpr* wasm_new_const_expr(struct WasmAllocator*); WasmExpr* wasm_new_convert_expr(struct WasmAllocator*); +WasmExpr* wasm_new_current_memory_expr(struct WasmAllocator*); +WasmExpr* wasm_new_drop_expr(struct WasmAllocator*); WasmExpr* wasm_new_get_local_expr(struct WasmAllocator*); WasmExpr* wasm_new_grow_memory_expr(struct WasmAllocator*); -WasmExpr* wasm_new_if_else_expr(struct WasmAllocator*); WasmExpr* wasm_new_if_expr(struct WasmAllocator*); +WasmExpr* wasm_new_if_else_expr(struct WasmAllocator*); WasmExpr* wasm_new_load_expr(struct WasmAllocator*); WasmExpr* wasm_new_loop_expr(struct WasmAllocator*); +WasmExpr* wasm_new_nop_expr(struct WasmAllocator*); WasmExpr* wasm_new_return_expr(struct WasmAllocator*); WasmExpr* wasm_new_select_expr(struct WasmAllocator*); WasmExpr* wasm_new_set_local_expr(struct WasmAllocator*); WasmExpr* wasm_new_store_expr(struct WasmAllocator*); +WasmExpr* wasm_new_tee_local_expr(struct WasmAllocator*); WasmExpr* wasm_new_unary_expr(struct WasmAllocator*); -/* for nop, unreachable and current_memory */ -WasmExpr* wasm_new_empty_expr(struct WasmAllocator*, WasmExprType); +WasmExpr* wasm_new_unreachable_expr(struct WasmAllocator*); /* destruction functions. not needed unless you're creating your own AST elements */ diff --git a/src/wasm-binary-reader-ast.c b/src/wasm-binary-reader-ast.c index 91a79dcd..845d671b 100644 --- a/src/wasm-binary-reader-ast.c +++ b/src/wasm-binary-reader-ast.c @@ -27,61 +27,21 @@ #include "wasm-binary-reader.h" #include "wasm-common.h" -#define LOG 0 - -#if LOG -#define LOGF(...) fprintf(stderr, __VA_ARGS__) -#else -#define LOGF(...) (void)0 -#endif - #define CHECK_RESULT(expr) \ do { \ if (WASM_FAILED(expr)) \ return WASM_ERROR; \ } while (0) -#define CHECK_DEPTH(depth) \ - do { \ - if ((depth) >= ctx->max_depth) { \ - print_error(ctx, "invalid depth: %d (max %u)", (depth), ctx->max_depth); \ - return WASM_ERROR; \ - } \ - } while (0) - -#define CHECK_LOCAL(local_index) \ - do { \ - uint32_t max_local_index = \ - wasm_get_num_params_and_locals(ctx->module, ctx->current_func); \ - if ((local_index) >= max_local_index) { \ - print_error(ctx, "invalid local_index: %d (max %d)", (local_index), \ - max_local_index); \ - return WASM_ERROR; \ - } \ - } while (0) - #if LOG #define V(rtype, type1, type2, mem_size, code, NAME, text) [code] = text, static const char* s_opcode_name[] = {WASM_FOREACH_OPCODE(V)}; #undef V #endif -typedef enum LabelType { - LABEL_TYPE_FUNC, - LABEL_TYPE_BLOCK, - LABEL_TYPE_IF, - LABEL_TYPE_ELSE, - LABEL_TYPE_LOOP, -} LabelType; - -static const char* s_label_type_name[] = {"func", "block", "if", "else", - "loop"}; - typedef struct LabelNode { - LabelType type; - WasmExpr* expr_stack_top; - size_t expr_stack_size; - WasmExpr* expr; + WasmExpr** first; + WasmExpr* last; } LabelNode; WASM_DEFINE_VECTOR(label_node, LabelNode); @@ -91,8 +51,6 @@ typedef struct Context { WasmModule* module; WasmFunc* current_func; - WasmExpr* expr_stack_top; - size_t expr_stack_size; LabelNodeVector label_stack; uint32_t max_depth; } Context; @@ -105,13 +63,11 @@ static void WASM_PRINTF_FORMAT(2, 3) on_error(WASM_UNKNOWN_OFFSET, buffer, ctx); } -static void push_label(Context* ctx, LabelType type, WasmExpr* expr) { +static void push_label(Context* ctx, WasmExpr** first) { LabelNode label; - label.type = type; - label.expr_stack_top = ctx->expr_stack_top; - label.expr_stack_size = ctx->expr_stack_size; - label.expr = expr; - ctx->max_depth += type == LABEL_TYPE_LOOP ? 2 : 1; + label.first = first; + label.last = NULL; + ctx->max_depth++; wasm_append_label_node_value(ctx->allocator, &ctx->label_stack, &label); } @@ -121,8 +77,7 @@ static WasmResult pop_label(Context* ctx) { return WASM_ERROR; } - LabelType type = ctx->label_stack.data[ctx->label_stack.size - 1].type; - ctx->max_depth -= type == LABEL_TYPE_LOOP ? 2 : 1; + ctx->max_depth--; ctx->label_stack.size--; return WASM_OK; } @@ -138,8 +93,8 @@ static WasmResult top_label(Context* ctx, LabelNode** label) { } static void dup_name(Context* ctx, - WasmStringSlice* name, - WasmStringSlice* out_name) { + WasmStringSlice* name, + WasmStringSlice* out_name) { if (name->length > 0) { *out_name = wasm_dup_string_slice(ctx->allocator, *name); } else { @@ -147,98 +102,19 @@ static void dup_name(Context* ctx, } } -static void push_expr(Context* ctx, WasmExpr* expr) { - expr->next = ctx->expr_stack_top; - ctx->expr_stack_top = expr; - ctx->expr_stack_size++; -} - -static WasmResult pop_expr(Context* ctx, WasmExpr** expr) { - if (!ctx->expr_stack_top) { - print_error(ctx, "popping empty stack"); - return WASM_ERROR; - } - - if (ctx->label_stack.size > 0) { - LabelNode* label; - WasmResult result = top_label(ctx, &label); - WASM_USE(result); - assert(WASM_SUCCEEDED(result)); - if (ctx->expr_stack_size <= label->expr_stack_size) { - print_error(ctx, "popping past %s label", s_label_type_name[label->type]); - return WASM_ERROR; - } - } - - *expr = ctx->expr_stack_top; - ctx->expr_stack_top = ctx->expr_stack_top->next; - ctx->expr_stack_size--; - return WASM_OK; -} - -static WasmResult pop_expr_if(Context* ctx, WasmExpr** expr, WasmBool cond) { - if (cond) - return pop_expr(ctx, expr); - *expr = NULL; - return WASM_OK; -} - -static void pop_into_expr_list(Context* ctx, - WasmExpr* new_expr_stack_top, - WasmExpr** out_first_expr) { - /* the stack contains expressions pushed on in execution order, e.g. - * - * new_expr_stack_top - * | - * V - * expr_stack_top -> expr2 -> expr1 -> expr0 -> other -> NULL - * - * |out_expr_first| will be set to the first element of the reversed list: - * - * out_first_expr -> expr0 -> expr1 -> expr2 -> NULL - * expr_stack_top -> other -> NULL - */ - assert(!*out_first_expr); - WasmExpr* first = NULL; - WasmExpr* expr = ctx->expr_stack_top; - while (expr != new_expr_stack_top) { - assert(expr); - WasmExpr* next = expr->next; - expr->next = first; - first = expr; - expr = next; - } - ctx->expr_stack_top = new_expr_stack_top; - *out_first_expr = first; -} - -static WasmResult pop_into_args(Context* ctx, - WasmFuncSignature* sig, - WasmExpr** out_first_arg) { - assert(!*out_first_arg); - size_t num_params = sig->param_types.size; - - WasmExpr* first = NULL; - WasmExpr* expr = ctx->expr_stack_top; - size_t i; - for (i = 0; i < num_params; ++i) { - if (!expr) { - print_error(ctx, - "call requires %" PRIzd " args, but only %" PRIzd " on stack", - num_params, i); - return WASM_ERROR; - } - WasmExpr* next = expr->next; - expr->next = first; - first = expr; - expr = next; +static WasmResult append_expr(Context* ctx, WasmExpr* expr) { + LabelNode* label; + CHECK_RESULT(top_label(ctx, &label)); + if (*label->first) { + label->last->next = expr; + label->last = expr; + } else { + *label->first = label->last = expr; } - ctx->expr_stack_top = expr; - *out_first_arg = first; return WASM_OK; } -void on_error(uint32_t offset, const char* message, void* user_data) { +static void on_error(uint32_t offset, const char* message, void* user_data) { Context* ctx = user_data; if (ctx->error_handler->on_error) { ctx->error_handler->on_error(offset, message, @@ -416,17 +292,7 @@ static WasmResult begin_function_body(uint32_t index, void* user_data) { Context* ctx = user_data; assert(index < ctx->module->funcs.size); ctx->current_func = ctx->module->funcs.data[index]; - ctx->expr_stack_size = 0; - LOGF("func %d\n", index); - push_label(ctx, LABEL_TYPE_FUNC, NULL); - return WASM_OK; -} - -static WasmResult end_function_body(uint32_t index, void* user_data) { - Context* ctx = user_data; - pop_into_expr_list(ctx, NULL, &ctx->current_func->first_expr); - CHECK_RESULT(pop_label(ctx)); - ctx->current_func = NULL; + push_label(ctx, &ctx->current_func->first_expr); return WASM_OK; } @@ -446,178 +312,39 @@ static WasmResult on_local_decl(uint32_t decl_index, return WASM_OK; } -static WasmResult on_unary_expr(WasmOpcode opcode, void* user_data) { - Context* ctx = user_data; - LOGF("%" PRIzd ": %s\n", ctx->expr_stack_size, s_opcode_name[opcode]); - WasmExpr *result, *expr; - CHECK_RESULT(pop_expr(ctx, &expr)); - result = wasm_new_unary_expr(ctx->allocator); - result->unary.opcode = opcode; - result->unary.expr = expr; - push_expr(ctx, result); - return WASM_OK; -} - static WasmResult on_binary_expr(WasmOpcode opcode, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": %s\n", ctx->expr_stack_size, s_opcode_name[opcode]); - WasmExpr *result, *left, *right; - CHECK_RESULT(pop_expr(ctx, &right)); - CHECK_RESULT(pop_expr(ctx, &left)); - result = wasm_new_binary_expr(ctx->allocator); - result->binary.opcode = opcode; - result->binary.left = left; - result->binary.right = right; - push_expr(ctx, result); - return WASM_OK; -} - -static WasmResult on_compare_expr(WasmOpcode opcode, void* user_data) { - Context* ctx = user_data; - LOGF("%" PRIzd ": %s\n", ctx->expr_stack_size, s_opcode_name[opcode]); - WasmExpr *result, *left, *right; - CHECK_RESULT(pop_expr(ctx, &right)); - CHECK_RESULT(pop_expr(ctx, &left)); - result = wasm_new_compare_expr(ctx->allocator); - result->compare.opcode = opcode; - result->compare.left = left; - result->compare.right = right; - push_expr(ctx, result); - return WASM_OK; -} - -static WasmResult on_convert_expr(WasmOpcode opcode, void* user_data) { - Context* ctx = user_data; - LOGF("%" PRIzd ": %s\n", ctx->expr_stack_size, s_opcode_name[opcode]); - WasmExpr *result, *expr; - CHECK_RESULT(pop_expr(ctx, &expr)); - result = wasm_new_convert_expr(ctx->allocator); - result->convert.opcode = opcode; - result->convert.expr = expr; - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_binary_expr(ctx->allocator); + expr->binary.opcode = opcode; + return append_expr(ctx, expr); } static WasmResult on_block_expr(void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": block\n", ctx->expr_stack_size); - WasmExpr* result; - result = wasm_new_block_expr(ctx->allocator); - push_label(ctx, LABEL_TYPE_BLOCK, result); - return WASM_OK; -} - -static WasmResult on_loop_expr(void* user_data) { - Context* ctx = user_data; - LOGF("%" PRIzd ": loop\n", ctx->expr_stack_size); - WasmExpr* result; - result = wasm_new_loop_expr(ctx->allocator); - push_label(ctx, LABEL_TYPE_LOOP, result); - return WASM_OK; -} - -static WasmResult on_if_expr(void* user_data) { - Context* ctx = user_data; - LOGF("%" PRIzd ": if\n", ctx->expr_stack_size); - WasmExpr *cond, *result; - CHECK_RESULT(pop_expr(ctx, &cond)); - result = wasm_new_if_expr(ctx->allocator); - result->if_.cond = cond; - push_label(ctx, LABEL_TYPE_IF, result); - return WASM_OK; -} - -static WasmResult on_else_expr(void* user_data) { - Context* ctx = user_data; - LOGF("%" PRIzd ": else\n", ctx->expr_stack_size); - LabelNode* label; - CHECK_RESULT(top_label(ctx, &label)); - if (label->type != LABEL_TYPE_IF) { - print_error(ctx, "else expression without matching if"); - return WASM_ERROR; - } - - /* destroy the if expr, replace it with an if_else */ - /* TODO(binji): remove if_else and just have false branch be an empty block - * for if without else? */ - WasmExpr* cond = label->expr->if_.cond; - label->expr->if_.cond = NULL; - wasm_free(ctx->allocator, label->expr); - - WasmExpr* result; - result = wasm_new_if_else_expr(ctx->allocator); - result->if_else.cond = cond; - pop_into_expr_list(ctx, label->expr_stack_top, &result->if_else.true_.first); - label->type = LABEL_TYPE_ELSE; - label->expr = result; - return WASM_OK; -} - -static WasmResult on_end_expr(void* user_data) { - Context* ctx = user_data; - LOGF("%" PRIzd ": end\n", ctx->expr_stack_size); - LabelNode* label; - CHECK_RESULT(top_label(ctx, &label)); - WasmExpr* expr = label->expr; - - switch (label->type) { - case LABEL_TYPE_IF: - pop_into_expr_list(ctx, label->expr_stack_top, &expr->if_.true_.first); - break; - - case LABEL_TYPE_ELSE: - pop_into_expr_list(ctx, label->expr_stack_top, - &expr->if_else.false_.first); - break; - - case LABEL_TYPE_BLOCK: - pop_into_expr_list(ctx, label->expr_stack_top, &expr->block.first); - break; - - case LABEL_TYPE_LOOP: - pop_into_expr_list(ctx, label->expr_stack_top, &expr->loop.first); - break; - - default: - assert(0); - return WASM_ERROR; - } - - CHECK_RESULT(pop_label(ctx)); - push_expr(ctx, expr); + WasmExpr* expr = wasm_new_block_expr(ctx->allocator); + append_expr(ctx, expr); + push_label(ctx, &expr->block.first); return WASM_OK; } static WasmResult on_br_expr(uint8_t arity, uint32_t depth, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": br:%d %u\n", ctx->expr_stack_size, arity, depth); - WasmExpr *result, *expr; - CHECK_RESULT(pop_expr_if(ctx, &expr, arity == 1)); - result = wasm_new_br_expr(ctx->allocator); - result->br.var.type = WASM_VAR_TYPE_INDEX; - CHECK_DEPTH(depth); - result->br.var.index = depth; - result->br.expr = expr; - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_br_expr(ctx->allocator); + expr->br.var.type = WASM_VAR_TYPE_INDEX; + expr->br.arity = arity; + expr->br.var.index = depth; + return append_expr(ctx, expr); } static WasmResult on_br_if_expr(uint8_t arity, uint32_t depth, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": br_if:%d %u\n", ctx->expr_stack_size, arity, depth); - WasmExpr *result, *cond, *expr; - CHECK_RESULT(pop_expr(ctx, &cond)); - CHECK_RESULT(pop_expr_if(ctx, &expr, arity == 1)); - result = wasm_new_br_if_expr(ctx->allocator); - result->br_if.var.type = WASM_VAR_TYPE_INDEX; - CHECK_DEPTH(depth); - result->br_if.var.index = depth; - result->br_if.cond = cond; - result->br_if.expr = expr; - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_br_if_expr(ctx->allocator); + expr->br_if.arity = arity; + expr->br_if.var.type = WASM_VAR_TYPE_INDEX; + expr->br_if.var.index = depth; + return append_expr(ctx, expr); } static WasmResult on_br_table_expr(uint8_t arity, @@ -626,177 +353,157 @@ static WasmResult on_br_table_expr(uint8_t arity, uint32_t default_target_depth, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": br_table:%d %u\n", ctx->expr_stack_size, arity, - num_targets); - WasmExpr *result, *expr, *key; - CHECK_RESULT(pop_expr(ctx, &key)); - CHECK_RESULT(pop_expr_if(ctx, &expr, arity == 1)); - result = wasm_new_br_table_expr(ctx->allocator); - wasm_reserve_vars(ctx->allocator, &result->br_table.targets, num_targets); - result->br_table.key = key; - result->br_table.expr = expr; - result->br_table.targets.size = num_targets; + WasmExpr* expr = wasm_new_br_table_expr(ctx->allocator); + wasm_reserve_vars(ctx->allocator, &expr->br_table.targets, num_targets); + expr->br_table.arity = arity; + expr->br_table.targets.size = num_targets; uint32_t i; for (i = 0; i < num_targets; ++i) { - WasmVar* var = &result->br_table.targets.data[i]; + WasmVar* var = &expr->br_table.targets.data[i]; var->type = WASM_VAR_TYPE_INDEX; - CHECK_DEPTH(target_depths[i]); var->index = target_depths[i]; } - result->br_table.default_target.type = WASM_VAR_TYPE_INDEX; - CHECK_DEPTH(default_target_depth); - result->br_table.default_target.index = default_target_depth; - push_expr(ctx, result); - return WASM_OK; + expr->br_table.default_target.type = WASM_VAR_TYPE_INDEX; + expr->br_table.default_target.index = default_target_depth; + return append_expr(ctx, expr); } static WasmResult on_call_expr(uint32_t arity, uint32_t func_index, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": call:%d %d\n", ctx->expr_stack_size, arity, func_index); assert(func_index < ctx->module->funcs.size); - WasmFunc* func = ctx->module->funcs.data[func_index]; - uint32_t sig_index = (uint32_t)func->decl.type_var.index; - assert(sig_index < ctx->module->func_types.size); - WasmFuncType* func_type = ctx->module->func_types.data[sig_index]; - - WasmExpr* result; - result = wasm_new_call_expr(ctx->allocator); - result->call.var.type = WASM_VAR_TYPE_INDEX; - result->call.var.index = func_index; - result->call.num_args = func_type->sig.param_types.size; - CHECK_RESULT(pop_into_args(ctx, &func_type->sig, &result->call.first_arg)); - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_call_expr(ctx->allocator); + expr->call.var.type = WASM_VAR_TYPE_INDEX; + expr->call.var.index = func_index; + return append_expr(ctx, expr); } static WasmResult on_call_import_expr(uint32_t arity, uint32_t import_index, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": call_import:%d %u\n", ctx->expr_stack_size, arity, - import_index); assert(import_index < ctx->module->imports.size); - WasmImport* import = ctx->module->imports.data[import_index]; - uint32_t sig_index = (uint32_t)import->decl.type_var.index; - assert(sig_index < ctx->module->func_types.size); - WasmFuncType* func_type = ctx->module->func_types.data[sig_index]; - - WasmExpr* result; - result = wasm_new_call_import_expr(ctx->allocator); - result->call.var.type = WASM_VAR_TYPE_INDEX; - result->call.var.index = import_index; - result->call.num_args = func_type->sig.param_types.size; - CHECK_RESULT(pop_into_args(ctx, &func_type->sig, &result->call.first_arg)); - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_call_import_expr(ctx->allocator); + expr->call.var.type = WASM_VAR_TYPE_INDEX; + expr->call.var.index = import_index; + return append_expr(ctx, expr); } static WasmResult on_call_indirect_expr(uint32_t arity, uint32_t sig_index, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": call_indirect:%d %u\n", ctx->expr_stack_size, arity, - sig_index); assert(sig_index < ctx->module->func_types.size); - WasmFuncType* func_type = ctx->module->func_types.data[sig_index]; - - WasmExpr* result; - result = wasm_new_call_indirect_expr(ctx->allocator); - result->call_indirect.var.type = WASM_VAR_TYPE_INDEX; - result->call_indirect.var.index = sig_index; - result->call_indirect.num_args = func_type->sig.param_types.size; - CHECK_RESULT( - pop_into_args(ctx, &func_type->sig, &result->call_indirect.first_arg)); - CHECK_RESULT(pop_expr(ctx, &result->call_indirect.expr)); - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_call_indirect_expr(ctx->allocator); + expr->call_indirect.var.type = WASM_VAR_TYPE_INDEX; + expr->call_indirect.var.index = sig_index; + return append_expr(ctx, expr); } -static WasmResult on_i32_const_expr(uint32_t value, void* user_data) { +static WasmResult on_compare_expr(WasmOpcode opcode, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": i32.const %u\n", ctx->expr_stack_size, value); - WasmExpr* result = wasm_new_const_expr(ctx->allocator); - result->const_.type = WASM_TYPE_I32; - result->const_.u32 = value; - push_expr(ctx, result); - return WASM_OK; + WasmExpr *expr = wasm_new_compare_expr(ctx->allocator); + expr->compare.opcode = opcode; + return append_expr(ctx, expr); } -static WasmResult on_i64_const_expr(uint64_t value, void* user_data) { +static WasmResult on_convert_expr(WasmOpcode opcode, void* user_data) { + Context* ctx = user_data; + WasmExpr* expr = wasm_new_convert_expr(ctx->allocator); + expr->convert.opcode = opcode; + return append_expr(ctx, expr); +} + +static WasmResult on_current_memory_expr(void* user_data) { + Context* ctx = user_data; + WasmExpr* expr = wasm_new_current_memory_expr(ctx->allocator); + return append_expr(ctx, expr); +} + +static WasmResult on_drop_expr(void* user_data) { + Context* ctx = user_data; + WasmExpr* expr = wasm_new_drop_expr(ctx->allocator); + return append_expr(ctx, expr); +} + +static WasmResult on_else_expr(void* user_data) { + /* destroy the if expr, replace it with an if_else */ + /* TODO(binji): remove if_else and just have false branch be an empty block + * for if without else? */ Context* ctx = user_data; - LOGF("%" PRIzd ": i64.const %" PRIu64 "\n", ctx->expr_stack_size, value); - WasmExpr* result = wasm_new_const_expr(ctx->allocator); - result->const_.type = WASM_TYPE_I64; - result->const_.u64 = value; - push_expr(ctx, result); + CHECK_RESULT(pop_label(ctx)); + LabelNode* label; + CHECK_RESULT(top_label(ctx, &label)); + WasmExpr* if_expr = label->last; + if (if_expr->type != WASM_EXPR_TYPE_IF) { + print_error(ctx, "else expression without matching if"); + return WASM_ERROR; + } + + WasmExpr* if_else_expr = wasm_new_if_else_expr(ctx->allocator); + if_else_expr->if_else.true_.first = if_expr->if_.true_.first; + wasm_free(ctx->allocator, if_expr); + push_label(ctx, &if_else_expr->if_else.false_.first); return WASM_OK; } +static WasmResult on_end_expr(void* user_data) { + Context* ctx = user_data; + return pop_label(ctx); +} + static WasmResult on_f32_const_expr(uint32_t value_bits, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": f32.const %u\n", ctx->expr_stack_size, value_bits); - WasmExpr* result = wasm_new_const_expr(ctx->allocator); - result->const_.type = WASM_TYPE_F32; - result->const_.f32_bits = value_bits; - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_const_expr(ctx->allocator); + expr->const_.type = WASM_TYPE_F32; + expr->const_.f32_bits = value_bits; + return append_expr(ctx, expr); } static WasmResult on_f64_const_expr(uint64_t value_bits, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": f64.const %" PRIu64 "\n", ctx->expr_stack_size, value_bits); - WasmExpr* result = wasm_new_const_expr(ctx->allocator); - result->const_.type = WASM_TYPE_F64; - result->const_.f64_bits = value_bits; - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_const_expr(ctx->allocator); + expr->const_.type = WASM_TYPE_F64; + expr->const_.f64_bits = value_bits; + return append_expr(ctx, expr); } static WasmResult on_get_local_expr(uint32_t local_index, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": get_local %u\n", ctx->expr_stack_size, local_index); - WasmExpr* result; - result = wasm_new_get_local_expr(ctx->allocator); - result->get_local.var.type = WASM_VAR_TYPE_INDEX; - result->get_local.var.index = local_index; - CHECK_LOCAL(local_index); - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_get_local_expr(ctx->allocator); + expr->get_local.var.type = WASM_VAR_TYPE_INDEX; + expr->get_local.var.index = local_index; + return append_expr(ctx, expr); } -static WasmResult on_set_local_expr(uint32_t local_index, void* user_data) { +static WasmResult on_grow_memory_expr(void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": set_local %u\n", ctx->expr_stack_size, local_index); - WasmExpr *result, *expr; - CHECK_RESULT(pop_expr(ctx, &expr)); - result = wasm_new_set_local_expr(ctx->allocator); - result->set_local.var.type = WASM_VAR_TYPE_INDEX; - result->set_local.var.index = local_index; - result->set_local.expr = expr; - CHECK_LOCAL(local_index); - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_grow_memory_expr(ctx->allocator); + return append_expr(ctx, expr); } -static WasmResult on_grow_memory_expr(void* user_data) { +static WasmResult on_i32_const_expr(uint32_t value, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": grow_memory\n", ctx->expr_stack_size); - WasmExpr *result, *expr; - CHECK_RESULT(pop_expr(ctx, &expr)); - result = wasm_new_grow_memory_expr(ctx->allocator); - result->grow_memory.expr = expr; - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_const_expr(ctx->allocator); + expr->const_.type = WASM_TYPE_I32; + expr->const_.u32 = value; + return append_expr(ctx, expr); } -static WasmResult on_current_memory_expr(void* user_data) { +static WasmResult on_i64_const_expr(uint64_t value, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": current_memory\n", ctx->expr_stack_size); - WasmExpr* result; - result = wasm_new_empty_expr(ctx->allocator, WASM_EXPR_TYPE_CURRENT_MEMORY); - push_expr(ctx, result); + WasmExpr* expr = wasm_new_const_expr(ctx->allocator); + expr->const_.type = WASM_TYPE_I64; + expr->const_.u64 = value; + return append_expr(ctx, expr); +} + +static WasmResult on_if_expr(void* user_data) { + Context* ctx = user_data; + WasmExpr* expr = wasm_new_if_expr(ctx->allocator); + append_expr(ctx, expr); + push_label(ctx, &expr->if_.true_.first); return WASM_OK; } @@ -805,80 +512,84 @@ static WasmResult on_load_expr(WasmOpcode opcode, uint32_t offset, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": %s align=%u offset=%u\n", ctx->expr_stack_size, - s_opcode_name[opcode], alignment_log2, offset); - WasmExpr *result, *addr; - CHECK_RESULT(pop_expr(ctx, &addr)); - result = wasm_new_load_expr(ctx->allocator); - result->load.opcode = opcode; - result->load.align = 1 << alignment_log2; - result->load.offset = offset; - result->load.addr = addr; - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_load_expr(ctx->allocator); + expr->load.opcode = opcode; + expr->load.align = 1 << alignment_log2; + expr->load.offset = offset; + return append_expr(ctx, expr); } -static WasmResult on_store_expr(WasmOpcode opcode, - uint32_t alignment_log2, - uint32_t offset, - void* user_data) { +static WasmResult on_loop_expr(void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": %s align=%u offset=%u\n", ctx->expr_stack_size, - s_opcode_name[opcode], alignment_log2, offset); - WasmExpr *result, *addr, *value; - CHECK_RESULT(pop_expr(ctx, &value)); - CHECK_RESULT(pop_expr(ctx, &addr)); - result = wasm_new_store_expr(ctx->allocator); - result->store.opcode = opcode; - result->store.align = 1 << alignment_log2; - result->store.offset = offset; - result->store.addr = addr; - result->store.value = value; - push_expr(ctx, result); + WasmExpr* expr = wasm_new_loop_expr(ctx->allocator); + append_expr(ctx, expr); + push_label(ctx, &expr->loop.first); return WASM_OK; } static WasmResult on_nop_expr(void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": nop\n", ctx->expr_stack_size); - WasmExpr* result; - result = wasm_new_empty_expr(ctx->allocator, WASM_EXPR_TYPE_NOP); - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_nop_expr(ctx->allocator); + return append_expr(ctx, expr); } static WasmResult on_return_expr(uint8_t arity, void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": return:%d\n", ctx->expr_stack_size, arity); - WasmExpr *result, *expr; - CHECK_RESULT(pop_expr_if(ctx, &expr, arity == 1)); - result = wasm_new_return_expr(ctx->allocator); - result->return_.expr = expr; - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_return_expr(ctx->allocator); + return append_expr(ctx, expr); } static WasmResult on_select_expr(void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": select\n", ctx->expr_stack_size); - WasmExpr *result, *true_, *false_, *cond; - CHECK_RESULT(pop_expr(ctx, &cond)); - CHECK_RESULT(pop_expr(ctx, &false_)); - CHECK_RESULT(pop_expr(ctx, &true_)); - result = wasm_new_select_expr(ctx->allocator); - result->select.cond = cond; - result->select.true_ = true_; - result->select.false_ = false_; - push_expr(ctx, result); - return WASM_OK; + WasmExpr* expr = wasm_new_select_expr(ctx->allocator); + return append_expr(ctx, expr); +} + +static WasmResult on_set_local_expr(uint32_t local_index, void* user_data) { + Context* ctx = user_data; + WasmExpr* expr = wasm_new_set_local_expr(ctx->allocator); + expr->set_local.var.type = WASM_VAR_TYPE_INDEX; + expr->set_local.var.index = local_index; + return append_expr(ctx, expr); +} + +static WasmResult on_store_expr(WasmOpcode opcode, + uint32_t alignment_log2, + uint32_t offset, + void* user_data) { + Context* ctx = user_data; + WasmExpr* expr = wasm_new_store_expr(ctx->allocator); + expr->store.opcode = opcode; + expr->store.align = 1 << alignment_log2; + expr->store.offset = offset; + return append_expr(ctx, expr); +} + +static WasmResult on_tee_local_expr(uint32_t local_index, void* user_data) { + Context* ctx = user_data; + WasmExpr* expr = wasm_new_tee_local_expr(ctx->allocator); + expr->tee_local.var.type = WASM_VAR_TYPE_INDEX; + expr->tee_local.var.index = local_index; + return append_expr(ctx, expr); +} + +static WasmResult on_unary_expr(WasmOpcode opcode, void* user_data) { + Context* ctx = user_data; + WasmExpr* expr = wasm_new_unary_expr(ctx->allocator); + expr->unary.opcode = opcode; + return append_expr(ctx, expr); } static WasmResult on_unreachable_expr(void* user_data) { Context* ctx = user_data; - LOGF("%" PRIzd ": unreachable\n", ctx->expr_stack_size); - WasmExpr* result; - result = wasm_new_empty_expr(ctx->allocator, WASM_EXPR_TYPE_UNREACHABLE); - push_expr(ctx, result); + WasmExpr* expr = wasm_new_unreachable_expr(ctx->allocator); + return append_expr(ctx, expr); +} + +static WasmResult end_function_body(uint32_t index, void* user_data) { + Context* ctx = user_data; + CHECK_RESULT(pop_label(ctx)); + ctx->current_func = NULL; return WASM_OK; } @@ -1055,6 +766,8 @@ static WasmBinaryReader s_binary_reader = { .on_call_indirect_expr = &on_call_indirect_expr, .on_compare_expr = &on_compare_expr, .on_convert_expr = &on_convert_expr, + .on_current_memory_expr = &on_current_memory_expr, + .on_drop_expr = &on_drop_expr, .on_else_expr = &on_else_expr, .on_end_expr = &on_end_expr, .on_f32_const_expr = &on_f32_const_expr, @@ -1066,12 +779,12 @@ static WasmBinaryReader s_binary_reader = { .on_if_expr = &on_if_expr, .on_load_expr = &on_load_expr, .on_loop_expr = &on_loop_expr, - .on_current_memory_expr = &on_current_memory_expr, .on_nop_expr = &on_nop_expr, .on_return_expr = &on_return_expr, .on_select_expr = &on_select_expr, .on_set_local_expr = &on_set_local_expr, .on_store_expr = &on_store_expr, + .on_tee_local_expr = &on_tee_local_expr, .on_unary_expr = &on_unary_expr, .on_unreachable_expr = &on_unreachable_expr, .end_function_body = &end_function_body, @@ -1091,8 +804,8 @@ static WasmBinaryReader s_binary_reader = { }; static void wasm_destroy_label_node(WasmAllocator* allocator, LabelNode* node) { - if (node->expr) - wasm_destroy_expr(allocator, node->expr); + if (*node->first) + wasm_destroy_expr_list(allocator, *node->first); } WasmResult wasm_read_binary_ast(struct WasmAllocator* allocator, @@ -1115,6 +828,5 @@ WasmResult wasm_read_binary_ast(struct WasmAllocator* allocator, WasmResult result = wasm_read_binary(allocator, data, size, &reader, 1, options); WASM_DESTROY_VECTOR_AND_ELEMENTS(allocator, ctx.label_stack, label_node); - wasm_destroy_expr_list(allocator, ctx.expr_stack_top); return result; } diff --git a/src/wasm-binary-reader.h b/src/wasm-binary-reader.h index 3571d9cb..d733e470 100644 --- a/src/wasm-binary-reader.h +++ b/src/wasm-binary-reader.h @@ -122,6 +122,7 @@ typedef struct WasmBinaryReader { void* user_data); WasmResult (*on_compare_expr)(WasmOpcode opcode, void* user_data); WasmResult (*on_convert_expr)(WasmOpcode opcode, void* user_data); + WasmResult (*on_drop_expr)(void* user_data); WasmResult (*on_else_expr)(void* user_data); WasmResult (*on_end_expr)(void* user_data); WasmResult (*on_f32_const_expr)(uint32_t value_bits, void* user_data); @@ -145,6 +146,7 @@ typedef struct WasmBinaryReader { uint32_t alignment_log2, uint32_t offset, void* user_data); + WasmResult (*on_tee_local_expr)(uint32_t local_index, void* user_data); WasmResult (*on_unary_expr)(WasmOpcode opcode, void* user_data); WasmResult (*on_unreachable_expr)(void* user_data); WasmResult (*end_function_body)(uint32_t index, void* user_data); diff --git a/src/wasm-binary-writer-spec.c b/src/wasm-binary-writer-spec.c index 1185c0d3..25792f64 100644 --- a/src/wasm-binary-writer-spec.c +++ b/src/wasm-binary-writer-spec.c @@ -48,38 +48,44 @@ typedef struct Context { WasmResult result; } Context; -static WasmExpr* create_const_expr(WasmAllocator* allocator, - WasmConst* const_) { +typedef struct ExprList { + WasmExpr* first; + WasmExpr* last; +} ExprList; + +static void append_expr(ExprList* expr_list, WasmExpr* expr) { + if (expr_list->last) + expr_list->last->next = expr; + else + expr_list->first = expr; + expr_list->last = expr; +} + +static void append_const_expr(WasmAllocator* allocator, + ExprList* expr_list, + WasmConst* const_) { WasmExpr* expr = wasm_new_const_expr(allocator); expr->const_ = *const_; - return expr; + append_expr(expr_list, expr); } -static WasmExpr* create_invoke_expr(WasmAllocator* allocator, - WasmCommandInvoke* invoke, - int func_index) { +static void append_invoke_expr(WasmAllocator* allocator, + ExprList* expr_list, + WasmCommandInvoke* invoke, + int func_index) { + size_t i; + for (i = 0; i < invoke->args.size; ++i) + append_const_expr(allocator, expr_list, &invoke->args.data[i]); + WasmExpr* expr = wasm_new_call_expr(allocator); expr->call.var.type = WASM_VAR_TYPE_INDEX; expr->call.var.index = func_index; - expr->call.num_args = invoke->args.size; - WasmExpr* arg; - WasmExpr* prev_arg = NULL; - size_t i; - for (i = 0; i < invoke->args.size; ++i) { - arg = create_const_expr(allocator, &invoke->args.data[i]); - if (prev_arg) - prev_arg->next = arg; - else - expr->call.first_arg = arg; - prev_arg = arg; - } - return expr; + append_expr(expr_list, expr); } -static WasmExpr* create_eq_expr(WasmAllocator* allocator, - WasmType type, - WasmExpr* left, - WasmExpr* right) { +static void append_eq_expr(WasmAllocator* allocator, + ExprList* expr_list, + WasmType type) { WasmExpr* expr = wasm_new_compare_expr(allocator); switch (type) { case WASM_TYPE_I32: @@ -97,15 +103,12 @@ static WasmExpr* create_eq_expr(WasmAllocator* allocator, default: assert(0); } - expr->compare.left = left; - expr->compare.right = right; - return expr; + append_expr(expr_list, expr); } -static WasmExpr* create_ne_expr(WasmAllocator* allocator, - WasmType type, - WasmExpr* left, - WasmExpr* right) { +static void append_ne_expr(WasmAllocator* allocator, + ExprList* expr_list, + WasmType type) { WasmExpr* expr = wasm_new_compare_expr(allocator); switch (type) { case WASM_TYPE_I32: @@ -123,45 +126,43 @@ static WasmExpr* create_ne_expr(WasmAllocator* allocator, default: assert(0); } - expr->compare.left = left; - expr->compare.right = right; - return expr; + append_expr(expr_list, expr); } -static WasmExpr* create_set_local_expr(WasmAllocator* allocator, - int index, - WasmExpr* value) { - WasmExpr* expr = wasm_new_set_local_expr(allocator); - expr->set_local.var.type = WASM_VAR_TYPE_INDEX; - expr->set_local.var.index = index; - expr->set_local.expr = value; - return expr; +static void append_tee_local_expr(WasmAllocator* allocator, + ExprList* expr_list, + int index) { + WasmExpr* expr = wasm_new_tee_local_expr(allocator); + expr->tee_local.var.type = WASM_VAR_TYPE_INDEX; + expr->tee_local.var.index = index; + append_expr(expr_list, expr); } -static WasmExpr* create_get_local_expr(WasmAllocator* allocator, int index) { +static void append_get_local_expr(WasmAllocator* allocator, + ExprList* expr_list, + int index) { WasmExpr* expr = wasm_new_get_local_expr(allocator); expr->get_local.var.type = WASM_VAR_TYPE_INDEX; expr->get_local.var.index = index; - return expr; + append_expr(expr_list, expr); } -static WasmExpr* create_reinterpret_expr(WasmAllocator* allocator, - WasmType type, - WasmExpr* expr) { - WasmExpr* result = wasm_new_convert_expr(allocator); +static void append_reinterpret_expr(WasmAllocator* allocator, + ExprList* expr_list, + WasmType type) { + WasmExpr* expr = wasm_new_convert_expr(allocator); switch (type) { case WASM_TYPE_F32: - result->convert.opcode = WASM_OPCODE_I32_REINTERPRET_F32; + expr->convert.opcode = WASM_OPCODE_I32_REINTERPRET_F32; break; case WASM_TYPE_F64: - result->convert.opcode = WASM_OPCODE_I64_REINTERPRET_F64; + expr->convert.opcode = WASM_OPCODE_I64_REINTERPRET_F64; break; default: assert(0); break; } - result->convert.expr = expr; - return result; + append_expr(expr_list, expr); } static WasmModuleField* append_module_field( @@ -273,6 +274,7 @@ static void write_module(Context* ctx, uint32_t index, WasmModule* module) { static void write_commands(Context* ctx, WasmScript* script) { uint32_t i; uint32_t num_modules = 0; + WasmAllocator* allocator = script->allocator; WasmModule* last_module = NULL; uint32_t num_assert_funcs = 0; for (i = 0; i < script->commands.size; ++i) { @@ -322,7 +324,7 @@ static void write_commands(Context* ctx, WasmScript* script) { callee = NULL; WasmStringSlice name = - create_assert_func_name(script->allocator, format, num_assert_funcs); + create_assert_func_name(allocator, format, num_assert_funcs); CALLBACK(ctx, on_command, num_assert_funcs, command->type, &name, &invoke->loc); @@ -331,80 +333,78 @@ static void write_commands(Context* ctx, WasmScript* script) { switch (command->type) { case WASM_COMMAND_TYPE_INVOKE: { - WasmFunc* caller = append_nullary_func(script->allocator, last_module, - result_type, name); - caller->first_expr = create_invoke_expr(script->allocator, - &command->invoke, func_index); + WasmFunc* caller = + append_nullary_func(allocator, last_module, result_type, name); + ExprList expr_list; + WASM_ZERO_MEMORY(expr_list); + append_invoke_expr(allocator, &expr_list, &command->invoke, + func_index); + caller->first_expr = expr_list.first; break; } case WASM_COMMAND_TYPE_ASSERT_RETURN: { - WasmFunc* caller = append_nullary_func(script->allocator, last_module, - WASM_TYPE_I32, name); - - WasmExpr* invoke_expr = create_invoke_expr( - script->allocator, &command->assert_return.invoke, func_index); + WasmFunc* caller = + append_nullary_func(allocator, last_module, WASM_TYPE_I32, name); + ExprList expr_list; + WASM_ZERO_MEMORY(expr_list); + append_invoke_expr(allocator, &expr_list, + &command->assert_return.invoke, func_index); if (result_type == WASM_TYPE_VOID) { /* The return type of the assert_return function is i32, but this invoked function has a return type of void, so we have nothing to compare to. Just return 1 to the caller, signifying everything is OK. */ - caller->first_expr = invoke_expr; WasmConst const_; const_.type = WASM_TYPE_I32; const_.u32 = 1; - invoke_expr->next = create_const_expr(script->allocator, &const_); + append_const_expr(allocator, &expr_list, &const_); } else { WasmConst* expected = &command->assert_return.expected; - WasmExpr* const_expr = - create_const_expr(script->allocator, expected); - if (expected->type == WASM_TYPE_F32) { - caller->first_expr = create_eq_expr( - script->allocator, WASM_TYPE_I32, - create_reinterpret_expr(script->allocator, WASM_TYPE_F32, - invoke_expr), - create_reinterpret_expr(script->allocator, WASM_TYPE_F32, - const_expr)); + append_reinterpret_expr(allocator, &expr_list, WASM_TYPE_F32); + append_const_expr(allocator, &expr_list, expected); + append_reinterpret_expr(allocator, &expr_list, WASM_TYPE_F32); + append_eq_expr(allocator, &expr_list, WASM_TYPE_I32); } else if (expected->type == WASM_TYPE_F64) { - caller->first_expr = create_eq_expr( - script->allocator, WASM_TYPE_I64, - create_reinterpret_expr(script->allocator, WASM_TYPE_F64, - invoke_expr), - create_reinterpret_expr(script->allocator, WASM_TYPE_F64, - const_expr)); + append_reinterpret_expr(allocator, &expr_list, WASM_TYPE_F64); + append_const_expr(allocator, &expr_list, expected); + append_reinterpret_expr(allocator, &expr_list, WASM_TYPE_F64); + append_eq_expr(allocator, &expr_list, WASM_TYPE_I64); } else { - caller->first_expr = create_eq_expr( - script->allocator, result_type, invoke_expr, const_expr); + append_const_expr(allocator, &expr_list, expected); + append_eq_expr(allocator, &expr_list, result_type); } } + caller->first_expr = expr_list.first; break; } case WASM_COMMAND_TYPE_ASSERT_RETURN_NAN: { - WasmFunc* caller = append_nullary_func(script->allocator, last_module, - WASM_TYPE_I32, name); - wasm_append_type_value(script->allocator, &caller->local_types, - &result_type); - caller->first_expr = create_set_local_expr( - script->allocator, 0, - create_invoke_expr(script->allocator, - &command->assert_return_nan.invoke, - func_index)); + WasmFunc* caller = + append_nullary_func(allocator, last_module, WASM_TYPE_I32, name); + wasm_append_type_value(allocator, &caller->local_types, &result_type); + ExprList expr_list; + WASM_ZERO_MEMORY(expr_list); + append_invoke_expr(allocator, &expr_list, + &command->assert_return_nan.invoke, func_index); + append_tee_local_expr(allocator, &expr_list, 0); + append_get_local_expr(allocator, &expr_list, 0); /* x != x is true iff x is NaN */ - caller->first_expr->next = - create_ne_expr(script->allocator, result_type, - create_get_local_expr(script->allocator, 0), - create_get_local_expr(script->allocator, 0)); + append_ne_expr(allocator, &expr_list, result_type); + caller->first_expr = expr_list.first; break; } case WASM_COMMAND_TYPE_ASSERT_TRAP: { - WasmFunc* caller = append_nullary_func(script->allocator, last_module, - result_type, name); - caller->first_expr = create_invoke_expr(script->allocator, - &command->invoke, func_index); + WasmFunc* caller = + append_nullary_func(allocator, last_module, result_type, name); + ExprList expr_list; + WASM_ZERO_MEMORY(expr_list); + append_invoke_expr(allocator, &expr_list, &command->invoke, + func_index); + caller->first_expr = expr_list.first; break; } diff --git a/src/wasm-binary-writer.c b/src/wasm-binary-writer.c index b27ced8b..684ea519 100644 --- a/src/wasm-binary-writer.c +++ b/src/wasm-binary-writer.c @@ -71,6 +71,15 @@ typedef struct Context { size_t last_section_leb_size_guess; } Context; +static uint8_t log2_u32(uint32_t x) { + uint8_t result = 0; + while (x > 1) { + x >>= 1; + result++; + } + return result; +} + static void write_header(Context* ctx, const char* name, int index) { if (ctx->log_stream) { if (index == PRINT_HEADER_NO_INDEX) { @@ -265,31 +274,21 @@ static WasmLabelNode* find_label_by_var(WasmLabelNode* top_label, return node; } -static void push_unused_label(Context* ctx, - WasmLabelNode* node, - const WasmLabel* label) { +static void push_label(Context* ctx, + WasmLabelNode* node, + const WasmLabel* label) { assert(label); node->label = label; node->next = ctx->top_label; node->depth = ctx->max_depth; ctx->top_label = node; -} - -static void pop_unused_label(Context* ctx, const WasmLabel* label) { - if (ctx->top_label && ctx->top_label->label == label) - ctx->top_label = ctx->top_label->next; -} - -static void push_label(Context* ctx, - WasmLabelNode* node, - const WasmLabel* label) { - push_unused_label(ctx, node, label); ctx->max_depth++; } static void pop_label(Context* ctx, const WasmLabel* label) { ctx->max_depth--; - pop_unused_label(ctx, label); + if (ctx->top_label && ctx->top_label->label == label) + ctx->top_label = ctx->top_label->next; } static void write_expr_list(Context* ctx, @@ -297,19 +296,12 @@ static void write_expr_list(Context* ctx, const WasmFunc* func, const WasmExpr* first_expr); -static void write_expr_opt(Context* ctx, - const WasmModule* module, - const WasmFunc* func, - const WasmExpr* expr); - static void write_expr(Context* ctx, const WasmModule* module, const WasmFunc* func, const WasmExpr* expr) { switch (expr->type) { case WASM_EXPR_TYPE_BINARY: - write_expr(ctx, module, func, expr->binary.left); - write_expr(ctx, module, func, expr->binary.right); write_opcode(&ctx->stream, expr->binary.opcode); break; case WASM_EXPR_TYPE_BLOCK: { @@ -324,9 +316,8 @@ static void write_expr(Context* ctx, case WASM_EXPR_TYPE_BR: { WasmLabelNode* node = find_label_by_var(ctx->top_label, &expr->br.var); assert(node); - write_expr_opt(ctx, module, func, expr->br.expr); write_opcode(&ctx->stream, WASM_OPCODE_BR); - wasm_write_u8(&ctx->stream, expr->br.expr ? 1 : 0, "br arity"); + wasm_write_u8(&ctx->stream, expr->br.arity, "br arity"); write_u32_leb128(&ctx->stream, ctx->max_depth - node->depth - 1, "break depth"); break; @@ -334,20 +325,15 @@ static void write_expr(Context* ctx, case WASM_EXPR_TYPE_BR_IF: { WasmLabelNode* node = find_label_by_var(ctx->top_label, &expr->br_if.var); assert(node); - write_expr_opt(ctx, module, func, expr->br_if.expr); - write_expr(ctx, module, func, expr->br_if.cond); write_opcode(&ctx->stream, WASM_OPCODE_BR_IF); - wasm_write_u8(&ctx->stream, expr->br_if.expr ? 1 : 0, "br_if arity"); + wasm_write_u8(&ctx->stream, expr->br_if.arity, "br_if arity"); write_u32_leb128(&ctx->stream, ctx->max_depth - node->depth - 1, "break depth"); break; } case WASM_EXPR_TYPE_BR_TABLE: { - write_expr_opt(ctx, module, func, expr->br_table.expr); - write_expr(ctx, module, func, expr->br_table.key); write_opcode(&ctx->stream, WASM_OPCODE_BR_TABLE); - wasm_write_u8(&ctx->stream, expr->br_table.expr ? 1 : 0, - "br_table arity"); + wasm_write_u8(&ctx->stream, expr->br_table.arity, "br_table arity"); write_u32_leb128(&ctx->stream, expr->br_table.targets.size, "num targets"); size_t i; @@ -366,18 +352,14 @@ static void write_expr(Context* ctx, case WASM_EXPR_TYPE_CALL: { int index = wasm_get_func_index_by_var(module, &expr->call.var); assert(index >= 0 && (size_t)index < module->funcs.size); - write_expr_list(ctx, module, func, expr->call.first_arg); write_opcode(&ctx->stream, WASM_OPCODE_CALL_FUNCTION); - write_u32_leb128(&ctx->stream, expr->call.num_args, "call arity"); write_u32_leb128(&ctx->stream, index, "func index"); break; } case WASM_EXPR_TYPE_CALL_IMPORT: { int index = wasm_get_import_index_by_var(module, &expr->call.var); assert(index >= 0 && (size_t)index < module->imports.size); - write_expr_list(ctx, module, func, expr->call.first_arg); write_opcode(&ctx->stream, WASM_OPCODE_CALL_IMPORT); - write_u32_leb128(&ctx->stream, expr->call.num_args, "call_import arity"); write_u32_leb128(&ctx->stream, index, "import index"); break; } @@ -385,17 +367,11 @@ static void write_expr(Context* ctx, int index = wasm_get_func_type_index_by_var(module, &expr->call_indirect.var); assert(index >= 0 && (size_t)index < module->func_types.size); - write_expr(ctx, module, func, expr->call_indirect.expr); - write_expr_list(ctx, module, func, expr->call_indirect.first_arg); write_opcode(&ctx->stream, WASM_OPCODE_CALL_INDIRECT); - write_u32_leb128(&ctx->stream, expr->call_indirect.num_args, - "call_indirect arity"); write_u32_leb128(&ctx->stream, index, "signature index"); break; } case WASM_EXPR_TYPE_COMPARE: - write_expr(ctx, module, func, expr->compare.left); - write_expr(ctx, module, func, expr->compare.right); write_opcode(&ctx->stream, expr->compare.opcode); break; case WASM_EXPR_TYPE_CONST: @@ -424,12 +400,14 @@ static void write_expr(Context* ctx, } break; case WASM_EXPR_TYPE_CONVERT: - write_expr(ctx, module, func, expr->convert.expr); write_opcode(&ctx->stream, expr->convert.opcode); break; case WASM_EXPR_TYPE_CURRENT_MEMORY: write_opcode(&ctx->stream, WASM_OPCODE_CURRENT_MEMORY); break; + case WASM_EXPR_TYPE_DROP: + write_opcode(&ctx->stream, WASM_OPCODE_DROP); + break; case WASM_EXPR_TYPE_GET_LOCAL: { int index = wasm_get_local_index_by_var(func, &expr->get_local.var); write_opcode(&ctx->stream, WASM_OPCODE_GET_LOCAL); @@ -437,12 +415,10 @@ static void write_expr(Context* ctx, break; } case WASM_EXPR_TYPE_GROW_MEMORY: - write_expr(ctx, module, func, expr->grow_memory.expr); write_opcode(&ctx->stream, WASM_OPCODE_GROW_MEMORY); break; case WASM_EXPR_TYPE_IF: { WasmLabelNode node; - write_expr(ctx, module, func, expr->if_.cond); write_opcode(&ctx->stream, WASM_OPCODE_IF); push_label(ctx, &node, &expr->if_.true_.label); write_expr_list(ctx, module, func, expr->if_.true_.first); @@ -452,7 +428,6 @@ static void write_expr(Context* ctx, } case WASM_EXPR_TYPE_IF_ELSE: { WasmLabelNode node; - write_expr(ctx, module, func, expr->if_else.cond); write_opcode(&ctx->stream, WASM_OPCODE_IF); push_label(ctx, &node, &expr->if_else.true_.label); write_expr_list(ctx, module, func, expr->if_else.true_.first); @@ -465,71 +440,55 @@ static void write_expr(Context* ctx, break; } case WASM_EXPR_TYPE_LOAD: { - write_expr(ctx, module, func, expr->load.addr); write_opcode(&ctx->stream, expr->load.opcode); uint32_t align = wasm_get_opcode_alignment(expr->load.opcode, expr->load.align); - uint8_t align_log = 0; - while (align > 1) { - align >>= 1; - align_log++; - } - wasm_write_u8(&ctx->stream, align_log, "alignment"); + wasm_write_u8(&ctx->stream, log2_u32(align), "alignment"); write_u32_leb128(&ctx->stream, (uint32_t)expr->load.offset, "load offset"); break; } case WASM_EXPR_TYPE_LOOP: { - WasmLabelNode outer; - WasmLabelNode inner; - push_label(ctx, &outer, &expr->loop.outer); - push_label(ctx, &inner, &expr->loop.inner); + WasmLabelNode node; + push_label(ctx, &node, &expr->loop.label); write_opcode(&ctx->stream, WASM_OPCODE_LOOP); write_expr_list(ctx, module, func, expr->loop.first); write_opcode(&ctx->stream, WASM_OPCODE_END); - pop_label(ctx, &expr->loop.inner); - pop_label(ctx, &expr->loop.outer); + pop_label(ctx, &expr->loop.label); break; } case WASM_EXPR_TYPE_NOP: write_opcode(&ctx->stream, WASM_OPCODE_NOP); break; case WASM_EXPR_TYPE_RETURN: - write_expr_opt(ctx, module, func, expr->return_.expr); write_opcode(&ctx->stream, WASM_OPCODE_RETURN); - wasm_write_u8(&ctx->stream, expr->return_.expr ? 1 : 0, "return arity"); break; case WASM_EXPR_TYPE_SELECT: - write_expr(ctx, module, func, expr->select.true_); - write_expr(ctx, module, func, expr->select.false_); - write_expr(ctx, module, func, expr->select.cond); write_opcode(&ctx->stream, WASM_OPCODE_SELECT); break; case WASM_EXPR_TYPE_SET_LOCAL: { int index = wasm_get_local_index_by_var(func, &expr->get_local.var); - write_expr(ctx, module, func, expr->set_local.expr); write_opcode(&ctx->stream, WASM_OPCODE_SET_LOCAL); write_u32_leb128(&ctx->stream, index, "local index"); break; } case WASM_EXPR_TYPE_STORE: { - write_expr(ctx, module, func, expr->store.addr); - write_expr(ctx, module, func, expr->store.value); write_opcode(&ctx->stream, expr->store.opcode); uint32_t align = wasm_get_opcode_alignment(expr->store.opcode, expr->store.align); - uint8_t align_log = 0; - while (align > 1) { - align >>= 1; - align_log++; - } - wasm_write_u8(&ctx->stream, align_log, "alignment"); + wasm_write_u8(&ctx->stream, log2_u32(align), "alignment"); write_u32_leb128(&ctx->stream, (uint32_t)expr->store.offset, "store offset"); break; } + case WASM_EXPR_TYPE_TEE_LOCAL: { + int index = wasm_get_local_index_by_var(func, &expr->get_local.var); + write_opcode(&ctx->stream, WASM_OPCODE_TEE_LOCAL); + write_u32_leb128(&ctx->stream, ctx->remapped_locals[index], + "remapped local index"); + break; + } case WASM_EXPR_TYPE_UNARY: - write_expr(ctx, module, func, expr->unary.expr); write_opcode(&ctx->stream, expr->unary.opcode); break; case WASM_EXPR_TYPE_UNREACHABLE: @@ -547,14 +506,6 @@ static void write_expr_list(Context* ctx, write_expr(ctx, module, func, expr); } -static void write_expr_opt(Context* ctx, - const WasmModule* module, - const WasmFunc* func, - const WasmExpr* expr) { - if (expr) - write_expr(ctx, module, func, expr); -} - static void write_func_locals(Context* ctx, const WasmModule* module, const WasmFunc* func, diff --git a/src/wasm-common.h b/src/wasm-common.h index 2655e5bf..8d0e63d7 100644 --- a/src/wasm-common.h +++ b/src/wasm-common.h @@ -146,7 +146,7 @@ enum { WASM_USE_NATURAL_ALIGNMENT = 0xFFFFFFFF }; * tr t1 t2 m code NAME text * ============================ */ #define WASM_FOREACH_OPCODE(V) \ - V(___, ___, ___, 0, 0x00, NOP, "nop") \ + V(___, ___, ___, 0, 0x00, UNREACHABLE, "unreachable") \ V(___, ___, ___, 0, 0x01, BLOCK, "block") \ V(___, ___, ___, 0, 0x02, LOOP, "loop") \ V(___, ___, ___, 0, 0x03, IF, "if") \ @@ -156,7 +156,8 @@ enum { WASM_USE_NATURAL_ALIGNMENT = 0xFFFFFFFF }; V(___, ___, ___, 0, 0x07, BR_IF, "br_if") \ V(___, ___, ___, 0, 0x08, BR_TABLE, "br_table") \ V(___, ___, ___, 0, 0x09, RETURN, "return") \ - V(___, ___, ___, 0, 0x0a, UNREACHABLE, "unreachable") \ + V(___, ___, ___, 0, 0x0a, NOP, "nop") \ + V(___, ___, ___, 0, 0x0b, DROP, "drop") \ V(___, ___, ___, 0, 0x0f, END, "end") \ V(I32, ___, ___, 0, 0x10, I32_CONST, "i32.const") \ V(I64, ___, ___, 0, 0x11, I64_CONST, "i64.const") \ @@ -167,6 +168,7 @@ enum { WASM_USE_NATURAL_ALIGNMENT = 0xFFFFFFFF }; V(___, ___, ___, 0, 0x16, CALL_FUNCTION, "call") \ V(___, ___, ___, 0, 0x17, CALL_INDIRECT, "call_indirect") \ V(___, ___, ___, 0, 0x18, CALL_IMPORT, "call_import") \ + V(___, ___, ___, 0, 0x19, TEE_LOCAL, "tee_local") \ V(I32, I32, ___, 1, 0x20, I32_LOAD8_S, "i32.load8_s") \ V(I32, I32, ___, 1, 0x21, I32_LOAD8_U, "i32.load8_u") \ V(I32, I32, ___, 2, 0x22, I32_LOAD16_S, "i32.load16_s") \ diff --git a/src/wasm-generate-names.c b/src/wasm-generate-names.c index 8cc95009..473bdf5c 100644 --- a/src/wasm-generate-names.c +++ b/src/wasm-generate-names.c @@ -109,9 +109,7 @@ static WasmResult begin_block_expr(WasmExpr* expr, void* user_data) { static WasmResult begin_loop_expr(WasmExpr* expr, void* user_data) { Context* ctx = user_data; maybe_generate_name(ctx->allocator, "$L", ctx->label_count++, - &expr->loop.outer); - maybe_generate_name(ctx->allocator, "$L", ctx->label_count++, - &expr->loop.inner); + &expr->loop.label); return WASM_OK; } diff --git a/src/wast2wasm.c b/src/wast2wasm.c index 6dc4b119..53876cef 100644 --- a/src/wast2wasm.c +++ b/src/wast2wasm.c @@ -400,10 +400,10 @@ int main(int argc, char** argv) { if (WASM_SUCCEEDED(result)) { if (s_check) { /* full validation of the module */ - result = wasm_check_ast(lexer, &script, &s_error_handler); + result = wasm_check_ast(allocator, lexer, &script, &s_error_handler); } else { /* minimal checks necessary to ensure we can generate a binary */ - result = wasm_check_names(lexer, &script, &s_error_handler); + result = wasm_check_names(allocator, lexer, &script, &s_error_handler); } if (WASM_SUCCEEDED(result) && s_check_assert_invalid) { |