diff options
-rw-r--r-- | src/prebuilt/wasm-ast-parser-gen.c | 1395 | ||||
-rw-r--r-- | src/wasm-ast-parser-lexer-shared.c | 10 | ||||
-rw-r--r-- | src/wasm-ast-parser-lexer-shared.h | 12 | ||||
-rw-r--r-- | src/wasm-ast-parser.y | 139 | ||||
-rw-r--r-- | test/parse/module/bad-binary-module-magic.txt | 9 | ||||
-rw-r--r-- | test/parse/module/binary-module.txt | 16 | ||||
-rw-r--r-- | test/parse/module/memory-segment-multi-string.txt | 3 |
7 files changed, 910 insertions, 674 deletions
diff --git a/src/prebuilt/wasm-ast-parser-gen.c b/src/prebuilt/wasm-ast-parser-gen.c index 54b3abdb..f28952aa 100644 --- a/src/prebuilt/wasm-ast-parser-gen.c +++ b/src/prebuilt/wasm-ast-parser-gen.c @@ -80,6 +80,8 @@ #include "wasm-allocator.h" #include "wasm-ast-parser.h" #include "wasm-ast-parser-lexer-shared.h" +#include "wasm-binary-reader-ast.h" +#include "wasm-binary-reader.h" #include "wasm-literal.h" #define DUPTEXT(dst, src) \ @@ -140,18 +142,32 @@ static WasmImport* new_import(WasmAllocator* allocator) { return wasm_alloc_zero(allocator, sizeof(WasmImport), WASM_DEFAULT_ALIGN); } +static WasmTextListNode* new_text_list_node(WasmAllocator* allocator) { + return wasm_alloc_zero(allocator, sizeof(WasmTextListNode), + WASM_DEFAULT_ALIGN); +} + static WasmResult parse_const(WasmType type, WasmLiteralType literal_type, const char* s, const char* end, WasmConst* out); -static WasmResult dup_string_contents(WasmAllocator*, WasmStringSlice* text, - void** out_data, size_t* out_size); +static WasmResult dup_text_list(WasmAllocator*, WasmTextList* text_list, + void** out_data, size_t* out_size); static WasmResult copy_signature_from_func_type( - WasmAllocator * allocator, WasmModule * module, WasmFuncDeclaration * decl); + WasmAllocator* allocator, WasmModule* module, WasmFuncDeclaration* decl); + +typedef struct BinaryErrorCallbackData { + WasmLocation* loc; + WasmAstLexer* lexer; + WasmAstParser* parser; +} BinaryErrorCallbackData; + +static void on_read_binary_error(uint32_t offset, const char* error, + void* user_data); #define wasm_ast_parser_lex wasm_ast_lexer_lex -#line 155 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:339 */ +#line 171 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:339 */ # ifndef YY_NULLPTR # if defined __cplusplus && 201103L <= __cplusplus @@ -281,7 +297,7 @@ int wasm_ast_parser_parse (WasmAstLexer* lexer, WasmAstParser* parser); /* Copy the second part of user declarations. */ -#line 285 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:358 */ +#line 301 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:358 */ #ifdef short # undef short @@ -530,11 +546,11 @@ union yyalloc /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 57 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 42 +#define YYNNTS 43 /* YYNRULES -- Number of rules. */ -#define YYNRULES 114 +#define YYNRULES 117 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 264 +#define YYNSTATES 268 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned by yylex, with out-of-bounds checking. */ @@ -586,18 +602,18 @@ static const yytype_uint8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 184, 184, 185, 191, 192, 196, 200, 207, 212, - 220, 232, 240, 241, 247, 251, 261, 268, 269, 273, - 274, 283, 284, 295, 298, 302, 308, 314, 321, 328, - 337, 343, 350, 357, 364, 370, 375, 383, 391, 398, - 405, 413, 418, 424, 432, 441, 454, 460, 467, 474, - 481, 487, 491, 496, 503, 504, 507, 511, 519, 520, - 525, 532, 538, 546, 552, 558, 568, 571, 635, 641, - 648, 653, 664, 668, 681, 689, 690, 697, 710, 722, - 728, 737, 741, 748, 752, 759, 767, 774, 785, 792, - 798, 801, 810, 819, 827, 835, 843, 851, 859, 869, - 965, 971, 978, 985, 993, 1000, 1010, 1011, 1019, 1031, - 1032, 1035, 1036, 1043, 1052 + 0, 200, 200, 208, 223, 224, 230, 231, 235, 239, + 246, 251, 259, 271, 279, 280, 286, 290, 306, 313, + 314, 318, 319, 328, 329, 340, 343, 347, 353, 359, + 366, 373, 382, 388, 395, 402, 409, 415, 420, 428, + 436, 443, 450, 458, 463, 469, 477, 486, 499, 505, + 512, 519, 526, 532, 536, 541, 548, 549, 552, 556, + 564, 565, 570, 577, 583, 591, 597, 603, 613, 616, + 680, 686, 693, 698, 709, 713, 726, 734, 735, 742, + 755, 767, 773, 782, 786, 793, 797, 804, 812, 819, + 830, 837, 843, 846, 855, 864, 872, 880, 888, 896, + 904, 914, 1004, 1029, 1035, 1042, 1049, 1057, 1064, 1074, + 1075, 1083, 1095, 1096, 1099, 1100, 1107, 1116 }; #endif @@ -615,14 +631,14 @@ static const char *const yytname[] = "MEMORY", "SEGMENT", "IMPORT", "EXPORT", "TABLE", "UNREACHABLE", "CURRENT_MEMORY", "GROW_MEMORY", "ASSERT_INVALID", "ASSERT_RETURN", "ASSERT_RETURN_NAN", "ASSERT_TRAP", "INVOKE", "LOW", "$accept", - "value_type_list", "func_type", "literal", "var", "var_list", "bind_var", - "quoted_text", "string_contents", "labeling", "offset", "align", "expr", - "expr1", "expr_opt", "non_empty_expr_list", "expr_list", "func_fields", - "type_use", "func_info", "func", "start", "segment_address", "segment", - "segment_list", "initial_pages", "max_pages", "memory", "type_def", - "table", "import", "export", "export_memory", "module_fields", "module", - "cmd", "cmd_list", "const", "const_opt", "const_list", "script", - "script_start", YY_NULLPTR + "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", "type_use", "func_info", "func", "start", + "segment_address", "segment", "segment_list", "initial_pages", + "max_pages", "memory", "type_def", "table", "import", "export", + "export_memory", "module_fields", "module", "cmd", "cmd_list", "const", + "const_opt", "const_list", "script", "script_start", YY_NULLPTR }; #endif @@ -640,10 +656,10 @@ static const yytype_uint16 yytoknum[] = }; # endif -#define YYPACT_NINF -168 +#define YYPACT_NINF -175 #define yypact_value_is_default(Yystate) \ - (!!((Yystate) == (-168))) + (!!((Yystate) == (-175))) #define YYTABLE_NINF -1 @@ -654,33 +670,33 @@ static const yytype_uint16 yytoknum[] = STATE-NUM. */ static const yytype_int16 yypact[] = { - -168, 5, -168, 12, -7, -168, -168, -168, -168, 11, - 19, 27, 55, 42, 89, 26, 42, 6, 23, 44, - -168, -168, 58, -168, -168, -168, -168, -168, -168, -168, - -168, -168, 67, 42, 42, 42, 103, 20, 24, 28, - 76, 104, 42, -168, -168, -168, -168, -168, 79, -168, - -168, 168, -168, 71, -168, 110, -168, -168, 128, 130, - -168, -168, 131, 105, 137, -168, 140, 42, 42, 16, - 72, 113, 115, 117, 118, -168, 138, 110, 138, 24, - 24, -168, 24, 24, 24, 110, 24, 24, 129, 129, - 118, 110, 110, 110, 110, 110, 24, 138, 141, 138, - -168, -168, 110, 150, 128, 154, 291, -168, 209, 155, - -168, -168, 157, 125, -168, 122, -168, 42, 159, 160, - 162, -168, -168, 164, 165, 42, -168, -168, 166, -168, - 110, 170, 138, 110, 110, 110, 24, 110, 110, 110, - -168, -168, -168, 110, -168, 134, 134, -168, -168, 110, - 110, -168, 110, 167, 47, 173, 172, 61, 178, -168, - -168, 192, -168, -168, 88, 193, 157, 124, -168, -168, - 126, 159, 46, 200, 206, -168, -168, -168, 207, -168, - 208, -168, -168, 250, 110, 110, -168, -168, 110, 110, - -168, -168, 110, -168, -168, 110, 110, -168, -168, 110, - -168, 128, -168, 210, 128, 128, 211, -168, -168, 204, - 218, 219, 169, -168, 224, 233, -168, -168, -168, -168, - 138, -168, -168, -168, 110, -168, -168, 110, -168, -168, - 128, -168, -168, 128, 63, 234, -168, 241, -168, 239, - -168, -168, 110, -168, -168, -168, -168, 174, -168, -168, - -168, 243, 247, 212, -168, 251, 244, 242, 260, 138, - -168, 110, 265, -168 + -175, 23, -175, 30, -6, -175, -175, -175, 31, 41, + 48, 50, 56, 61, -175, 86, 13, 42, 61, 75, + 79, 80, -175, -175, -175, -175, 29, -175, -175, -175, + -175, -175, -175, -175, -175, -175, 66, 61, 61, 61, + 74, 11, 91, 15, 100, 87, 61, -175, -175, -175, + -175, -175, 83, -175, -175, 168, -175, 126, -175, 128, + -175, -175, 137, 141, -175, -175, 142, 105, 147, -175, + 149, 61, 61, 19, 84, 107, 113, 115, 118, -175, + 150, 128, 150, 91, 91, -175, 91, 91, 91, 128, + 91, 91, 129, 129, 118, 128, 128, 128, 128, 128, + 91, 150, 151, 150, -175, -175, 128, 155, 137, 157, + 291, -175, 209, 158, -175, -175, 160, 130, -175, 117, + -175, 61, 161, 163, 164, -175, -175, 166, 167, 61, + -175, -175, 169, -175, 128, 171, 150, 128, 128, 128, + 91, 128, 128, 128, -175, -175, -175, 128, -175, 148, + 148, -175, -175, 128, 128, -175, 128, 172, 28, 173, + 183, 76, 187, -175, -175, 193, -175, -175, 88, 200, + 160, 170, -175, -175, 122, 161, 63, 206, 207, -175, + -175, -175, 208, -175, 211, -175, -175, 250, 128, 128, + -175, -175, 128, 128, -175, -175, 128, -175, -175, 128, + 128, -175, -175, 128, -175, 137, -175, 218, 137, 137, + 219, -175, -175, 204, 224, 233, 165, -175, 234, 241, + -175, -175, -175, -175, 150, -175, -175, -175, 128, -175, + -175, 128, -175, -175, 137, -175, -175, 137, 77, 242, + -175, 243, -175, 31, -175, -175, 128, -175, -175, -175, + -175, 248, -175, -175, 245, 249, 251, 214, -175, 253, + 255, 264, 265, 150, -175, 128, 275, -175 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -688,53 +704,53 @@ static const yytype_int16 yypact[] = means the default is an error. */ static const yytype_uint8 yydefact[] = { - 106, 113, 114, 0, 0, 100, 107, 1, 90, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 15, 111, 0, 99, 91, 98, 97, 96, 95, 92, - 93, 94, 0, 0, 0, 0, 0, 58, 0, 0, - 0, 0, 0, 12, 102, 111, 111, 111, 0, 101, - 112, 0, 14, 58, 56, 59, 60, 67, 58, 0, - 10, 11, 0, 0, 0, 77, 75, 0, 0, 0, - 0, 0, 0, 0, 0, 24, 17, 0, 17, 0, - 0, 12, 0, 0, 0, 54, 0, 0, 19, 19, - 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, - 51, 52, 0, 0, 58, 0, 0, 57, 0, 0, - 70, 72, 4, 0, 78, 0, 75, 0, 4, 0, - 0, 83, 13, 109, 0, 0, 8, 9, 0, 18, - 58, 0, 18, 58, 54, 0, 0, 58, 58, 0, - 55, 35, 41, 0, 20, 21, 21, 45, 46, 0, - 0, 50, 0, 0, 0, 0, 0, 0, 0, 53, - 23, 0, 71, 68, 0, 0, 4, 0, 80, 76, - 0, 4, 0, 0, 0, 89, 88, 110, 0, 104, - 0, 108, 25, 0, 26, 58, 32, 34, 30, 13, - 38, 39, 58, 42, 22, 0, 0, 47, 49, 0, - 66, 58, 3, 0, 58, 58, 0, 69, 2, 0, - 0, 0, 0, 79, 0, 0, 86, 84, 103, 105, - 17, 28, 33, 31, 36, 40, 43, 0, 48, 61, - 58, 63, 64, 58, 0, 0, 81, 0, 73, 0, - 87, 85, 58, 37, 44, 62, 65, 5, 7, 82, - 16, 0, 0, 0, 74, 27, 0, 0, 0, 17, - 6, 58, 0, 29 + 109, 116, 117, 0, 0, 103, 110, 1, 92, 0, + 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, + 0, 0, 17, 114, 102, 3, 0, 101, 93, 100, + 99, 98, 97, 94, 95, 96, 0, 0, 0, 0, + 0, 60, 0, 0, 0, 0, 0, 14, 105, 114, + 114, 114, 0, 104, 115, 0, 16, 60, 58, 61, + 62, 69, 60, 0, 12, 13, 0, 0, 0, 79, + 77, 0, 0, 0, 0, 0, 0, 0, 0, 26, + 19, 0, 19, 0, 0, 14, 0, 0, 0, 56, + 0, 0, 21, 21, 0, 0, 0, 0, 0, 0, + 0, 4, 0, 4, 53, 54, 0, 0, 60, 0, + 0, 59, 0, 0, 72, 74, 6, 0, 80, 0, + 77, 0, 6, 0, 0, 85, 15, 112, 0, 0, + 10, 11, 0, 20, 60, 0, 20, 60, 56, 0, + 0, 60, 60, 0, 57, 37, 43, 0, 22, 23, + 23, 47, 48, 0, 0, 52, 0, 0, 0, 0, + 0, 0, 0, 55, 25, 0, 73, 70, 0, 0, + 6, 0, 82, 78, 0, 6, 0, 0, 0, 91, + 90, 113, 0, 107, 0, 111, 27, 0, 28, 60, + 34, 36, 32, 15, 40, 41, 60, 44, 24, 0, + 0, 49, 51, 0, 68, 60, 5, 0, 60, 60, + 0, 71, 4, 0, 0, 0, 0, 81, 0, 0, + 88, 86, 106, 108, 19, 30, 35, 33, 38, 42, + 45, 0, 50, 63, 60, 65, 66, 60, 0, 0, + 83, 0, 75, 0, 89, 87, 60, 39, 46, 64, + 67, 7, 9, 84, 18, 0, 0, 0, 76, 29, + 0, 0, 0, 19, 8, 60, 0, 31 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -168, -93, -111, 188, 69, 198, -24, -15, -168, -78, - 197, 109, -52, -168, 153, -168, -128, -167, -49, -42, - -168, -168, -168, -168, 175, -168, -168, -168, -168, -168, - -168, -168, -168, -168, 279, -168, -168, 171, -168, 43, - -168, -168 + -175, 43, -97, -114, 194, 65, 202, -30, -17, -175, + -82, 196, 140, -56, -175, 153, -175, -132, -174, -53, + -50, -175, -175, -175, -175, 174, -175, -175, -175, -175, + -175, -175, -175, -175, -175, 283, -175, -175, 177, -175, + 58, -175, -175 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int16 yydefgoto[] = { - -1, 154, 165, 128, 62, 70, 129, 21, 251, 130, - 145, 195, 54, 103, 141, 55, 56, 57, 58, 59, - 24, 25, 239, 169, 115, 66, 116, 26, 27, 28, - 29, 30, 31, 14, 5, 6, 1, 50, 178, 36, - 2, 3 + -1, 15, 158, 169, 132, 66, 74, 133, 23, 255, + 134, 149, 199, 58, 107, 145, 59, 60, 61, 62, + 63, 28, 29, 243, 173, 119, 70, 120, 30, 31, + 32, 33, 34, 35, 16, 5, 6, 1, 54, 182, + 40, 2, 3 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -742,76 +758,76 @@ static const yytype_int16 yydefgoto[] = number is the opposite. If YYTABLE_NINF, syntax error. */ static const yytype_uint16 yytable[] = { - 133, 32, 182, 107, 104, 186, 157, 173, 4, 190, - 191, 105, 7, 53, 15, 64, 109, 67, 45, 46, - 47, 60, 17, 51, 61, 131, 68, 69, 52, 60, - 18, 63, 61, 140, 229, 8, 52, 231, 232, 148, - 149, 150, 151, 152, 9, 10, 11, 12, 13, 20, - 159, 201, 117, 118, 132, 211, 202, 222, 19, 119, - 214, 33, 161, 245, 225, 205, 246, 247, 8, 174, - 202, 44, 202, 155, 51, 158, 121, 60, 34, 184, - 61, 65, 140, 188, 96, 208, 209, 192, 71, 72, - 73, 193, 22, 23, 37, 38, 39, 197, 198, 35, - 199, 40, 171, 41, 42, 43, 48, 49, 185, 74, - 180, 20, 52, 106, 252, 234, 48, 123, 48, 124, - 48, 125, 215, 126, 127, 167, 168, 208, 209, 167, - 213, 108, 221, 262, 110, 111, 223, 224, 120, 122, - 113, 112, 242, 226, 227, 114, 52, 228, 134, 135, - 156, 137, 138, 139, 160, 142, 143, 144, 162, 163, - 164, 166, 172, 194, 175, 153, 176, 48, 212, 179, - 181, 200, 243, 183, 238, 244, 204, 253, 75, 76, - 77, 261, 203, 78, 79, 80, 81, 206, 82, 83, - 84, 85, 86, 87, 88, 89, 207, 210, 90, 91, - 92, 93, 94, 95, 216, 189, 96, 97, 98, 99, - 217, 218, 219, 235, 230, 233, 100, 101, 102, 75, - 76, 77, 236, 237, 78, 79, 80, 81, 240, 82, - 83, 84, 85, 86, 87, 88, 89, 241, 248, 90, - 91, 92, 93, 94, 95, 249, 250, 254, 97, 98, - 99, 255, 256, 258, 257, 196, 259, 100, 101, 102, - 75, 76, 77, 220, 260, 78, 79, 80, 81, 263, - 82, 83, 84, 85, 86, 87, 88, 89, 147, 136, - 90, 91, 92, 93, 94, 95, 146, 187, 16, 0, - 0, 170, 0, 0, 177, 0, 0, 0, 100, 101, - 102, 75, 76, 77, 0, 0, 78, 79, 80, 81, - 0, 82, 83, 84, 85, 86, 87, 88, 89, 0, - 0, 90, 91, 92, 93, 94, 95, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, - 101, 102 + 137, 36, 186, 111, 108, 190, 161, 109, 177, 194, + 195, 57, 113, 68, 55, 71, 26, 27, 67, 56, + 49, 50, 51, 56, 64, 135, 4, 65, 72, 73, + 7, 233, 205, 144, 235, 236, 8, 206, 14, 152, + 153, 154, 155, 156, 17, 9, 10, 11, 12, 13, + 163, 19, 136, 20, 121, 122, 215, 226, 165, 21, + 249, 218, 123, 250, 229, 41, 42, 43, 22, 178, + 48, 159, 44, 162, 45, 46, 47, 52, 53, 188, + 209, 251, 144, 192, 8, 206, 206, 196, 125, 64, + 24, 197, 65, 25, 22, 56, 64, 201, 202, 65, + 203, 100, 212, 213, 175, 69, 189, 75, 76, 77, + 52, 127, 184, 78, 256, 238, 52, 128, 52, 129, + 171, 172, 219, 130, 131, 171, 217, 212, 213, 55, + 37, 110, 225, 266, 38, 39, 227, 228, 124, 126, + 112, 116, 246, 230, 231, 114, 115, 232, 138, 139, + 117, 141, 142, 143, 118, 146, 147, 148, 56, 164, + 160, 166, 167, 168, 176, 157, 170, 179, 180, 52, + 242, 183, 247, 185, 187, 248, 204, 198, 79, 80, + 81, 265, 207, 82, 83, 84, 85, 208, 86, 87, + 88, 89, 90, 91, 92, 93, 210, 211, 94, 95, + 96, 97, 98, 99, 214, 193, 100, 101, 102, 103, + 220, 221, 222, 239, 216, 223, 104, 105, 106, 79, + 80, 81, 234, 237, 82, 83, 84, 85, 240, 86, + 87, 88, 89, 90, 91, 92, 93, 241, 244, 94, + 95, 96, 97, 98, 99, 245, 252, 253, 101, 102, + 103, 257, 25, 258, 260, 259, 261, 104, 105, 106, + 79, 80, 81, 224, 262, 82, 83, 84, 85, 264, + 86, 87, 88, 89, 90, 91, 92, 93, 263, 267, + 94, 95, 96, 97, 98, 99, 254, 140, 151, 150, + 200, 191, 18, 0, 174, 0, 0, 0, 104, 105, + 106, 79, 80, 81, 181, 0, 82, 83, 84, 85, + 0, 86, 87, 88, 89, 90, 91, 92, 93, 0, + 0, 94, 95, 96, 97, 98, 99, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, + 105, 106 }; static const yytype_int16 yycheck[] = { - 78, 16, 130, 55, 53, 133, 99, 118, 3, 137, - 138, 53, 0, 37, 3, 39, 58, 41, 33, 34, - 35, 5, 3, 3, 8, 77, 41, 42, 8, 5, - 3, 3, 8, 85, 201, 42, 8, 204, 205, 91, - 92, 93, 94, 95, 51, 52, 53, 54, 55, 7, - 102, 4, 67, 68, 78, 166, 9, 185, 3, 43, - 171, 55, 104, 230, 192, 4, 233, 4, 42, 118, - 9, 4, 9, 97, 3, 99, 4, 5, 55, 131, - 8, 5, 134, 135, 38, 39, 40, 139, 45, 46, - 47, 143, 3, 4, 36, 37, 38, 149, 150, 55, - 152, 43, 117, 45, 46, 47, 3, 4, 132, 30, - 125, 7, 8, 3, 242, 208, 3, 4, 3, 4, - 3, 4, 171, 5, 6, 3, 4, 39, 40, 3, - 4, 3, 184, 261, 4, 4, 188, 189, 69, 70, - 3, 36, 220, 195, 196, 5, 8, 199, 79, 80, - 9, 82, 83, 84, 4, 86, 87, 28, 4, 4, - 3, 36, 3, 29, 4, 96, 4, 3, 44, 4, - 4, 4, 224, 3, 5, 227, 4, 3, 10, 11, - 12, 259, 9, 15, 16, 17, 18, 9, 20, 21, - 22, 23, 24, 25, 26, 27, 4, 4, 30, 31, - 32, 33, 34, 35, 4, 136, 38, 39, 40, 41, - 4, 4, 4, 9, 4, 4, 48, 49, 50, 10, + 82, 18, 134, 59, 57, 137, 103, 57, 122, 141, + 142, 41, 62, 43, 3, 45, 3, 4, 3, 8, + 37, 38, 39, 8, 5, 81, 3, 8, 45, 46, + 0, 205, 4, 89, 208, 209, 42, 9, 7, 95, + 96, 97, 98, 99, 3, 51, 52, 53, 54, 55, + 106, 3, 82, 3, 71, 72, 170, 189, 108, 3, + 234, 175, 43, 237, 196, 36, 37, 38, 7, 122, + 4, 101, 43, 103, 45, 46, 47, 3, 4, 135, + 4, 4, 138, 139, 42, 9, 9, 143, 4, 5, + 4, 147, 8, 7, 7, 8, 5, 153, 154, 8, + 156, 38, 39, 40, 121, 5, 136, 49, 50, 51, + 3, 4, 129, 30, 246, 212, 3, 4, 3, 4, + 3, 4, 175, 5, 6, 3, 4, 39, 40, 3, + 55, 3, 188, 265, 55, 55, 192, 193, 73, 74, + 3, 36, 224, 199, 200, 4, 4, 203, 83, 84, + 3, 86, 87, 88, 5, 90, 91, 28, 8, 4, + 9, 4, 4, 3, 3, 100, 36, 4, 4, 3, + 5, 4, 228, 4, 3, 231, 4, 29, 10, 11, + 12, 263, 9, 15, 16, 17, 18, 4, 20, 21, + 22, 23, 24, 25, 26, 27, 9, 4, 30, 31, + 32, 33, 34, 35, 4, 140, 38, 39, 40, 41, + 4, 4, 4, 9, 44, 4, 48, 49, 50, 10, 11, 12, 4, 4, 15, 16, 17, 18, 4, 20, 21, 22, 23, 24, 25, 26, 27, 4, 4, 30, - 31, 32, 33, 34, 35, 4, 7, 4, 39, 40, - 41, 4, 40, 9, 3, 146, 14, 48, 49, 50, - 10, 11, 12, 13, 4, 15, 16, 17, 18, 4, - 20, 21, 22, 23, 24, 25, 26, 27, 90, 81, - 30, 31, 32, 33, 34, 35, 89, 134, 9, -1, - -1, 116, -1, -1, 123, -1, -1, -1, 48, 49, - 50, 10, 11, 12, -1, -1, 15, 16, 17, 18, + 31, 32, 33, 34, 35, 4, 4, 4, 39, 40, + 41, 3, 7, 4, 40, 4, 3, 48, 49, 50, + 10, 11, 12, 13, 9, 15, 16, 17, 18, 4, + 20, 21, 22, 23, 24, 25, 26, 27, 14, 4, + 30, 31, 32, 33, 34, 35, 243, 85, 94, 93, + 150, 138, 9, -1, 120, -1, -1, -1, 48, 49, + 50, 10, 11, 12, 127, -1, 15, 16, 17, 18, -1, 20, 21, 22, 23, 24, 25, 26, 27, -1, -1, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 48, @@ -822,67 +838,67 @@ static const yytype_int16 yycheck[] = symbol of state STATE-NUM. */ static const yytype_uint8 yystos[] = { - 0, 93, 97, 98, 3, 91, 92, 0, 42, 51, - 52, 53, 54, 55, 90, 3, 91, 3, 3, 3, - 7, 64, 3, 4, 77, 78, 84, 85, 86, 87, - 88, 89, 64, 55, 55, 55, 96, 36, 37, 38, - 43, 45, 46, 47, 4, 64, 64, 64, 3, 4, - 94, 3, 8, 63, 69, 72, 73, 74, 75, 76, - 5, 8, 61, 3, 63, 5, 82, 63, 64, 64, - 62, 96, 96, 96, 30, 10, 11, 12, 15, 16, - 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, - 30, 31, 32, 33, 34, 35, 38, 39, 40, 41, - 48, 49, 50, 70, 75, 76, 3, 69, 3, 76, - 4, 4, 36, 3, 5, 81, 83, 64, 64, 43, - 61, 4, 61, 4, 4, 4, 5, 6, 60, 63, - 66, 69, 63, 66, 61, 61, 62, 61, 61, 61, - 69, 71, 61, 61, 28, 67, 67, 60, 69, 69, - 69, 69, 69, 61, 58, 63, 9, 58, 63, 69, - 4, 76, 4, 4, 3, 59, 36, 3, 4, 80, - 81, 64, 3, 59, 75, 4, 4, 94, 95, 4, - 64, 4, 73, 3, 69, 63, 73, 71, 69, 61, - 73, 73, 69, 69, 29, 68, 68, 69, 69, 69, - 4, 4, 9, 9, 4, 4, 9, 4, 39, 40, - 4, 59, 44, 4, 59, 75, 4, 4, 4, 4, - 13, 69, 73, 69, 69, 73, 69, 69, 69, 74, - 4, 74, 74, 4, 58, 9, 4, 4, 5, 79, - 4, 4, 66, 69, 69, 74, 74, 4, 4, 4, - 7, 65, 73, 3, 4, 4, 40, 3, 9, 14, - 4, 66, 73, 4 + 0, 94, 98, 99, 3, 92, 93, 0, 42, 51, + 52, 53, 54, 55, 7, 58, 91, 3, 92, 3, + 3, 3, 7, 65, 4, 7, 3, 4, 78, 79, + 85, 86, 87, 88, 89, 90, 65, 55, 55, 55, + 97, 36, 37, 38, 43, 45, 46, 47, 4, 65, + 65, 65, 3, 4, 95, 3, 8, 64, 70, 73, + 74, 75, 76, 77, 5, 8, 62, 3, 64, 5, + 83, 64, 65, 65, 63, 97, 97, 97, 30, 10, + 11, 12, 15, 16, 17, 18, 20, 21, 22, 23, + 24, 25, 26, 27, 30, 31, 32, 33, 34, 35, + 38, 39, 40, 41, 48, 49, 50, 71, 76, 77, + 3, 70, 3, 77, 4, 4, 36, 3, 5, 82, + 84, 65, 65, 43, 62, 4, 62, 4, 4, 4, + 5, 6, 61, 64, 67, 70, 64, 67, 62, 62, + 63, 62, 62, 62, 70, 72, 62, 62, 28, 68, + 68, 61, 70, 70, 70, 70, 70, 62, 59, 64, + 9, 59, 64, 70, 4, 77, 4, 4, 3, 60, + 36, 3, 4, 81, 82, 65, 3, 60, 76, 4, + 4, 95, 96, 4, 65, 4, 74, 3, 70, 64, + 74, 72, 70, 62, 74, 74, 70, 70, 29, 69, + 69, 70, 70, 70, 4, 4, 9, 9, 4, 4, + 9, 4, 39, 40, 4, 60, 44, 4, 60, 76, + 4, 4, 4, 4, 13, 70, 74, 70, 70, 74, + 70, 70, 70, 75, 4, 75, 75, 4, 59, 9, + 4, 4, 5, 80, 4, 4, 67, 70, 70, 75, + 75, 4, 4, 4, 58, 66, 74, 3, 4, 4, + 40, 3, 9, 14, 4, 67, 74, 4 }; /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { - 0, 57, 58, 58, 59, 59, 59, 59, 60, 60, - 61, 61, 62, 62, 63, 64, 65, 66, 66, 67, - 67, 68, 68, 69, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, - 70, 70, 70, 70, 71, 71, 72, 72, 73, 73, - 74, 74, 74, 74, 74, 74, 75, 76, 77, 77, - 77, 77, 78, 79, 80, 81, 81, 82, 83, 84, - 84, 85, 85, 86, 87, 87, 87, 87, 88, 89, - 90, 90, 90, 90, 90, 90, 90, 90, 90, 91, - 92, 92, 92, 92, 92, 92, 93, 93, 94, 95, - 95, 96, 96, 97, 98 + 0, 57, 58, 58, 59, 59, 60, 60, 60, 60, + 61, 61, 62, 62, 63, 63, 64, 65, 66, 67, + 67, 68, 68, 69, 69, 70, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 71, 71, 71, 72, 72, 73, 73, + 74, 74, 75, 75, 75, 75, 75, 75, 76, 77, + 78, 78, 78, 78, 79, 80, 81, 82, 82, 83, + 84, 85, 85, 86, 86, 87, 88, 88, 88, 88, + 89, 90, 91, 91, 91, 91, 91, 91, 91, 91, + 91, 92, 92, 93, 93, 93, 93, 93, 93, 94, + 94, 95, 96, 96, 97, 97, 98, 99 }; /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { - 0, 2, 0, 2, 0, 4, 8, 4, 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, 6, 5, 5, 6, 4, 1, 5, 6, - 4, 5, 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, - 1, 5, 5, 9, 8, 9, 0, 2, 4, 0, - 1, 0, 2, 1, 1 + 0, 2, 1, 2, 0, 2, 0, 4, 8, 4, + 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, 6, 5, 5, 6, 4, 1, + 5, 6, 4, 5, 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, 5, 5, 9, 8, 9, 0, + 2, 4, 0, 1, 0, 2, 1, 1 }; @@ -1378,184 +1394,190 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN switch (yytype) { - case 58: /* value_type_list */ -#line 154 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 58: /* text_list */ +#line 169 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + { wasm_destroy_text_list(parser->allocator, &((*yyvaluep).text_list)); } +#line 1401 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ + break; + + case 59: /* value_type_list */ +#line 172 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_type_vector(parser->allocator, &((*yyvaluep).types)); } -#line 1385 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1407 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 59: /* func_type */ -#line 164 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 60: /* func_type */ +#line 182 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_func_signature(parser->allocator, &((*yyvaluep).func_sig)); } -#line 1391 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1413 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 60: /* literal */ -#line 153 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 61: /* literal */ +#line 171 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).literal).text); } -#line 1397 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1419 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 61: /* var */ -#line 155 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 62: /* var */ +#line 173 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_var(parser->allocator, &((*yyvaluep).var)); } -#line 1403 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1425 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 62: /* var_list */ -#line 156 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 63: /* var_list */ +#line 174 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_var_vector_and_elements(parser->allocator, &((*yyvaluep).vars)); } -#line 1409 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1431 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 63: /* bind_var */ -#line 152 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 64: /* bind_var */ +#line 170 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); } -#line 1415 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1437 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 64: /* quoted_text */ -#line 152 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 65: /* quoted_text */ +#line 170 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); } -#line 1421 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1443 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 65: /* string_contents */ -#line 161 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 66: /* segment_contents */ +#line 179 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_segment(parser->allocator, &((*yyvaluep).segment)); } -#line 1427 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1449 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 66: /* labeling */ -#line 152 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 67: /* labeling */ +#line 170 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_string_slice(parser->allocator, &((*yyvaluep).text)); } -#line 1433 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1455 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 69: /* expr */ -#line 157 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 70: /* expr */ +#line 175 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_expr(parser->allocator, ((*yyvaluep).expr)); } -#line 1439 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1461 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 70: /* expr1 */ -#line 157 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 71: /* expr1 */ +#line 175 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_expr(parser->allocator, ((*yyvaluep).expr)); } -#line 1445 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1467 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 71: /* expr_opt */ -#line 157 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 72: /* expr_opt */ +#line 175 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_expr(parser->allocator, ((*yyvaluep).expr)); } -#line 1451 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1473 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 72: /* non_empty_expr_list */ -#line 158 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 73: /* non_empty_expr_list */ +#line 176 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); } -#line 1457 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1479 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 73: /* expr_list */ -#line 158 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 74: /* expr_list */ +#line 176 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_expr_list(parser->allocator, ((*yyvaluep).expr_list).first); } -#line 1463 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1485 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 74: /* func_fields */ -#line 159 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 75: /* func_fields */ +#line 177 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_func_fields(parser->allocator, ((*yyvaluep).func_fields)); } -#line 1469 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1491 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 76: /* func_info */ -#line 160 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 77: /* func_info */ +#line 178 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_func(parser->allocator, ((*yyvaluep).func)); wasm_free(parser->allocator, ((*yyvaluep).func)); } -#line 1475 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1497 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 77: /* func */ -#line 160 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 78: /* func */ +#line 178 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_func(parser->allocator, ((*yyvaluep).func)); wasm_free(parser->allocator, ((*yyvaluep).func)); } -#line 1481 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1503 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 80: /* segment */ -#line 161 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 81: /* segment */ +#line 179 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_segment(parser->allocator, &((*yyvaluep).segment)); } -#line 1487 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1509 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 81: /* segment_list */ -#line 162 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 82: /* segment_list */ +#line 180 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_segment_vector_and_elements(parser->allocator, &((*yyvaluep).segments)); } -#line 1493 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1515 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 84: /* memory */ -#line 163 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 85: /* memory */ +#line 181 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_memory(parser->allocator, &((*yyvaluep).memory)); } -#line 1499 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1521 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 85: /* type_def */ -#line 165 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 86: /* type_def */ +#line 183 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_func_type(parser->allocator, &((*yyvaluep).func_type)); } -#line 1505 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1527 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 86: /* table */ -#line 156 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 87: /* table */ +#line 174 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_var_vector_and_elements(parser->allocator, &((*yyvaluep).vars)); } -#line 1511 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1533 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 87: /* import */ -#line 166 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 88: /* import */ +#line 184 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_import(parser->allocator, ((*yyvaluep).import)); wasm_free(parser->allocator, ((*yyvaluep).import)); } -#line 1517 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1539 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 88: /* export */ -#line 167 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 89: /* export */ +#line 185 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_export(parser->allocator, &((*yyvaluep).export_)); } -#line 1523 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1545 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 90: /* module_fields */ -#line 168 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 91: /* module_fields */ +#line 186 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_module(parser->allocator, ((*yyvaluep).module)); wasm_free(parser->allocator, ((*yyvaluep).module)); } -#line 1529 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1551 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 91: /* module */ -#line 168 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 92: /* module */ +#line 186 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_module(parser->allocator, ((*yyvaluep).module)); wasm_free(parser->allocator, ((*yyvaluep).module)); } -#line 1535 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1557 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 92: /* cmd */ -#line 170 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 93: /* cmd */ +#line 188 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_command(parser->allocator, ((*yyvaluep).command)); wasm_free(parser->allocator, ((*yyvaluep).command)); } -#line 1541 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1563 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 93: /* cmd_list */ -#line 171 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 94: /* cmd_list */ +#line 189 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_command_vector_and_elements(parser->allocator, &((*yyvaluep).commands)); } -#line 1547 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1569 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 96: /* const_list */ -#line 169 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 97: /* const_list */ +#line 187 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_const_vector(parser->allocator, &((*yyvaluep).consts)); } -#line 1553 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1575 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; - case 97: /* script */ -#line 172 "src/wasm-ast-parser.y" /* yacc.c:1257 */ + case 98: /* script */ +#line 190 "src/wasm-ast-parser.y" /* yacc.c:1257 */ { wasm_destroy_script(&((*yyvaluep).script)); } -#line 1559 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ +#line 1581 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1257 */ break; @@ -1847,72 +1869,100 @@ yyreduce: switch (yyn) { case 2: -#line 184 "src/wasm-ast-parser.y" /* yacc.c:1646 */ - { WASM_ZERO_MEMORY((yyval.types)); } -#line 1853 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 200 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmTextListNode* node = new_text_list_node(parser->allocator); + CHECK_ALLOC_NULL(node); + DUPTEXT(node->text, (yyvsp[0].text)); + CHECK_ALLOC_STR(node->text); + node->next = NULL; + (yyval.text_list).first = (yyval.text_list).last = node; + } +#line 1882 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; case 3: -#line 185 "src/wasm-ast-parser.y" /* yacc.c:1646 */ +#line 208 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + (yyval.text_list) = (yyvsp[-1].text_list); + WasmTextListNode* node = new_text_list_node(parser->allocator); + CHECK_ALLOC_NULL(node); + DUPTEXT(node->text, (yyvsp[0].text)); + CHECK_ALLOC_STR(node->text); + node->next = NULL; + (yyval.text_list).last->next = node; + (yyval.text_list).last = node; + } +#line 1897 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 4: +#line 223 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { WASM_ZERO_MEMORY((yyval.types)); } +#line 1903 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 5: +#line 224 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.types) = (yyvsp[-1].types); CHECK_ALLOC(wasm_append_type_value(parser->allocator, &(yyval.types), &(yyvsp[0].type))); } -#line 1862 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 1912 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 4: -#line 191 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 6: +#line 230 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.func_sig)); } -#line 1868 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 1918 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 5: -#line 192 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 7: +#line 231 "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 1877 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 1927 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 6: -#line 196 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 8: +#line 235 "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 1886 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 1936 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 7: -#line 200 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 9: +#line 239 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.func_sig)); (yyval.func_sig).result_type = (yyvsp[-1].type); } -#line 1892 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 1942 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 8: -#line 207 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 10: +#line 246 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.literal).type = (yyvsp[0].literal).type; DUPTEXT((yyval.literal).text, (yyvsp[0].literal).text); CHECK_ALLOC_STR((yyval.literal).text); } -#line 1902 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 1952 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 9: -#line 212 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 11: +#line 251 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.literal).type = (yyvsp[0].literal).type; DUPTEXT((yyval.literal).text, (yyvsp[0].literal).text); CHECK_ALLOC_STR((yyval.literal).text); } -#line 1912 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 1962 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 10: -#line 220 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 12: +#line 259 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.var).loc = (yylsp[0]); (yyval.var).type = WASM_VAR_TYPE_INDEX; @@ -1925,82 +1975,88 @@ yyreduce: } (yyval.var).index = index; } -#line 1929 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 1979 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 11: -#line 232 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 13: +#line 271 "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)); CHECK_ALLOC_STR((yyval.var).name); } -#line 1940 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 1990 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 12: -#line 240 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 14: +#line 279 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.vars)); } -#line 1946 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 1996 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 13: -#line 241 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 15: +#line 280 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.vars) = (yyvsp[-1].vars); CHECK_ALLOC(wasm_append_var_value(parser->allocator, &(yyval.vars), &(yyvsp[0].var))); } -#line 1955 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2005 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 14: -#line 247 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 16: +#line 286 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { DUPTEXT((yyval.text), (yyvsp[0].text)); CHECK_ALLOC_STR((yyval.text)); } -#line 1961 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2011 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 15: -#line 251 "src/wasm-ast-parser.y" /* yacc.c:1646 */ - { + case 17: +#line 290 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + WasmTextListNode node; + node.text = (yyvsp[0].text); + node.next = NULL; + WasmTextList text_list; + text_list.first = &node; + text_list.last = &node; void* data; size_t size; - CHECK_ALLOC(dup_string_contents(parser->allocator, &(yyvsp[0].text), &data, &size)); + CHECK_ALLOC(dup_text_list(parser->allocator, &text_list, &data, &size)); (yyval.text).start = data; (yyval.text).length = size; } -#line 1973 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2029 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 16: -#line 261 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 18: +#line 306 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { - CHECK_ALLOC(dup_string_contents(parser->allocator, &(yyvsp[0].text), &(yyval.segment).data, - &(yyval.segment).size)); + CHECK_ALLOC(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 1982 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2038 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 17: -#line 268 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 19: +#line 313 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.text)); } -#line 1988 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2044 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 18: -#line 269 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 20: +#line 314 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.text) = (yyvsp[0].text); } -#line 1994 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2050 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 19: -#line 273 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 21: +#line 318 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.u64) = 0; } -#line 2000 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2056 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 20: -#line 274 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 22: +#line 319 "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_ast_parser_error(&(yylsp[0]), lexer, parser, @@ -2008,17 +2064,17 @@ yyreduce: WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].text))); } } -#line 2012 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2068 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 21: -#line 283 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 23: +#line 328 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.u32) = USE_NATURAL_ALIGNMENT; } -#line 2018 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2074 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 22: -#line 284 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 24: +#line 329 "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))) { @@ -2027,48 +2083,48 @@ yyreduce: WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].text))); } } -#line 2031 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2087 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 23: -#line 295 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 25: +#line 340 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = (yyvsp[-1].expr); (yyval.expr)->loc = (yylsp[-2]); } -#line 2037 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2093 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 24: -#line 298 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 26: +#line 343 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_empty_expr(parser->allocator, WASM_EXPR_TYPE_NOP); CHECK_ALLOC_NULL((yyval.expr)); } -#line 2046 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2102 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 25: -#line 302 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 27: +#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; CHECK_ALLOC_NULL((yyval.expr)); } -#line 2057 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2113 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 26: -#line 308 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 28: +#line 353 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_if_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); (yyval.expr)->if_.cond = (yyvsp[-1].expr); (yyval.expr)->if_.true_.first = (yyvsp[0].expr); } -#line 2068 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2124 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 27: -#line 314 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 29: +#line 359 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_if_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2076,11 +2132,11 @@ yyreduce: (yyval.expr)->if_.true_.label = (yyvsp[-2].text); (yyval.expr)->if_.true_.first = (yyvsp[-1].expr_list).first; } -#line 2080 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2136 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 28: -#line 321 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 30: +#line 366 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_if_else_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2088,11 +2144,11 @@ yyreduce: (yyval.expr)->if_else.true_.first = (yyvsp[-1].expr); (yyval.expr)->if_else.false_.first = (yyvsp[0].expr); } -#line 2092 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2148 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 29: -#line 328 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 31: +#line 373 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_if_else_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2102,22 +2158,22 @@ yyreduce: (yyval.expr)->if_else.false_.label = (yyvsp[-2].text); (yyval.expr)->if_else.false_.first = (yyvsp[-1].expr_list).first; } -#line 2106 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2162 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 30: -#line 337 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 32: +#line 382 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_br_if_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); (yyval.expr)->br_if.var = (yyvsp[-1].var); (yyval.expr)->br_if.cond = (yyvsp[0].expr); } -#line 2117 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2173 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 31: -#line 343 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 33: +#line 388 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_br_if_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2125,11 +2181,11 @@ yyreduce: (yyval.expr)->br_if.expr = (yyvsp[-1].expr); (yyval.expr)->br_if.cond = (yyvsp[0].expr); } -#line 2129 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2185 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 32: -#line 350 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 34: +#line 395 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_loop_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2137,11 +2193,11 @@ yyreduce: (yyval.expr)->loop.inner = (yyvsp[-1].text); (yyval.expr)->loop.first = (yyvsp[0].expr_list).first; } -#line 2141 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2197 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 33: -#line 357 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 35: +#line 402 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_loop_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2149,32 +2205,32 @@ yyreduce: (yyval.expr)->loop.inner = (yyvsp[-1].text); (yyval.expr)->loop.first = (yyvsp[0].expr_list).first; } -#line 2153 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2209 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 34: -#line 364 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 36: +#line 409 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_br_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); (yyval.expr)->br.var = (yyvsp[-1].var); (yyval.expr)->br.expr = (yyvsp[0].expr); } -#line 2164 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2220 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 35: -#line 370 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 37: +#line 415 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_return_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); (yyval.expr)->return_.expr = (yyvsp[0].expr); } -#line 2174 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2230 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 36: -#line 375 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 38: +#line 420 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_br_table_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2183,11 +2239,11 @@ yyreduce: (yyval.expr)->br_table.targets = (yyvsp[-2].vars); (yyval.expr)->br_table.default_target = (yyvsp[-1].var); } -#line 2187 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2243 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 37: -#line 383 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 39: +#line 428 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_br_table_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2196,11 +2252,11 @@ yyreduce: (yyval.expr)->br_table.targets = (yyvsp[-3].vars); (yyval.expr)->br_table.default_target = (yyvsp[-2].var); } -#line 2200 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2256 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 38: -#line 391 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 40: +#line 436 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_call_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2208,11 +2264,11 @@ yyreduce: (yyval.expr)->call.first_arg = (yyvsp[0].expr_list).first; (yyval.expr)->call.num_args = (yyvsp[0].expr_list).size; } -#line 2212 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2268 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 39: -#line 398 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 41: +#line 443 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_call_import_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2220,11 +2276,11 @@ yyreduce: (yyval.expr)->call.first_arg = (yyvsp[0].expr_list).first; (yyval.expr)->call.num_args = (yyvsp[0].expr_list).size; } -#line 2224 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2280 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 40: -#line 405 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 42: +#line 450 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_call_indirect_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2233,32 +2289,32 @@ yyreduce: (yyval.expr)->call_indirect.first_arg = (yyvsp[0].expr_list).first; (yyval.expr)->call_indirect.num_args = (yyvsp[0].expr_list).size; } -#line 2237 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2293 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 41: -#line 413 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 43: +#line 458 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_get_local_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); (yyval.expr)->get_local.var = (yyvsp[0].var); } -#line 2247 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2303 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 42: -#line 418 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 44: +#line 463 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_set_local_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); (yyval.expr)->set_local.var = (yyvsp[-1].var); (yyval.expr)->set_local.expr = (yyvsp[0].expr); } -#line 2258 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2314 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 43: -#line 424 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 45: +#line 469 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_load_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2267,11 +2323,11 @@ yyreduce: (yyval.expr)->load.align = (yyvsp[-1].u32); (yyval.expr)->load.addr = (yyvsp[0].expr); } -#line 2271 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2327 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 44: -#line 432 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 46: +#line 477 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_store_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2281,11 +2337,11 @@ yyreduce: (yyval.expr)->store.addr = (yyvsp[-1].expr); (yyval.expr)->store.value = (yyvsp[0].expr); } -#line 2285 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2341 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 45: -#line 441 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 47: +#line 486 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_const_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2299,22 +2355,22 @@ yyreduce: } wasm_free(parser->allocator, (char*)(yyvsp[0].literal).text.start); } -#line 2303 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2359 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 46: -#line 454 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 48: +#line 499 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_unary_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); (yyval.expr)->unary.opcode = (yyvsp[-1].opcode); (yyval.expr)->unary.expr = (yyvsp[0].expr); } -#line 2314 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2370 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 47: -#line 460 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 49: +#line 505 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_binary_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2322,11 +2378,11 @@ yyreduce: (yyval.expr)->binary.left = (yyvsp[-1].expr); (yyval.expr)->binary.right = (yyvsp[0].expr); } -#line 2326 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2382 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 48: -#line 467 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 50: +#line 512 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_select_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2334,11 +2390,11 @@ yyreduce: (yyval.expr)->select.false_ = (yyvsp[-1].expr); (yyval.expr)->select.cond = (yyvsp[0].expr); } -#line 2338 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2394 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 49: -#line 474 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 51: +#line 519 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_compare_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); @@ -2346,83 +2402,83 @@ yyreduce: (yyval.expr)->compare.left = (yyvsp[-1].expr); (yyval.expr)->compare.right = (yyvsp[0].expr); } -#line 2350 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2406 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 50: -#line 481 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 52: +#line 526 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_convert_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); (yyval.expr)->convert.opcode = (yyvsp[-1].opcode); (yyval.expr)->convert.expr = (yyvsp[0].expr); } -#line 2361 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2417 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 51: -#line 487 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 53: +#line 532 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_empty_expr(parser->allocator, WASM_EXPR_TYPE_UNREACHABLE); CHECK_ALLOC_NULL((yyval.expr)); } -#line 2370 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2426 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 52: -#line 491 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 54: +#line 536 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_empty_expr(parser->allocator, WASM_EXPR_TYPE_CURRENT_MEMORY); CHECK_ALLOC_NULL((yyval.expr)); } -#line 2380 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2436 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 53: -#line 496 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 55: +#line 541 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = wasm_new_grow_memory_expr(parser->allocator); CHECK_ALLOC_NULL((yyval.expr)); (yyval.expr)->grow_memory.expr = (yyvsp[0].expr); } -#line 2390 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2446 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 54: -#line 503 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 56: +#line 548 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr) = NULL; } -#line 2396 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2452 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 56: -#line 507 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 58: +#line 552 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.expr_list).first = (yyval.expr_list).last = (yyvsp[0].expr); (yyval.expr_list).size = 1; } -#line 2405 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2461 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 57: -#line 511 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 59: +#line 556 "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++; } -#line 2416 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2472 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 58: -#line 519 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 60: +#line 564 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.expr_list)); } -#line 2422 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2478 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 60: -#line 525 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 62: +#line 570 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func_fields) = new_func_field(parser->allocator); CHECK_ALLOC_NULL((yyval.func_fields)); @@ -2430,22 +2486,22 @@ yyreduce: (yyval.func_fields)->first_expr = (yyvsp[0].expr_list).first; (yyval.func_fields)->next = NULL; } -#line 2434 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2490 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 61: -#line 532 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 63: +#line 577 "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 2445 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2501 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 62: -#line 538 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 64: +#line 583 "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; @@ -2454,33 +2510,33 @@ yyreduce: (yyval.func_fields)->bound_type.type = (yyvsp[-2].type); (yyval.func_fields)->next = (yyvsp[0].func_fields); } -#line 2458 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2514 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 63: -#line 546 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 65: +#line 591 "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 2469 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2525 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 64: -#line 552 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 66: +#line 597 "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 2480 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2536 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 65: -#line 558 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 67: +#line 603 "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; @@ -2489,17 +2545,17 @@ yyreduce: (yyval.func_fields)->bound_type.type = (yyvsp[-2].type); (yyval.func_fields)->next = (yyvsp[0].func_fields); } -#line 2493 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2549 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 66: -#line 568 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 68: +#line 613 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.var) = (yyvsp[-1].var); } -#line 2499 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2555 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 67: -#line 571 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 69: +#line 616 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func) = new_func(parser->allocator); CHECK_ALLOC_NULL((yyval.func)); @@ -2562,22 +2618,22 @@ yyreduce: field = next; } } -#line 2566 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2622 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 68: -#line 635 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 70: +#line 680 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func) = (yyvsp[-1].func); (yyval.func)->loc = (yylsp[-3]); (yyval.func)->decl.flags |= WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE; (yyval.func)->decl.type_var = (yyvsp[-2].var); } -#line 2577 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2633 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 69: -#line 641 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 71: +#line 686 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func) = (yyvsp[-1].func); (yyval.func)->loc = (yylsp[-4]); @@ -2585,38 +2641,38 @@ yyreduce: (yyval.func)->decl.type_var = (yyvsp[-2].var); (yyval.func)->name = (yyvsp[-3].text); } -#line 2589 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2645 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 70: -#line 648 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 72: +#line 693 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func) = (yyvsp[-1].func); (yyval.func)->loc = (yylsp[-2]); (yyval.func)->decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_SIGNATURE; } -#line 2599 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2655 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 71: -#line 653 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 73: +#line 698 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func) = (yyvsp[-1].func); (yyval.func)->loc = (yylsp[-3]); (yyval.func)->decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_SIGNATURE; (yyval.func)->name = (yyvsp[-2].text); } -#line 2610 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2666 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 72: -#line 664 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 74: +#line 709 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.var) = (yyvsp[-1].var); } -#line 2616 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2672 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 73: -#line 668 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 75: +#line 713 "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), @@ -2627,37 +2683,37 @@ yyreduce: WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].literal).text)); } } -#line 2631 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2687 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 74: -#line 681 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 76: +#line 726 "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 2642 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2698 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 75: -#line 689 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 77: +#line 734 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.segments)); } -#line 2648 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2704 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 76: -#line 690 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 78: +#line 735 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.segments) = (yyvsp[-1].segments); CHECK_ALLOC(wasm_append_segment_value(parser->allocator, &(yyval.segments), &(yyvsp[0].segment))); } -#line 2657 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2713 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 77: -#line 697 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 79: +#line 742 "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), @@ -2668,11 +2724,11 @@ yyreduce: WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].literal).text)); } } -#line 2672 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2728 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 78: -#line 710 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 80: +#line 755 "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), @@ -2682,57 +2738,57 @@ yyreduce: WASM_PRINTF_STRING_SLICE_ARG((yyvsp[0].literal).text)); } } -#line 2686 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2742 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 79: -#line 722 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 81: +#line 767 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.memory).loc = (yylsp[-4]); (yyval.memory).initial_pages = (yyvsp[-3].u32); (yyval.memory).max_pages = (yyvsp[-2].u32); (yyval.memory).segments = (yyvsp[-1].segments); } -#line 2697 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2753 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 80: -#line 728 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 82: +#line 773 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.memory).loc = (yylsp[-3]); (yyval.memory).initial_pages = (yyvsp[-2].u32); (yyval.memory).max_pages = (yyval.memory).initial_pages; (yyval.memory).segments = (yyvsp[-1].segments); } -#line 2708 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2764 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 81: -#line 737 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 83: +#line 782 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.func_type)); (yyval.func_type).sig = (yyvsp[-2].func_sig); } -#line 2717 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2773 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 82: -#line 741 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 84: +#line 786 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.func_type).name = (yyvsp[-5].text); (yyval.func_type).sig = (yyvsp[-2].func_sig); } -#line 2726 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2782 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 83: -#line 748 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 85: +#line 793 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.vars) = (yyvsp[-1].vars); } -#line 2732 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2788 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 84: -#line 752 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 86: +#line 797 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.import) = new_import(parser->allocator); (yyval.import)->module_name = (yyvsp[-3].text); @@ -2740,11 +2796,11 @@ yyreduce: (yyval.import)->decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE; (yyval.import)->decl.type_var = (yyvsp[-1].var); } -#line 2744 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2800 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 85: -#line 759 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 87: +#line 804 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.import) = new_import(parser->allocator); (yyval.import)->name = (yyvsp[-4].text); @@ -2753,11 +2809,11 @@ yyreduce: (yyval.import)->decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE; (yyval.import)->decl.type_var = (yyvsp[-1].var); } -#line 2757 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2813 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 86: -#line 767 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 88: +#line 812 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.import) = new_import(parser->allocator); (yyval.import)->module_name = (yyvsp[-3].text); @@ -2765,11 +2821,11 @@ yyreduce: (yyval.import)->decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_SIGNATURE; (yyval.import)->decl.sig = (yyvsp[-1].func_sig); } -#line 2769 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2825 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 87: -#line 774 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 89: +#line 819 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.import) = new_import(parser->allocator); (yyval.import)->name = (yyvsp[-4].text); @@ -2778,36 +2834,36 @@ yyreduce: (yyval.import)->decl.flags = WASM_FUNC_DECLARATION_FLAG_HAS_SIGNATURE; (yyval.import)->decl.sig = (yyvsp[-1].func_sig); } -#line 2782 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2838 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 88: -#line 785 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 90: +#line 830 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.export_).name = (yyvsp[-2].text); (yyval.export_).var = (yyvsp[-1].var); } -#line 2791 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2847 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 89: -#line 792 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 91: +#line 837 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.export_memory).name = (yyvsp[-2].text); } -#line 2799 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2855 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 90: -#line 798 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 92: +#line 843 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = new_module(parser->allocator); } -#line 2807 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2863 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 91: -#line 801 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 93: +#line 846 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -2817,11 +2873,11 @@ yyreduce: field->func = *(yyvsp[0].func); wasm_free(parser->allocator, (yyvsp[0].func)); } -#line 2821 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2877 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 92: -#line 810 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 94: +#line 855 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -2831,11 +2887,11 @@ yyreduce: field->import = *(yyvsp[0].import); wasm_free(parser->allocator, (yyvsp[0].import)); } -#line 2835 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2891 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 93: -#line 819 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 95: +#line 864 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -2844,11 +2900,11 @@ yyreduce: field->type = WASM_MODULE_FIELD_TYPE_EXPORT; field->export_ = (yyvsp[0].export_); } -#line 2848 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2904 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 94: -#line 827 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 96: +#line 872 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -2857,11 +2913,11 @@ yyreduce: field->type = WASM_MODULE_FIELD_TYPE_EXPORT_MEMORY; field->export_memory = (yyvsp[0].export_memory); } -#line 2861 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2917 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 95: -#line 835 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 97: +#line 880 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -2870,11 +2926,11 @@ yyreduce: field->type = WASM_MODULE_FIELD_TYPE_TABLE; field->table = (yyvsp[0].vars); } -#line 2874 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2930 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 96: -#line 843 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 98: +#line 888 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -2883,11 +2939,11 @@ yyreduce: field->type = WASM_MODULE_FIELD_TYPE_FUNC_TYPE; field->func_type = (yyvsp[0].func_type); } -#line 2887 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2943 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 97: -#line 851 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 99: +#line 896 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -2896,11 +2952,11 @@ yyreduce: field->type = WASM_MODULE_FIELD_TYPE_MEMORY; field->memory = (yyvsp[0].memory); } -#line 2900 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2956 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 98: -#line 859 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 100: +#line 904 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); WasmModuleField* field = wasm_append_module_field(parser->allocator, (yyval.module)); @@ -2909,11 +2965,11 @@ yyreduce: field->type = WASM_MODULE_FIELD_TYPE_START; field->start = (yyvsp[0].var); } -#line 2913 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 2969 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 99: -#line 869 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 101: +#line 914 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.module) = (yyvsp[-1].module); (yyval.module)->loc = (yylsp[-2]); @@ -3004,22 +3060,46 @@ yyreduce: &import->decl)); } } -#line 3008 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3064 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 100: -#line 965 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 102: +#line 1004 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + { + (yyval.module) = new_module(parser->allocator); + CHECK_ALLOC_NULL((yyval.module)); + void* data; + size_t size; + CHECK_ALLOC(dup_text_list(parser->allocator, &(yyvsp[-1].text_list), &data, &size)); + wasm_destroy_text_list(parser->allocator, &(yyvsp[-1].text_list)); + WasmReadBinaryOptions options = WASM_READ_BINARY_OPTIONS_DEFAULT; + BinaryErrorCallbackData user_data; + user_data.loc = &(yylsp[-1]); + user_data.lexer = lexer; + user_data.parser = parser; + WasmBinaryErrorHandler error_handler; + error_handler.on_error = on_read_binary_error; + error_handler.user_data = &user_data; + wasm_read_binary_ast(parser->allocator, data, size, &options, + &error_handler, (yyval.module)); + wasm_free(parser->allocator, data); + } +#line 3088 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ + break; + + case 103: +#line 1029 "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 3019 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3099 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 101: -#line 971 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 104: +#line 1035 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.command) = new_command(parser->allocator); (yyval.command)->type = WASM_COMMAND_TYPE_INVOKE; @@ -3027,11 +3107,11 @@ yyreduce: (yyval.command)->invoke.name = (yyvsp[-2].text); (yyval.command)->invoke.args = (yyvsp[-1].consts); } -#line 3031 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3111 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 102: -#line 978 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 105: +#line 1042 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.command) = new_command(parser->allocator); (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_INVALID; @@ -3039,11 +3119,11 @@ yyreduce: (yyval.command)->assert_invalid.text = (yyvsp[-1].text); wasm_free(parser->allocator, (yyvsp[-2].module)); } -#line 3043 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3123 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 103: -#line 985 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 106: +#line 1049 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.command) = new_command(parser->allocator); (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_RETURN; @@ -3052,11 +3132,11 @@ yyreduce: (yyval.command)->assert_return.invoke.args = (yyvsp[-3].consts); (yyval.command)->assert_return.expected = (yyvsp[-1].const_); } -#line 3056 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3136 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 104: -#line 993 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 107: +#line 1057 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.command) = new_command(parser->allocator); (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_RETURN_NAN; @@ -3064,11 +3144,11 @@ yyreduce: (yyval.command)->assert_return_nan.invoke.name = (yyvsp[-3].text); (yyval.command)->assert_return_nan.invoke.args = (yyvsp[-2].consts); } -#line 3068 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3148 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 105: -#line 1000 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 108: +#line 1064 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.command) = new_command(parser->allocator); (yyval.command)->type = WASM_COMMAND_TYPE_ASSERT_TRAP; @@ -3077,27 +3157,27 @@ yyreduce: (yyval.command)->assert_trap.invoke.args = (yyvsp[-3].consts); (yyval.command)->assert_trap.text = (yyvsp[-1].text); } -#line 3081 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3161 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 106: -#line 1010 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 109: +#line 1074 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.commands)); } -#line 3087 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3167 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 107: -#line 1011 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 110: +#line 1075 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.commands) = (yyvsp[-1].commands); CHECK_ALLOC(wasm_append_command_value(parser->allocator, &(yyval.commands), (yyvsp[0].command))); wasm_free(parser->allocator, (yyvsp[0].command)); } -#line 3097 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3177 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 108: -#line 1019 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 111: +#line 1083 "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, @@ -3108,41 +3188,41 @@ yyreduce: } wasm_free(parser->allocator, (char*)(yyvsp[-1].literal).text.start); } -#line 3112 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3192 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 109: -#line 1031 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 112: +#line 1095 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.const_).type = WASM_TYPE_VOID; } -#line 3118 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3198 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 111: -#line 1035 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 114: +#line 1099 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { WASM_ZERO_MEMORY((yyval.consts)); } -#line 3124 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3204 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 112: -#line 1036 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 115: +#line 1100 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.consts) = (yyvsp[-1].consts); CHECK_ALLOC(wasm_append_const_value(parser->allocator, &(yyval.consts), &(yyvsp[0].const_))); } -#line 3133 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3213 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; - case 113: -#line 1043 "src/wasm-ast-parser.y" /* yacc.c:1646 */ + case 116: +#line 1107 "src/wasm-ast-parser.y" /* yacc.c:1646 */ { (yyval.script).commands = (yyvsp[0].commands); parser->script = (yyval.script); } -#line 3142 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3222 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ break; -#line 3146 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ +#line 3226 "src/prebuilt/wasm-ast-parser-gen.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -3377,7 +3457,7 @@ yyreturn: #endif return yyresult; } -#line 1055 "src/wasm-ast-parser.y" /* yacc.c:1906 */ +#line 1119 "src/wasm-ast-parser.y" /* yacc.c:1906 */ static WasmResult parse_const(WasmType type, @@ -3403,9 +3483,7 @@ static WasmResult parse_const(WasmType type, return WASM_ERROR; } -static size_t copy_string_contents(WasmStringSlice* text, - char* dest, - size_t size) { +static size_t copy_string_contents(WasmStringSlice* text, char* dest) { const char* src = text->start + 1; const char* end = text->start + text->length - 1; @@ -3454,22 +3532,33 @@ static size_t copy_string_contents(WasmStringSlice* text, return dest - dest_start; } -static WasmResult dup_string_contents(WasmAllocator* allocator, - WasmStringSlice* text, - void** out_data, - size_t* out_size) { - const char* src = text->start + 1; - const char* end = text->start + text->length - 1; - /* Always allocate enough space for the entire string including the escape - * characters. It will only get shorter, and this way we only have to iterate - * through the string once. */ - size_t size = end - src; - char* result = wasm_alloc(allocator, size, 1); +static WasmResult dup_text_list(WasmAllocator* allocator, + WasmTextList* text_list, + void** out_data, + size_t* out_size) { + /* walk the linked list to see how much total space is needed */ + size_t total_size = 0; + WasmTextListNode* node; + for (node = text_list->first; node; node = node->next) { + /* Always allocate enough space for the entire string including the escape + * characters. It will only get shorter, and this way we only have to + * iterate through the string once. */ + const char* src = node->text.start + 1; + const char* end = node->text.start + node->text.length - 1; + size_t size = end - src; + total_size += size; + } + char* result = wasm_alloc(allocator, total_size, 1); if (!result) return WASM_ERROR; - size_t actual_size = copy_string_contents(text, result, size); + + char* dest = result; + for (node = text_list->first; node; node = node->next) { + size_t actual_size = copy_string_contents(&node->text, dest); + dest += actual_size; + } *out_data = result; - *out_size = actual_size; + *out_size = dest - result; return WASM_OK; } @@ -3507,3 +3596,15 @@ static WasmResult copy_signature_from_func_type(WasmAllocator* allocator, } return WASM_OK; } + +static void on_read_binary_error(uint32_t offset, const char* error, + void* user_data) { + BinaryErrorCallbackData* data = user_data; + if (offset == WASM_UNKNOWN_OFFSET) { + wasm_ast_parser_error(data->loc, data->lexer, data->parser, + "error in binary module: %s", error); + } else { + wasm_ast_parser_error(data->loc, data->lexer, data->parser, + "error in binary module: @0x%08x: %s", offset, error); + } +} diff --git a/src/wasm-ast-parser-lexer-shared.c b/src/wasm-ast-parser-lexer-shared.c index 94d5fc2b..dc06b36a 100644 --- a/src/wasm-ast-parser-lexer-shared.c +++ b/src/wasm-ast-parser-lexer-shared.c @@ -70,3 +70,13 @@ void wasm_ast_format_error(WasmSourceErrorHandler* error_handler, } va_end(args_copy); } + +void wasm_destroy_text_list(WasmAllocator* allocator, WasmTextList* text_list) { + WasmTextListNode* node = text_list->first; + while (node) { + WasmTextListNode* next = node->next; + wasm_destroy_string_slice(allocator, &node->text); + wasm_free(allocator, node); + node = next; + } +} diff --git a/src/wasm-ast-parser-lexer-shared.h b/src/wasm-ast-parser-lexer-shared.h index b2346eb6..c1ec8674 100644 --- a/src/wasm-ast-parser-lexer-shared.h +++ b/src/wasm-ast-parser-lexer-shared.h @@ -38,6 +38,16 @@ typedef struct WasmExprList { size_t size; } WasmExprList; +typedef struct WasmTextListNode { + WasmStringSlice text; + struct WasmTextListNode* next; +} WasmTextListNode; + +typedef struct WasmTextList { + WasmTextListNode* first; + WasmTextListNode* last; +} WasmTextList; + typedef union WasmToken { /* terminals */ WasmStringSlice text; @@ -50,6 +60,7 @@ typedef union WasmToken { tokens is a hotspot when parsing large files. */ uint32_t u32; uint64_t u64; + WasmTextList text_list; WasmTypeVector types; WasmVar var; WasmVarVector vars; @@ -102,6 +113,7 @@ void wasm_ast_format_error(WasmSourceErrorHandler*, WasmAstLexer*, const char* format, va_list); +void wasm_destroy_text_list(WasmAllocator*, WasmTextList*); WASM_EXTERN_C_END #endif /* WASM_AST_PARSER_LEXER_SHARED_H_ */ diff --git a/src/wasm-ast-parser.y b/src/wasm-ast-parser.y index f3469a20..9864a9b0 100644 --- a/src/wasm-ast-parser.y +++ b/src/wasm-ast-parser.y @@ -23,6 +23,8 @@ #include "wasm-allocator.h" #include "wasm-ast-parser.h" #include "wasm-ast-parser-lexer-shared.h" +#include "wasm-binary-reader-ast.h" +#include "wasm-binary-reader.h" #include "wasm-literal.h" #define DUPTEXT(dst, src) \ @@ -83,13 +85,27 @@ static WasmImport* new_import(WasmAllocator* allocator) { return wasm_alloc_zero(allocator, sizeof(WasmImport), WASM_DEFAULT_ALIGN); } +static WasmTextListNode* new_text_list_node(WasmAllocator* allocator) { + return wasm_alloc_zero(allocator, sizeof(WasmTextListNode), + WASM_DEFAULT_ALIGN); +} + static WasmResult parse_const(WasmType type, WasmLiteralType literal_type, const char* s, const char* end, WasmConst* out); -static WasmResult dup_string_contents(WasmAllocator*, WasmStringSlice* text, - void** out_data, size_t* out_size); +static WasmResult dup_text_list(WasmAllocator*, WasmTextList* text_list, + void** out_data, size_t* out_size); static WasmResult copy_signature_from_func_type( - WasmAllocator * allocator, WasmModule * module, WasmFuncDeclaration * decl); + WasmAllocator* allocator, WasmModule* module, WasmFuncDeclaration* decl); + +typedef struct BinaryErrorCallbackData { + WasmLocation* loc; + WasmAstLexer* lexer; + WasmAstParser* parser; +} BinaryErrorCallbackData; + +static void on_read_binary_error(uint32_t offset, const char* error, + void* user_data); #define wasm_ast_parser_lex wasm_ast_lexer_lex @@ -140,15 +156,17 @@ static WasmResult copy_signature_from_func_type( %type<module> module module_fields %type<literal> literal %type<script> script -%type<segment> segment string_contents +%type<segment> segment segment_contents %type<segments> segment_list %type<text> bind_var labeling quoted_text +%type<text_list> text_list %type<types> value_type_list %type<u32> align initial_pages max_pages segment_address %type<u64> offset %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, &$$.text); } literal %destructor { wasm_destroy_type_vector(parser->allocator, &$$); } value_type_list @@ -158,7 +176,7 @@ static WasmResult copy_signature_from_func_type( %destructor { wasm_destroy_expr_list(parser->allocator, $$.first); } expr_list non_empty_expr_list %destructor { wasm_destroy_func_fields(parser->allocator, $$); } func_fields %destructor { wasm_destroy_func(parser->allocator, $$); wasm_free(parser->allocator, $$); } func func_info -%destructor { wasm_destroy_segment(parser->allocator, &$$); } segment string_contents +%destructor { wasm_destroy_segment(parser->allocator, &$$); } segment segment_contents %destructor { wasm_destroy_segment_vector_and_elements(parser->allocator, &$$); } segment_list %destructor { wasm_destroy_memory(parser->allocator, &$$); } memory %destructor { wasm_destroy_func_signature(parser->allocator, &$$); } func_type @@ -178,6 +196,27 @@ static WasmResult copy_signature_from_func_type( %% +text_list : + TEXT { + WasmTextListNode* node = new_text_list_node(parser->allocator); + CHECK_ALLOC_NULL(node); + DUPTEXT(node->text, $1); + CHECK_ALLOC_STR(node->text); + node->next = NULL; + $$.first = $$.last = node; + } + | text_list TEXT { + $$ = $1; + WasmTextListNode* node = new_text_list_node(parser->allocator); + CHECK_ALLOC_NULL(node); + DUPTEXT(node->text, $2); + CHECK_ALLOC_STR(node->text); + node->next = NULL; + $$.last->next = node; + $$.last = node; + } +; + /* Types */ value_type_list : @@ -249,18 +288,24 @@ bind_var : quoted_text : TEXT { + WasmTextListNode node; + node.text = $1; + node.next = NULL; + WasmTextList text_list; + text_list.first = &node; + text_list.last = &node; void* data; size_t size; - CHECK_ALLOC(dup_string_contents(parser->allocator, &$1, &data, &size)); + CHECK_ALLOC(dup_text_list(parser->allocator, &text_list, &data, &size)); $$.start = data; $$.length = size; } ; -string_contents : - TEXT { - CHECK_ALLOC(dup_string_contents(parser->allocator, &$1, &$$.data, - &$$.size)); +segment_contents : + text_list { + CHECK_ALLOC(dup_text_list(parser->allocator, &$1, &$$.data, &$$.size)); + wasm_destroy_text_list(parser->allocator, &$1); } ; @@ -678,7 +723,7 @@ segment_address : ; segment : - LPAR SEGMENT segment_address string_contents RPAR { + LPAR SEGMENT segment_address segment_contents RPAR { $$.loc = @2; $$.data = $4.data; $$.size = $4.size; @@ -956,6 +1001,25 @@ module : &import->decl)); } } + | LPAR MODULE text_list RPAR { + $$ = new_module(parser->allocator); + CHECK_ALLOC_NULL($$); + void* data; + size_t size; + CHECK_ALLOC(dup_text_list(parser->allocator, &$3, &data, &size)); + wasm_destroy_text_list(parser->allocator, &$3); + WasmReadBinaryOptions options = WASM_READ_BINARY_OPTIONS_DEFAULT; + BinaryErrorCallbackData user_data; + user_data.loc = &@3; + user_data.lexer = lexer; + user_data.parser = parser; + WasmBinaryErrorHandler error_handler; + error_handler.on_error = on_read_binary_error; + error_handler.user_data = &user_data; + wasm_read_binary_ast(parser->allocator, data, size, &options, + &error_handler, $$); + wasm_free(parser->allocator, data); + } ; @@ -1077,9 +1141,7 @@ static WasmResult parse_const(WasmType type, return WASM_ERROR; } -static size_t copy_string_contents(WasmStringSlice* text, - char* dest, - size_t size) { +static size_t copy_string_contents(WasmStringSlice* text, char* dest) { const char* src = text->start + 1; const char* end = text->start + text->length - 1; @@ -1128,22 +1190,33 @@ static size_t copy_string_contents(WasmStringSlice* text, return dest - dest_start; } -static WasmResult dup_string_contents(WasmAllocator* allocator, - WasmStringSlice* text, - void** out_data, - size_t* out_size) { - const char* src = text->start + 1; - const char* end = text->start + text->length - 1; - /* Always allocate enough space for the entire string including the escape - * characters. It will only get shorter, and this way we only have to iterate - * through the string once. */ - size_t size = end - src; - char* result = wasm_alloc(allocator, size, 1); +static WasmResult dup_text_list(WasmAllocator* allocator, + WasmTextList* text_list, + void** out_data, + size_t* out_size) { + /* walk the linked list to see how much total space is needed */ + size_t total_size = 0; + WasmTextListNode* node; + for (node = text_list->first; node; node = node->next) { + /* Always allocate enough space for the entire string including the escape + * characters. It will only get shorter, and this way we only have to + * iterate through the string once. */ + const char* src = node->text.start + 1; + const char* end = node->text.start + node->text.length - 1; + size_t size = end - src; + total_size += size; + } + char* result = wasm_alloc(allocator, total_size, 1); if (!result) return WASM_ERROR; - size_t actual_size = copy_string_contents(text, result, size); + + char* dest = result; + for (node = text_list->first; node; node = node->next) { + size_t actual_size = copy_string_contents(&node->text, dest); + dest += actual_size; + } *out_data = result; - *out_size = actual_size; + *out_size = dest - result; return WASM_OK; } @@ -1181,3 +1254,15 @@ static WasmResult copy_signature_from_func_type(WasmAllocator* allocator, } return WASM_OK; } + +static void on_read_binary_error(uint32_t offset, const char* error, + void* user_data) { + BinaryErrorCallbackData* data = user_data; + if (offset == WASM_UNKNOWN_OFFSET) { + wasm_ast_parser_error(data->loc, data->lexer, data->parser, + "error in binary module: %s", error); + } else { + wasm_ast_parser_error(data->loc, data->lexer, data->parser, + "error in binary module: @0x%08x: %s", offset, error); + } +} diff --git a/test/parse/module/bad-binary-module-magic.txt b/test/parse/module/bad-binary-module-magic.txt new file mode 100644 index 00000000..9f8c7e7c --- /dev/null +++ b/test/parse/module/bad-binary-module-magic.txt @@ -0,0 +1,9 @@ +;;; ERROR: 1 +(module + "\00ASM" + "\0b\00\00\00") +(;; STDERR ;;; +parse/module/bad-binary-module-magic.txt:3:3: error in binary module: @0x00000004: magic value mismatch + "\00ASM" + ^^^^^^^^ +;;; STDERR ;;) diff --git a/test/parse/module/binary-module.txt b/test/parse/module/binary-module.txt new file mode 100644 index 00000000..578f1930 --- /dev/null +++ b/test/parse/module/binary-module.txt @@ -0,0 +1,16 @@ +(module + "\00asm" ;; magic + "\0b\00\00\00" ;; version + "\04type\05" ;; "type" section, 5 bytes + "\01\40\00\01\01" ;; 1 type, function, no params, i32 result + "\08function\02" ;; "function" section, 2 bytes + "\01\00" ;; 1 function, type 0 + "\06export\07" ;; "export" section, 7 bytes + "\01\00\04main" ;; 1 export, function 0, named "main" + "\04code\08" ;; "code" section, 8 bytes + "\01" ;; 1 function + "\06\00" ;; 0 locals + "\10" ;; i32.const + "\dc\7c" ;; -420 + "\09\01" ;; return arity 1 +) diff --git a/test/parse/module/memory-segment-multi-string.txt b/test/parse/module/memory-segment-multi-string.txt new file mode 100644 index 00000000..51503ee4 --- /dev/null +++ b/test/parse/module/memory-segment-multi-string.txt @@ -0,0 +1,3 @@ +(module + (memory 1 + (segment 0 "hi" "there" "how" "are" "you"))) |