summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2017-02-23 16:19:52 -0800
committerGitHub <noreply@github.com>2017-02-23 16:19:52 -0800
commite20131dac9bd01799ce4397cdf7e67f40001356d (patch)
tree9ae94b119bbe04e8047468fff74a165028fcb4a5 /src
parentadaf0c5b86925975ca2a7048b3057da6414722cc (diff)
downloadwabt-e20131dac9bd01799ce4397cdf7e67f40001356d.tar.gz
wabt-e20131dac9bd01799ce4397cdf7e67f40001356d.tar.bz2
wabt-e20131dac9bd01799ce4397cdf7e67f40001356d.zip
Switch C files to CC files (#309)
Mostly this involves adding additional casts. Though there are a few more substantial changes: * The default method for relocating parser stacks no longer works because Bison assumes that C++ values can't be memcpy'd. Ours can, but there's no easy way to make the generated code do the right thing, so we do it manually * Removed all uses of WabtBool and replaced with bool * Renamed all uses of export and mutable -> export_ and mutable_ * Casting an invalid value to an enum triggers ubsan, so we have to be a little more careful about when we do it (see binary-reader.c:read_sections()) * It's illegal to forward-declare enums, so we just #include instead. * Designated initializers are not allowed in g++, so we have to switch them to lazily initialized structures instead. Pretty horrible, so it will be nice to have a better solution for C++.
Diffstat (limited to 'src')
-rw-r--r--src/apply-names.cc (renamed from src/apply-names.c)38
-rw-r--r--src/array.h2
-rw-r--r--src/ast-lexer.cc (renamed from src/ast-lexer.c)14
-rw-r--r--src/ast-lexer.h2
-rw-r--r--src/ast-parser-lexer-shared.cc (renamed from src/ast-parser-lexer-shared.c)4
-rw-r--r--src/ast-parser-lexer-shared.h10
-rw-r--r--src/ast-parser.y89
-rw-r--r--src/ast-writer.cc (renamed from src/ast-writer.c)28
-rw-r--r--src/ast.cc (renamed from src/ast.c)19
-rw-r--r--src/ast.h16
-rw-r--r--src/binary-reader-ast.cc (renamed from src/binary-reader-ast.c)363
-rw-r--r--src/binary-reader-interpreter.cc (renamed from src/binary-reader-interpreter.c)350
-rw-r--r--src/binary-reader-linker.cc (renamed from src/binary-reader-linker.c)98
-rw-r--r--src/binary-reader-objdump.cc (renamed from src/binary-reader-objdump.c)280
-rw-r--r--src/binary-reader-objdump.h14
-rw-r--r--src/binary-reader-opcnt.cc (renamed from src/binary-reader-opcnt.c)35
-rw-r--r--src/binary-reader.cc (renamed from src/binary-reader.c)474
-rw-r--r--src/binary-reader.h8
-rw-r--r--src/binary-writer-spec.cc (renamed from src/binary-writer-spec.c)18
-rw-r--r--src/binary-writer.cc (renamed from src/binary-writer.c)18
-rw-r--r--src/binary-writer.h14
-rw-r--r--src/binary.cc (renamed from src/binary.c)0
-rw-r--r--src/binding-hash.cc (renamed from src/binding-hash.c)2
-rw-r--r--src/binding-hash.h2
-rw-r--r--src/common.cc (renamed from src/common.c)50
-rw-r--r--src/common.h27
-rw-r--r--src/config.cc (renamed from src/config.c)0
-rw-r--r--src/config.h.in18
-rw-r--r--src/emscripten-helpers.cc (renamed from src/emscripten-helpers.c)0
-rw-r--r--src/generate-names.cc (renamed from src/generate-names.c)10
-rw-r--r--src/interpreter.cc (renamed from src/interpreter.c)86
-rw-r--r--src/interpreter.h18
-rw-r--r--src/literal.cc (renamed from src/literal.c)68
-rw-r--r--src/option-parser.cc (renamed from src/option-parser.c)6
-rw-r--r--src/prebuilt/ast-lexer-gen.cc (renamed from src/prebuilt/ast-lexer-gen.c)984
-rw-r--r--src/prebuilt/ast-parser-gen.cc (renamed from src/prebuilt/ast-parser-gen.c)997
-rw-r--r--src/resolve-names.cc (renamed from src/resolve-names.c)46
-rw-r--r--src/stream.cc (renamed from src/stream.c)2
-rw-r--r--src/tools/wasm-interp.cc (renamed from src/tools/wasm-interp.c)97
-rw-r--r--src/tools/wasm-link.cc (renamed from src/tools/wasm-link.c)50
-rw-r--r--src/tools/wasm2wast.cc (renamed from src/tools/wasm2wast.c)8
-rw-r--r--src/tools/wasmdump.cc (renamed from src/tools/wasmdump.c)19
-rw-r--r--src/tools/wasmopcodecnt.cc (renamed from src/tools/wasmopcodecnt.c)8
-rw-r--r--src/tools/wast-desugar.cc (renamed from src/tools/wast-desugar.c)4
-rw-r--r--src/tools/wast2wasm.cc (renamed from src/tools/wast2wasm.c)20
-rw-r--r--src/type-checker.cc (renamed from src/type-checker.c)16
-rw-r--r--src/type-checker.h4
-rw-r--r--src/type-vector.h12
-rw-r--r--src/validator.cc (renamed from src/validator.c)22
-rw-r--r--src/vector.cc (renamed from src/vector.c)0
-rw-r--r--src/wasm-link.h4
-rw-r--r--src/writer.cc (renamed from src/writer.c)6
52 files changed, 2270 insertions, 2210 deletions
diff --git a/src/apply-names.c b/src/apply-names.cc
index e7bf63a8..d8c9680d 100644
--- a/src/apply-names.c
+++ b/src/apply-names.cc
@@ -151,45 +151,45 @@ static WabtResult use_name_for_param_and_local_var(Context* ctx,
}
static WabtResult begin_block_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
push_label(ctx, &expr->block.label);
return WABT_OK;
}
static WabtResult end_block_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
pop_label(ctx);
return WABT_OK;
}
static WabtResult begin_loop_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
push_label(ctx, &expr->loop.label);
return WABT_OK;
}
static WabtResult end_loop_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
pop_label(ctx);
return WABT_OK;
}
static WabtResult on_br_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtLabel* label = find_label_by_var(ctx, &expr->br.var);
use_name_for_var(label, &expr->br.var);
return WABT_OK;
}
static WabtResult on_br_if_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtLabel* label = find_label_by_var(ctx, &expr->br_if.var);
use_name_for_var(label, &expr->br_if.var);
return WABT_OK;
}
static WabtResult on_br_table_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
size_t i;
WabtVarVector* targets = &expr->br_table.targets;
for (i = 0; i < targets->size; ++i) {
@@ -204,58 +204,58 @@ static WabtResult on_br_table_expr(WabtExpr* expr, void* user_data) {
}
static WabtResult on_call_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(use_name_for_func_var(ctx->module, &expr->call.var));
return WABT_OK;
}
static WabtResult on_call_indirect_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(
use_name_for_func_type_var(ctx->module, &expr->call_indirect.var));
return WABT_OK;
}
static WabtResult on_get_global_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(use_name_for_global_var(ctx->module, &expr->get_global.var));
return WABT_OK;
}
static WabtResult on_get_local_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(use_name_for_param_and_local_var(ctx, ctx->current_func,
&expr->get_local.var));
return WABT_OK;
}
static WabtResult begin_if_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
push_label(ctx, &expr->if_.true_.label);
return WABT_OK;
}
static WabtResult end_if_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
pop_label(ctx);
return WABT_OK;
}
static WabtResult on_set_global_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(use_name_for_global_var(ctx->module, &expr->set_global.var));
return WABT_OK;
}
static WabtResult on_set_local_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(use_name_for_param_and_local_var(ctx, ctx->current_func,
&expr->set_local.var));
return WABT_OK;
}
static WabtResult on_tee_local_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(use_name_for_param_and_local_var(ctx, ctx->current_func,
&expr->tee_local.var));
return WABT_OK;
@@ -283,9 +283,9 @@ static WabtResult visit_func(Context* ctx,
static WabtResult visit_export(Context* ctx,
uint32_t export_index,
- WabtExport* export) {
- if (export->kind == WABT_EXTERNAL_KIND_FUNC) {
- use_name_for_func_var(ctx->module, &export->var);
+ WabtExport* export_) {
+ if (export_->kind == WABT_EXTERNAL_KIND_FUNC) {
+ use_name_for_func_var(ctx->module, &export_->var);
}
return WABT_OK;
}
diff --git a/src/array.h b/src/array.h
index e1f37a79..341c6243 100644
--- a/src/array.h
+++ b/src/array.h
@@ -39,7 +39,7 @@
} \
void wabt_new_##name##_array(type##Array* array, size_t size) { \
array->size = size; \
- array->data = wabt_alloc_zero(size * sizeof(type)); \
+ array->data = (type*)wabt_alloc_zero(size * sizeof(type)); \
}
#define WABT_DESTROY_ARRAY_AND_ELEMENTS(v, name) \
diff --git a/src/ast-lexer.c b/src/ast-lexer.cc
index 8298b927..07f3c425 100644
--- a/src/ast-lexer.c
+++ b/src/ast-lexer.cc
@@ -113,7 +113,7 @@ static WabtResult fill(WabtLocation* loc,
/* TODO(binji): could just alloc instead, because we know we'll need to
* memmove below */
- char* new_buffer = wabt_realloc(lexer->buffer, new_buffer_size);
+ char* new_buffer = (char*)wabt_realloc(lexer->buffer, new_buffer_size);
if (new_buffer == NULL) {
wabt_ast_parser_error(loc, lexer, parser,
"unable to reallocate lexer buffer.");
@@ -157,7 +157,7 @@ static WabtResult fill(WabtLocation* loc,
* characters", that are not a lexeme nor a lexeme suffix. see
* http://re2c.org/examples/example_03.html */
if (lexer->limit < lexer->buffer + lexer->buffer_size - YYMAXFILL) {
- lexer->eof = WABT_TRUE;
+ lexer->eof = true;
memset(lexer->limit, 0, YYMAXFILL);
lexer->limit += YYMAXFILL;
}
@@ -468,7 +468,7 @@ int wabt_ast_lexer_lex(WABT_AST_PARSER_STYPE* lval,
static WabtAstLexer* wabt_new_lexer(WabtAstLexerSourceType type,
const char* filename) {
- WabtAstLexer* lexer = wabt_alloc_zero(sizeof(WabtAstLexer));
+ WabtAstLexer* lexer = (WabtAstLexer*)wabt_alloc_zero(sizeof(WabtAstLexer));
lexer->line = 1;
lexer->filename = filename;
lexer->source.type = type;
@@ -519,7 +519,7 @@ static WabtResult scan_forward_for_line_offset_in_buffer(
int line = buffer_line;
int line_offset = 0;
const char* p;
- WabtBool is_previous_carriage = 0;
+ bool is_previous_carriage = 0;
for (p = buffer_start; p < buffer_end; ++p) {
if (*p == '\n') {
if (find_position == WABT_LINE_OFFSET_POSITION_START) {
@@ -609,7 +609,7 @@ static WabtResult scan_forward_for_line_offset(
size_t* out_line_offset) {
assert(line <= find_line);
if (lexer->source.type == WABT_LEXER_SOURCE_TYPE_BUFFER) {
- const char* source_buffer = lexer->source.buffer.data;
+ const char* source_buffer = (const char*)lexer->source.buffer.data;
const char* buffer_start = source_buffer + line_start_offset;
const char* buffer_end = source_buffer + lexer->source.buffer.size;
return scan_forward_for_line_offset_in_buffer(
@@ -714,8 +714,8 @@ WabtResult wabt_ast_lexer_get_source_line(WabtAstLexer* lexer,
clamp_source_line_offsets_to_location(line_start, line_end, loc->first_column,
loc->last_column, line_max_length,
&new_line_start, &new_line_end);
- WabtBool has_start_ellipsis = line_start != new_line_start;
- WabtBool has_end_ellipsis = line_end != new_line_end;
+ bool has_start_ellipsis = line_start != new_line_start;
+ bool has_end_ellipsis = line_end != new_line_end;
char* write_start = line;
size_t line_length = new_line_end - new_line_start;
diff --git a/src/ast-lexer.h b/src/ast-lexer.h
index d85f0fb4..0b620be3 100644
--- a/src/ast-lexer.h
+++ b/src/ast-lexer.h
@@ -49,7 +49,7 @@ typedef struct WabtAstLexer {
size_t line_file_offset; /* file offset of the start of the current line */
/* lexing data needed by re2c */
- WabtBool eof;
+ bool eof;
char* buffer;
size_t buffer_size;
char* marker;
diff --git a/src/ast-parser-lexer-shared.c b/src/ast-parser-lexer-shared.cc
index 8c41e3ca..8e5ef684 100644
--- a/src/ast-parser-lexer-shared.c
+++ b/src/ast-parser-lexer-shared.cc
@@ -43,7 +43,7 @@ void wabt_ast_format_error(WabtSourceErrorHandler* error_handler,
char* buffer = fixed_buf;
size_t len = wabt_vsnprintf(fixed_buf, sizeof(fixed_buf), format, args);
if (len + 1 > sizeof(fixed_buf)) {
- buffer = alloca(len + 1);
+ buffer = (char*)alloca(len + 1);
len = wabt_vsnprintf(buffer, len + 1, format, args_copy);
}
@@ -52,7 +52,7 @@ void wabt_ast_format_error(WabtSourceErrorHandler* error_handler,
int source_line_column_offset = 0;
size_t source_line_max_length = error_handler->source_line_max_length;
if (loc && lexer) {
- source_line = alloca(source_line_max_length + 1);
+ source_line = (char*)alloca(source_line_max_length + 1);
WabtResult result = wabt_ast_lexer_get_source_line(
lexer, loc, source_line_max_length, source_line, &source_line_length,
&source_line_column_offset);
diff --git a/src/ast-parser-lexer-shared.h b/src/ast-parser-lexer-shared.h
index f66e19e6..0b759556 100644
--- a/src/ast-parser-lexer-shared.h
+++ b/src/ast-parser-lexer-shared.h
@@ -48,7 +48,7 @@ typedef struct WabtTextList {
typedef struct WabtOptionalExport {
WabtExport export_;
- WabtBool has_export;
+ bool has_export;
} WabtOptionalExport;
typedef struct WabtExportedFunc {
@@ -65,14 +65,14 @@ typedef struct WabtExportedTable {
WabtTable table;
WabtElemSegment elem_segment;
WabtOptionalExport export_;
- WabtBool has_elem_segment;
+ bool has_elem_segment;
} WabtExportedTable;
typedef struct WabtExportedMemory {
WabtMemory memory;
WabtDataSegment data_segment;
WabtOptionalExport export_;
- WabtBool has_data_segment;
+ bool has_data_segment;
} WabtExportedMemory;
typedef enum WabtFuncFieldType {
@@ -150,6 +150,10 @@ typedef struct WabtAstParser {
WabtScript script;
WabtSourceErrorHandler* error_handler;
int errors;
+ /* Cached pointers to reallocated parser buffers, so they don't leak. */
+ int16_t* yyssa;
+ YYSTYPE* yyvsa;
+ YYLTYPE* yylsa;
} WabtAstParser;
WABT_EXTERN_C_BEGIN
diff --git a/src/ast-parser.y b/src/ast-parser.y
index 4fc591c2..16315080 100644
--- a/src/ast-parser.y
+++ b/src/ast-parser.y
@@ -28,16 +28,26 @@
#define INVALID_VAR_INDEX (-1)
-/* the default value for YYMAXDEPTH is 10000, which can be easily hit since our
- grammar is right-recursive.
+#define RELOCATE_STACK(type, array, stack_base, old_byte_size, new_size) \
+ do { \
+ if ((stack_base) == (array)) { \
+ (stack_base) = (type*)wabt_alloc((new_size) * sizeof(*(stack_base))); \
+ memcpy((stack_base), (array), old_byte_size); \
+ } else { \
+ (stack_base) = (type*)wabt_realloc((stack_base), \
+ (new_size) * sizeof(*(stack_base))); \
+ } \
+ /* Cache the pointer in the parser struct to be free'd later. */ \
+ parser->array = (stack_base); \
+ } while (0)
- we can increase YYMAXDEPTH, but the generated parser says that "results are
- undefined" if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES(YYMAXDEPTH) with
- infinite-precision arithmetic. That's tricky to write a static assertion
- for, so let's "just" limit YYSTACK_BYTES(YYMAXDEPTH) to UINT32_MAX and use
- 64-bit arithmetic. this static assert is done at the end of the file, so all
- defines are available. */
-#define YYMAXDEPTH 10000000
+#define yyoverflow(message, ss, ss_size, vs, vs_size, ls, ls_size, new_size) \
+ do { \
+ *(new_size) *= 2; \
+ RELOCATE_STACK(yytype_int16, yyssa, *(ss), (ss_size), *(new_size)); \
+ RELOCATE_STACK(YYSTYPE, yyvsa, *(vs), (vs_size), *(new_size)); \
+ RELOCATE_STACK(YYLTYPE, yylsa, *(ls), (ls_size), *(new_size)); \
+ } while (0)
#define DUPTEXT(dst, src) \
(dst).start = wabt_strndup((src).start, (src).length); \
@@ -136,27 +146,27 @@ static WabtExprList join_exprs2(WabtLocation* loc, WabtExprList* expr1,
WabtExpr* expr2);
static WabtFuncField* new_func_field(void) {
- return wabt_alloc_zero(sizeof(WabtFuncField));
+ return (WabtFuncField*)wabt_alloc_zero(sizeof(WabtFuncField));
}
static WabtFunc* new_func(void) {
- return wabt_alloc_zero(sizeof(WabtFunc));
+ return (WabtFunc*)wabt_alloc_zero(sizeof(WabtFunc));
}
static WabtCommand* new_command(void) {
- return wabt_alloc_zero(sizeof(WabtCommand));
+ return (WabtCommand*)wabt_alloc_zero(sizeof(WabtCommand));
}
static WabtModule* new_module(void) {
- return wabt_alloc_zero(sizeof(WabtModule));
+ return (WabtModule*)wabt_alloc_zero(sizeof(WabtModule));
}
static WabtImport* new_import(void) {
- return wabt_alloc_zero(sizeof(WabtImport));
+ return (WabtImport*)wabt_alloc_zero(sizeof(WabtImport));
}
static WabtTextListNode* new_text_list_node(void) {
- return wabt_alloc_zero(sizeof(WabtTextListNode));
+ return (WabtTextListNode*)wabt_alloc_zero(sizeof(WabtTextListNode));
}
static WabtResult parse_const(WabtType type, WabtLiteralType literal_type,
@@ -164,7 +174,7 @@ static WabtResult parse_const(WabtType type, WabtLiteralType literal_type,
static void dup_text_list(WabtTextList * text_list, void** out_data,
size_t* out_size);
-static WabtBool is_empty_signature(WabtFuncSignature* sig);
+static bool is_empty_signature(WabtFuncSignature* sig);
static void append_implicit_func_declaration(WabtLocation*, WabtModule*,
WabtFuncDeclaration*);
@@ -323,7 +333,7 @@ quoted_text :
void* data;
size_t size;
dup_text_list(&text_list, &data, &size);
- $$.start = data;
+ $$.start = (const char*)data;
$$.length = size;
}
;
@@ -344,12 +354,12 @@ global_type :
VALUE_TYPE {
WABT_ZERO_MEMORY($$);
$$.type = $1;
- $$.mutable_ = WABT_FALSE;
+ $$.mutable_ = false;
}
| LPAR MUT VALUE_TYPE RPAR {
WABT_ZERO_MEMORY($$);
$$.type = $3;
- $$.mutable_ = WABT_TRUE;
+ $$.mutable_ = true;
}
;
func_type :
@@ -380,12 +390,12 @@ memory_sig :
;
limits :
nat {
- $$.has_max = WABT_FALSE;
+ $$.has_max = false;
$$.initial = $1;
$$.max = 0;
}
| nat nat {
- $$.has_max = WABT_TRUE;
+ $$.has_max = true;
$$.initial = $1;
$$.max = $2;
}
@@ -869,7 +879,7 @@ table :
LPAR TABLE bind_var_opt inline_export_opt table_sig RPAR {
$$.table = $5;
$$.table.name = $3;
- $$.has_elem_segment = WABT_FALSE;
+ $$.has_elem_segment = false;
$$.export_ = $4;
}
| LPAR TABLE bind_var_opt inline_export_opt elem_type
@@ -883,8 +893,8 @@ table :
$$.table.name = $3;
$$.table.elem_limits.initial = $8.size;
$$.table.elem_limits.max = $8.size;
- $$.table.elem_limits.has_max = WABT_TRUE;
- $$.has_elem_segment = WABT_TRUE;
+ $$.table.elem_limits.has_max = true;
+ $$.has_elem_segment = true;
$$.elem_segment.offset = expr;
$$.elem_segment.vars = $8;
$$.export_ = $4;
@@ -915,7 +925,7 @@ memory :
WABT_ZERO_MEMORY($$);
$$.memory = $5;
$$.memory.name = $3;
- $$.has_data_segment = WABT_FALSE;
+ $$.has_data_segment = false;
$$.export_ = $4;
}
| LPAR MEMORY bind_var_opt inline_export LPAR DATA text_list RPAR RPAR {
@@ -925,7 +935,7 @@ memory :
expr->const_.u32 = 0;
WABT_ZERO_MEMORY($$);
- $$.has_data_segment = WABT_TRUE;
+ $$.has_data_segment = true;
$$.data_segment.offset = expr;
dup_text_list(&$7, &$$.data_segment.data, &$$.data_segment.size);
wabt_destroy_text_list(&$7);
@@ -934,7 +944,7 @@ memory :
$$.memory.name = $3;
$$.memory.page_limits.initial = page_size;
$$.memory.page_limits.max = page_size;
- $$.memory.page_limits.has_max = WABT_TRUE;
+ $$.memory.page_limits.has_max = true;
$$.export_ = $4;
}
/* Duplicate above for empty inline_export_opt to avoid LR(1) conflict. */
@@ -945,7 +955,7 @@ memory :
expr->const_.u32 = 0;
WABT_ZERO_MEMORY($$);
- $$.has_data_segment = WABT_TRUE;
+ $$.has_data_segment = true;
$$.data_segment.offset = expr;
dup_text_list(&$6, &$$.data_segment.data, &$$.data_segment.size);
wabt_destroy_text_list(&$6);
@@ -954,8 +964,8 @@ memory :
$$.memory.name = $3;
$$.memory.page_limits.initial = page_size;
$$.memory.page_limits.max = page_size;
- $$.memory.page_limits.has_max = WABT_TRUE;
- $$.export_.has_export = WABT_FALSE;
+ $$.memory.page_limits.has_max = true;
+ $$.export_.has_export = false;
}
;
@@ -972,7 +982,7 @@ global :
$$.global = $4;
$$.global.name = $3;
$$.global.init_expr = $5.first;
- $$.export_.has_export = WABT_FALSE;
+ $$.export_.has_export = false;
}
;
@@ -1091,14 +1101,14 @@ export :
inline_export_opt :
/* empty */ {
WABT_ZERO_MEMORY($$);
- $$.has_export = WABT_FALSE;
+ $$.has_export = false;
}
| inline_export
;
inline_export :
LPAR EXPORT quoted_text RPAR {
WABT_ZERO_MEMORY($$);
- $$.has_export = WABT_TRUE;
+ $$.has_export = true;
$$.export_.name = $3;
}
;
@@ -1637,7 +1647,7 @@ static void dup_text_list(WabtTextList* text_list,
size_t size = (end > src) ? (end - src) : 0;
total_size += size;
}
- char* result = wabt_alloc(total_size);
+ char* result = (char*)wabt_alloc(total_size);
char* dest = result;
for (node = text_list->first; node; node = node->next) {
size_t actual_size = copy_string_contents(&node->text, dest);
@@ -1647,7 +1657,7 @@ static void dup_text_list(WabtTextList* text_list,
*out_size = dest - result;
}
-static WabtBool is_empty_signature(WabtFuncSignature* sig) {
+static bool is_empty_signature(WabtFuncSignature* sig) {
return sig->result_types.size == 0 && sig->param_types.size == 0;
}
@@ -1677,13 +1687,16 @@ WabtResult wabt_parse_ast(WabtAstLexer* lexer,
WABT_ZERO_MEMORY(parser);
parser.error_handler = error_handler;
int result = wabt_ast_parser_parse(lexer, &parser);
+ wabt_free(parser.yyssa);
+ wabt_free(parser.yyvsa);
+ wabt_free(parser.yylsa);
*out_script = parser.script;
return result == 0 && parser.errors == 0 ? WABT_OK : WABT_ERROR;
}
static void on_read_binary_error(uint32_t offset, const char* error,
void* user_data) {
- BinaryErrorCallbackData* data = user_data;
+ BinaryErrorCallbackData* data = (BinaryErrorCallbackData*)user_data;
if (offset == WABT_UNKNOWN_OFFSET) {
wabt_ast_parser_error(data->loc, data->lexer, data->parser,
"error in binary module: %s", error);
@@ -1692,7 +1705,3 @@ static void on_read_binary_error(uint32_t offset, const char* error,
"error in binary module: @0x%08x: %s", offset, error);
}
}
-
-/* see comment above definition of YYMAXDEPTH at the top of this file */
-WABT_STATIC_ASSERT(YYSTACK_ALLOC_MAXIMUM >= UINT32_MAX);
-WABT_STATIC_ASSERT(YYSTACK_BYTES((uint64_t)YYMAXDEPTH) <= UINT32_MAX);
diff --git a/src/ast-writer.c b/src/ast-writer.cc
index b6d64b71..58f220f4 100644
--- a/src/ast-writer.c
+++ b/src/ast-writer.cc
@@ -142,7 +142,7 @@ static void write_puts_newline(Context* ctx, const char* s) {
write_puts(ctx, s, NEXT_CHAR_NEWLINE);
}
-static void write_newline(Context* ctx, WabtBool force) {
+static void write_newline(Context* ctx, bool force) {
if (ctx->next_char == NEXT_CHAR_FORCE_NEWLINE)
write_next_char(ctx);
ctx->next_char = force ? NEXT_CHAR_FORCE_NEWLINE : NEXT_CHAR_NEWLINE;
@@ -184,12 +184,12 @@ static void write_string_slice(Context* ctx,
ctx->next_char = next_char;
}
-static WabtBool write_string_slice_opt(Context* ctx,
+static bool write_string_slice_opt(Context* ctx,
const WabtStringSlice* str,
NextChar next_char) {
if (str->start)
write_string_slice(ctx, str, next_char);
- return str->start ? WABT_TRUE : WABT_FALSE;
+ return str->start != NULL;
}
static void write_string_slice_or_index(Context* ctx,
@@ -203,7 +203,7 @@ static void write_string_slice_or_index(Context* ctx,
}
static void write_quoted_data(Context* ctx, const void* data, size_t length) {
- const uint8_t* u8_data = data;
+ const uint8_t* u8_data = (const uint8_t*)data;
static const char s_hexdigits[] = "0123456789abcdef";
write_next_char(ctx);
write_putc(ctx, '\"');
@@ -282,7 +282,7 @@ static void write_begin_block(Context* ctx,
const WabtBlock* block,
const char* text) {
write_puts_space(ctx, text);
- WabtBool has_label =
+ bool has_label =
write_string_slice_opt(ctx, &block->label, NEXT_CHAR_SPACE);
write_types(ctx, &block->sig, NULL);
if (!has_label)
@@ -529,22 +529,22 @@ static void write_type_bindings(Context* ctx,
* (param $foo i32)
* (param i32 i64 f32)
*/
- WabtBool is_open = WABT_FALSE;
+ bool is_open = false;
size_t i;
for (i = 0; i < types->size; ++i) {
if (!is_open) {
write_open_space(ctx, prefix);
- is_open = WABT_TRUE;
+ is_open = true;
}
const WabtStringSlice* name = &ctx->index_to_name.data[i];
- WabtBool has_name = name->start != NULL;
+ bool has_name = name->start != NULL;
if (has_name)
write_string_slice(ctx, name, NEXT_CHAR_SPACE);
write_type(ctx, types->data[i], NEXT_CHAR_SPACE);
if (has_name) {
write_close_space(ctx);
- is_open = WABT_FALSE;
+ is_open = false;
}
}
if (is_open)
@@ -673,14 +673,14 @@ static void write_import(Context* ctx, const WabtImport* import) {
write_close_newline(ctx);
}
-static void write_export(Context* ctx, const WabtExport* export) {
+static void write_export(Context* ctx, const WabtExport* export_) {
static const char* s_kind_names[] = {"func", "table", "memory", "global"};
WABT_STATIC_ASSERT(WABT_ARRAY_SIZE(s_kind_names) == WABT_NUM_EXTERNAL_KINDS);
write_open_space(ctx, "export");
- write_quoted_string_slice(ctx, &export->name, NEXT_CHAR_SPACE);
- assert(export->kind < WABT_ARRAY_SIZE(s_kind_names));
- write_open_space(ctx, s_kind_names[export->kind]);
- write_var(ctx, &export->var, NEXT_CHAR_SPACE);
+ write_quoted_string_slice(ctx, &export_->name, NEXT_CHAR_SPACE);
+ assert(export_->kind < WABT_ARRAY_SIZE(s_kind_names));
+ write_open_space(ctx, s_kind_names[export_->kind]);
+ write_var(ctx, &export_->var, NEXT_CHAR_SPACE);
write_close_space(ctx);
write_close_newline(ctx);
}
diff --git a/src/ast.c b/src/ast.cc
index 0a7b200b..80d41f53 100644
--- a/src/ast.c
+++ b/src/ast.cc
@@ -199,7 +199,8 @@ void wabt_find_duplicate_bindings(const WabtBindingHash* bindings,
}
WabtModuleField* wabt_append_module_field(WabtModule* module) {
- WabtModuleField* result = wabt_alloc_zero(sizeof(WabtModuleField));
+ WabtModuleField* result =
+ (WabtModuleField*)wabt_alloc_zero(sizeof(WabtModuleField));
if (!module->first_field)
module->first_field = result;
else if (module->last_field)
@@ -250,11 +251,11 @@ WabtFuncType* wabt_append_implicit_func_type(WabtLocation* loc,
V(WABT_EXPR_TYPE_SELECT, select) \
V(WABT_EXPR_TYPE_UNREACHABLE, unreachable)
-#define DEFINE_NEW_EXPR(type_, name) \
- WabtExpr* wabt_new_##name##_expr(void) { \
- WabtExpr* result = wabt_alloc_zero(sizeof(WabtExpr)); \
- result->type = type_; \
- return result; \
+#define DEFINE_NEW_EXPR(type_, name) \
+ WabtExpr* wabt_new_##name##_expr(void) { \
+ WabtExpr* result = (WabtExpr*)wabt_alloc_zero(sizeof(WabtExpr)); \
+ result->type = type_; \
+ return result; \
}
FOREACH_EXPR_TYPE(DEFINE_NEW_EXPR)
#undef DEFINE_NEW_EXPR
@@ -393,9 +394,9 @@ void wabt_destroy_import(WabtImport* import) {
}
}
-void wabt_destroy_export(WabtExport* export) {
- wabt_destroy_string_slice(&export->name);
- wabt_destroy_var(&export->var);
+void wabt_destroy_export(WabtExport* export_) {
+ wabt_destroy_string_slice(&export_->name);
+ wabt_destroy_var(&export_->var);
}
void wabt_destroy_func_type(WabtFuncType* func_type) {
diff --git a/src/ast.h b/src/ast.h
index 4b7eeff5..39fd5fc4 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -152,7 +152,7 @@ WABT_DEFINE_VECTOR(func_ptr, WabtFuncPtr);
typedef struct WabtGlobal {
WabtStringSlice name;
WabtType type;
- WabtBool mutable_;
+ bool mutable_;
WabtExpr* init_expr;
} WabtGlobal;
typedef WabtGlobal* WabtGlobalPtr;
@@ -510,18 +510,18 @@ void wabt_find_duplicate_bindings(const WabtBindingHash*,
WabtDuplicateBindingCallback callback,
void* user_data);
-static WABT_INLINE WabtBool
+static WABT_INLINE bool
wabt_decl_has_func_type(const WabtFuncDeclaration* decl) {
- return (WabtBool)((decl->flags & WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE) !=
- 0);
+ return (bool)((decl->flags & WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE) != 0);
}
-static WABT_INLINE WabtBool
+static WABT_INLINE bool
wabt_signatures_are_equal(const WabtFuncSignature* sig1,
const WabtFuncSignature* sig2) {
- return (WabtBool)(
- wabt_type_vectors_are_equal(&sig1->param_types, &sig2->param_types) &&
- wabt_type_vectors_are_equal(&sig1->result_types, &sig2->result_types));
+ return (bool)(wabt_type_vectors_are_equal(&sig1->param_types,
+ &sig2->param_types) &&
+ wabt_type_vectors_are_equal(&sig1->result_types,
+ &sig2->result_types));
}
static WABT_INLINE size_t wabt_get_num_params(const WabtFunc* func) {
diff --git a/src/binary-reader-ast.c b/src/binary-reader-ast.cc
index d03d8a7b..89ede529 100644
--- a/src/binary-reader-ast.c
+++ b/src/binary-reader-ast.cc
@@ -130,12 +130,12 @@ static void handle_error(Context* ctx, uint32_t offset, const char* message) {
static void on_error(WabtBinaryReaderContext* reader_context,
const char* message) {
- Context* ctx = reader_context->user_data;
+ Context* ctx = (Context*)reader_context->user_data;
handle_error(ctx, reader_context->offset, message);
}
static WabtResult on_signature_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
wabt_reserve_func_type_ptrs(&ctx->module->func_types, count);
return WABT_OK;
}
@@ -146,7 +146,7 @@ static WabtResult on_signature(uint32_t index,
uint32_t result_count,
WabtType* result_types,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtModuleField* field = wabt_append_module_field(ctx->module);
field->type = WABT_MODULE_FIELD_TYPE_FUNC_TYPE;
@@ -171,7 +171,7 @@ static WabtResult on_signature(uint32_t index,
}
static WabtResult on_import_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
wabt_reserve_import_ptrs(&ctx->module->imports, count);
return WABT_OK;
}
@@ -180,7 +180,7 @@ static WabtResult on_import(uint32_t index,
WabtStringSlice module_name,
WabtStringSlice field_name,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(index < ctx->module->imports.capacity);
WabtModuleField* field = wabt_append_module_field(ctx->module);
@@ -200,7 +200,7 @@ static WabtResult on_import_func(uint32_t import_index,
uint32_t func_index,
uint32_t sig_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(import_index == ctx->module->imports.size - 1);
assert(sig_index < ctx->module->func_types.size);
WabtImport* import = ctx->module->imports.data[import_index];
@@ -223,7 +223,7 @@ static WabtResult on_import_table(uint32_t import_index,
WabtType elem_type,
const WabtLimits* elem_limits,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(import_index == ctx->module->imports.size - 1);
WabtImport* import = ctx->module->imports.data[import_index];
import->kind = WABT_EXTERNAL_KIND_TABLE;
@@ -239,7 +239,7 @@ static WabtResult on_import_memory(uint32_t import_index,
uint32_t memory_index,
const WabtLimits* page_limits,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(import_index == ctx->module->imports.size - 1);
WabtImport* import = ctx->module->imports.data[import_index];
import->kind = WABT_EXTERNAL_KIND_MEMORY;
@@ -254,9 +254,9 @@ static WabtResult on_import_memory(uint32_t import_index,
static WabtResult on_import_global(uint32_t import_index,
uint32_t global_index,
WabtType type,
- WabtBool mutable_,
+ bool mutable_,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(import_index == ctx->module->imports.size - 1);
WabtImport* import = ctx->module->imports.data[import_index];
import->kind = WABT_EXTERNAL_KIND_GLOBAL;
@@ -271,7 +271,7 @@ static WabtResult on_import_global(uint32_t import_index,
static WabtResult on_function_signatures_count(uint32_t count,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
wabt_reserve_func_ptrs(&ctx->module->funcs,
ctx->module->num_func_imports + count);
return WABT_OK;
@@ -280,7 +280,7 @@ static WabtResult on_function_signatures_count(uint32_t count,
static WabtResult on_function_signature(uint32_t index,
uint32_t sig_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(index < ctx->module->funcs.capacity);
assert(sig_index < ctx->module->func_types.size);
@@ -301,7 +301,7 @@ static WabtResult on_function_signature(uint32_t index,
}
static WabtResult on_table_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
wabt_reserve_table_ptrs(&ctx->module->tables,
ctx->module->num_table_imports + count);
return WABT_OK;
@@ -311,7 +311,7 @@ static WabtResult on_table(uint32_t index,
WabtType elem_type,
const WabtLimits* elem_limits,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(index < ctx->module->tables.capacity);
WabtModuleField* field = wabt_append_module_field(ctx->module);
@@ -327,7 +327,7 @@ static WabtResult on_table(uint32_t index,
}
static WabtResult on_memory_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
wabt_reserve_memory_ptrs(&ctx->module->memories,
ctx->module->num_memory_imports + count);
return WABT_OK;
@@ -336,7 +336,7 @@ static WabtResult on_memory_count(uint32_t count, void* user_data) {
static WabtResult on_memory(uint32_t index,
const WabtLimits* page_limits,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(index < ctx->module->memories.capacity);
WabtModuleField* field = wabt_append_module_field(ctx->module);
@@ -352,7 +352,7 @@ static WabtResult on_memory(uint32_t index,
}
static WabtResult on_global_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
wabt_reserve_global_ptrs(&ctx->module->globals,
ctx->module->num_global_imports + count);
return WABT_OK;
@@ -360,9 +360,9 @@ static WabtResult on_global_count(uint32_t count, void* user_data) {
static WabtResult begin_global(uint32_t index,
WabtType type,
- WabtBool mutable_,
+ bool mutable_,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(index < ctx->module->globals.capacity);
WabtModuleField* field = wabt_append_module_field(ctx->module);
@@ -379,7 +379,7 @@ static WabtResult begin_global(uint32_t index,
}
static WabtResult begin_global_init_expr(uint32_t index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(index == ctx->module->globals.size - 1);
WabtGlobal* global = ctx->module->globals.data[index];
ctx->current_init_expr = &global->init_expr;
@@ -387,13 +387,13 @@ static WabtResult begin_global_init_expr(uint32_t index, void* user_data) {
}
static WabtResult end_global_init_expr(uint32_t index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
ctx->current_init_expr = NULL;
return WABT_OK;
}
static WabtResult on_export_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
wabt_reserve_export_ptrs(&ctx->module->exports, count);
return WABT_OK;
}
@@ -403,13 +403,13 @@ static WabtResult on_export(uint32_t index,
uint32_t item_index,
WabtStringSlice name,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtModuleField* field = wabt_append_module_field(ctx->module);
field->type = WABT_MODULE_FIELD_TYPE_EXPORT;
- WabtExport* export = &field->export_;
- WABT_ZERO_MEMORY(*export);
- export->name = wabt_dup_string_slice(name);
+ WabtExport* export_ = &field->export_;
+ WABT_ZERO_MEMORY(*export_);
+ export_->name = wabt_dup_string_slice(name);
switch (kind) {
case WABT_EXTERNAL_KIND_FUNC:
assert(item_index < ctx->module->funcs.size);
@@ -427,18 +427,18 @@ static WabtResult on_export(uint32_t index,
assert(0);
break;
}
- export->var.type = WABT_VAR_TYPE_INDEX;
- export->var.index = item_index;
- export->kind = kind;
+ export_->var.type = WABT_VAR_TYPE_INDEX;
+ export_->var.index = item_index;
+ export_->kind = kind;
assert(index < ctx->module->exports.capacity);
WabtExportPtr* export_ptr = wabt_append_export_ptr(&ctx->module->exports);
- *export_ptr = export;
+ *export_ptr = export_;
return WABT_OK;
}
static WabtResult on_start_function(uint32_t func_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtModuleField* field = wabt_append_module_field(ctx->module);
field->type = WABT_MODULE_FIELD_TYPE_START;
@@ -451,7 +451,7 @@ static WabtResult on_start_function(uint32_t func_index, void* user_data) {
}
static WabtResult on_function_bodies_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(ctx->module->num_func_imports + count == ctx->module->funcs.size);
(void)ctx;
return WABT_OK;
@@ -459,7 +459,7 @@ static WabtResult on_function_bodies_count(uint32_t count, void* user_data) {
static WabtResult begin_function_body(WabtBinaryReaderContext* context,
uint32_t index) {
- Context* ctx = context->user_data;
+ Context* ctx = (Context*)context->user_data;
assert(index < ctx->module->funcs.size);
ctx->current_func = ctx->module->funcs.data[index];
push_label(ctx, WABT_LABEL_TYPE_FUNC, &ctx->current_func->first_expr);
@@ -470,7 +470,7 @@ static WabtResult on_local_decl(uint32_t decl_index,
uint32_t count,
WabtType type,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
size_t old_local_count = ctx->current_func->local_types.size;
size_t new_local_count = old_local_count + count;
wabt_reserve_types(&ctx->current_func->local_types, new_local_count);
@@ -483,7 +483,7 @@ static WabtResult on_local_decl(uint32_t decl_index,
}
static WabtResult on_binary_expr(WabtOpcode opcode, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_binary_expr();
expr->binary.opcode = opcode;
return append_expr(ctx, expr);
@@ -492,7 +492,7 @@ static WabtResult on_binary_expr(WabtOpcode opcode, void* user_data) {
static WabtResult on_block_expr(uint32_t num_types,
WabtType* sig_types,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_block_expr();
WabtTypeVector src;
WABT_ZERO_MEMORY(src);
@@ -505,7 +505,7 @@ static WabtResult on_block_expr(uint32_t num_types,
}
static WabtResult on_br_expr(uint32_t depth, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_br_expr();
expr->br.var.type = WABT_VAR_TYPE_INDEX;
expr->br.var.index = depth;
@@ -513,7 +513,7 @@ static WabtResult on_br_expr(uint32_t depth, void* user_data) {
}
static WabtResult on_br_if_expr(uint32_t depth, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_br_if_expr();
expr->br_if.var.type = WABT_VAR_TYPE_INDEX;
expr->br_if.var.index = depth;
@@ -524,7 +524,7 @@ static WabtResult on_br_table_expr(WabtBinaryReaderContext* context,
uint32_t num_targets,
uint32_t* target_depths,
uint32_t default_target_depth) {
- Context* ctx = context->user_data;
+ Context* ctx = (Context*)context->user_data;
WabtExpr* expr = wabt_new_br_table_expr();
wabt_reserve_vars(&expr->br_table.targets, num_targets);
expr->br_table.targets.size = num_targets;
@@ -540,7 +540,7 @@ static WabtResult on_br_table_expr(WabtBinaryReaderContext* context,
}
static WabtResult on_call_expr(uint32_t func_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(func_index < ctx->module->funcs.size);
WabtExpr* expr = wabt_new_call_expr();
expr->call.var.type = WABT_VAR_TYPE_INDEX;
@@ -549,7 +549,7 @@ static WabtResult on_call_expr(uint32_t func_index, void* user_data) {
}
static WabtResult on_call_indirect_expr(uint32_t sig_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(sig_index < ctx->module->func_types.size);
WabtExpr* expr = wabt_new_call_indirect_expr();
expr->call_indirect.var.type = WABT_VAR_TYPE_INDEX;
@@ -558,33 +558,33 @@ static WabtResult on_call_indirect_expr(uint32_t sig_index, void* user_data) {
}
static WabtResult on_compare_expr(WabtOpcode opcode, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_compare_expr();
expr->compare.opcode = opcode;
return append_expr(ctx, expr);
}
static WabtResult on_convert_expr(WabtOpcode opcode, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_convert_expr();
expr->convert.opcode = opcode;
return append_expr(ctx, expr);
}
static WabtResult on_current_memory_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_current_memory_expr();
return append_expr(ctx, expr);
}
static WabtResult on_drop_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_drop_expr();
return append_expr(ctx, expr);
}
static WabtResult on_else_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
LabelNode* label;
CHECK_RESULT(top_label(ctx, &label));
if (label->label_type != WABT_LABEL_TYPE_IF) {
@@ -603,12 +603,12 @@ static WabtResult on_else_expr(void* user_data) {
}
static WabtResult on_end_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
return pop_label(ctx);
}
static WabtResult on_f32_const_expr(uint32_t value_bits, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_const_expr();
expr->const_.type = WABT_TYPE_F32;
expr->const_.f32_bits = value_bits;
@@ -616,7 +616,7 @@ static WabtResult on_f32_const_expr(uint32_t value_bits, void* user_data) {
}
static WabtResult on_f64_const_expr(uint64_t value_bits, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_const_expr();
expr->const_.type = WABT_TYPE_F64;
expr->const_.f64_bits = value_bits;
@@ -624,7 +624,7 @@ static WabtResult on_f64_const_expr(uint64_t value_bits, void* user_data) {
}
static WabtResult on_get_global_expr(uint32_t global_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_get_global_expr();
expr->get_global.var.type = WABT_VAR_TYPE_INDEX;
expr->get_global.var.index = global_index;
@@ -632,7 +632,7 @@ static WabtResult on_get_global_expr(uint32_t global_index, void* user_data) {
}
static WabtResult on_get_local_expr(uint32_t local_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_get_local_expr();
expr->get_local.var.type = WABT_VAR_TYPE_INDEX;
expr->get_local.var.index = local_index;
@@ -640,13 +640,13 @@ static WabtResult on_get_local_expr(uint32_t local_index, void* user_data) {
}
static WabtResult on_grow_memory_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_grow_memory_expr();
return append_expr(ctx, expr);
}
static WabtResult on_i32_const_expr(uint32_t value, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_const_expr();
expr->const_.type = WABT_TYPE_I32;
expr->const_.u32 = value;
@@ -654,7 +654,7 @@ static WabtResult on_i32_const_expr(uint32_t value, void* user_data) {
}
static WabtResult on_i64_const_expr(uint64_t value, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_const_expr();
expr->const_.type = WABT_TYPE_I64;
expr->const_.u64 = value;
@@ -664,7 +664,7 @@ static WabtResult on_i64_const_expr(uint64_t value, void* user_data) {
static WabtResult on_if_expr(uint32_t num_types,
WabtType* sig_types,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_if_expr();
WabtTypeVector src;
WABT_ZERO_MEMORY(src);
@@ -680,7 +680,7 @@ static WabtResult on_load_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_load_expr();
expr->load.opcode = opcode;
expr->load.align = 1 << alignment_log2;
@@ -691,7 +691,7 @@ static WabtResult on_load_expr(WabtOpcode opcode,
static WabtResult on_loop_expr(uint32_t num_types,
WabtType* sig_types,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_loop_expr();
WabtTypeVector src;
WABT_ZERO_MEMORY(src);
@@ -704,25 +704,25 @@ static WabtResult on_loop_expr(uint32_t num_types,
}
static WabtResult on_nop_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_nop_expr();
return append_expr(ctx, expr);
}
static WabtResult on_return_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_return_expr();
return append_expr(ctx, expr);
}
static WabtResult on_select_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_select_expr();
return append_expr(ctx, expr);
}
static WabtResult on_set_global_expr(uint32_t global_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_set_global_expr();
expr->set_global.var.type = WABT_VAR_TYPE_INDEX;
expr->set_global.var.index = global_index;
@@ -730,7 +730,7 @@ static WabtResult on_set_global_expr(uint32_t global_index, void* user_data) {
}
static WabtResult on_set_local_expr(uint32_t local_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_set_local_expr();
expr->set_local.var.type = WABT_VAR_TYPE_INDEX;
expr->set_local.var.index = local_index;
@@ -741,7 +741,7 @@ static WabtResult on_store_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_store_expr();
expr->store.opcode = opcode;
expr->store.align = 1 << alignment_log2;
@@ -750,7 +750,7 @@ static WabtResult on_store_expr(WabtOpcode opcode,
}
static WabtResult on_tee_local_expr(uint32_t local_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_tee_local_expr();
expr->tee_local.var.type = WABT_VAR_TYPE_INDEX;
expr->tee_local.var.index = local_index;
@@ -758,27 +758,27 @@ static WabtResult on_tee_local_expr(uint32_t local_index, void* user_data) {
}
static WabtResult on_unary_expr(WabtOpcode opcode, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_unary_expr();
expr->unary.opcode = opcode;
return append_expr(ctx, expr);
}
static WabtResult on_unreachable_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_unreachable_expr();
return append_expr(ctx, expr);
}
static WabtResult end_function_body(uint32_t index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(pop_label(ctx));
ctx->current_func = NULL;
return WABT_OK;
}
static WabtResult on_elem_segment_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
wabt_reserve_elem_segment_ptrs(&ctx->module->elem_segments,
count);
return WABT_OK;
@@ -787,7 +787,7 @@ static WabtResult on_elem_segment_count(uint32_t count, void* user_data) {
static WabtResult begin_elem_segment(uint32_t index,
uint32_t table_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtModuleField* field = wabt_append_module_field(ctx->module);
field->type = WABT_MODULE_FIELD_TYPE_ELEM_SEGMENT;
@@ -806,7 +806,7 @@ static WabtResult begin_elem_segment(uint32_t index,
static WabtResult begin_elem_segment_init_expr(uint32_t index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(index == ctx->module->elem_segments.size - 1);
WabtElemSegment* segment = ctx->module->elem_segments.data[index];
ctx->current_init_expr = &segment->offset;
@@ -814,7 +814,7 @@ static WabtResult begin_elem_segment_init_expr(uint32_t index,
}
static WabtResult end_elem_segment_init_expr(uint32_t index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
ctx->current_init_expr = NULL;
return WABT_OK;
}
@@ -823,7 +823,7 @@ static WabtResult on_elem_segment_function_index_count(
WabtBinaryReaderContext* context,
uint32_t index,
uint32_t count) {
- Context* ctx = context->user_data;
+ Context* ctx = (Context*)context->user_data;
assert(index == ctx->module->elem_segments.size - 1);
WabtElemSegment* segment = ctx->module->elem_segments.data[index];
wabt_reserve_vars(&segment->vars, count);
@@ -833,7 +833,7 @@ static WabtResult on_elem_segment_function_index_count(
static WabtResult on_elem_segment_function_index(uint32_t index,
uint32_t func_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(index == ctx->module->elem_segments.size - 1);
WabtElemSegment* segment = ctx->module->elem_segments.data[index];
WabtVar* var = wabt_append_var(&segment->vars);
@@ -843,7 +843,7 @@ static WabtResult on_elem_segment_function_index(uint32_t index,
}
static WabtResult on_data_segment_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
wabt_reserve_data_segment_ptrs(&ctx->module->data_segments, count);
return WABT_OK;
}
@@ -851,7 +851,7 @@ static WabtResult on_data_segment_count(uint32_t count, void* user_data) {
static WabtResult begin_data_segment(uint32_t index,
uint32_t memory_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtModuleField* field = wabt_append_module_field(ctx->module);
field->type = WABT_MODULE_FIELD_TYPE_DATA_SEGMENT;
@@ -870,7 +870,7 @@ static WabtResult begin_data_segment(uint32_t index,
static WabtResult begin_data_segment_init_expr(uint32_t index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(index == ctx->module->data_segments.size - 1);
WabtDataSegment* segment = ctx->module->data_segments.data[index];
ctx->current_init_expr = &segment->offset;
@@ -878,7 +878,7 @@ static WabtResult begin_data_segment_init_expr(uint32_t index,
}
static WabtResult end_data_segment_init_expr(uint32_t index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
ctx->current_init_expr = NULL;
return WABT_OK;
}
@@ -887,7 +887,7 @@ static WabtResult on_data_segment_data(uint32_t index,
const void* data,
uint32_t size,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(index == ctx->module->data_segments.size - 1);
WabtDataSegment* segment = ctx->module->data_segments.data[index];
segment->data = wabt_alloc(size);
@@ -897,7 +897,7 @@ static WabtResult on_data_segment_data(uint32_t index,
}
static WabtResult on_function_names_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (count > ctx->module->funcs.size) {
print_error(
ctx, "expected function name count (%u) <= function count (%" PRIzd ")",
@@ -910,7 +910,7 @@ static WabtResult on_function_names_count(uint32_t count, void* user_data) {
static WabtResult on_function_name(uint32_t index,
WabtStringSlice name,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtStringSlice new_name;
dup_name(ctx, &name, &new_name);
@@ -927,7 +927,7 @@ static WabtResult on_function_name(uint32_t index,
static WabtResult on_local_names_count(uint32_t index,
uint32_t count,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtModule* module = ctx->module;
assert(index < module->funcs.size);
WabtFunc* func = module->funcs.data[index];
@@ -943,7 +943,7 @@ static WabtResult on_local_names_count(uint32_t index,
static WabtResult on_init_expr_f32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_const_expr();
expr->const_.type = WABT_TYPE_F32;
expr->const_.f32_bits = value;
@@ -954,7 +954,7 @@ static WabtResult on_init_expr_f32_const_expr(uint32_t index,
static WabtResult on_init_expr_f64_const_expr(uint32_t index,
uint64_t value,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_const_expr();
expr->const_.type = WABT_TYPE_F64;
expr->const_.f64_bits = value;
@@ -965,7 +965,7 @@ static WabtResult on_init_expr_f64_const_expr(uint32_t index,
static WabtResult on_init_expr_get_global_expr(uint32_t index,
uint32_t global_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_get_global_expr();
expr->get_global.var.type = WABT_VAR_TYPE_INDEX;
expr->get_global.var.index = global_index;
@@ -976,7 +976,7 @@ static WabtResult on_init_expr_get_global_expr(uint32_t index,
static WabtResult on_init_expr_i32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_const_expr();
expr->const_.type = WABT_TYPE_I32;
expr->const_.u32 = value;
@@ -987,7 +987,7 @@ static WabtResult on_init_expr_i32_const_expr(uint32_t index,
static WabtResult on_init_expr_i64_const_expr(uint32_t index,
uint64_t value,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtExpr* expr = wabt_new_const_expr();
expr->const_.type = WABT_TYPE_I64;
expr->const_.u64 = value;
@@ -999,7 +999,7 @@ static WabtResult on_local_name(uint32_t func_index,
uint32_t local_index,
WabtStringSlice name,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtModule* module = ctx->module;
WabtFunc* func = module->funcs.data[func_index];
uint32_t num_params = wabt_get_num_params(func);
@@ -1022,102 +1022,6 @@ static WabtResult on_local_name(uint32_t func_index,
return WABT_OK;
}
-static WabtBinaryReader s_binary_reader = {
- .user_data = NULL,
- .on_error = on_error,
-
- .on_signature_count = on_signature_count,
- .on_signature = on_signature,
-
- .on_import_count = on_import_count,
- .on_import = on_import,
- .on_import_func = on_import_func,
- .on_import_table = on_import_table,
- .on_import_memory = on_import_memory,
- .on_import_global = on_import_global,
-
- .on_function_signatures_count = on_function_signatures_count,
- .on_function_signature = on_function_signature,
-
- .on_table_count = on_table_count,
- .on_table = on_table,
-
- .on_memory_count = on_memory_count,
- .on_memory = on_memory,
-
- .on_global_count = on_global_count,
- .begin_global = begin_global,
- .begin_global_init_expr = begin_global_init_expr,
- .end_global_init_expr = end_global_init_expr,
-
- .on_export_count = on_export_count,
- .on_export = on_export,
-
- .on_start_function = on_start_function,
-
- .on_function_bodies_count = on_function_bodies_count,
- .begin_function_body = begin_function_body,
- .on_local_decl = on_local_decl,
- .on_binary_expr = on_binary_expr,
- .on_block_expr = on_block_expr,
- .on_br_expr = on_br_expr,
- .on_br_if_expr = on_br_if_expr,
- .on_br_table_expr = on_br_table_expr,
- .on_call_expr = on_call_expr,
- .on_call_indirect_expr = on_call_indirect_expr,
- .on_compare_expr = on_compare_expr,
- .on_convert_expr = on_convert_expr,
- .on_current_memory_expr = on_current_memory_expr,
- .on_drop_expr = on_drop_expr,
- .on_else_expr = on_else_expr,
- .on_end_expr = on_end_expr,
- .on_f32_const_expr = on_f32_const_expr,
- .on_f64_const_expr = on_f64_const_expr,
- .on_get_global_expr = on_get_global_expr,
- .on_get_local_expr = on_get_local_expr,
- .on_grow_memory_expr = on_grow_memory_expr,
- .on_i32_const_expr = on_i32_const_expr,
- .on_i64_const_expr = on_i64_const_expr,
- .on_if_expr = on_if_expr,
- .on_load_expr = on_load_expr,
- .on_loop_expr = on_loop_expr,
- .on_nop_expr = on_nop_expr,
- .on_return_expr = on_return_expr,
- .on_select_expr = on_select_expr,
- .on_set_global_expr = on_set_global_expr,
- .on_set_local_expr = on_set_local_expr,
- .on_store_expr = on_store_expr,
- .on_tee_local_expr = on_tee_local_expr,
- .on_unary_expr = on_unary_expr,
- .on_unreachable_expr = on_unreachable_expr,
- .end_function_body = end_function_body,
-
- .on_elem_segment_count = on_elem_segment_count,
- .begin_elem_segment = begin_elem_segment,
- .begin_elem_segment_init_expr = begin_elem_segment_init_expr,
- .end_elem_segment_init_expr = end_elem_segment_init_expr,
- .on_elem_segment_function_index_count =
- on_elem_segment_function_index_count,
- .on_elem_segment_function_index = on_elem_segment_function_index,
-
- .on_data_segment_count = on_data_segment_count,
- .begin_data_segment = begin_data_segment,
- .begin_data_segment_init_expr = begin_data_segment_init_expr,
- .end_data_segment_init_expr = end_data_segment_init_expr,
- .on_data_segment_data = on_data_segment_data,
-
- .on_function_names_count = on_function_names_count,
- .on_function_name = on_function_name,
- .on_local_names_count = on_local_names_count,
- .on_local_name = on_local_name,
-
- .on_init_expr_f32_const_expr = on_init_expr_f32_const_expr,
- .on_init_expr_f64_const_expr = on_init_expr_f64_const_expr,
- .on_init_expr_get_global_expr = on_init_expr_get_global_expr,
- .on_init_expr_i32_const_expr = on_init_expr_i32_const_expr,
- .on_init_expr_i64_const_expr = on_init_expr_i64_const_expr,
-};
-
static void wabt_destroy_label_node(LabelNode* node) {
if (*node->first)
wabt_destroy_expr_list(*node->first);
@@ -1135,8 +1039,99 @@ WabtResult wabt_read_binary_ast(const void* data,
WabtBinaryReader reader;
WABT_ZERO_MEMORY(reader);
- reader = s_binary_reader;
reader.user_data = &ctx;
+ reader.on_error = on_error;
+
+ reader.on_signature_count = on_signature_count;
+ reader.on_signature = on_signature;
+
+ reader.on_import_count = on_import_count;
+ reader.on_import = on_import;
+ reader.on_import_func = on_import_func;
+ reader.on_import_table = on_import_table;
+ reader.on_import_memory = on_import_memory;
+ reader.on_import_global = on_import_global;
+
+ reader.on_function_signatures_count = on_function_signatures_count;
+ reader.on_function_signature = on_function_signature;
+
+ reader.on_table_count = on_table_count;
+ reader.on_table = on_table;
+
+ reader.on_memory_count = on_memory_count;
+ reader.on_memory = on_memory;
+
+ reader.on_global_count = on_global_count;
+ reader.begin_global = begin_global;
+ reader.begin_global_init_expr = begin_global_init_expr;
+ reader.end_global_init_expr = end_global_init_expr;
+
+ reader.on_export_count = on_export_count;
+ reader.on_export = on_export;
+
+ reader.on_start_function = on_start_function;
+
+ reader.on_function_bodies_count = on_function_bodies_count;
+ reader.begin_function_body = begin_function_body;
+ reader.on_local_decl = on_local_decl;
+ reader.on_binary_expr = on_binary_expr;
+ reader.on_block_expr = on_block_expr;
+ reader.on_br_expr = on_br_expr;
+ reader.on_br_if_expr = on_br_if_expr;
+ reader.on_br_table_expr = on_br_table_expr;
+ reader.on_call_expr = on_call_expr;
+ reader.on_call_indirect_expr = on_call_indirect_expr;
+ reader.on_compare_expr = on_compare_expr;
+ reader.on_convert_expr = on_convert_expr;
+ reader.on_current_memory_expr = on_current_memory_expr;
+ reader.on_drop_expr = on_drop_expr;
+ reader.on_else_expr = on_else_expr;
+ reader.on_end_expr = on_end_expr;
+ reader.on_f32_const_expr = on_f32_const_expr;
+ reader.on_f64_const_expr = on_f64_const_expr;
+ reader.on_get_global_expr = on_get_global_expr;
+ reader.on_get_local_expr = on_get_local_expr;
+ reader.on_grow_memory_expr = on_grow_memory_expr;
+ reader.on_i32_const_expr = on_i32_const_expr;
+ reader.on_i64_const_expr = on_i64_const_expr;
+ reader.on_if_expr = on_if_expr;
+ reader.on_load_expr = on_load_expr;
+ reader.on_loop_expr = on_loop_expr;
+ reader.on_nop_expr = on_nop_expr;
+ reader.on_return_expr = on_return_expr;
+ reader.on_select_expr = on_select_expr;
+ reader.on_set_global_expr = on_set_global_expr;
+ reader.on_set_local_expr = on_set_local_expr;
+ reader.on_store_expr = on_store_expr;
+ reader.on_tee_local_expr = on_tee_local_expr;
+ reader.on_unary_expr = on_unary_expr;
+ reader.on_unreachable_expr = on_unreachable_expr;
+ reader.end_function_body = end_function_body;
+
+ reader.on_elem_segment_count = on_elem_segment_count;
+ reader.begin_elem_segment = begin_elem_segment;
+ reader.begin_elem_segment_init_expr = begin_elem_segment_init_expr;
+ reader.end_elem_segment_init_expr = end_elem_segment_init_expr;
+ reader.on_elem_segment_function_index_count =
+ on_elem_segment_function_index_count;
+ reader.on_elem_segment_function_index = on_elem_segment_function_index;
+
+ reader.on_data_segment_count = on_data_segment_count;
+ reader.begin_data_segment = begin_data_segment;
+ reader.begin_data_segment_init_expr = begin_data_segment_init_expr;
+ reader.end_data_segment_init_expr = end_data_segment_init_expr;
+ reader.on_data_segment_data = on_data_segment_data;
+
+ reader.on_function_names_count = on_function_names_count;
+ reader.on_function_name = on_function_name;
+ reader.on_local_names_count = on_local_names_count;
+ reader.on_local_name = on_local_name;
+
+ reader.on_init_expr_f32_const_expr = on_init_expr_f32_const_expr;
+ reader.on_init_expr_f64_const_expr = on_init_expr_f64_const_expr;
+ reader.on_init_expr_get_global_expr = on_init_expr_get_global_expr;
+ reader.on_init_expr_i32_const_expr = on_init_expr_i32_const_expr;
+ reader.on_init_expr_i64_const_expr = on_init_expr_i64_const_expr;
WabtResult result = wabt_read_binary(data, size, &reader, 1, options);
WABT_DESTROY_VECTOR_AND_ELEMENTS(ctx.label_stack, label_node);
diff --git a/src/binary-reader-interpreter.c b/src/binary-reader-interpreter.cc
index cb1ab7de..b325e1f3 100644
--- a/src/binary-reader-interpreter.c
+++ b/src/binary-reader-interpreter.cc
@@ -87,7 +87,7 @@ typedef struct Context {
/* values cached in the Context so they can be shared between callbacks */
WabtInterpreterTypedValue init_expr_value;
uint32_t table_offset;
- WabtBool is_host_import;
+ bool is_host_import;
WabtInterpreterModule* host_import_module;
uint32_t import_env_index;
} Context;
@@ -115,7 +115,7 @@ static void WABT_PRINTF_FORMAT(2, 3)
}
static void on_typechecker_error(const char* msg, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
print_error(ctx, "%s", msg);
}
@@ -237,7 +237,7 @@ static WabtResult emit_drop_keep(Context* ctx, uint32_t drop, uint8_t keep) {
if (drop == 1 && keep == 0) {
CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_DROP));
} else {
- CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_DROP_KEEP));
+ CHECK_RESULT(emit_opcode(ctx, (WabtOpcode)WABT_OPCODE_DROP_KEEP));
CHECK_RESULT(emit_i32(ctx, drop));
CHECK_RESULT(emit_i8(ctx, keep));
}
@@ -350,11 +350,11 @@ static WabtResult emit_func_offset(Context* ctx,
}
static void on_error(WabtBinaryReaderContext* ctx, const char* message) {
- handle_error(ctx->offset, message, ctx->user_data);
+ handle_error(ctx->offset, message, (Context*)ctx->user_data);
}
static WabtResult on_signature_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
wabt_resize_uint32_vector(&ctx->sig_index_mapping, count);
uint32_t i;
for (i = 0; i < count; ++i)
@@ -370,7 +370,7 @@ static WabtResult on_signature(uint32_t index,
uint32_t result_count,
WabtType* result_types,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtInterpreterFuncSignature* sig = get_signature_by_module_index(ctx, index);
wabt_reserve_types(&sig->param_types, param_count);
@@ -384,7 +384,7 @@ static WabtResult on_signature(uint32_t index,
}
static WabtResult on_import_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
wabt_new_interpreter_import_array(&ctx->module->defined.imports, count);
return WABT_OK;
}
@@ -393,7 +393,7 @@ static WabtResult on_import(uint32_t index,
WabtStringSlice module_name,
WabtStringSlice field_name,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(index < ctx->module->defined.imports.size);
WabtInterpreterImport* import = &ctx->module->defined.imports.data[index];
import->module_name = wabt_dup_string_slice(module_name);
@@ -412,20 +412,20 @@ static WabtResult on_import(uint32_t index,
/* We don't yet know the kind of a host import module, so just assume it
* exists for now. We'll fail later (in on_import_* below) if it doesn't
* exist). */
- ctx->is_host_import = WABT_TRUE;
+ ctx->is_host_import = true;
ctx->host_import_module = module;
} else {
- WabtInterpreterExport* export =
+ WabtInterpreterExport* export_ =
wabt_get_interpreter_export_by_name(module, &import->field_name);
- if (!export) {
+ if (!export_) {
print_error(ctx, "unknown module field \"" PRIstringslice "\"",
WABT_PRINTF_STRING_SLICE_ARG(import->field_name));
return WABT_ERROR;
}
- import->kind = export->kind;
- ctx->is_host_import = WABT_FALSE;
- ctx->import_env_index = export->index;
+ import->kind = export_->kind;
+ ctx->is_host_import = false;
+ ctx->import_env_index = export_->index;
}
return WABT_OK;
}
@@ -483,20 +483,20 @@ static WabtResult append_export(Context* ctx,
return WABT_ERROR;
}
- WabtInterpreterExport* export =
+ WabtInterpreterExport* export_ =
wabt_append_interpreter_export(&module->exports);
- export->name = wabt_dup_string_slice(name);
- export->kind = kind;
- export->index = item_index;
+ export_->name = wabt_dup_string_slice(name);
+ export_->kind = kind;
+ export_->index = item_index;
WabtBinding* binding =
- wabt_insert_binding(&module->export_bindings, &export->name);
+ wabt_insert_binding(&module->export_bindings, &export_->name);
binding->index = module->exports.size - 1;
return WABT_OK;
}
static void on_host_import_print_error(const char* msg, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
print_error(ctx, "%s", msg);
}
@@ -511,7 +511,7 @@ static WabtResult on_import_func(uint32_t import_index,
uint32_t func_index,
uint32_t sig_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(import_index < ctx->module->defined.imports.size);
WabtInterpreterImport* import =
&ctx->module->defined.imports.data[import_index];
@@ -521,7 +521,7 @@ static WabtResult on_import_func(uint32_t import_index,
uint32_t func_env_index;
if (ctx->is_host_import) {
WabtInterpreterFunc* func = wabt_append_interpreter_func(&ctx->env->funcs);
- func->is_host = WABT_TRUE;
+ func->is_host = true;
func->sig_index = import->func.sig_index;
func->host.module_name = import->module_name;
func->host.field_name = import->field_name;
@@ -566,7 +566,7 @@ static WabtResult on_import_table(uint32_t import_index,
WabtType elem_type,
const WabtLimits* elem_limits,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (ctx->module->table_index != WABT_INVALID_INDEX) {
print_error(ctx, "only one table allowed");
return WABT_ERROR;
@@ -609,7 +609,7 @@ static WabtResult on_import_memory(uint32_t import_index,
uint32_t memory_index,
const WabtLimits* page_limits,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (ctx->module->memory_index != WABT_INVALID_INDEX) {
print_error(ctx, "only one memory allowed");
return WABT_ERROR;
@@ -651,9 +651,9 @@ static WabtResult on_import_memory(uint32_t import_index,
static WabtResult on_import_global(uint32_t import_index,
uint32_t global_index,
WabtType type,
- WabtBool mutable,
+ bool mutable_,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(import_index < ctx->module->defined.imports.size);
WabtInterpreterImport* import =
&ctx->module->defined.imports.data[import_index];
@@ -663,7 +663,7 @@ static WabtResult on_import_global(uint32_t import_index,
WabtInterpreterGlobal* global =
wabt_append_interpreter_global(&ctx->env->globals);
global->typed_value.type = type;
- global->mutable_ = mutable;
+ global->mutable_ = mutable_;
WabtInterpreterHostImportDelegate* host_delegate =
&ctx->host_import_module->host.import_delegate;
@@ -678,7 +678,7 @@ static WabtResult on_import_global(uint32_t import_index,
CHECK_RESULT(check_import_kind(ctx, import, WABT_EXTERNAL_KIND_GLOBAL));
// TODO: check type and mutability
import->global.type = type;
- import->global.mutable_ = mutable;
+ import->global.mutable_ = mutable_;
global_env_index = ctx->import_env_index;
}
wabt_append_uint32_value(&ctx->global_index_mapping, &global_env_index);
@@ -688,7 +688,7 @@ static WabtResult on_import_global(uint32_t import_index,
static WabtResult on_function_signatures_count(uint32_t count,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
size_t old_size = ctx->func_index_mapping.size;
wabt_resize_uint32_vector(&ctx->func_index_mapping, old_size + count);
uint32_t i;
@@ -703,7 +703,7 @@ static WabtResult on_function_signatures_count(uint32_t count,
static WabtResult on_function_signature(uint32_t index,
uint32_t sig_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtInterpreterFunc* func = get_func_by_module_index(ctx, index);
func->defined.offset = WABT_INVALID_OFFSET;
func->sig_index = translate_sig_index_to_env(ctx, sig_index);
@@ -714,7 +714,7 @@ static WabtResult on_table(uint32_t index,
WabtType elem_type,
const WabtLimits* elem_limits,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (ctx->module->table_index != WABT_INVALID_INDEX) {
print_error(ctx, "only one table allowed");
return WABT_ERROR;
@@ -730,7 +730,7 @@ static WabtResult on_table(uint32_t index,
static WabtResult on_memory(uint32_t index,
const WabtLimits* page_limits,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (ctx->module->memory_index != WABT_INVALID_INDEX) {
print_error(ctx, "only one memory allowed");
return WABT_ERROR;
@@ -745,7 +745,7 @@ static WabtResult on_memory(uint32_t index,
}
static WabtResult on_global_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
size_t old_size = ctx->global_index_mapping.size;
wabt_resize_uint32_vector(&ctx->global_index_mapping, old_size + count);
uint32_t i;
@@ -758,9 +758,9 @@ static WabtResult on_global_count(uint32_t count, void* user_data) {
static WabtResult begin_global(uint32_t index,
WabtType type,
- WabtBool mutable_,
+ bool mutable_,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtInterpreterGlobal* global = get_global_by_module_index(ctx, index);
global->typed_value.type = type;
global->mutable_ = mutable_;
@@ -768,7 +768,7 @@ static WabtResult begin_global(uint32_t index,
}
static WabtResult end_global_init_expr(uint32_t index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtInterpreterGlobal* global = get_global_by_module_index(ctx, index);
if (ctx->init_expr_value.type != global->typed_value.type) {
print_error(ctx, "type mismatch in global, expected %s but got %s.",
@@ -783,7 +783,7 @@ static WabtResult end_global_init_expr(uint32_t index, void* user_data) {
static WabtResult on_init_expr_f32_const_expr(uint32_t index,
uint32_t value_bits,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
ctx->init_expr_value.type = WABT_TYPE_F32;
ctx->init_expr_value.value.f32_bits = value_bits;
return WABT_OK;
@@ -792,7 +792,7 @@ static WabtResult on_init_expr_f32_const_expr(uint32_t index,
static WabtResult on_init_expr_f64_const_expr(uint32_t index,
uint64_t value_bits,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
ctx->init_expr_value.type = WABT_TYPE_F64;
ctx->init_expr_value.value.f64_bits = value_bits;
return WABT_OK;
@@ -801,7 +801,7 @@ static WabtResult on_init_expr_f64_const_expr(uint32_t index,
static WabtResult on_init_expr_get_global_expr(uint32_t index,
uint32_t global_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (global_index >= ctx->num_global_imports) {
print_error(ctx,
"initializer expression can only reference an imported global");
@@ -821,7 +821,7 @@ static WabtResult on_init_expr_get_global_expr(uint32_t index,
static WabtResult on_init_expr_i32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
ctx->init_expr_value.type = WABT_TYPE_I32;
ctx->init_expr_value.value.i32 = value;
return WABT_OK;
@@ -830,7 +830,7 @@ static WabtResult on_init_expr_i32_const_expr(uint32_t index,
static WabtResult on_init_expr_i64_const_expr(uint32_t index,
uint64_t value,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
ctx->init_expr_value.type = WABT_TYPE_I64;
ctx->init_expr_value.value.i64 = value;
return WABT_OK;
@@ -841,7 +841,7 @@ static WabtResult on_export(uint32_t index,
uint32_t item_index,
WabtStringSlice name,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
switch (kind) {
case WABT_EXTERNAL_KIND_FUNC:
item_index = translate_func_index_to_env(ctx, item_index);
@@ -873,7 +873,7 @@ static WabtResult on_export(uint32_t index,
}
static WabtResult on_start_function(uint32_t func_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
uint32_t start_func_index = translate_func_index_to_env(ctx, func_index);
WabtInterpreterFunc* start_func =
get_func_by_env_index(ctx, start_func_index);
@@ -892,7 +892,7 @@ static WabtResult on_start_function(uint32_t func_index, void* user_data) {
}
static WabtResult end_elem_segment_init_expr(uint32_t index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (ctx->init_expr_value.type != WABT_TYPE_I32) {
print_error(ctx, "type mismatch in elem segment, expected i32 but got %s",
wabt_get_type_name(ctx->init_expr_value.type));
@@ -905,7 +905,7 @@ static WabtResult end_elem_segment_init_expr(uint32_t index, void* user_data) {
static WabtResult on_elem_segment_function_index_check(uint32_t index,
uint32_t func_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(ctx->module->table_index != WABT_INVALID_INDEX);
WabtInterpreterTable* table =
&ctx->env->tables.data[ctx->module->table_index];
@@ -931,7 +931,7 @@ static WabtResult on_elem_segment_function_index_check(uint32_t index,
static WabtResult on_elem_segment_function_index(uint32_t index,
uint32_t func_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(ctx->module->table_index != WABT_INVALID_INDEX);
WabtInterpreterTable* table =
&ctx->env->tables.data[ctx->module->table_index];
@@ -944,7 +944,7 @@ static WabtResult on_data_segment_data_check(uint32_t index,
const void* src_data,
uint32_t size,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(ctx->module->memory_index != WABT_INVALID_INDEX);
WabtInterpreterMemory* memory =
&ctx->env->memories.data[ctx->module->memory_index];
@@ -968,12 +968,12 @@ static WabtResult on_data_segment_data(uint32_t index,
const void* src_data,
uint32_t size,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
assert(ctx->module->memory_index != WABT_INVALID_INDEX);
WabtInterpreterMemory* memory =
&ctx->env->memories.data[ctx->module->memory_index];
uint32_t address = ctx->init_expr_value.value.i32;
- uint8_t* dst_data = memory->data;
+ uint8_t* dst_data = (uint8_t*)memory->data;
memcpy(&dst_data[address], src_data, size);
return WABT_OK;
}
@@ -1000,12 +1000,12 @@ static void pop_label(Context* ctx) {
static WabtResult begin_function_body(WabtBinaryReaderContext* context,
uint32_t index) {
- Context* ctx = context->user_data;
+ Context* ctx = (Context*)context->user_data;
WabtInterpreterFunc* func = get_func_by_module_index(ctx, index);
WabtInterpreterFuncSignature* sig =
get_signature_by_env_index(ctx, func->sig_index);
- func->is_host = WABT_FALSE;
+ func->is_host = false;
func->defined.offset = get_istream_offset(ctx);
func->defined.local_decl_count = 0;
func->defined.local_count = 0;
@@ -1036,7 +1036,7 @@ static WabtResult begin_function_body(WabtBinaryReaderContext* context,
}
static WabtResult end_function_body(uint32_t index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
fixup_top_label(ctx);
uint32_t drop_count, keep_count;
CHECK_RESULT(get_return_drop_keep_count(ctx, &drop_count, &keep_count));
@@ -1049,7 +1049,7 @@ static WabtResult end_function_body(uint32_t index, void* user_data) {
}
static WabtResult on_local_decl_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtInterpreterFunc* func = ctx->current_func;
func->defined.local_decl_count = count;
return WABT_OK;
@@ -1059,7 +1059,7 @@ static WabtResult on_local_decl(uint32_t decl_index,
uint32_t count,
WabtType type,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtInterpreterFunc* func = ctx->current_func;
func->defined.local_count += count;
@@ -1070,7 +1070,7 @@ static WabtResult on_local_decl(uint32_t decl_index,
if (decl_index == func->defined.local_decl_count - 1) {
/* last local declaration, allocate space for all locals. */
- CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_ALLOCA));
+ CHECK_RESULT(emit_opcode(ctx, (WabtOpcode)WABT_OPCODE_ALLOCA));
CHECK_RESULT(emit_i32(ctx, func->defined.local_count));
}
return WABT_OK;
@@ -1097,14 +1097,14 @@ static WabtResult check_align(Context* ctx,
}
static WabtResult on_unary_expr(WabtOpcode opcode, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(wabt_typechecker_on_unary(&ctx->typechecker, opcode));
CHECK_RESULT(emit_opcode(ctx, opcode));
return WABT_OK;
}
static WabtResult on_binary_expr(WabtOpcode opcode, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(wabt_typechecker_on_binary(&ctx->typechecker, opcode));
CHECK_RESULT(emit_opcode(ctx, opcode));
return WABT_OK;
@@ -1113,7 +1113,7 @@ static WabtResult on_binary_expr(WabtOpcode opcode, void* user_data) {
static WabtResult on_block_expr(uint32_t num_types,
WabtType* sig_types,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtTypeVector sig;
sig.size = num_types;
sig.data = sig_types;
@@ -1125,7 +1125,7 @@ static WabtResult on_block_expr(uint32_t num_types,
static WabtResult on_loop_expr(uint32_t num_types,
WabtType* sig_types,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtTypeVector sig;
sig.size = num_types;
sig.data = sig_types;
@@ -1137,12 +1137,12 @@ static WabtResult on_loop_expr(uint32_t num_types,
static WabtResult on_if_expr(uint32_t num_types,
WabtType* sig_types,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtTypeVector sig;
sig.size = num_types;
sig.data = sig_types;
CHECK_RESULT(wabt_typechecker_on_if(&ctx->typechecker, &sig));
- CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_BR_UNLESS));
+ CHECK_RESULT(emit_opcode(ctx, (WabtOpcode)WABT_OPCODE_BR_UNLESS));
uint32_t fixup_offset = get_istream_offset(ctx);
CHECK_RESULT(emit_i32(ctx, WABT_INVALID_OFFSET));
push_label(ctx, WABT_INVALID_OFFSET, fixup_offset);
@@ -1150,7 +1150,7 @@ static WabtResult on_if_expr(uint32_t num_types,
}
static WabtResult on_else_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(wabt_typechecker_on_else(&ctx->typechecker));
Label* label = top_label(ctx);
uint32_t fixup_cond_offset = label->fixup_offset;
@@ -1162,7 +1162,7 @@ static WabtResult on_else_expr(void* user_data) {
}
static WabtResult on_end_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtTypeCheckerLabel* label;
CHECK_RESULT(wabt_typechecker_get_label(&ctx->typechecker, 0, &label));
WabtLabelType label_type = label->label_type;
@@ -1177,7 +1177,7 @@ static WabtResult on_end_expr(void* user_data) {
}
static WabtResult on_br_expr(uint32_t depth, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
uint32_t drop_count, keep_count;
CHECK_RESULT(get_br_drop_keep_count(ctx, depth, &drop_count, &keep_count));
CHECK_RESULT(wabt_typechecker_on_br(&ctx->typechecker, depth));
@@ -1186,12 +1186,12 @@ static WabtResult on_br_expr(uint32_t depth, void* user_data) {
}
static WabtResult on_br_if_expr(uint32_t depth, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
uint32_t drop_count, keep_count;
CHECK_RESULT(wabt_typechecker_on_br_if(&ctx->typechecker, depth));
CHECK_RESULT(get_br_drop_keep_count(ctx, depth, &drop_count, &keep_count));
/* flip the br_if so if <cond> is true it can drop values from the stack */
- CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_BR_UNLESS));
+ CHECK_RESULT(emit_opcode(ctx, (WabtOpcode)WABT_OPCODE_BR_UNLESS));
uint32_t fixup_br_offset = get_istream_offset(ctx);
CHECK_RESULT(emit_i32(ctx, WABT_INVALID_OFFSET));
CHECK_RESULT(emit_br(ctx, depth, drop_count, keep_count));
@@ -1203,7 +1203,7 @@ static WabtResult on_br_table_expr(WabtBinaryReaderContext* context,
uint32_t num_targets,
uint32_t* target_depths,
uint32_t default_target_depth) {
- Context* ctx = context->user_data;
+ Context* ctx = (Context*)context->user_data;
CHECK_RESULT(wabt_typechecker_begin_br_table(&ctx->typechecker));
CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_BR_TABLE));
CHECK_RESULT(emit_i32(ctx, num_targets));
@@ -1211,7 +1211,7 @@ static WabtResult on_br_table_expr(WabtBinaryReaderContext* context,
CHECK_RESULT(emit_i32(ctx, WABT_INVALID_OFFSET));
/* not necessary for the interpreter, but it makes it easier to disassemble.
* This opcode specifies how many bytes of data follow. */
- CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_DATA));
+ CHECK_RESULT(emit_opcode(ctx, (WabtOpcode)WABT_OPCODE_DATA));
CHECK_RESULT(emit_i32(ctx, (num_targets + 1) * WABT_TABLE_ENTRY_SIZE));
CHECK_RESULT(emit_i32_at(ctx, fixup_table_offset, get_istream_offset(ctx)));
@@ -1227,7 +1227,7 @@ static WabtResult on_br_table_expr(WabtBinaryReaderContext* context,
}
static WabtResult on_call_expr(uint32_t func_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtInterpreterFunc* func = get_func_by_module_index(ctx, func_index);
WabtInterpreterFuncSignature* sig =
get_signature_by_env_index(ctx, func->sig_index);
@@ -1235,7 +1235,7 @@ static WabtResult on_call_expr(uint32_t func_index, void* user_data) {
&sig->result_types));
if (func->is_host) {
- CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_CALL_HOST));
+ CHECK_RESULT(emit_opcode(ctx, (WabtOpcode)WABT_OPCODE_CALL_HOST));
CHECK_RESULT(emit_i32(ctx, translate_func_index_to_env(ctx, func_index)));
} else {
CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_CALL));
@@ -1246,7 +1246,7 @@ static WabtResult on_call_expr(uint32_t func_index, void* user_data) {
}
static WabtResult on_call_indirect_expr(uint32_t sig_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (ctx->module->table_index == WABT_INVALID_INDEX) {
print_error(ctx, "found call_indirect operator, but no table");
return WABT_ERROR;
@@ -1263,14 +1263,14 @@ static WabtResult on_call_indirect_expr(uint32_t sig_index, void* user_data) {
}
static WabtResult on_drop_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(wabt_typechecker_on_drop(&ctx->typechecker));
CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_DROP));
return WABT_OK;
}
static WabtResult on_i32_const_expr(uint32_t value, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(wabt_typechecker_on_const(&ctx->typechecker, WABT_TYPE_I32));
CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_I32_CONST));
CHECK_RESULT(emit_i32(ctx, value));
@@ -1278,7 +1278,7 @@ static WabtResult on_i32_const_expr(uint32_t value, void* user_data) {
}
static WabtResult on_i64_const_expr(uint64_t value, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(wabt_typechecker_on_const(&ctx->typechecker, WABT_TYPE_I64));
CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_I64_CONST));
CHECK_RESULT(emit_i64(ctx, value));
@@ -1286,7 +1286,7 @@ static WabtResult on_i64_const_expr(uint64_t value, void* user_data) {
}
static WabtResult on_f32_const_expr(uint32_t value_bits, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(wabt_typechecker_on_const(&ctx->typechecker, WABT_TYPE_F32));
CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_F32_CONST));
CHECK_RESULT(emit_i32(ctx, value_bits));
@@ -1294,7 +1294,7 @@ static WabtResult on_f32_const_expr(uint32_t value_bits, void* user_data) {
}
static WabtResult on_f64_const_expr(uint64_t value_bits, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(wabt_typechecker_on_const(&ctx->typechecker, WABT_TYPE_F64));
CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_F64_CONST));
CHECK_RESULT(emit_i64(ctx, value_bits));
@@ -1302,7 +1302,7 @@ static WabtResult on_f64_const_expr(uint64_t value_bits, void* user_data) {
}
static WabtResult on_get_global_expr(uint32_t global_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_GLOBAL(ctx, global_index);
WabtType type = get_global_type_by_module_index(ctx, global_index);
CHECK_RESULT(wabt_typechecker_on_get_global(&ctx->typechecker, type));
@@ -1312,10 +1312,10 @@ static WabtResult on_get_global_expr(uint32_t global_index, void* user_data) {
}
static WabtResult on_set_global_expr(uint32_t global_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_GLOBAL(ctx, global_index);
WabtInterpreterGlobal* global = get_global_by_module_index(ctx, global_index);
- if (global->mutable_ != WABT_TRUE) {
+ if (!global->mutable_) {
print_error(ctx, "can't set_global on immutable global at index %u.",
global_index);
return WABT_ERROR;
@@ -1333,7 +1333,7 @@ static uint32_t translate_local_index(Context* ctx, uint32_t local_index) {
}
static WabtResult on_get_local_expr(uint32_t local_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_LOCAL(ctx, local_index);
WabtType type = get_local_type_by_index(ctx->current_func, local_index);
/* Get the translated index before calling wabt_typechecker_on_get_local
@@ -1347,7 +1347,7 @@ static WabtResult on_get_local_expr(uint32_t local_index, void* user_data) {
}
static WabtResult on_set_local_expr(uint32_t local_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_LOCAL(ctx, local_index);
WabtType type = get_local_type_by_index(ctx->current_func, local_index);
CHECK_RESULT(wabt_typechecker_on_set_local(&ctx->typechecker, type));
@@ -1357,7 +1357,7 @@ static WabtResult on_set_local_expr(uint32_t local_index, void* user_data) {
}
static WabtResult on_tee_local_expr(uint32_t local_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_LOCAL(ctx, local_index);
WabtType type = get_local_type_by_index(ctx->current_func, local_index);
CHECK_RESULT(wabt_typechecker_on_tee_local(&ctx->typechecker, type));
@@ -1367,7 +1367,7 @@ static WabtResult on_tee_local_expr(uint32_t local_index, void* user_data) {
}
static WabtResult on_grow_memory_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(check_has_memory(ctx, WABT_OPCODE_GROW_MEMORY));
CHECK_RESULT(wabt_typechecker_on_grow_memory(&ctx->typechecker));
CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_GROW_MEMORY));
@@ -1379,7 +1379,7 @@ static WabtResult on_load_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(check_has_memory(ctx, opcode));
CHECK_RESULT(
check_align(ctx, alignment_log2, wabt_get_opcode_memory_size(opcode)));
@@ -1394,7 +1394,7 @@ static WabtResult on_store_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(check_has_memory(ctx, opcode));
CHECK_RESULT(
check_align(ctx, alignment_log2, wabt_get_opcode_memory_size(opcode)));
@@ -1406,7 +1406,7 @@ static WabtResult on_store_expr(WabtOpcode opcode,
}
static WabtResult on_current_memory_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(check_has_memory(ctx, WABT_OPCODE_CURRENT_MEMORY));
CHECK_RESULT(wabt_typechecker_on_current_memory(&ctx->typechecker));
CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_CURRENT_MEMORY));
@@ -1419,7 +1419,7 @@ static WabtResult on_nop_expr(void* user_data) {
}
static WabtResult on_return_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
uint32_t drop_count, keep_count;
CHECK_RESULT(get_return_drop_keep_count(ctx, &drop_count, &keep_count));
CHECK_RESULT(wabt_typechecker_on_return(&ctx->typechecker));
@@ -1429,113 +1429,19 @@ static WabtResult on_return_expr(void* user_data) {
}
static WabtResult on_select_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(wabt_typechecker_on_select(&ctx->typechecker));
CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_SELECT));
return WABT_OK;
}
static WabtResult on_unreachable_expr(void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
CHECK_RESULT(wabt_typechecker_on_unreachable(&ctx->typechecker));
CHECK_RESULT(emit_opcode(ctx, WABT_OPCODE_UNREACHABLE));
return WABT_OK;
}
-static WabtBinaryReader s_binary_reader = {
- .user_data = NULL,
- .on_error = on_error,
-
- .on_signature_count = on_signature_count,
- .on_signature = on_signature,
-
- .on_import_count = on_import_count,
- .on_import = on_import,
- .on_import_func = on_import_func,
- .on_import_table = on_import_table,
- .on_import_memory = on_import_memory,
- .on_import_global = on_import_global,
-
- .on_function_signatures_count = on_function_signatures_count,
- .on_function_signature = on_function_signature,
-
- .on_table = on_table,
-
- .on_memory = on_memory,
-
- .on_global_count = on_global_count,
- .begin_global = begin_global,
- .end_global_init_expr = end_global_init_expr,
-
- .on_export = on_export,
-
- .on_start_function = on_start_function,
-
- .begin_function_body = begin_function_body,
- .on_local_decl_count = on_local_decl_count,
- .on_local_decl = on_local_decl,
- .on_binary_expr = on_binary_expr,
- .on_block_expr = on_block_expr,
- .on_br_expr = on_br_expr,
- .on_br_if_expr = on_br_if_expr,
- .on_br_table_expr = on_br_table_expr,
- .on_call_expr = on_call_expr,
- .on_call_indirect_expr = on_call_indirect_expr,
- .on_compare_expr = on_binary_expr,
- .on_convert_expr = on_unary_expr,
- .on_current_memory_expr = on_current_memory_expr,
- .on_drop_expr = on_drop_expr,
- .on_else_expr = on_else_expr,
- .on_end_expr = on_end_expr,
- .on_f32_const_expr = on_f32_const_expr,
- .on_f64_const_expr = on_f64_const_expr,
- .on_get_global_expr = on_get_global_expr,
- .on_get_local_expr = on_get_local_expr,
- .on_grow_memory_expr = on_grow_memory_expr,
- .on_i32_const_expr = on_i32_const_expr,
- .on_i64_const_expr = on_i64_const_expr,
- .on_if_expr = on_if_expr,
- .on_load_expr = on_load_expr,
- .on_loop_expr = on_loop_expr,
- .on_nop_expr = on_nop_expr,
- .on_return_expr = on_return_expr,
- .on_select_expr = on_select_expr,
- .on_set_global_expr = on_set_global_expr,
- .on_set_local_expr = on_set_local_expr,
- .on_store_expr = on_store_expr,
- .on_tee_local_expr = on_tee_local_expr,
- .on_unary_expr = on_unary_expr,
- .on_unreachable_expr = on_unreachable_expr,
- .end_function_body = end_function_body,
-
- .end_elem_segment_init_expr = end_elem_segment_init_expr,
- .on_elem_segment_function_index = on_elem_segment_function_index_check,
-
- .on_data_segment_data = on_data_segment_data_check,
-
- .on_init_expr_f32_const_expr = on_init_expr_f32_const_expr,
- .on_init_expr_f64_const_expr = on_init_expr_f64_const_expr,
- .on_init_expr_get_global_expr = on_init_expr_get_global_expr,
- .on_init_expr_i32_const_expr = on_init_expr_i32_const_expr,
- .on_init_expr_i64_const_expr = on_init_expr_i64_const_expr,
-};
-
-/* Second pass to assign data and elem segments after they are checked above. */
-static WabtBinaryReader s_binary_reader_segments = {
- .user_data = NULL,
- .on_error = on_error,
-
- .end_elem_segment_init_expr = end_elem_segment_init_expr,
- .on_elem_segment_function_index = on_elem_segment_function_index,
- .on_data_segment_data = on_data_segment_data,
-
- .on_init_expr_f32_const_expr = on_init_expr_f32_const_expr,
- .on_init_expr_f64_const_expr = on_init_expr_f64_const_expr,
- .on_init_expr_get_global_expr = on_init_expr_get_global_expr,
- .on_init_expr_i32_const_expr = on_init_expr_i32_const_expr,
- .on_init_expr_i64_const_expr = on_init_expr_i64_const_expr,
-};
-
static void destroy_context(Context* ctx) {
wabt_destroy_label_vector(&ctx->label_stack);
WABT_DESTROY_VECTOR_AND_ELEMENTS(ctx->depth_fixups, uint32_vector);
@@ -1566,7 +1472,7 @@ WabtResult wabt_read_binary_interpreter(WabtInterpreterEnvironment* env,
ctx.error_handler = error_handler;
ctx.env = env;
ctx.module = module;
- ctx.module->is_host = WABT_FALSE;
+ ctx.module->is_host = false;
ctx.module->table_index = WABT_INVALID_INDEX;
ctx.module->memory_index = WABT_INVALID_INDEX;
ctx.module->defined.start_func_index = WABT_INVALID_INDEX;
@@ -1580,8 +1486,70 @@ WabtResult wabt_read_binary_interpreter(WabtInterpreterEnvironment* env,
tc_error_handler.user_data = &ctx;
ctx.typechecker.error_handler = &tc_error_handler;
- reader = s_binary_reader;
+ WABT_ZERO_MEMORY(reader);
reader.user_data = &ctx;
+ reader.on_error = on_error;
+ reader.on_signature_count = on_signature_count;
+ reader.on_signature = on_signature;
+ reader.on_import_count = on_import_count;
+ reader.on_import = on_import;
+ reader.on_import_func = on_import_func;
+ reader.on_import_table = on_import_table;
+ reader.on_import_memory = on_import_memory;
+ reader.on_import_global = on_import_global;
+ reader.on_function_signatures_count = on_function_signatures_count;
+ reader.on_function_signature = on_function_signature;
+ reader.on_table = on_table;
+ reader.on_memory = on_memory;
+ reader.on_global_count = on_global_count;
+ reader.begin_global = begin_global;
+ reader.end_global_init_expr = end_global_init_expr;
+ reader.on_export = on_export;
+ reader.on_start_function = on_start_function;
+ reader.begin_function_body = begin_function_body;
+ reader.on_local_decl_count = on_local_decl_count;
+ reader.on_local_decl = on_local_decl;
+ reader.on_binary_expr = on_binary_expr;
+ reader.on_block_expr = on_block_expr;
+ reader.on_br_expr = on_br_expr;
+ reader.on_br_if_expr = on_br_if_expr;
+ reader.on_br_table_expr = on_br_table_expr;
+ reader.on_call_expr = on_call_expr;
+ reader.on_call_indirect_expr = on_call_indirect_expr;
+ reader.on_compare_expr = on_binary_expr;
+ reader.on_convert_expr = on_unary_expr;
+ reader.on_current_memory_expr = on_current_memory_expr;
+ reader.on_drop_expr = on_drop_expr;
+ reader.on_else_expr = on_else_expr;
+ reader.on_end_expr = on_end_expr;
+ reader.on_f32_const_expr = on_f32_const_expr;
+ reader.on_f64_const_expr = on_f64_const_expr;
+ reader.on_get_global_expr = on_get_global_expr;
+ reader.on_get_local_expr = on_get_local_expr;
+ reader.on_grow_memory_expr = on_grow_memory_expr;
+ reader.on_i32_const_expr = on_i32_const_expr;
+ reader.on_i64_const_expr = on_i64_const_expr;
+ reader.on_if_expr = on_if_expr;
+ reader.on_load_expr = on_load_expr;
+ reader.on_loop_expr = on_loop_expr;
+ reader.on_nop_expr = on_nop_expr;
+ reader.on_return_expr = on_return_expr;
+ reader.on_select_expr = on_select_expr;
+ reader.on_set_global_expr = on_set_global_expr;
+ reader.on_set_local_expr = on_set_local_expr;
+ reader.on_store_expr = on_store_expr;
+ reader.on_tee_local_expr = on_tee_local_expr;
+ reader.on_unary_expr = on_unary_expr;
+ reader.on_unreachable_expr = on_unreachable_expr;
+ reader.end_function_body = end_function_body;
+ reader.end_elem_segment_init_expr = end_elem_segment_init_expr;
+ reader.on_elem_segment_function_index = on_elem_segment_function_index_check;
+ reader.on_data_segment_data = on_data_segment_data_check;
+ reader.on_init_expr_f32_const_expr = on_init_expr_f32_const_expr;
+ reader.on_init_expr_f64_const_expr = on_init_expr_f64_const_expr;
+ reader.on_init_expr_get_global_expr = on_init_expr_get_global_expr;
+ reader.on_init_expr_i32_const_expr = on_init_expr_i32_const_expr;
+ reader.on_init_expr_i64_const_expr = on_init_expr_i64_const_expr;
const uint32_t num_function_passes = 1;
WabtResult result =
@@ -1589,8 +1557,18 @@ WabtResult wabt_read_binary_interpreter(WabtInterpreterEnvironment* env,
wabt_steal_mem_writer_output_buffer(&ctx.istream_writer, &env->istream);
if (WABT_SUCCEEDED(result)) {
/* Another pass on the read binary to assign data and elem segments. */
- reader = s_binary_reader_segments;
+ WABT_ZERO_MEMORY(reader);
reader.user_data = &ctx;
+ reader.on_error = on_error;
+ reader.end_elem_segment_init_expr = end_elem_segment_init_expr;
+ reader.on_elem_segment_function_index = on_elem_segment_function_index;
+ reader.on_data_segment_data = on_data_segment_data;
+ reader.on_init_expr_f32_const_expr = on_init_expr_f32_const_expr;
+ reader.on_init_expr_f64_const_expr = on_init_expr_f64_const_expr;
+ reader.on_init_expr_get_global_expr = on_init_expr_get_global_expr;
+ reader.on_init_expr_i32_const_expr = on_init_expr_i32_const_expr;
+ reader.on_init_expr_i64_const_expr = on_init_expr_i64_const_expr;
+
result =
wabt_read_binary(data, size, &reader, num_function_passes, options);
assert(WABT_SUCCEEDED(result));
diff --git a/src/binary-reader-linker.c b/src/binary-reader-linker.cc
index f09a4339..6eae025a 100644
--- a/src/binary-reader-linker.c
+++ b/src/binary-reader-linker.cc
@@ -34,7 +34,7 @@ static WabtResult on_reloc_count(uint32_t count,
WabtBinarySection section_code,
WabtStringSlice section_name,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtLinkerInputBinary* binary = ctx->binary;
if (section_code == WABT_BINARY_SECTION_CUSTOM) {
WABT_FATAL("relocation for custom sections not yet supported\n");
@@ -56,7 +56,7 @@ static WabtResult on_reloc_count(uint32_t count,
static WabtResult on_reloc(WabtRelocType type,
uint32_t offset,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (offset + RELOC_SIZE > ctx->reloc_section->size) {
WABT_FATAL("invalid relocation offset: %#x\n", offset);
@@ -73,7 +73,7 @@ static WabtResult on_import(uint32_t index,
WabtStringSlice module_name,
WabtStringSlice field_name,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (!wabt_string_slice_eq_cstr(&module_name, WABT_LINK_MODULE_NAME)) {
WABT_FATAL("unsupported import module: " PRIstringslice,
WABT_PRINTF_STRING_SLICE_ARG(module_name));
@@ -86,12 +86,12 @@ static WabtResult on_import_func(uint32_t import_index,
uint32_t global_index,
uint32_t sig_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtFunctionImport* import =
wabt_append_function_import(&ctx->binary->function_imports);
import->name = ctx->import_name;
import->sig_index = sig_index;
- import->active = WABT_TRUE;
+ import->active = true;
ctx->binary->active_function_imports++;
return WABT_OK;
}
@@ -99,14 +99,14 @@ static WabtResult on_import_func(uint32_t import_index,
static WabtResult on_import_global(uint32_t import_index,
uint32_t global_index,
WabtType type,
- WabtBool mutable,
+ bool mutable_,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtGlobalImport* import =
wabt_append_global_import(&ctx->binary->global_imports);
import->name = ctx->import_name;
import->type = type;
- import->mutable = mutable;
+ import->mutable_ = mutable_;
ctx->binary->active_global_imports++;
return WABT_OK;
}
@@ -114,7 +114,7 @@ static WabtResult on_import_global(uint32_t import_index,
static WabtResult begin_section(WabtBinaryReaderContext* ctx,
WabtBinarySection section_code,
uint32_t size) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
WabtLinkerInputBinary* binary = context->binary;
WabtSection* sec = wabt_append_section(&binary->sections);
context->current_section = sec;
@@ -138,7 +138,7 @@ static WabtResult begin_section(WabtBinaryReaderContext* ctx,
static WabtResult begin_custom_section(WabtBinaryReaderContext* ctx,
uint32_t size,
WabtStringSlice section_name) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
WabtLinkerInputBinary* binary = context->binary;
WabtSection* sec = context->current_section;
sec->data_custom.name = section_name;
@@ -184,7 +184,7 @@ static WabtResult on_table(uint32_t index,
if (elem_limits->has_max && (elem_limits->max != elem_limits->initial))
WABT_FATAL("Tables with max != initial not supported by wabt-link\n");
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
ctx->binary->table_elem_count = elem_limits->initial;
return WABT_OK;
}
@@ -193,7 +193,7 @@ static WabtResult on_elem_segment_function_index_count(
WabtBinaryReaderContext* ctx,
uint32_t index,
uint32_t count) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
WabtSection* sec = context->current_section;
/* Modify the payload to include only the actual function indexes */
@@ -206,7 +206,7 @@ static WabtResult on_elem_segment_function_index_count(
static WabtResult on_memory(uint32_t index,
const WabtLimits* page_limits,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtSection* sec = ctx->current_section;
sec->memory_limits = *page_limits;
ctx->binary->memory_page_count = page_limits->initial;
@@ -216,7 +216,7 @@ static WabtResult on_memory(uint32_t index,
static WabtResult begin_data_segment(uint32_t index,
uint32_t memory_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtSection* sec = ctx->current_section;
WabtDataSegment* segment = wabt_append_data_segment(&sec->data_segments);
segment->memory_index = memory_index;
@@ -226,7 +226,7 @@ static WabtResult begin_data_segment(uint32_t index,
static WabtResult on_init_expr_i32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtSection* sec = ctx->current_section;
if (sec->section_code != WABT_BINARY_SECTION_DATA)
return WABT_OK;
@@ -240,11 +240,11 @@ static WabtResult on_data_segment_data(uint32_t index,
const void* src_data,
uint32_t size,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
WabtSection* sec = ctx->current_section;
WabtDataSegment* segment =
&sec->data_segments.data[sec->data_segments.size - 1];
- segment->data = src_data;
+ segment->data = (uint8_t*)src_data;
segment->size = size;
return WABT_OK;
}
@@ -254,61 +254,57 @@ static WabtResult on_export(uint32_t index,
uint32_t item_index,
WabtStringSlice name,
void* user_data) {
- Context* ctx = user_data;
- WabtExport* export = wabt_append_export(&ctx->binary->exports);
- export->name = name;
- export->kind = kind;
- export->index = item_index;
+ Context* ctx = (Context*)user_data;
+ WabtExport* export_ = wabt_append_export(&ctx->binary->exports);
+ export_->name = name;
+ export_->kind = kind;
+ export_->index = item_index;
return WABT_OK;
}
static WabtResult on_function_name(uint32_t index,
WabtStringSlice name,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
wabt_append_string_slice_value(&ctx->binary->debug_names, &name);
return WABT_OK;
}
-static WabtBinaryReader s_binary_reader = {
- .begin_section = begin_section,
- .begin_custom_section = begin_custom_section,
+WabtResult wabt_read_binary_linker(WabtLinkerInputBinary* input_info) {
+ Context context;
+ WABT_ZERO_MEMORY(context);
+ context.binary = input_info;
- .on_reloc_count = on_reloc_count,
- .on_reloc = on_reloc,
+ WabtBinaryReader reader;
+ WABT_ZERO_MEMORY(reader);
+ reader.user_data = &context;
+ reader.begin_section = begin_section;
+ reader.begin_custom_section = begin_custom_section;
- .on_import = on_import,
- .on_import_func = on_import_func,
- .on_import_global = on_import_global,
+ reader.on_reloc_count = on_reloc_count;
+ reader.on_reloc = on_reloc;
- .on_export = on_export,
+ reader.on_import = on_import;
+ reader.on_import_func = on_import_func;
+ reader.on_import_global = on_import_global;
- .on_table = on_table,
+ reader.on_export = on_export;
- .on_memory = on_memory,
+ reader.on_table = on_table;
- .begin_data_segment = begin_data_segment,
- .on_init_expr_i32_const_expr = on_init_expr_i32_const_expr,
- .on_data_segment_data = on_data_segment_data,
+ reader.on_memory = on_memory;
- .on_elem_segment_function_index_count =
- on_elem_segment_function_index_count,
+ reader.begin_data_segment = begin_data_segment;
+ reader.on_init_expr_i32_const_expr = on_init_expr_i32_const_expr;
+ reader.on_data_segment_data = on_data_segment_data;
- .on_function_name = on_function_name,
-};
+ reader.on_elem_segment_function_index_count =
+ on_elem_segment_function_index_count;
-WabtResult wabt_read_binary_linker(WabtLinkerInputBinary* input_info) {
- Context context;
- WABT_ZERO_MEMORY(context);
- context.binary = input_info;
-
- WabtBinaryReader reader;
- WABT_ZERO_MEMORY(reader);
- reader = s_binary_reader;
- reader.user_data = &context;
+ reader.on_function_name = on_function_name;
WabtReadBinaryOptions read_options = WABT_READ_BINARY_OPTIONS_DEFAULT;
- read_options.read_debug_names = WABT_TRUE;
+ read_options.read_debug_names = true;
return wabt_read_binary(input_info->data, input_info->size, &reader, 1,
&read_options);
}
diff --git a/src/binary-reader-objdump.c b/src/binary-reader-objdump.cc
index 700f12d3..18173e81 100644
--- a/src/binary-reader-objdump.c
+++ b/src/binary-reader-objdump.cc
@@ -37,8 +37,8 @@ typedef struct Context {
size_t current_opcode_offset;
size_t last_opcode_end;
int indent_level;
- WabtBool print_details;
- WabtBool header_printed;
+ bool print_details;
+ bool header_printed;
int section_found;
uint32_t section_starts[WABT_NUM_BINARY_SECTIONS];
@@ -50,9 +50,9 @@ typedef struct Context {
uint32_t next_reloc;
} Context;
-static WabtBool should_print_details(Context* ctx) {
+static bool should_print_details(Context* ctx) {
if (ctx->options->mode != WABT_DUMP_DETAILS)
- return WABT_FALSE;
+ return false;
return ctx->print_details;
}
@@ -69,15 +69,15 @@ static void WABT_PRINTF_FORMAT(2, 3)
static WabtResult begin_section(WabtBinaryReaderContext* ctx,
WabtBinarySection section_code,
uint32_t size) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
context->section_starts[section_code] = ctx->offset;
const char* name = wabt_get_section_name(section_code);
- WabtBool section_match = !context->options->section_name ||
+ bool section_match = !context->options->section_name ||
!strcasecmp(context->options->section_name, name);
if (section_match)
- context->section_found = WABT_TRUE;
+ context->section_found = true;
switch (context->options->mode) {
case WABT_DUMP_PREPASS:
@@ -90,9 +90,9 @@ static WabtResult begin_section(WabtBinaryReaderContext* ctx,
if (section_match) {
if (section_code != WABT_BINARY_SECTION_CODE)
printf("%s:\n", name);
- context->print_details = WABT_TRUE;
+ context->print_details = true;
} else {
- context->print_details = WABT_FALSE;
+ context->print_details = false;
}
break;
case WABT_DUMP_RAW_DATA:
@@ -111,7 +111,7 @@ static WabtResult begin_section(WabtBinaryReaderContext* ctx,
static WabtResult begin_custom_section(WabtBinaryReaderContext* ctx,
uint32_t size,
WabtStringSlice section_name) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
print_details(context, " - name: \"" PRIstringslice "\"\n",
WABT_PRINTF_STRING_SLICE_ARG(section_name));
if (context->options->mode == WABT_DUMP_HEADERS) {
@@ -122,7 +122,7 @@ static WabtResult begin_custom_section(WabtBinaryReaderContext* ctx,
}
static WabtResult on_count(uint32_t count, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (ctx->options->mode == WABT_DUMP_HEADERS) {
printf("count: %d\n", count);
}
@@ -130,7 +130,7 @@ static WabtResult on_count(uint32_t count, void* user_data) {
}
static WabtResult begin_module(uint32_t version, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (ctx->options->print_header) {
const char *basename = strrchr(ctx->options->infile, '/');
if (basename)
@@ -138,7 +138,7 @@ static WabtResult begin_module(uint32_t version, void* user_data) {
else
basename = ctx->options->infile;
printf("%s:\tfile format wasm %#08x\n", basename, version);
- ctx->header_printed = WABT_TRUE;
+ ctx->header_printed = true;
}
switch (ctx->options->mode) {
@@ -163,7 +163,7 @@ static WabtResult begin_module(uint32_t version, void* user_data) {
}
static WabtResult end_module(void *user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (ctx->options->section_name) {
if (!ctx->section_found) {
printf("Section not found: %s\n", ctx->options->section_name);
@@ -175,7 +175,7 @@ static WabtResult end_module(void *user_data) {
}
static WabtResult on_opcode(WabtBinaryReaderContext* ctx, WabtOpcode opcode) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
if (context->options->debug) {
const char* opcode_name = wabt_get_opcode_name(opcode);
@@ -185,7 +185,8 @@ static WabtResult on_opcode(WabtBinaryReaderContext* ctx, WabtOpcode opcode) {
if (context->last_opcode_end) {
if (ctx->offset != context->last_opcode_end + 1) {
uint8_t missing_opcode = ctx->data[context->last_opcode_end];
- const char* opcode_name = wabt_get_opcode_name(missing_opcode);
+ const char* opcode_name =
+ wabt_get_opcode_name((WabtOpcode)missing_opcode);
fprintf(stderr, "warning: %#" PRIzx " missing opcode callback at %#" PRIzx
" (%#02x=%s)\n",
ctx->offset, context->last_opcode_end + 1,
@@ -257,14 +258,14 @@ static void log_opcode(Context* ctx,
}
static WabtResult on_opcode_bare(WabtBinaryReaderContext* ctx) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
log_opcode(context, ctx->data, 0, NULL);
return WABT_OK;
}
static WabtResult on_opcode_uint32(WabtBinaryReaderContext* ctx,
uint32_t value) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
size_t immediate_len = ctx->offset - context->current_opcode_offset;
log_opcode(context, ctx->data, immediate_len, "%#x", value);
return WABT_OK;
@@ -273,7 +274,7 @@ static WabtResult on_opcode_uint32(WabtBinaryReaderContext* ctx,
static WabtResult on_opcode_uint32_uint32(WabtBinaryReaderContext* ctx,
uint32_t value,
uint32_t value2) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
size_t immediate_len = ctx->offset - context->current_opcode_offset;
log_opcode(context, ctx->data, immediate_len, "%lu %lu", value, value2);
return WABT_OK;
@@ -281,7 +282,7 @@ static WabtResult on_opcode_uint32_uint32(WabtBinaryReaderContext* ctx,
static WabtResult on_opcode_uint64(WabtBinaryReaderContext* ctx,
uint64_t value) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
size_t immediate_len = ctx->offset - context->current_opcode_offset;
log_opcode(context, ctx->data, immediate_len, "%d", value);
return WABT_OK;
@@ -289,7 +290,7 @@ static WabtResult on_opcode_uint64(WabtBinaryReaderContext* ctx,
static WabtResult on_opcode_f32(WabtBinaryReaderContext* ctx,
uint32_t value) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
size_t immediate_len = ctx->offset - context->current_opcode_offset;
char buffer[WABT_MAX_FLOAT_HEX];
wabt_write_float_hex(buffer, sizeof(buffer), value);
@@ -299,7 +300,7 @@ static WabtResult on_opcode_f32(WabtBinaryReaderContext* ctx,
static WabtResult on_opcode_f64(WabtBinaryReaderContext* ctx,
uint64_t value) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
size_t immediate_len = ctx->offset - context->current_opcode_offset;
char buffer[WABT_MAX_DOUBLE_HEX];
wabt_write_double_hex(buffer, sizeof(buffer), value);
@@ -311,7 +312,7 @@ WabtResult on_br_table_expr(WabtBinaryReaderContext* ctx,
uint32_t num_targets,
uint32_t* target_depths,
uint32_t default_target_depth) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
size_t immediate_len = ctx->offset - context->current_opcode_offset;
/* TODO(sbc): Print targets */
log_opcode(context, ctx->data, immediate_len, NULL);
@@ -319,7 +320,7 @@ WabtResult on_br_table_expr(WabtBinaryReaderContext* ctx,
}
static WabtResult on_end_expr(void* user_data) {
- Context* context = user_data;
+ Context* context = (Context*)user_data;
context->indent_level--;
assert(context->indent_level >= 0);
log_opcode(context, NULL, 0, NULL);
@@ -349,7 +350,7 @@ static const char* wabt_type_name(WabtType type) {
static WabtResult on_opcode_block_sig(WabtBinaryReaderContext* ctx,
uint32_t num_types,
WabtType* sig_types) {
- Context* context = ctx->user_data;
+ Context* context = (Context*)ctx->user_data;
if (num_types)
log_opcode(context, ctx->data, 1, "%s", wabt_type_name(*sig_types));
else
@@ -364,7 +365,7 @@ static WabtResult on_signature(uint32_t index,
uint32_t result_count,
WabtType* result_types,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (!should_print_details(ctx))
return WABT_OK;
@@ -388,13 +389,13 @@ static WabtResult on_signature(uint32_t index,
static WabtResult on_function_signature(uint32_t index,
uint32_t sig_index,
void* user_data) {
- print_details(user_data, " - func[%d] sig=%d\n", index, sig_index);
+ print_details((Context*)user_data, " - func[%d] sig=%d\n", index, sig_index);
return WABT_OK;
}
static WabtResult begin_function_body(WabtBinaryReaderContext* context,
uint32_t index) {
- Context* ctx = context->user_data;
+ Context* ctx = (Context*)context->user_data;
if (ctx->options->mode == WABT_DUMP_DISASSEMBLE) {
if (index < ctx->options->function_names.size)
@@ -413,7 +414,7 @@ static WabtResult on_import(uint32_t index,
WabtStringSlice module_name,
WabtStringSlice field_name,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
ctx->import_module_name = module_name;
ctx->import_field_name = field_name;
return WABT_OK;
@@ -423,8 +424,8 @@ static WabtResult on_import_func(uint32_t import_index,
uint32_t func_index,
uint32_t sig_index,
void* user_data) {
- Context* ctx = user_data;
- print_details(user_data,
+ Context* ctx = (Context*)user_data;
+ print_details(ctx,
" - func[%d] sig=%d <- " PRIstringslice "." PRIstringslice "\n",
func_index, sig_index,
WABT_PRINTF_STRING_SLICE_ARG(ctx->import_module_name),
@@ -437,10 +438,10 @@ static WabtResult on_import_table(uint32_t import_index,
WabtType elem_type,
const WabtLimits* elem_limits,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
print_details(
- user_data, " - " PRIstringslice "." PRIstringslice
- " -> table elem_type=%s init=%" PRId64 " max=%" PRId64 "\n",
+ ctx, " - " PRIstringslice "." PRIstringslice
+ " -> table elem_type=%s init=%" PRId64 " max=%" PRId64 "\n",
WABT_PRINTF_STRING_SLICE_ARG(ctx->import_module_name),
WABT_PRINTF_STRING_SLICE_ARG(ctx->import_field_name),
wabt_get_type_name(elem_type), elem_limits->initial, elem_limits->max);
@@ -451,9 +452,8 @@ static WabtResult on_import_memory(uint32_t import_index,
uint32_t memory_index,
const WabtLimits* page_limits,
void* user_data) {
- Context* ctx = user_data;
- print_details(user_data,
- " - " PRIstringslice "." PRIstringslice " -> memory\n",
+ Context* ctx = (Context*)user_data;
+ print_details(ctx, " - " PRIstringslice "." PRIstringslice " -> memory\n",
WABT_PRINTF_STRING_SLICE_ARG(ctx->import_module_name),
WABT_PRINTF_STRING_SLICE_ARG(ctx->import_field_name));
return WABT_OK;
@@ -462,11 +462,11 @@ static WabtResult on_import_memory(uint32_t import_index,
static WabtResult on_import_global(uint32_t import_index,
uint32_t global_index,
WabtType type,
- WabtBool mutable_,
+ bool mutable_,
void* user_data) {
- Context* ctx = user_data;
- print_details(user_data, " - global[%d] %s mutable=%d <- " PRIstringslice
- "." PRIstringslice "\n",
+ Context* ctx = (Context*)user_data;
+ print_details(ctx, " - global[%d] %s mutable=%d <- " PRIstringslice
+ "." PRIstringslice "\n",
global_index, wabt_get_type_name(type), mutable_,
WABT_PRINTF_STRING_SLICE_ARG(ctx->import_module_name),
WABT_PRINTF_STRING_SLICE_ARG(ctx->import_field_name));
@@ -476,12 +476,12 @@ static WabtResult on_import_global(uint32_t import_index,
static WabtResult on_memory(uint32_t index,
const WabtLimits* page_limits,
void* user_data) {
- print_details(user_data, " - memory[%d] pages: initial=%" PRId64,
- index,
- page_limits->initial);
+ Context* ctx = (Context*)user_data;
+ print_details(ctx, " - memory[%d] pages: initial=%" PRId64, index,
+ page_limits->initial);
if (page_limits->has_max)
- print_details(user_data, " max=%" PRId64, page_limits->max);
- print_details(user_data, "\n");
+ print_details(ctx, " max=%" PRId64, page_limits->max);
+ print_details(ctx, "\n");
return WABT_OK;
}
@@ -489,13 +489,12 @@ static WabtResult on_table(uint32_t index,
WabtType elem_type,
const WabtLimits* elem_limits,
void* user_data) {
- print_details(user_data, " - table[%d] type=%s initial=%" PRId64,
- index,
- wabt_get_type_name(elem_type),
- elem_limits->initial);
+ Context* ctx = (Context*)user_data;
+ print_details(ctx, " - table[%d] type=%s initial=%" PRId64, index,
+ wabt_get_type_name(elem_type), elem_limits->initial);
if (elem_limits->has_max)
- print_details(user_data, " max=%" PRId64, elem_limits->max);
- print_details(user_data, "\n");
+ print_details(ctx, " max=%" PRId64, elem_limits->max);
+ print_details(ctx, "\n");
return WABT_OK;
}
@@ -504,78 +503,87 @@ static WabtResult on_export(uint32_t index,
uint32_t item_index,
WabtStringSlice name,
void* user_data) {
- print_details(user_data, " - %s[%d] ", wabt_get_kind_name(kind), item_index);
- print_details(user_data, PRIstringslice, WABT_PRINTF_STRING_SLICE_ARG(name));
- print_details(user_data, "\n");
+ Context* ctx = (Context*)user_data;
+ print_details(ctx, " - %s[%d] ", wabt_get_kind_name(kind), item_index);
+ print_details(ctx, PRIstringslice, WABT_PRINTF_STRING_SLICE_ARG(name));
+ print_details(ctx, "\n");
return WABT_OK;
}
static WabtResult on_elem_segment_function_index(uint32_t index,
uint32_t func_index,
void* user_data) {
- print_details(user_data, " - func[%d]\n", func_index);
+ Context* ctx = (Context*)user_data;
+ print_details(ctx, " - func[%d]\n", func_index);
return WABT_OK;
}
static WabtResult begin_elem_segment(uint32_t index,
uint32_t table_index,
void* user_data) {
- print_details(user_data, " - segment[%d] table=%d\n", index, table_index);
+ Context* ctx = (Context*)user_data;
+ print_details(ctx, " - segment[%d] table=%d\n", index, table_index);
return WABT_OK;
}
static WabtResult begin_global(uint32_t index,
WabtType type,
- WabtBool mutable,
+ bool mutable_,
void* user_data) {
- print_details(user_data, " - global[%d] %s mutable=%d", index,
- wabt_get_type_name(type), mutable);
+ Context* ctx = (Context*)user_data;
+ print_details(ctx, " - global[%d] %s mutable=%d", index,
+ wabt_get_type_name(type), mutable_);
return WABT_OK;
}
static WabtResult on_init_expr_f32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
+ Context* ctx = (Context*)user_data;
char buffer[WABT_MAX_FLOAT_HEX];
wabt_write_float_hex(buffer, sizeof(buffer), value);
- print_details(user_data, " - init f32=%s\n", buffer);
+ print_details(ctx, " - init f32=%s\n", buffer);
return WABT_OK;
}
static WabtResult on_init_expr_f64_const_expr(uint32_t index,
uint64_t value,
void* user_data) {
+ Context* ctx = (Context*)user_data;
char buffer[WABT_MAX_DOUBLE_HEX];
wabt_write_float_hex(buffer, sizeof(buffer), value);
- print_details(user_data, " - init f64=%s\n", buffer);
+ print_details(ctx, " - init f64=%s\n", buffer);
return WABT_OK;
}
static WabtResult on_init_expr_get_global_expr(uint32_t index,
uint32_t global_index,
void* user_data) {
- print_details(user_data, " - init global=%d\n", global_index);
+ Context* ctx = (Context*)user_data;
+ print_details(ctx, " - init global=%d\n", global_index);
return WABT_OK;
}
static WabtResult on_init_expr_i32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
- print_details(user_data, " - init i32=%d\n", value);
+ Context* ctx = (Context*)user_data;
+ print_details(ctx, " - init i32=%d\n", value);
return WABT_OK;
}
static WabtResult on_init_expr_i64_const_expr(uint32_t index,
uint64_t value,
void* user_data) {
- print_details(user_data, " - init i64=%" PRId64 "\n", value);
+ Context* ctx = (Context*)user_data;
+ print_details(ctx, " - init i64=%" PRId64 "\n", value);
return WABT_OK;
}
static WabtResult on_function_name(uint32_t index,
WabtStringSlice name,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
print_details(ctx, " - func[%d] " PRIstringslice "\n", index,
WABT_PRINTF_STRING_SLICE_ARG(name));
if (ctx->options->mode == WABT_DUMP_PREPASS)
@@ -587,8 +595,9 @@ static WabtResult on_local_name(uint32_t func_index,
uint32_t local_index,
WabtStringSlice name,
void* user_data) {
+ Context* ctx = (Context*)user_data;
if (name.length) {
- print_details(user_data, " - local[%d] " PRIstringslice "\n", local_index,
+ print_details(ctx, " - local[%d] " PRIstringslice "\n", local_index,
WABT_PRINTF_STRING_SLICE_ARG(name));
}
return WABT_OK;
@@ -598,19 +607,18 @@ WabtResult on_reloc_count(uint32_t count,
WabtBinarySection section_code,
WabtStringSlice section_name,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
ctx->reloc_section = section_code;
- print_details(user_data, " - section: %s\n",
- wabt_get_section_name(section_code));
+ print_details(ctx, " - section: %s\n", wabt_get_section_name(section_code));
return WABT_OK;
}
WabtResult on_reloc(WabtRelocType type,
uint32_t offset,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
uint32_t total_offset = ctx->section_starts[ctx->reloc_section] + offset;
- print_details(user_data, " - %-18s offset=%#x (%#x)\n",
+ print_details(ctx, " - %-18s offset=%#x (%#x)\n",
wabt_get_reloc_type_name(type), total_offset, offset);
if (ctx->options->mode == WABT_DUMP_PREPASS &&
ctx->reloc_section == WABT_BINARY_SECTION_CODE) {
@@ -633,7 +641,7 @@ static void on_error(WabtBinaryReaderContext* ctx, const char* message) {
static WabtResult begin_data_segment(uint32_t index,
uint32_t memory_index,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
print_details(ctx, " - memory[%d]", memory_index);
return WABT_OK;
}
@@ -642,7 +650,7 @@ static WabtResult on_data_segment_data(uint32_t index,
const void* src_data,
uint32_t size,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (should_print_details(ctx)) {
wabt_write_memory_dump(ctx->out_stream, src_data, size, 0, WABT_PRINT_CHARS,
" - ", NULL);
@@ -650,100 +658,94 @@ static WabtResult on_data_segment_data(uint32_t index,
return WABT_OK;
}
-static WabtBinaryReader s_binary_reader = {
- .user_data = NULL,
+WabtResult wabt_read_binary_objdump(const uint8_t* data,
+ size_t size,
+ WabtObjdumpOptions* options) {
+ Context context;
+ WABT_ZERO_MEMORY(context);
+ context.header_printed = false;
+ context.print_details = false;
+ context.section_found = false;
+ context.data = data;
+ context.size = size;
+ context.options = options;
+ context.out_stream = wabt_init_stdout_stream();
- .begin_module = begin_module,
- .end_module = end_module,
- .on_error = on_error,
+ WabtBinaryReader reader;
+ WABT_ZERO_MEMORY(reader);
+ if (options->mode == WABT_DUMP_PREPASS) {
+ reader.on_function_name = on_function_name;
+ reader.on_reloc_count = on_reloc_count;
+ reader.on_reloc = on_reloc;
+ } else {
+ reader.begin_module = begin_module;
+ reader.end_module = end_module;
+ reader.on_error = on_error;
- .begin_section = begin_section,
+ reader.begin_section = begin_section;
// User section
- .begin_custom_section = begin_custom_section,
+ reader.begin_custom_section = begin_custom_section;
// Signature section
- .on_signature_count = on_count,
- .on_signature = on_signature,
+ reader.on_signature_count = on_count;
+ reader.on_signature = on_signature;
// Import section
- .on_import_count = on_count,
- .on_import = on_import,
- .on_import_func = on_import_func,
- .on_import_table = on_import_table,
- .on_import_memory = on_import_memory,
- .on_import_global = on_import_global,
+ reader.on_import_count = on_count;
+ reader.on_import = on_import;
+ reader.on_import_func = on_import_func;
+ reader.on_import_table = on_import_table;
+ reader.on_import_memory = on_import_memory;
+ reader.on_import_global = on_import_global;
// Function sigs section
- .on_function_signatures_count = on_count,
- .on_function_signature = on_function_signature,
+ reader.on_function_signatures_count = on_count;
+ reader.on_function_signature = on_function_signature;
// Table section
- .on_table_count = on_count,
- .on_table = on_table,
+ reader.on_table_count = on_count;
+ reader.on_table = on_table;
// Memory section
- .on_memory_count = on_count,
- .on_memory = on_memory,
+ reader.on_memory_count = on_count;
+ reader.on_memory = on_memory;
// Globl seciont
- .begin_global = begin_global,
- .on_global_count = on_count,
+ reader.begin_global = begin_global;
+ reader.on_global_count = on_count;
// Export section
- .on_export_count = on_count,
- .on_export = on_export,
+ reader.on_export_count = on_count;
+ reader.on_export = on_export;
// Body section
- .on_function_bodies_count = on_count,
- .begin_function_body = begin_function_body,
+ reader.on_function_bodies_count = on_count;
+ reader.begin_function_body = begin_function_body;
// Elems section
- .begin_elem_segment = begin_elem_segment,
- .on_elem_segment_count = on_count,
- .on_elem_segment_function_index = on_elem_segment_function_index,
+ reader.begin_elem_segment = begin_elem_segment;
+ reader.on_elem_segment_count = on_count;
+ reader.on_elem_segment_function_index = on_elem_segment_function_index;
// Data section
- .begin_data_segment = begin_data_segment,
- .on_data_segment_data = on_data_segment_data,
- .on_data_segment_count = on_count,
+ reader.begin_data_segment = begin_data_segment;
+ reader.on_data_segment_data = on_data_segment_data;
+ reader.on_data_segment_count = on_count;
// Known "User" sections:
// - Names section
- .on_function_name = on_function_name,
- .on_local_name = on_local_name,
-
- .on_reloc_count = on_reloc_count,
- .on_reloc = on_reloc,
-
- .on_init_expr_i32_const_expr = on_init_expr_i32_const_expr,
- .on_init_expr_i64_const_expr = on_init_expr_i64_const_expr,
- .on_init_expr_f32_const_expr = on_init_expr_f32_const_expr,
- .on_init_expr_f64_const_expr = on_init_expr_f64_const_expr,
- .on_init_expr_get_global_expr = on_init_expr_get_global_expr,
-};
-
-WabtResult wabt_read_binary_objdump(const uint8_t* data,
- size_t size,
- WabtObjdumpOptions* options) {
- Context context;
- WABT_ZERO_MEMORY(context);
- context.header_printed = WABT_FALSE;
- context.print_details = WABT_FALSE;
- context.section_found = WABT_FALSE;
- context.data = data;
- context.size = size;
- context.options = options;
- context.out_stream = wabt_init_stdout_stream();
-
- WabtBinaryReader reader;
- WABT_ZERO_MEMORY(reader);
- if (options->mode == WABT_DUMP_PREPASS) {
reader.on_function_name = on_function_name;
+ reader.on_local_name = on_local_name;
+
reader.on_reloc_count = on_reloc_count;
reader.on_reloc = on_reloc;
- } else {
- reader = s_binary_reader;
+
+ reader.on_init_expr_i32_const_expr = on_init_expr_i32_const_expr;
+ reader.on_init_expr_i64_const_expr = on_init_expr_i64_const_expr;
+ reader.on_init_expr_f32_const_expr = on_init_expr_f32_const_expr;
+ reader.on_init_expr_f64_const_expr = on_init_expr_f64_const_expr;
+ reader.on_init_expr_get_global_expr = on_init_expr_get_global_expr;
}
if (options->mode == WABT_DUMP_DISASSEMBLE) {
@@ -762,6 +764,6 @@ WabtResult wabt_read_binary_objdump(const uint8_t* data,
reader.user_data = &context;
WabtReadBinaryOptions read_options = WABT_READ_BINARY_OPTIONS_DEFAULT;
- read_options.read_debug_names = WABT_TRUE;
+ read_options.read_debug_names = true;
return wabt_read_binary(data, size, &reader, 1, &read_options);
}
diff --git a/src/binary-reader-objdump.h b/src/binary-reader-objdump.h
index f0b55e6a..7d313676 100644
--- a/src/binary-reader-objdump.h
+++ b/src/binary-reader-objdump.h
@@ -41,16 +41,16 @@ typedef enum WabtObjdumpMode {
} WabtObjdumpMode;
typedef struct WabtObjdumpOptions {
- WabtBool headers;
- WabtBool details;
- WabtBool raw;
- WabtBool disassemble;
- WabtBool debug;
- WabtBool relocs;
+ bool headers;
+ bool details;
+ bool raw;
+ bool disassemble;
+ bool debug;
+ bool relocs;
WabtObjdumpMode mode;
const char* infile;
const char* section_name;
- WabtBool print_header;
+ bool print_header;
WabtStringSliceVector function_names;
WabtRelocVector code_relocations;
} WabtObjdumpOptions;
diff --git a/src/binary-reader-opcnt.c b/src/binary-reader-opcnt.cc
index c1b7ac38..b79e656a 100644
--- a/src/binary-reader-opcnt.c
+++ b/src/binary-reader-opcnt.cc
@@ -65,7 +65,7 @@ static WabtResult add_int_pair_counter_value(WabtIntPairCounterVector* vec,
static WabtResult on_opcode(WabtBinaryReaderContext* context,
WabtOpcode opcode) {
- Context* ctx = context->user_data;
+ Context* ctx = (Context*)context->user_data;
WabtIntCounterVector* opcnt_vec = &ctx->opcnt_data->opcode_vec;
while (opcode >= opcnt_vec->size) {
WabtIntCounter Counter;
@@ -78,22 +78,22 @@ static WabtResult on_opcode(WabtBinaryReaderContext* context,
}
static WabtResult on_i32_const_expr(uint32_t value, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
return add_int_counter_value(&ctx->opcnt_data->i32_const_vec, (int32_t)value);
}
static WabtResult on_get_local_expr(uint32_t local_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
return add_int_counter_value(&ctx->opcnt_data->get_local_vec, local_index);
}
static WabtResult on_set_local_expr(uint32_t local_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
return add_int_counter_value(&ctx->opcnt_data->set_local_vec, local_index);
}
static WabtResult on_tee_local_expr(uint32_t local_index, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
return add_int_counter_value(&ctx->opcnt_data->tee_local_vec, local_index);
}
@@ -101,7 +101,7 @@ static WabtResult on_load_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (opcode == WABT_OPCODE_I32_LOAD)
return add_int_pair_counter_value(&ctx->opcnt_data->i32_load_vec,
alignment_log2, offset);
@@ -112,7 +112,7 @@ static WabtResult on_store_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
if (opcode == WABT_OPCODE_I32_STORE)
return add_int_pair_counter_value(&ctx->opcnt_data->i32_store_vec,
alignment_log2, offset);
@@ -127,18 +127,6 @@ static void on_error(WabtBinaryReaderContext* ctx, const char* message) {
wabt_default_binary_error_callback(ctx->offset, message, &info);
}
-static WabtBinaryReader s_binary_reader = {
- .user_data = NULL,
- .on_error = on_error,
- .on_opcode = on_opcode,
- .on_i32_const_expr = on_i32_const_expr,
- .on_get_local_expr = on_get_local_expr,
- .on_set_local_expr = on_set_local_expr,
- .on_tee_local_expr = on_tee_local_expr,
- .on_load_expr = on_load_expr,
- .on_store_expr = on_store_expr
-};
-
void wabt_init_opcnt_data(WabtOpcntData* data) {
WABT_ZERO_MEMORY(*data);
}
@@ -160,8 +148,15 @@ WabtResult wabt_read_binary_opcnt(const void* data,
WabtBinaryReader reader;
WABT_ZERO_MEMORY(reader);
- reader = s_binary_reader;
reader.user_data = &ctx;
+ reader.on_error = on_error;
+ reader.on_opcode = on_opcode;
+ reader.on_i32_const_expr = on_i32_const_expr;
+ reader.on_get_local_expr = on_get_local_expr;
+ reader.on_set_local_expr = on_set_local_expr;
+ reader.on_tee_local_expr = on_tee_local_expr;
+ reader.on_load_expr = on_load_expr;
+ reader.on_store_expr = on_store_expr;
return wabt_read_binary(data, size, &reader, 1, options);
}
diff --git a/src/binary-reader.c b/src/binary-reader.cc
index 8fdd6574..704886ad 100644
--- a/src/binary-reader.c
+++ b/src/binary-reader.cc
@@ -98,8 +98,7 @@ WABT_DEFINE_VECTOR(uint32, Uint32);
? ctx->reader->member(__VA_ARGS__, ctx->reader->user_data) \
: WABT_OK
-#define RAISE_ERROR(...) \
- (ctx->reader->on_error ? raise_error(ctx, __VA_ARGS__) : (void)0)
+#define RAISE_ERROR(...) raise_error(ctx, __VA_ARGS__)
#define RAISE_ERROR_UNLESS(cond, ...) \
if (!(cond)) \
@@ -116,7 +115,7 @@ typedef struct Context {
WabtTypeVector param_types;
Uint32Vector target_depths;
const WabtReadBinaryOptions* options;
- WabtBinarySection last_known_section_code;
+ WabtBinarySection last_known_section;
uint32_t num_signatures;
uint32_t num_imports;
uint32_t num_func_imports;
@@ -148,8 +147,12 @@ static WabtBinaryReaderContext* get_user_context(Context* ctx) {
static void WABT_PRINTF_FORMAT(2, 3)
raise_error(Context* ctx, const char* format, ...) {
WABT_SNPRINTF_ALLOCA(buffer, length, format);
- assert(ctx->reader->on_error);
- ctx->reader->on_error(get_user_context(ctx), buffer);
+ if (ctx->reader->on_error) {
+ ctx->reader->on_error(get_user_context(ctx), buffer);
+ } else {
+ /* Not great to just print, but we don't want to eat the error either. */
+ fprintf(stderr, "*ERROR*: %s\n", buffer);
+ }
longjmp(ctx->error_jmp_buf, 1);
}
@@ -254,7 +257,7 @@ size_t wabt_read_i32_leb128(const uint8_t* p,
return 4;
} else if (p + 4 < end && (p[4] & 0x80) == 0) {
/* the top bits should be a sign-extension of the sign bit */
- WabtBool sign_bit_set = (p[4] & 0x8);
+ bool sign_bit_set = (p[4] & 0x8);
int top_bits = p[4] & 0xf0;
if ((sign_bit_set && top_bits != 0x70) ||
(!sign_bit_set && top_bits != 0)) {
@@ -320,7 +323,7 @@ static void in_i64_leb128(Context* ctx, uint64_t* out_value, const char* desc) {
ctx->offset += 9;
} else if (p + 9 < end && (p[9] & 0x80) == 0) {
/* the top bits should be a sign-extension of the sign bit */
- WabtBool sign_bit_set = (p[9] & 0x1);
+ bool sign_bit_set = (p[9] & 0x1);
int top_bits = p[9] & 0xfe;
if ((sign_bit_set && top_bits != 0x7e) ||
(!sign_bit_set && top_bits != 0)) {
@@ -355,7 +358,7 @@ static void in_type(Context* ctx, WabtType* out_value, const char* desc) {
/* Must be in the vs7 range: [-128, 127). */
if ((int32_t)type < -128 || (int32_t)type > 127)
RAISE_ERROR("invalid type: %d", type);
- *out_value = type;
+ *out_value = (WabtType)type;
}
static void in_str(Context* ctx, WabtStringSlice* out_str, const char* desc) {
@@ -385,24 +388,24 @@ static void in_bytes(Context* ctx,
ctx->offset += data_size;
}
-static WabtBool is_valid_external_kind(uint8_t kind) {
+static bool is_valid_external_kind(uint8_t kind) {
return kind < WABT_NUM_EXTERNAL_KINDS;
}
-static WabtBool is_concrete_type(WabtType type) {
+static bool is_concrete_type(WabtType type) {
switch (type) {
case WABT_TYPE_I32:
case WABT_TYPE_I64:
case WABT_TYPE_F32:
case WABT_TYPE_F64:
- return WABT_TRUE;
+ return true;
default:
- return WABT_FALSE;
+ return false;
}
}
-static WabtBool is_inline_sig_type(WabtType type) {
+static bool is_inline_sig_type(WabtType type) {
return is_concrete_type(type) || type == WABT_TYPE_VOID;
}
@@ -463,7 +466,7 @@ static void write_indent(LoggingContext* ctx) {
static void logging_on_error(WabtBinaryReaderContext* ctx,
const char* message) {
- LoggingContext* logging_ctx = ctx->user_data;
+ LoggingContext* logging_ctx = (LoggingContext*)ctx->user_data;
if (logging_ctx->reader->on_error) {
WabtBinaryReaderContext new_ctx = *ctx;
new_ctx.user_data = logging_ctx->reader->user_data;
@@ -474,7 +477,7 @@ static void logging_on_error(WabtBinaryReaderContext* ctx,
static WabtResult logging_begin_custom_section(WabtBinaryReaderContext* context,
uint32_t size,
WabtStringSlice section_name) {
- LoggingContext* ctx = context->user_data;
+ LoggingContext* ctx = (LoggingContext*)context->user_data;
LOGF("begin_custom_section: '" PRIstringslice "' size=%d\n",
WABT_PRINTF_STRING_SLICE_ARG(section_name), size);
indent(ctx);
@@ -484,7 +487,7 @@ static WabtResult logging_begin_custom_section(WabtBinaryReaderContext* context,
#define LOGGING_BEGIN(name) \
static WabtResult logging_begin_##name(WabtBinaryReaderContext* context, \
uint32_t size) { \
- LoggingContext* ctx = context->user_data; \
+ LoggingContext* ctx = (LoggingContext*)context->user_data; \
LOGF("begin_" #name "\n"); \
indent(ctx); \
FORWARD_CTX(begin_##name, size); \
@@ -492,7 +495,7 @@ static WabtResult logging_begin_custom_section(WabtBinaryReaderContext* context,
#define LOGGING_END(name) \
static WabtResult logging_end_##name(WabtBinaryReaderContext* context) { \
- LoggingContext* ctx = context->user_data; \
+ LoggingContext* ctx = (LoggingContext*)context->user_data; \
dedent(ctx); \
LOGF("end_" #name "\n"); \
FORWARD_CTX0(end_##name); \
@@ -500,7 +503,7 @@ static WabtResult logging_begin_custom_section(WabtBinaryReaderContext* context,
#define LOGGING_UINT32(name) \
static WabtResult logging_##name(uint32_t value, void* user_data) { \
- LoggingContext* ctx = user_data; \
+ LoggingContext* ctx = (LoggingContext*)user_data; \
LOGF(#name "(%u)\n", value); \
FORWARD(name, value); \
}
@@ -508,14 +511,14 @@ static WabtResult logging_begin_custom_section(WabtBinaryReaderContext* context,
#define LOGGING_UINT32_CTX(name) \
static WabtResult logging_##name(WabtBinaryReaderContext* context, \
uint32_t value) { \
- LoggingContext* ctx = context->user_data; \
+ LoggingContext* ctx = (LoggingContext*)context->user_data; \
LOGF(#name "(%u)\n", value); \
FORWARD_CTX(name, value); \
}
#define LOGGING_UINT32_DESC(name, desc) \
static WabtResult logging_##name(uint32_t value, void* user_data) { \
- LoggingContext* ctx = user_data; \
+ LoggingContext* ctx = (LoggingContext*)user_data; \
LOGF(#name "(" desc ": %u)\n", value); \
FORWARD(name, value); \
}
@@ -523,7 +526,7 @@ static WabtResult logging_begin_custom_section(WabtBinaryReaderContext* context,
#define LOGGING_UINT32_UINT32(name, desc0, desc1) \
static WabtResult logging_##name(uint32_t value0, uint32_t value1, \
void* user_data) { \
- LoggingContext* ctx = user_data; \
+ LoggingContext* ctx = (LoggingContext*)user_data; \
LOGF(#name "(" desc0 ": %u, " desc1 ": %u)\n", value0, value1); \
FORWARD(name, value0, value1); \
}
@@ -531,21 +534,21 @@ static WabtResult logging_begin_custom_section(WabtBinaryReaderContext* context,
#define LOGGING_UINT32_UINT32_CTX(name, desc0, desc1) \
static WabtResult logging_##name(WabtBinaryReaderContext* context, \
uint32_t value0, uint32_t value1) { \
- LoggingContext* ctx = context->user_data; \
+ LoggingContext* ctx = (LoggingContext*)context->user_data; \
LOGF(#name "(" desc0 ": %u, " desc1 ": %u)\n", value0, value1); \
FORWARD_CTX(name, value0, value1); \
}
#define LOGGING_OPCODE(name) \
static WabtResult logging_##name(WabtOpcode opcode, void* user_data) { \
- LoggingContext* ctx = user_data; \
+ LoggingContext* ctx = (LoggingContext*)user_data; \
LOGF(#name "(\"%s\" (%u))\n", wabt_get_opcode_name(opcode), opcode); \
FORWARD(name, opcode); \
}
#define LOGGING0(name) \
static WabtResult logging_##name(void* user_data) { \
- LoggingContext* ctx = user_data; \
+ LoggingContext* ctx = (LoggingContext*)user_data; \
LOGF(#name "\n"); \
FORWARD0(name); \
}
@@ -665,7 +668,7 @@ static WabtResult logging_on_signature(uint32_t index,
uint32_t result_count,
WabtType* result_types,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_signature(index: %u, params: ", index);
log_types(ctx, param_count, param_types);
LOGF_NOINDENT(", results: ");
@@ -679,7 +682,7 @@ static WabtResult logging_on_import(uint32_t index,
WabtStringSlice module_name,
WabtStringSlice field_name,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_import(index: %u, module: \"" PRIstringslice
"\", field: \"" PRIstringslice "\")\n",
index, WABT_PRINTF_STRING_SLICE_ARG(module_name),
@@ -691,7 +694,7 @@ static WabtResult logging_on_import_func(uint32_t import_index,
uint32_t func_index,
uint32_t sig_index,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_import_func(import_index: %u, func_index: %u, sig_index: %u)\n",
import_index, func_index, sig_index);
FORWARD(on_import_func, import_index, func_index, sig_index);
@@ -703,7 +706,7 @@ static WabtResult logging_on_import_table(uint32_t import_index,
WabtType elem_type,
const WabtLimits* elem_limits,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
char buf[100];
sprint_limits(buf, sizeof(buf), elem_limits);
LOGF(
@@ -716,7 +719,7 @@ static WabtResult logging_on_import_memory(uint32_t import_index,
uint32_t memory_index,
const WabtLimits* page_limits,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
char buf[100];
sprint_limits(buf, sizeof(buf), page_limits);
LOGF("on_import_memory(import_index: %u, memory_index: %u, %s)\n",
@@ -727,9 +730,9 @@ static WabtResult logging_on_import_memory(uint32_t import_index,
static WabtResult logging_on_import_global(uint32_t import_index,
uint32_t global_index,
WabtType type,
- WabtBool mutable_,
+ bool mutable_,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF(
"on_import_global(import_index: %u, global_index: %u, type: %s, mutable: "
"%s)\n",
@@ -742,7 +745,7 @@ static WabtResult logging_on_table(uint32_t index,
WabtType elem_type,
const WabtLimits* elem_limits,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
char buf[100];
sprint_limits(buf, sizeof(buf), elem_limits);
LOGF("on_table(index: %u, elem_type: %s, %s)\n", index,
@@ -753,7 +756,7 @@ static WabtResult logging_on_table(uint32_t index,
static WabtResult logging_on_memory(uint32_t index,
const WabtLimits* page_limits,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
char buf[100];
sprint_limits(buf, sizeof(buf), page_limits);
LOGF("on_memory(index: %u, %s)\n", index, buf);
@@ -762,9 +765,9 @@ static WabtResult logging_on_memory(uint32_t index,
static WabtResult logging_begin_global(uint32_t index,
WabtType type,
- WabtBool mutable_,
+ bool mutable_,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("begin_global(index: %u, type: %s, mutable: %s)\n", index,
wabt_get_type_name(type), mutable_ ? "true" : "false");
FORWARD(begin_global, index, type, mutable_);
@@ -775,7 +778,7 @@ static WabtResult logging_on_export(uint32_t index,
uint32_t item_index,
WabtStringSlice name,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_export(index: %u, kind: %s, item_index: %u, name: \"" PRIstringslice
"\")\n",
index, wabt_get_kind_name(kind), item_index,
@@ -786,7 +789,7 @@ static WabtResult logging_on_export(uint32_t index,
static WabtResult logging_begin_function_body_pass(uint32_t index,
uint32_t pass,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("begin_function_body_pass(index: %u, pass: %u)\n", index, pass);
indent(ctx);
FORWARD(begin_function_body_pass, index, pass);
@@ -796,7 +799,7 @@ static WabtResult logging_on_local_decl(uint32_t decl_index,
uint32_t count,
WabtType type,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_local_decl(index: %u, count: %u, type: %s)\n", decl_index, count,
wabt_get_type_name(type));
FORWARD(on_local_decl, decl_index, count, type);
@@ -805,7 +808,7 @@ static WabtResult logging_on_local_decl(uint32_t decl_index,
static WabtResult logging_on_block_expr(uint32_t num_types,
WabtType* sig_types,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_block_expr(sig: ");
log_types(ctx, num_types, sig_types);
LOGF_NOINDENT(")\n");
@@ -813,13 +816,13 @@ static WabtResult logging_on_block_expr(uint32_t num_types,
}
static WabtResult logging_on_br_expr(uint32_t depth, void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_br_expr(depth: %u)\n", depth);
FORWARD(on_br_expr, depth);
}
static WabtResult logging_on_br_if_expr(uint32_t depth, void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_br_if_expr(depth: %u)\n", depth);
FORWARD(on_br_if_expr, depth);
}
@@ -828,7 +831,7 @@ static WabtResult logging_on_br_table_expr(WabtBinaryReaderContext* context,
uint32_t num_targets,
uint32_t* target_depths,
uint32_t default_target_depth) {
- LoggingContext* ctx = context->user_data;
+ LoggingContext* ctx = (LoggingContext*)context->user_data;
LOGF("on_br_table_expr(num_targets: %u, depths: [", num_targets);
uint32_t i;
for (i = 0; i < num_targets; ++i) {
@@ -843,7 +846,7 @@ static WabtResult logging_on_br_table_expr(WabtBinaryReaderContext* context,
static WabtResult logging_on_f32_const_expr(uint32_t value_bits,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
float value;
memcpy(&value, &value_bits, sizeof(value));
LOGF("on_f32_const_expr(%g (0x04%x))\n", value, value_bits);
@@ -852,7 +855,7 @@ static WabtResult logging_on_f32_const_expr(uint32_t value_bits,
static WabtResult logging_on_f64_const_expr(uint64_t value_bits,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
double value;
memcpy(&value, &value_bits, sizeof(value));
LOGF("on_f64_const_expr(%g (0x08%" PRIx64 "))\n", value, value_bits);
@@ -860,13 +863,13 @@ static WabtResult logging_on_f64_const_expr(uint64_t value_bits,
}
static WabtResult logging_on_i32_const_expr(uint32_t value, void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_i32_const_expr(%u (0x%x))\n", value, value);
FORWARD(on_i32_const_expr, value);
}
static WabtResult logging_on_i64_const_expr(uint64_t value, void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_i64_const_expr(%" PRIu64 " (0x%" PRIx64 "))\n", value, value);
FORWARD(on_i64_const_expr, value);
}
@@ -874,7 +877,7 @@ static WabtResult logging_on_i64_const_expr(uint64_t value, void* user_data) {
static WabtResult logging_on_if_expr(uint32_t num_types,
WabtType* sig_types,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_if_expr(sig: ");
log_types(ctx, num_types, sig_types);
LOGF_NOINDENT(")\n");
@@ -885,7 +888,7 @@ static WabtResult logging_on_load_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_load_expr(opcode: \"%s\" (%u), align log2: %u, offset: %u)\n",
wabt_get_opcode_name(opcode), opcode, alignment_log2, offset);
FORWARD(on_load_expr, opcode, alignment_log2, offset);
@@ -894,7 +897,7 @@ static WabtResult logging_on_load_expr(WabtOpcode opcode,
static WabtResult logging_on_loop_expr(uint32_t num_types,
WabtType* sig_types,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_loop_expr(sig: ");
log_types(ctx, num_types, sig_types);
LOGF_NOINDENT(")\n");
@@ -905,7 +908,7 @@ static WabtResult logging_on_store_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_store_expr(opcode: \"%s\" (%u), align log2: %u, offset: %u)\n",
wabt_get_opcode_name(opcode), opcode, alignment_log2, offset);
FORWARD(on_store_expr, opcode, alignment_log2, offset);
@@ -914,7 +917,7 @@ static WabtResult logging_on_store_expr(WabtOpcode opcode,
static WabtResult logging_end_function_body_pass(uint32_t index,
uint32_t pass,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
dedent(ctx);
LOGF("end_function_body_pass(index: %u, pass: %u)\n", index, pass);
FORWARD(end_function_body_pass, index, pass);
@@ -924,7 +927,7 @@ static WabtResult logging_on_data_segment_data(uint32_t index,
const void* data,
uint32_t size,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_data_segment_data(index:%u, size:%u)\n", index, size);
FORWARD(on_data_segment_data, index, data, size);
}
@@ -932,7 +935,7 @@ static WabtResult logging_on_data_segment_data(uint32_t index,
static WabtResult logging_on_function_name(uint32_t index,
WabtStringSlice name,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_function_name(index: %u, name: \"" PRIstringslice "\")\n", index,
WABT_PRINTF_STRING_SLICE_ARG(name));
FORWARD(on_function_name, index, name);
@@ -942,7 +945,7 @@ static WabtResult logging_on_local_name(uint32_t func_index,
uint32_t local_index,
WabtStringSlice name,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_local_name(func_index: %u, local_index: %u, name: \"" PRIstringslice
"\")\n",
func_index, local_index, WABT_PRINTF_STRING_SLICE_ARG(name));
@@ -952,7 +955,7 @@ static WabtResult logging_on_local_name(uint32_t func_index,
static WabtResult logging_on_init_expr_f32_const_expr(uint32_t index,
uint32_t value_bits,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
float value;
memcpy(&value, &value_bits, sizeof(value));
LOGF("on_init_expr_f32_const_expr(index: %u, value: %g (0x04%x))\n", index,
@@ -963,7 +966,7 @@ static WabtResult logging_on_init_expr_f32_const_expr(uint32_t index,
static WabtResult logging_on_init_expr_f64_const_expr(uint32_t index,
uint64_t value_bits,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
double value;
memcpy(&value, &value_bits, sizeof(value));
LOGF("on_init_expr_f64_const_expr(index: %u value: %g (0x08%" PRIx64 "))\n",
@@ -974,7 +977,7 @@ static WabtResult logging_on_init_expr_f64_const_expr(uint32_t index,
static WabtResult logging_on_init_expr_i32_const_expr(uint32_t index,
uint32_t value,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_init_expr_i32_const_expr(index: %u, value: %u)\n", index, value);
FORWARD(on_init_expr_i32_const_expr, index, value);
}
@@ -982,7 +985,7 @@ static WabtResult logging_on_init_expr_i32_const_expr(uint32_t index,
static WabtResult logging_on_init_expr_i64_const_expr(uint32_t index,
uint64_t value,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_init_expr_i64_const_expr(index: %u, value: %" PRIu64 ")\n", index,
value);
FORWARD(on_init_expr_i64_const_expr, index, value);
@@ -992,7 +995,7 @@ static WabtResult logging_on_reloc_count(uint32_t count,
WabtBinarySection section_code,
WabtStringSlice section_name,
void* user_data) {
- LoggingContext* ctx = user_data;
+ LoggingContext* ctx = (LoggingContext*)user_data;
LOGF("on_reloc_count(count: %d, section: %s, section_name: " PRIstringslice
")\n",
count, wabt_get_section_name(section_code),
@@ -1000,143 +1003,6 @@ static WabtResult logging_on_reloc_count(uint32_t count,
FORWARD(on_reloc_count, count, section_code, section_name);
}
-static WabtBinaryReader s_logging_binary_reader = {
- .user_data = NULL,
- .on_error = logging_on_error,
- .begin_module = logging_begin_module,
- .end_module = logging_end_module,
-
- .begin_custom_section = logging_begin_custom_section,
- .end_custom_section = logging_end_custom_section,
-
- .begin_signature_section = logging_begin_signature_section,
- .on_signature_count = logging_on_signature_count,
- .on_signature = logging_on_signature,
- .end_signature_section = logging_end_signature_section,
-
- .begin_import_section = logging_begin_import_section,
- .on_import_count = logging_on_import_count,
- .on_import = logging_on_import,
- .on_import_func = logging_on_import_func,
- .on_import_table = logging_on_import_table,
- .on_import_memory = logging_on_import_memory,
- .on_import_global = logging_on_import_global,
- .end_import_section = logging_end_import_section,
-
- .begin_function_signatures_section =
- logging_begin_function_signatures_section,
- .on_function_signatures_count = logging_on_function_signatures_count,
- .on_function_signature = logging_on_function_signature,
- .end_function_signatures_section = logging_end_function_signatures_section,
-
- .begin_table_section = logging_begin_table_section,
- .on_table_count = logging_on_table_count,
- .on_table = logging_on_table,
- .end_table_section = logging_end_table_section,
-
- .begin_memory_section = logging_begin_memory_section,
- .on_memory_count = logging_on_memory_count,
- .on_memory = logging_on_memory,
- .end_memory_section = logging_end_memory_section,
-
- .begin_global_section = logging_begin_global_section,
- .on_global_count = logging_on_global_count,
- .begin_global = logging_begin_global,
- .begin_global_init_expr = logging_begin_global_init_expr,
- .end_global_init_expr = logging_end_global_init_expr,
- .end_global = logging_end_global,
- .end_global_section = logging_end_global_section,
-
- .begin_export_section = logging_begin_export_section,
- .on_export_count = logging_on_export_count,
- .on_export = logging_on_export,
- .end_export_section = logging_end_export_section,
-
- .begin_start_section = logging_begin_start_section,
- .on_start_function = logging_on_start_function,
- .end_start_section = logging_end_start_section,
-
- .begin_function_bodies_section = logging_begin_function_bodies_section,
- .on_function_bodies_count = logging_on_function_bodies_count,
- .begin_function_body_pass = logging_begin_function_body_pass,
- .begin_function_body = logging_begin_function_body,
- .on_local_decl_count = logging_on_local_decl_count,
- .on_local_decl = logging_on_local_decl,
- .on_binary_expr = logging_on_binary_expr,
- .on_block_expr = logging_on_block_expr,
- .on_br_expr = logging_on_br_expr,
- .on_br_if_expr = logging_on_br_if_expr,
- .on_br_table_expr = logging_on_br_table_expr,
- .on_call_expr = logging_on_call_expr,
- .on_call_import_expr = logging_on_call_import_expr,
- .on_call_indirect_expr = logging_on_call_indirect_expr,
- .on_compare_expr = logging_on_compare_expr,
- .on_convert_expr = logging_on_convert_expr,
- .on_drop_expr = logging_on_drop_expr,
- .on_else_expr = logging_on_else_expr,
- .on_end_expr = logging_on_end_expr,
- .on_f32_const_expr = logging_on_f32_const_expr,
- .on_f64_const_expr = logging_on_f64_const_expr,
- .on_get_global_expr = logging_on_get_global_expr,
- .on_get_local_expr = logging_on_get_local_expr,
- .on_grow_memory_expr = logging_on_grow_memory_expr,
- .on_i32_const_expr = logging_on_i32_const_expr,
- .on_i64_const_expr = logging_on_i64_const_expr,
- .on_if_expr = logging_on_if_expr,
- .on_load_expr = logging_on_load_expr,
- .on_loop_expr = logging_on_loop_expr,
- .on_current_memory_expr = logging_on_current_memory_expr,
- .on_nop_expr = logging_on_nop_expr,
- .on_return_expr = logging_on_return_expr,
- .on_select_expr = logging_on_select_expr,
- .on_set_global_expr = logging_on_set_global_expr,
- .on_set_local_expr = logging_on_set_local_expr,
- .on_store_expr = logging_on_store_expr,
- .on_tee_local_expr = logging_on_tee_local_expr,
- .on_unary_expr = logging_on_unary_expr,
- .on_unreachable_expr = logging_on_unreachable_expr,
- .end_function_body = logging_end_function_body,
- .end_function_body_pass = logging_end_function_body_pass,
- .end_function_bodies_section = logging_end_function_bodies_section,
-
- .begin_elem_section = logging_begin_elem_section,
- .on_elem_segment_count = logging_on_elem_segment_count,
- .begin_elem_segment = logging_begin_elem_segment,
- .begin_elem_segment_init_expr = logging_begin_elem_segment_init_expr,
- .end_elem_segment_init_expr = logging_end_elem_segment_init_expr,
- .on_elem_segment_function_index_count =
- logging_on_elem_segment_function_index_count,
- .on_elem_segment_function_index = logging_on_elem_segment_function_index,
- .end_elem_segment = logging_end_elem_segment,
- .end_elem_section = logging_end_elem_section,
-
- .begin_data_section = logging_begin_data_section,
- .on_data_segment_count = logging_on_data_segment_count,
- .begin_data_segment = logging_begin_data_segment,
- .begin_data_segment_init_expr = logging_begin_data_segment_init_expr,
- .end_data_segment_init_expr = logging_end_data_segment_init_expr,
- .on_data_segment_data = logging_on_data_segment_data,
- .end_data_segment = logging_end_data_segment,
- .end_data_section = logging_end_data_section,
-
- .begin_names_section = logging_begin_names_section,
- .on_function_names_count = logging_on_function_names_count,
- .on_function_name = logging_on_function_name,
- .on_local_names_count = logging_on_local_names_count,
- .on_local_name = logging_on_local_name,
- .end_names_section = logging_end_names_section,
-
- .begin_reloc_section = logging_begin_reloc_section,
- .on_reloc_count = logging_on_reloc_count,
- .end_reloc_section = logging_end_reloc_section,
-
- .on_init_expr_f32_const_expr = logging_on_init_expr_f32_const_expr,
- .on_init_expr_f64_const_expr = logging_on_init_expr_f64_const_expr,
- .on_init_expr_get_global_expr = logging_on_init_expr_get_global_expr,
- .on_init_expr_i32_const_expr = logging_on_init_expr_i32_const_expr,
- .on_init_expr_i64_const_expr = logging_on_init_expr_i64_const_expr,
-};
-
static void read_init_expr(Context* ctx, uint32_t index) {
uint8_t opcode;
in_u8(ctx, &opcode, "opcode");
@@ -1202,7 +1068,7 @@ static void read_table(Context* ctx,
uint32_t max = 0;
in_u32_leb128(ctx, &flags, "table flags");
in_u32_leb128(ctx, &initial, "table initial elem count");
- WabtBool has_max = flags & WABT_BINARY_LIMITS_HAS_MAX_FLAG;
+ bool has_max = flags & WABT_BINARY_LIMITS_HAS_MAX_FLAG;
if (has_max) {
in_u32_leb128(ctx, &max, "table max elem count");
RAISE_ERROR_UNLESS(initial <= max,
@@ -1220,7 +1086,7 @@ static void read_memory(Context* ctx, WabtLimits* out_page_limits) {
uint32_t max = 0;
in_u32_leb128(ctx, &flags, "memory flags");
in_u32_leb128(ctx, &initial, "memory initial page count");
- WabtBool has_max = flags & WABT_BINARY_LIMITS_HAS_MAX_FLAG;
+ bool has_max = flags & WABT_BINARY_LIMITS_HAS_MAX_FLAG;
RAISE_ERROR_UNLESS(initial <= WABT_MAX_PAGES, "invalid memory initial size");
if (has_max) {
in_u32_leb128(ctx, &max, "memory max page count");
@@ -1236,7 +1102,7 @@ static void read_memory(Context* ctx, WabtLimits* out_page_limits) {
static void read_global_header(Context* ctx,
WabtType* out_type,
- WabtBool* out_mutable) {
+ bool* out_mutable) {
WabtType global_type;
uint8_t mutable_;
in_type(ctx, &global_type, "global type");
@@ -1251,10 +1117,11 @@ static void read_global_header(Context* ctx,
}
static void read_function_body(Context* ctx, uint32_t end_offset) {
- WabtBool seen_end_opcode = WABT_FALSE;
+ bool seen_end_opcode = false;
while (ctx->offset < end_offset) {
- uint8_t opcode;
- in_u8(ctx, &opcode, "opcode");
+ uint8_t opcode_u8;
+ in_u8(ctx, &opcode_u8, "opcode");
+ WabtOpcode opcode = (WabtOpcode)opcode_u8;
CALLBACK_CTX(on_opcode, opcode);
switch (opcode) {
case WABT_OPCODE_UNREACHABLE:
@@ -1362,7 +1229,7 @@ static void read_function_body(Context* ctx, uint32_t end_offset) {
case WABT_OPCODE_END:
if (ctx->offset == end_offset)
- seen_end_opcode = WABT_TRUE;
+ seen_end_opcode = true;
else
CALLBACK0(on_end_expr);
break;
@@ -1679,8 +1546,7 @@ static void read_custom_section(Context* ctx, uint32_t section_size) {
in_str(ctx, &section_name, "section name");
CALLBACK_CTX(begin_custom_section, section_size, section_name);
- WabtBool name_section_ok =
- ctx->last_known_section_code >= WABT_BINARY_SECTION_IMPORT;
+ bool name_section_ok = ctx->last_known_section >= WABT_BINARY_SECTION_IMPORT;
if (ctx->options->read_debug_names && name_section_ok &&
strncmp(section_name.start, WABT_BINARY_SECTION_NAME,
section_name.length) == 0) {
@@ -1703,7 +1569,7 @@ static void read_custom_section(Context* ctx, uint32_t section_size) {
CALLBACK(on_local_name, i, j, local_name);
}
}
- CALLBACK0(end_names_section);
+ CALLBACK_CTX0(end_names_section);
} else if (strncmp(section_name.start, WABT_BINARY_SECTION_RELOC,
strlen(WABT_BINARY_SECTION_RELOC)) == 0) {
CALLBACK_SECTION(begin_reloc_section, section_size);
@@ -1713,14 +1579,15 @@ static void read_custom_section(Context* ctx, uint32_t section_size) {
if (section == WABT_BINARY_SECTION_CUSTOM)
in_str(ctx, &section_name, "section name");
in_u32_leb128(ctx, &num_relocs, "relocation count");
- CALLBACK(on_reloc_count, num_relocs, section, section_name);
+ CALLBACK(on_reloc_count, num_relocs, (WabtBinarySection)section,
+ section_name);
for (i = 0; i < num_relocs; ++i) {
uint32_t reloc_type, offset;
in_u32_leb128(ctx, &reloc_type, "relocation type");
in_u32_leb128(ctx, &offset, "offset");
- CALLBACK(on_reloc, reloc_type, offset);
+ CALLBACK(on_reloc, (WabtRelocType)reloc_type, offset);
}
- CALLBACK0(end_reloc_section);
+ CALLBACK_CTX0(end_reloc_section);
} else {
/* This is an unknown custom section, skip it. */
ctx->offset = ctx->read_end;
@@ -1816,7 +1683,7 @@ static void read_import_section(Context* ctx, uint32_t section_size) {
case WABT_EXTERNAL_KIND_GLOBAL: {
WabtType type;
- WabtBool mutable_;
+ bool mutable_;
read_global_header(ctx, &type, &mutable_);
CALLBACK(on_import_global, i, ctx->num_global_imports, type, mutable_);
ctx->num_global_imports++;
@@ -1886,7 +1753,7 @@ static void read_global_section(Context* ctx, uint32_t section_size) {
for (i = 0; i < ctx->num_globals; ++i) {
uint32_t global_index = ctx->num_global_imports + i;
WabtType global_type;
- WabtBool mutable_;
+ bool mutable_;
read_global_header(ctx, &global_type, &mutable_);
CALLBACK(begin_global, global_index, global_type, mutable_);
CALLBACK(begin_global_init_expr, global_index);
@@ -1935,7 +1802,7 @@ static void read_export_section(Context* ctx, uint32_t section_size) {
break;
}
- CALLBACK(on_export, i, external_kind, item_index, name);
+ CALLBACK(on_export, i, (WabtExternalKind)external_kind, item_index, name);
}
CALLBACK_CTX0(end_export_section);
}
@@ -2051,29 +1918,35 @@ static void read_sections(Context* ctx) {
in_u32_leb128(ctx, &section_code, "section code");
in_u32_leb128(ctx, &section_size, "section size");
ctx->read_end = ctx->offset + section_size;
+ if (section_code >= WABT_NUM_BINARY_SECTIONS) {
+ RAISE_ERROR("invalid section code: %u; max is %u", section_code,
+ WABT_NUM_BINARY_SECTIONS - 1);
+ }
+
+ WabtBinarySection section = (WabtBinarySection)section_code;
if (ctx->read_end > ctx->data_size)
RAISE_ERROR("invalid section size: extends past end");
- if (ctx->last_known_section_code != WABT_NUM_BINARY_SECTIONS &&
- section_code != WABT_BINARY_SECTION_CUSTOM &&
- section_code <= ctx->last_known_section_code) {
- RAISE_ERROR("section %s out of order",
- wabt_get_section_name(section_code));
+ if (ctx->last_known_section != WABT_NUM_BINARY_SECTIONS &&
+ section != WABT_BINARY_SECTION_CUSTOM &&
+ section_code <= ctx->last_known_section) {
+ RAISE_ERROR("section %s out of order", wabt_get_section_name(section));
}
- CALLBACK_CTX(begin_section, section_code, section_size);
+ CALLBACK_CTX(begin_section, section, section_size);
#define V(NAME, name, code) \
case WABT_BINARY_SECTION_##NAME: \
read_##name##_section(ctx, section_size); \
break;
- switch (section_code) {
+ switch (section) {
WABT_FOREACH_BINARY_SECTION(V)
+
default:
- RAISE_ERROR("invalid section code: %u; max is %u", section_code,
- WABT_NUM_BINARY_SECTIONS - 1);
+ assert(0);
+ break;
}
#undef V
@@ -2083,8 +1956,8 @@ static void read_sections(Context* ctx) {
ctx->read_end);
}
- if (section_code != WABT_BINARY_SECTION_CUSTOM)
- ctx->last_known_section_code = section_code;
+ if (section != WABT_BINARY_SECTION_CUSTOM)
+ ctx->last_known_section = section;
}
}
@@ -2098,18 +1971,167 @@ WabtResult wabt_read_binary(const void* data,
logging_context.reader = reader;
logging_context.stream = options->log_stream;
- WabtBinaryReader logging_reader = s_logging_binary_reader;
+ WabtBinaryReader logging_reader;
+ WABT_ZERO_MEMORY(logging_reader);
logging_reader.user_data = &logging_context;
+ logging_reader.on_error = logging_on_error;
+ logging_reader.begin_module = logging_begin_module;
+ logging_reader.end_module = logging_end_module;
+
+ logging_reader.begin_custom_section = logging_begin_custom_section;
+ logging_reader.end_custom_section = logging_end_custom_section;
+
+ logging_reader.begin_signature_section = logging_begin_signature_section;
+ logging_reader.on_signature_count = logging_on_signature_count;
+ logging_reader.on_signature = logging_on_signature;
+ logging_reader.end_signature_section = logging_end_signature_section;
+
+ logging_reader.begin_import_section = logging_begin_import_section;
+ logging_reader.on_import_count = logging_on_import_count;
+ logging_reader.on_import = logging_on_import;
+ logging_reader.on_import_func = logging_on_import_func;
+ logging_reader.on_import_table = logging_on_import_table;
+ logging_reader.on_import_memory = logging_on_import_memory;
+ logging_reader.on_import_global = logging_on_import_global;
+ logging_reader.end_import_section = logging_end_import_section;
+
+ logging_reader.begin_function_signatures_section =
+ logging_begin_function_signatures_section;
+ logging_reader.on_function_signatures_count =
+ logging_on_function_signatures_count;
+ logging_reader.on_function_signature = logging_on_function_signature;
+ logging_reader.end_function_signatures_section =
+ logging_end_function_signatures_section;
+
+ logging_reader.begin_table_section = logging_begin_table_section;
+ logging_reader.on_table_count = logging_on_table_count;
+ logging_reader.on_table = logging_on_table;
+ logging_reader.end_table_section = logging_end_table_section;
+
+ logging_reader.begin_memory_section = logging_begin_memory_section;
+ logging_reader.on_memory_count = logging_on_memory_count;
+ logging_reader.on_memory = logging_on_memory;
+ logging_reader.end_memory_section = logging_end_memory_section;
+
+ logging_reader.begin_global_section = logging_begin_global_section;
+ logging_reader.on_global_count = logging_on_global_count;
+ logging_reader.begin_global = logging_begin_global;
+ logging_reader.begin_global_init_expr = logging_begin_global_init_expr;
+ logging_reader.end_global_init_expr = logging_end_global_init_expr;
+ logging_reader.end_global = logging_end_global;
+ logging_reader.end_global_section = logging_end_global_section;
+
+ logging_reader.begin_export_section = logging_begin_export_section;
+ logging_reader.on_export_count = logging_on_export_count;
+ logging_reader.on_export = logging_on_export;
+ logging_reader.end_export_section = logging_end_export_section;
+
+ logging_reader.begin_start_section = logging_begin_start_section;
+ logging_reader.on_start_function = logging_on_start_function;
+ logging_reader.end_start_section = logging_end_start_section;
+
+ logging_reader.begin_function_bodies_section =
+ logging_begin_function_bodies_section;
+ logging_reader.on_function_bodies_count = logging_on_function_bodies_count;
+ logging_reader.begin_function_body_pass = logging_begin_function_body_pass;
+ logging_reader.begin_function_body = logging_begin_function_body;
+ logging_reader.on_local_decl_count = logging_on_local_decl_count;
+ logging_reader.on_local_decl = logging_on_local_decl;
+ logging_reader.on_binary_expr = logging_on_binary_expr;
+ logging_reader.on_block_expr = logging_on_block_expr;
+ logging_reader.on_br_expr = logging_on_br_expr;
+ logging_reader.on_br_if_expr = logging_on_br_if_expr;
+ logging_reader.on_br_table_expr = logging_on_br_table_expr;
+ logging_reader.on_call_expr = logging_on_call_expr;
+ logging_reader.on_call_import_expr = logging_on_call_import_expr;
+ logging_reader.on_call_indirect_expr = logging_on_call_indirect_expr;
+ logging_reader.on_compare_expr = logging_on_compare_expr;
+ logging_reader.on_convert_expr = logging_on_convert_expr;
+ logging_reader.on_drop_expr = logging_on_drop_expr;
+ logging_reader.on_else_expr = logging_on_else_expr;
+ logging_reader.on_end_expr = logging_on_end_expr;
+ logging_reader.on_f32_const_expr = logging_on_f32_const_expr;
+ logging_reader.on_f64_const_expr = logging_on_f64_const_expr;
+ logging_reader.on_get_global_expr = logging_on_get_global_expr;
+ logging_reader.on_get_local_expr = logging_on_get_local_expr;
+ logging_reader.on_grow_memory_expr = logging_on_grow_memory_expr;
+ logging_reader.on_i32_const_expr = logging_on_i32_const_expr;
+ logging_reader.on_i64_const_expr = logging_on_i64_const_expr;
+ logging_reader.on_if_expr = logging_on_if_expr;
+ logging_reader.on_load_expr = logging_on_load_expr;
+ logging_reader.on_loop_expr = logging_on_loop_expr;
+ logging_reader.on_current_memory_expr = logging_on_current_memory_expr;
+ logging_reader.on_nop_expr = logging_on_nop_expr;
+ logging_reader.on_return_expr = logging_on_return_expr;
+ logging_reader.on_select_expr = logging_on_select_expr;
+ logging_reader.on_set_global_expr = logging_on_set_global_expr;
+ logging_reader.on_set_local_expr = logging_on_set_local_expr;
+ logging_reader.on_store_expr = logging_on_store_expr;
+ logging_reader.on_tee_local_expr = logging_on_tee_local_expr;
+ logging_reader.on_unary_expr = logging_on_unary_expr;
+ logging_reader.on_unreachable_expr = logging_on_unreachable_expr;
+ logging_reader.end_function_body = logging_end_function_body;
+ logging_reader.end_function_body_pass = logging_end_function_body_pass;
+ logging_reader.end_function_bodies_section =
+ logging_end_function_bodies_section;
+
+ logging_reader.begin_elem_section = logging_begin_elem_section;
+ logging_reader.on_elem_segment_count = logging_on_elem_segment_count;
+ logging_reader.begin_elem_segment = logging_begin_elem_segment;
+ logging_reader.begin_elem_segment_init_expr =
+ logging_begin_elem_segment_init_expr;
+ logging_reader.end_elem_segment_init_expr =
+ logging_end_elem_segment_init_expr;
+ logging_reader.on_elem_segment_function_index_count =
+ logging_on_elem_segment_function_index_count;
+ logging_reader.on_elem_segment_function_index =
+ logging_on_elem_segment_function_index;
+ logging_reader.end_elem_segment = logging_end_elem_segment;
+ logging_reader.end_elem_section = logging_end_elem_section;
+
+ logging_reader.begin_data_section = logging_begin_data_section;
+ logging_reader.on_data_segment_count = logging_on_data_segment_count;
+ logging_reader.begin_data_segment = logging_begin_data_segment;
+ logging_reader.begin_data_segment_init_expr =
+ logging_begin_data_segment_init_expr;
+ logging_reader.end_data_segment_init_expr =
+ logging_end_data_segment_init_expr;
+ logging_reader.on_data_segment_data = logging_on_data_segment_data;
+ logging_reader.end_data_segment = logging_end_data_segment;
+ logging_reader.end_data_section = logging_end_data_section;
+
+ logging_reader.begin_names_section = logging_begin_names_section;
+ logging_reader.on_function_names_count = logging_on_function_names_count;
+ logging_reader.on_function_name = logging_on_function_name;
+ logging_reader.on_local_names_count = logging_on_local_names_count;
+ logging_reader.on_local_name = logging_on_local_name;
+ logging_reader.end_names_section = logging_end_names_section;
+
+ logging_reader.begin_reloc_section = logging_begin_reloc_section;
+ logging_reader.on_reloc_count = logging_on_reloc_count;
+ logging_reader.end_reloc_section = logging_end_reloc_section;
+
+ logging_reader.on_init_expr_f32_const_expr =
+ logging_on_init_expr_f32_const_expr;
+ logging_reader.on_init_expr_f64_const_expr =
+ logging_on_init_expr_f64_const_expr;
+ logging_reader.on_init_expr_get_global_expr =
+ logging_on_init_expr_get_global_expr;
+ logging_reader.on_init_expr_i32_const_expr =
+ logging_on_init_expr_i32_const_expr;
+ logging_reader.on_init_expr_i64_const_expr =
+ logging_on_init_expr_i64_const_expr;
+
Context context;
WABT_ZERO_MEMORY(context);
/* all the macros assume a Context* named ctx */
Context* ctx = &context;
- ctx->data = data;
+ ctx->data = (const uint8_t*)data;
ctx->data_size = ctx->read_end = size;
ctx->reader = options->log_stream ? &logging_reader : reader;
ctx->options = options;
- ctx->last_known_section_code = WABT_NUM_BINARY_SECTIONS;
+ ctx->last_known_section = WABT_NUM_BINARY_SECTIONS;
if (setjmp(ctx->error_jmp_buf) == 1) {
destroy_context(ctx);
diff --git a/src/binary-reader.h b/src/binary-reader.h
index 5f13ebe5..6e4b929f 100644
--- a/src/binary-reader.h
+++ b/src/binary-reader.h
@@ -24,11 +24,11 @@
#include "common.h"
#define WABT_READ_BINARY_OPTIONS_DEFAULT \
- { NULL, WABT_FALSE }
+ { NULL, false }
typedef struct WabtReadBinaryOptions {
struct WabtStream* log_stream;
- WabtBool read_debug_names;
+ bool read_debug_names;
} WabtReadBinaryOptions;
typedef struct WabtBinaryReaderContext {
@@ -94,7 +94,7 @@ typedef struct WabtBinaryReader {
WabtResult (*on_import_global)(uint32_t import_index,
uint32_t global_index,
WabtType type,
- WabtBool mutable_,
+ bool mutable_,
void* user_data);
WabtResult (*end_import_section)(WabtBinaryReaderContext* ctx);
@@ -133,7 +133,7 @@ typedef struct WabtBinaryReader {
WabtResult (*on_global_count)(uint32_t count, void* user_data);
WabtResult (*begin_global)(uint32_t index,
WabtType type,
- WabtBool mutable_,
+ bool mutable_,
void* user_data);
WabtResult (*begin_global_init_expr)(uint32_t index, void* user_data);
WabtResult (*end_global_init_expr)(uint32_t index, void* user_data);
diff --git a/src/binary-writer-spec.c b/src/binary-writer-spec.cc
index ae916905..5dd3e2fe 100644
--- a/src/binary-writer-spec.c
+++ b/src/binary-writer-spec.cc
@@ -31,7 +31,7 @@ typedef struct Context {
WabtStream json_stream;
WabtStringSlice source_filename;
WabtStringSlice module_filename_noext;
- WabtBool write_modules; /* Whether to write the modules files. */
+ bool write_modules; /* Whether to write the modules files. */
const WabtWriteBinarySpecOptions* spec_options;
WabtResult result;
size_t num_modules;
@@ -96,7 +96,7 @@ static WabtStringSlice get_basename(const char* s) {
static char* get_module_filename(Context* ctx) {
size_t buflen = ctx->module_filename_noext.length + 20;
- char* str = wabt_alloc(buflen);
+ char* str = (char*)wabt_alloc(buflen);
size_t length =
wabt_snprintf(str, buflen, PRIstringslice ".%" PRIzd ".wasm",
WABT_PRINTF_STRING_SLICE_ARG(ctx->module_filename_noext),
@@ -265,13 +265,13 @@ static void write_action_result_type(Context* ctx,
const WabtAction* action) {
const WabtModule* module =
wabt_get_module_by_var(script, &action->module_var);
- const WabtExport* export;
+ const WabtExport* export_;
wabt_writef(&ctx->json_stream, "[");
switch (action->type) {
case WABT_ACTION_TYPE_INVOKE: {
- export = wabt_get_export_by_name(module, &action->invoke.name);
- assert(export->kind == WABT_EXTERNAL_KIND_FUNC);
- WabtFunc* func = wabt_get_func_by_var(module, &export->var);
+ export_ = wabt_get_export_by_name(module, &action->invoke.name);
+ assert(export_->kind == WABT_EXTERNAL_KIND_FUNC);
+ WabtFunc* func = wabt_get_func_by_var(module, &export_->var);
size_t num_results = wabt_get_num_results(func);
size_t i;
for (i = 0; i < num_results; ++i)
@@ -280,9 +280,9 @@ static void write_action_result_type(Context* ctx,
}
case WABT_ACTION_TYPE_GET: {
- export = wabt_get_export_by_name(module, &action->get.name);
- assert(export->kind == WABT_EXTERNAL_KIND_GLOBAL);
- WabtGlobal* global = wabt_get_global_by_var(module, &export->var);
+ export_ = wabt_get_export_by_name(module, &action->get.name);
+ assert(export_->kind == WABT_EXTERNAL_KIND_GLOBAL);
+ WabtGlobal* global = wabt_get_global_by_var(module, &export_->var);
write_type_object(ctx, global->type);
break;
}
diff --git a/src/binary-writer.c b/src/binary-writer.cc
index 61a26e70..0c94b079 100644
--- a/src/binary-writer.c
+++ b/src/binary-writer.cc
@@ -248,7 +248,7 @@ void wabt_write_str(WabtStream* stream,
stream->offset += length;
}
-void wabt_write_opcode(WabtStream* stream, uint8_t opcode) {
+void wabt_write_opcode(WabtStream* stream, WabtOpcode opcode) {
wabt_write_u8(stream, opcode, wabt_get_opcode_name(opcode));
}
@@ -776,28 +776,28 @@ static WabtResult write_module(Context* ctx, const WabtModule* module) {
wabt_write_u32_leb128(&ctx->stream, module->exports.size, "num exports");
for (i = 0; i < module->exports.size; ++i) {
- const WabtExport* export = module->exports.data[i];
- wabt_write_str(&ctx->stream, export->name.start, export->name.length,
+ const WabtExport* export_ = module->exports.data[i];
+ wabt_write_str(&ctx->stream, export_->name.start, export_->name.length,
WABT_PRINT_CHARS, "export name");
- wabt_write_u8(&ctx->stream, export->kind, "export kind");
- switch (export->kind) {
+ wabt_write_u8(&ctx->stream, export_->kind, "export kind");
+ switch (export_->kind) {
case WABT_EXTERNAL_KIND_FUNC: {
- int index = wabt_get_func_index_by_var(module, &export->var);
+ int index = wabt_get_func_index_by_var(module, &export_->var);
wabt_write_u32_leb128(&ctx->stream, index, "export func index");
break;
}
case WABT_EXTERNAL_KIND_TABLE: {
- int index = wabt_get_table_index_by_var(module, &export->var);
+ int index = wabt_get_table_index_by_var(module, &export_->var);
wabt_write_u32_leb128(&ctx->stream, index, "export table index");
break;
}
case WABT_EXTERNAL_KIND_MEMORY: {
- int index = wabt_get_memory_index_by_var(module, &export->var);
+ int index = wabt_get_memory_index_by_var(module, &export_->var);
wabt_write_u32_leb128(&ctx->stream, index, "export memory index");
break;
}
case WABT_EXTERNAL_KIND_GLOBAL: {
- int index = wabt_get_global_index_by_var(module, &export->var);
+ int index = wabt_get_global_index_by_var(module, &export_->var);
wabt_write_u32_leb128(&ctx->stream, index, "export global index");
break;
}
diff --git a/src/binary-writer.h b/src/binary-writer.h
index 04c61fa0..8d1d4b2f 100644
--- a/src/binary-writer.h
+++ b/src/binary-writer.h
@@ -18,21 +18,21 @@
#define WABT_BINARY_WRITER_H_
#include "common.h"
+#include "stream.h"
struct WabtModule;
struct WabtScript;
struct WabtWriter;
struct WabtStream;
-enum WabtPrintChars;
#define WABT_WRITE_BINARY_OPTIONS_DEFAULT \
- { NULL, WABT_TRUE, WABT_FALSE, WABT_FALSE }
+ { NULL, true, false, false }
typedef struct WabtWriteBinaryOptions {
struct WabtStream* log_stream;
- WabtBool canonicalize_lebs;
- WabtBool relocatable;
- WabtBool write_debug_names;
+ bool canonicalize_lebs;
+ bool relocatable;
+ bool write_debug_names;
} WabtWriteBinaryOptions;
WABT_EXTERN_C_BEGIN
@@ -69,10 +69,10 @@ void wabt_write_type(struct WabtStream* stream, WabtType type);
void wabt_write_str(struct WabtStream* stream,
const char* s,
size_t length,
- enum WabtPrintChars print_chars,
+ WabtPrintChars print_chars,
const char* desc);
-void wabt_write_opcode(struct WabtStream* stream, uint8_t opcode);
+void wabt_write_opcode(struct WabtStream* stream, WabtOpcode opcode);
void wabt_write_limits(struct WabtStream* stream, const WabtLimits* limits);
WABT_EXTERN_C_END
diff --git a/src/binary.c b/src/binary.cc
index 970fccb4..970fccb4 100644
--- a/src/binary.c
+++ b/src/binary.cc
diff --git a/src/binding-hash.c b/src/binding-hash.cc
index c64d8b22..59249571 100644
--- a/src/binding-hash.c
+++ b/src/binding-hash.cc
@@ -36,7 +36,7 @@ static WabtBindingHashEntry* hash_main_entry(const WabtBindingHash* hash,
return &hash->entries.data[hash_name(name) % hash->entries.capacity];
}
-WabtBool wabt_hash_entry_is_free(const WabtBindingHashEntry* entry) {
+bool wabt_hash_entry_is_free(const WabtBindingHashEntry* entry) {
return !entry->binding.name.start;
}
diff --git a/src/binding-hash.h b/src/binding-hash.h
index c751548e..e49cab12 100644
--- a/src/binding-hash.h
+++ b/src/binding-hash.h
@@ -41,7 +41,7 @@ typedef struct WabtBindingHash {
WABT_EXTERN_C_BEGIN
WabtBinding* wabt_insert_binding(WabtBindingHash*, const WabtStringSlice*);
void wabt_remove_binding(WabtBindingHash*, const WabtStringSlice*);
-WabtBool wabt_hash_entry_is_free(const WabtBindingHashEntry*);
+bool wabt_hash_entry_is_free(const WabtBindingHashEntry*);
/* returns -1 if the name is not in the hash */
int wabt_find_binding_index_by_name(const WabtBindingHash*,
const WabtStringSlice* name);
diff --git a/src/common.c b/src/common.cc
index d5cdfe63..7d9a688a 100644
--- a/src/common.c
+++ b/src/common.cc
@@ -26,11 +26,26 @@
#include <io.h>
#endif
-#define V(rtype, type1, type2, mem_size, code, NAME, text) \
- [code] = {text, WABT_TYPE_##rtype, WABT_TYPE_##type1, WABT_TYPE_##type2, \
- mem_size},
-WabtOpcodeInfo g_wabt_opcode_info[] = {WABT_FOREACH_OPCODE(V)};
+WabtOpcodeInfo g_wabt_opcode_info[WABT_NUM_OPCODES];
+
+/* TODO(binji): It's annoying to have to have an initializer function, but it
+ * seems to be necessary as g++ doesn't allow non-trival designated
+ * initializers (e.g. [314] = "blah") */
+void wabt_init_opcode_info(void) {
+ static bool s_initialized = false;
+ if (!s_initialized) {
+#define V(rtype, type1, type2, mem_size, code, NAME, text) \
+ g_wabt_opcode_info[code].name = text; \
+ g_wabt_opcode_info[code].result_type = WABT_TYPE_##rtype; \
+ g_wabt_opcode_info[code].param1_type = WABT_TYPE_##type1; \
+ g_wabt_opcode_info[code].param2_type = WABT_TYPE_##type2; \
+ g_wabt_opcode_info[code].memory_size = mem_size;
+
+ WABT_FOREACH_OPCODE(V)
+
#undef V
+ }
+}
const char* g_wabt_kind_name[] = {"func", "table", "memory", "global"};
WABT_STATIC_ASSERT(WABT_ARRAY_SIZE(g_wabt_kind_name) ==
@@ -42,7 +57,7 @@ const char* g_wabt_reloc_type_name[] = {
WABT_STATIC_ASSERT(WABT_ARRAY_SIZE(g_wabt_reloc_type_name) ==
WABT_NUM_RELOC_TYPES);
-WabtBool wabt_is_naturally_aligned(WabtOpcode opcode, uint32_t alignment) {
+bool wabt_is_naturally_aligned(WabtOpcode opcode, uint32_t alignment) {
uint32_t opcode_align = wabt_get_opcode_memory_size(opcode);
return alignment == WABT_USE_NATURAL_ALIGNMENT || alignment == opcode_align;
}
@@ -60,21 +75,20 @@ WabtStringSlice wabt_empty_string_slice(void) {
return result;
}
-WabtBool wabt_string_slice_eq_cstr(const WabtStringSlice* s1, const char* s2) {
+bool wabt_string_slice_eq_cstr(const WabtStringSlice* s1, const char* s2) {
size_t s2_len = strlen(s2);
if (s2_len != s1->length)
- return WABT_FALSE;
+ return false;
- return strncmp(s1->start, s2, s2_len) == 0 ? WABT_TRUE : WABT_FALSE;
+ return strncmp(s1->start, s2, s2_len) == 0;
}
-WabtBool wabt_string_slice_startswith(const WabtStringSlice* s1,
- const char* s2) {
+bool wabt_string_slice_startswith(const WabtStringSlice* s1, const char* s2) {
size_t s2_len = strlen(s2);
if (s2_len > s1->length)
- return WABT_FALSE;
+ return false;
- return strncmp(s1->start, s2, s2_len) == 0 ? WABT_TRUE : WABT_FALSE;
+ return strncmp(s1->start, s2, s2_len) == 0;
}
WabtStringSlice wabt_string_slice_from_cstr(const char* string) {
@@ -84,13 +98,13 @@ WabtStringSlice wabt_string_slice_from_cstr(const char* string) {
return result;
}
-WabtBool wabt_string_slice_is_empty(const WabtStringSlice* str) {
+bool wabt_string_slice_is_empty(const WabtStringSlice* str) {
assert(str);
return str->start == NULL || str->length == 0;
}
-WabtBool wabt_string_slices_are_equal(const WabtStringSlice* a,
- const WabtStringSlice* b) {
+bool wabt_string_slices_are_equal(const WabtStringSlice* a,
+ const WabtStringSlice* b) {
assert(a && b);
return a->start && b->start && a->length == b->length &&
memcmp(a->start, b->start, a->length) == 0;
@@ -143,7 +157,7 @@ static void print_carets(FILE* out,
size_t num_carets,
size_t max_line) {
/* print the caret */
- char* carets = alloca(max_line);
+ char* carets = (char*)alloca(max_line);
memset(carets, '^', max_line);
if (num_carets > max_line - num_spaces)
num_carets = max_line - num_spaces;
@@ -199,7 +213,7 @@ void wabt_default_source_error_callback(const WabtLocation* loc,
size_t source_line_length,
size_t source_line_column_offset,
void* user_data) {
- WabtDefaultErrorHandlerInfo* info = user_data;
+ WabtDefaultErrorHandlerInfo* info = (WabtDefaultErrorHandlerInfo*)user_data;
FILE* out = get_default_error_handler_info_output_file(info);
print_error_header(out, info);
print_source_error(out, loc, error, source_line, source_line_length,
@@ -209,7 +223,7 @@ void wabt_default_source_error_callback(const WabtLocation* loc,
void wabt_default_binary_error_callback(uint32_t offset,
const char* error,
void* user_data) {
- WabtDefaultErrorHandlerInfo* info = user_data;
+ WabtDefaultErrorHandlerInfo* info = (WabtDefaultErrorHandlerInfo*)user_data;
FILE* out = get_default_error_handler_info_output_file(info);
print_error_header(out, info);
if (offset == WABT_UNKNOWN_OFFSET)
diff --git a/src/common.h b/src/common.h
index 410f6149..88808ec4 100644
--- a/src/common.h
+++ b/src/common.h
@@ -63,16 +63,11 @@
size_t len = wabt_vsnprintf(fixed_buf, sizeof(fixed_buf), format, args); \
va_end(args); \
if (len + 1 > sizeof(fixed_buf)) { \
- buffer = alloca(len + 1); \
+ buffer = (char*)alloca(len + 1); \
len = wabt_vsnprintf(buffer, len + 1, format, args_copy); \
} \
va_end(args_copy)
-typedef enum WabtBool {
- WABT_FALSE,
- WABT_TRUE,
-} WabtBool;
-
typedef enum WabtResult {
WABT_OK,
WABT_ERROR,
@@ -183,7 +178,7 @@ typedef enum WabtExternalKind {
typedef struct WabtLimits {
uint64_t initial;
uint64_t max;
- WabtBool has_max;
+ bool has_max;
} WabtLimits;
enum { WABT_USE_NATURAL_ALIGNMENT = 0xFFFFFFFF };
@@ -445,20 +440,20 @@ static WABT_INLINE WabtStringSlice wabt_dup_string_slice(WabtStringSlice str) {
/* return 1 if |alignment| matches the alignment of |opcode|, or if |alignment|
* is WABT_USE_NATURAL_ALIGNMENT */
-WabtBool wabt_is_naturally_aligned(WabtOpcode opcode, uint32_t alignment);
+bool wabt_is_naturally_aligned(WabtOpcode opcode, uint32_t alignment);
/* if |alignment| is WABT_USE_NATURAL_ALIGNMENT, return the alignment of
* |opcode|, else return |alignment| */
uint32_t wabt_get_opcode_alignment(WabtOpcode opcode, uint32_t alignment);
WabtStringSlice wabt_empty_string_slice(void);
-WabtBool wabt_string_slice_eq_cstr(const WabtStringSlice* s1, const char* s2);
-WabtBool wabt_string_slice_startswith(const WabtStringSlice* s1,
+bool wabt_string_slice_eq_cstr(const WabtStringSlice* s1, const char* s2);
+bool wabt_string_slice_startswith(const WabtStringSlice* s1,
const char* s2);
WabtStringSlice wabt_string_slice_from_cstr(const char* string);
-WabtBool wabt_string_slice_is_empty(const WabtStringSlice*);
-WabtBool wabt_string_slices_are_equal(const WabtStringSlice*,
- const WabtStringSlice*);
+bool wabt_string_slice_is_empty(const WabtStringSlice*);
+bool wabt_string_slices_are_equal(const WabtStringSlice*,
+ const WabtStringSlice*);
void wabt_destroy_string_slice(WabtStringSlice*);
WabtResult wabt_read_file(const char* filename,
void** out_data,
@@ -479,29 +474,35 @@ void wabt_init_stdio();
/* opcode info */
extern WabtOpcodeInfo g_wabt_opcode_info[];
+void wabt_init_opcode_info(void);
static WABT_INLINE const char* wabt_get_opcode_name(WabtOpcode opcode) {
assert(opcode < WABT_NUM_OPCODES);
+ wabt_init_opcode_info();
return g_wabt_opcode_info[opcode].name;
}
static WABT_INLINE WabtType wabt_get_opcode_result_type(WabtOpcode opcode) {
assert(opcode < WABT_NUM_OPCODES);
+ wabt_init_opcode_info();
return g_wabt_opcode_info[opcode].result_type;
}
static WABT_INLINE WabtType wabt_get_opcode_param_type_1(WabtOpcode opcode) {
assert(opcode < WABT_NUM_OPCODES);
+ wabt_init_opcode_info();
return g_wabt_opcode_info[opcode].param1_type;
}
static WABT_INLINE WabtType wabt_get_opcode_param_type_2(WabtOpcode opcode) {
assert(opcode < WABT_NUM_OPCODES);
+ wabt_init_opcode_info();
return g_wabt_opcode_info[opcode].param2_type;
}
static WABT_INLINE int wabt_get_opcode_memory_size(WabtOpcode opcode) {
assert(opcode < WABT_NUM_OPCODES);
+ wabt_init_opcode_info();
return g_wabt_opcode_info[opcode].memory_size;
}
diff --git a/src/config.c b/src/config.cc
index e9dc087f..e9dc087f 100644
--- a/src/config.c
+++ b/src/config.cc
diff --git a/src/config.h.in b/src/config.h.in
index 48393b84..7dd91576 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -64,12 +64,24 @@
#define WABT_UNUSED __attribute__ ((unused))
#define WABT_WARN_UNUSED __attribute__ ((warn_unused_result))
#define WABT_INLINE inline
-#define WABT_STATIC_ASSERT(x) _Static_assert((x), #x)
#define WABT_UNLIKELY(x) __builtin_expect(!!(x), 0)
#define WABT_LIKELY(x) __builtin_expect(!!(x), 1)
#define WABT_PRINTF_FORMAT(format_arg, first_arg) \
__attribute__((format(printf, (format_arg), (first_arg))))
+#ifdef __cplusplus
+#if __cplusplus >= 201103L
+#define WABT_STATIC_ASSERT(x) static_assert((x), #x)
+#else
+#define WABT_STATIC_ASSERT__(x, c) \
+ static int static_assert_##c[(x ? 0 : -1)] WABT_UNUSED
+#define WABT_STATIC_ASSERT_(x, c) WABT_STATIC_ASSERT__(x, c)
+#define WABT_STATIC_ASSERT(x) WABT_STATIC_ASSERT_(x, __COUNTER__)
+#endif
+#else
+#define WABT_STATIC_ASSERT(x) _Static_assert((x), #x)
+#endif
+
#if SIZEOF_INT == 4
#define wabt_clz_u32(x) __builtin_clz(x)
#define wabt_ctz_u32(x) __builtin_ctz(x)
@@ -98,7 +110,9 @@
#elif COMPILER_IS_MSVC
-#include <vcruntime_string.h>
+#include <intrin.h>
+#include <string.h>
+
#define WABT_UNUSED
#define WABT_WARN_UNUSED _Check_return_
#define WABT_INLINE __inline
diff --git a/src/emscripten-helpers.c b/src/emscripten-helpers.cc
index 4e8d92f6..4e8d92f6 100644
--- a/src/emscripten-helpers.c
+++ b/src/emscripten-helpers.cc
diff --git a/src/generate-names.c b/src/generate-names.cc
index 98aa448f..5778d1cd 100644
--- a/src/generate-names.c
+++ b/src/generate-names.cc
@@ -34,7 +34,7 @@ typedef struct Context {
uint32_t label_count;
} Context;
-static WabtBool has_name(WabtStringSlice* str) {
+static bool has_name(WabtStringSlice* str) {
return str->length > 0;
}
@@ -43,7 +43,7 @@ static void generate_name(const char* prefix,
WabtStringSlice* str) {
size_t prefix_len = strlen(prefix);
size_t buffer_len = prefix_len + 20; /* add space for the number */
- char* buffer = alloca(buffer_len);
+ char* buffer = (char*)alloca(buffer_len);
int actual_len = wabt_snprintf(buffer, buffer_len, "%s%u", prefix, index);
WabtStringSlice buf;
@@ -93,19 +93,19 @@ static void generate_and_bind_local_names(WabtStringSliceVector* index_to_name,
}
static WabtResult begin_block_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
maybe_generate_name("$B", ctx->label_count++, &expr->block.label);
return WABT_OK;
}
static WabtResult begin_loop_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
maybe_generate_name("$L", ctx->label_count++, &expr->loop.label);
return WABT_OK;
}
static WabtResult begin_if_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
maybe_generate_name("$L", ctx->label_count++, &expr->if_.true_.label);
return WABT_OK;
}
diff --git a/src/interpreter.c b/src/interpreter.cc
index 1de70232..1630c34a 100644
--- a/src/interpreter.c
+++ b/src/interpreter.cc
@@ -24,16 +24,7 @@
#define INITIAL_ISTREAM_CAPACITY (64 * 1024)
-#define V(rtype, type1, type2, mem_size, code, NAME, text) [code] = text,
-static const char* s_interpreter_opcode_name[] = {
- WABT_FOREACH_OPCODE(V)
- [WABT_OPCODE_ALLOCA] = "alloca",
- [WABT_OPCODE_BR_UNLESS] = "br_unless",
- [WABT_OPCODE_CALL_HOST] = "call_host",
- [WABT_OPCODE_DATA] = "data",
- [WABT_OPCODE_DROP_KEEP] = "drop_keep",
-};
-#undef V
+static const char* s_interpreter_opcode_name[256];
#define CHECK_RESULT(expr) \
do { \
@@ -41,8 +32,28 @@ static const char* s_interpreter_opcode_name[] = {
return WABT_ERROR; \
} while (0)
+/* TODO(binji): It's annoying to have to have an initializer function, but it
+ * seems to be necessary as g++ doesn't allow non-trival designated
+ * initializers (e.g. [314] = "blah") */
+static void init_interpreter_opcode_table(void) {
+ static bool s_initialized = false;
+ if (!s_initialized) {
+#define V(rtype, type1, type2, mem_size, code, NAME, text) \
+ s_interpreter_opcode_name[code] = text;
+
+ WABT_FOREACH_OPCODE(V)
+ s_interpreter_opcode_name[WABT_OPCODE_ALLOCA] = "alloca";
+ s_interpreter_opcode_name[WABT_OPCODE_BR_UNLESS] = "br_unless";
+ s_interpreter_opcode_name[WABT_OPCODE_CALL_HOST] = "call_host";
+ s_interpreter_opcode_name[WABT_OPCODE_DATA] = "data";
+ s_interpreter_opcode_name[WABT_OPCODE_DROP_KEEP] = "drop_keep";
+
+#undef V
+ }
+}
+
static const char* wabt_get_interpreter_opcode_name(uint8_t opcode) {
- assert(opcode < WABT_ARRAY_SIZE(s_interpreter_opcode_name));
+ init_interpreter_opcode_table();
return s_interpreter_opcode_name[opcode];
}
@@ -161,7 +172,7 @@ WabtInterpreterModule* wabt_append_host_module(WabtInterpreterEnvironment* env,
module->name = wabt_dup_string_slice(name);
module->memory_index = WABT_INVALID_INDEX;
module->table_index = WABT_INVALID_INDEX;
- module->is_host = WABT_TRUE;
+ module->is_host = true;
WabtStringSlice dup_name = wabt_dup_string_slice(name);
WabtBinding* binding =
@@ -246,31 +257,31 @@ void wabt_destroy_interpreter_thread(WabtInterpreterThread* thread) {
#define F32_SIG_MASK 0x7fffff
#define F32_SIGN_MASK 0x80000000U
-WABT_INLINE WabtBool wabt_is_nan_f32(uint32_t f32_bits) {
+bool wabt_is_nan_f32(uint32_t f32_bits) {
return (f32_bits > F32_INF && f32_bits < F32_NEG_ZERO) ||
(f32_bits > F32_NEG_INF);
}
-static WABT_INLINE WabtBool is_zero_f32(uint32_t f32_bits) {
+static WABT_INLINE bool is_zero_f32(uint32_t f32_bits) {
return f32_bits == 0 || f32_bits == F32_NEG_ZERO;
}
-static WABT_INLINE WabtBool is_in_range_i32_trunc_s_f32(uint32_t f32_bits) {
+static WABT_INLINE bool is_in_range_i32_trunc_s_f32(uint32_t f32_bits) {
return (f32_bits < 0x4f000000U) ||
(f32_bits >= F32_NEG_ZERO && f32_bits <= 0xcf000000U);
}
-static WABT_INLINE WabtBool is_in_range_i64_trunc_s_f32(uint32_t f32_bits) {
+static WABT_INLINE bool is_in_range_i64_trunc_s_f32(uint32_t f32_bits) {
return (f32_bits < 0x5f000000U) ||
(f32_bits >= F32_NEG_ZERO && f32_bits <= 0xdf000000U);
}
-static WABT_INLINE WabtBool is_in_range_i32_trunc_u_f32(uint32_t f32_bits) {
+static WABT_INLINE bool is_in_range_i32_trunc_u_f32(uint32_t f32_bits) {
return (f32_bits < 0x4f800000U) ||
(f32_bits >= F32_NEG_ZERO && f32_bits < F32_NEG_ONE);
}
-static WABT_INLINE WabtBool is_in_range_i64_trunc_u_f32(uint32_t f32_bits) {
+static WABT_INLINE bool is_in_range_i64_trunc_u_f32(uint32_t f32_bits) {
return (f32_bits < 0x5f800000U) ||
(f32_bits >= F32_NEG_ZERO && f32_bits < F32_NEG_ONE);
}
@@ -311,36 +322,36 @@ static WABT_INLINE WabtBool is_in_range_i64_trunc_u_f32(uint32_t f32_bits) {
#define F64_SIG_MASK 0xfffffffffffffULL
#define F64_SIGN_MASK 0x8000000000000000ULL
-WABT_INLINE WabtBool wabt_is_nan_f64(uint64_t f64_bits) {
+bool wabt_is_nan_f64(uint64_t f64_bits) {
return (f64_bits > F64_INF && f64_bits < F64_NEG_ZERO) ||
(f64_bits > F64_NEG_INF);
}
-static WABT_INLINE WabtBool is_zero_f64(uint64_t f64_bits) {
+static WABT_INLINE bool is_zero_f64(uint64_t f64_bits) {
return f64_bits == 0 || f64_bits == F64_NEG_ZERO;
}
-static WABT_INLINE WabtBool is_in_range_i32_trunc_s_f64(uint64_t f64_bits) {
+static WABT_INLINE bool is_in_range_i32_trunc_s_f64(uint64_t f64_bits) {
return (f64_bits <= 0x41dfffffffc00000ULL) ||
(f64_bits >= F64_NEG_ZERO && f64_bits <= 0xc1e0000000000000ULL);
}
-static WABT_INLINE WabtBool is_in_range_i32_trunc_u_f64(uint64_t f64_bits) {
+static WABT_INLINE bool is_in_range_i32_trunc_u_f64(uint64_t f64_bits) {
return (f64_bits <= 0x41efffffffe00000ULL) ||
(f64_bits >= F64_NEG_ZERO && f64_bits < F64_NEG_ONE);
}
-static WABT_INLINE WabtBool is_in_range_i64_trunc_s_f64(uint64_t f64_bits) {
+static WABT_INLINE bool is_in_range_i64_trunc_s_f64(uint64_t f64_bits) {
return (f64_bits < 0x43e0000000000000ULL) ||
(f64_bits >= F64_NEG_ZERO && f64_bits <= 0xc3e0000000000000ULL);
}
-static WABT_INLINE WabtBool is_in_range_i64_trunc_u_f64(uint64_t f64_bits) {
+static WABT_INLINE bool is_in_range_i64_trunc_u_f64(uint64_t f64_bits) {
return (f64_bits < 0x43f0000000000000ULL) ||
(f64_bits >= F64_NEG_ZERO && f64_bits < F64_NEG_ONE);
}
-static WABT_INLINE WabtBool is_in_range_f64_demote_f32(uint64_t f64_bits) {
+static WABT_INLINE bool is_in_range_f64_demote_f32(uint64_t f64_bits) {
return (f64_bits <= 0x47efffffe0000000ULL) ||
(f64_bits >= F64_NEG_ZERO && f64_bits <= 0xc7efffffe0000000ULL);
}
@@ -349,13 +360,13 @@ static WABT_INLINE WabtBool is_in_range_f64_demote_f32(uint64_t f64_bits) {
* should be rounded to F32_MAX and not set to infinity. Unfortunately, UBSAN
* complains that the value is not representable as a float, so we'll special
* case them. */
-static WABT_INLINE WabtBool
-is_in_range_f64_demote_f32_round_to_f32_max(uint64_t f64_bits) {
+static WABT_INLINE bool is_in_range_f64_demote_f32_round_to_f32_max(
+ uint64_t f64_bits) {
return f64_bits > 0x47efffffe0000000ULL && f64_bits < 0x47effffff0000000ULL;
}
-static WABT_INLINE WabtBool
-is_in_range_f64_demote_f32_round_to_neg_f32_max(uint64_t f64_bits) {
+static WABT_INLINE bool is_in_range_f64_demote_f32_round_to_neg_f32_max(
+ uint64_t f64_bits) {
return f64_bits > 0xc7efffffe0000000ULL && f64_bits < 0xc7effffff0000000ULL;
}
@@ -712,11 +723,11 @@ static WABT_INLINE void read_table_entry_at(const uint8_t* pc,
*out_keep = *(pc + WABT_TABLE_ENTRY_KEEP_OFFSET);
}
-WabtBool wabt_func_signatures_are_equal(WabtInterpreterEnvironment* env,
- uint32_t sig_index_0,
- uint32_t sig_index_1) {
+bool wabt_func_signatures_are_equal(WabtInterpreterEnvironment* env,
+ uint32_t sig_index_0,
+ uint32_t sig_index_1) {
if (sig_index_0 == sig_index_1)
- return WABT_TRUE;
+ return true;
WabtInterpreterFuncSignature* sig_0 = &env->sigs.data[sig_index_0];
WabtInterpreterFuncSignature* sig_1 = &env->sigs.data[sig_index_1];
return wabt_type_vectors_are_equal(&sig_0->param_types,
@@ -746,7 +757,8 @@ WabtInterpreterResult wabt_call_host(WabtInterpreterThread* thread,
uint32_t num_results = sig->result_types.size;
WabtInterpreterTypedValue* call_result_values =
- alloca(sizeof(WabtInterpreterTypedValue) * num_results);
+ (WabtInterpreterTypedValue*)alloca(sizeof(WabtInterpreterTypedValue) *
+ num_results);
WabtResult call_result = func->host.callback(
func, sig, num_args, thread->host_args.data, num_results,
@@ -770,7 +782,7 @@ WabtInterpreterResult wabt_run_interpreter(WabtInterpreterThread* thread,
WabtInterpreterEnvironment* env = thread->env;
- const uint8_t* istream = env->istream.start;
+ const uint8_t* istream = (const uint8_t*)env->istream.start;
const uint8_t* pc = &istream[thread->pc];
uint32_t i;
for (i = 0; i < num_instructions; ++i) {
@@ -1671,7 +1683,7 @@ exit_loop:
}
void wabt_trace_pc(WabtInterpreterThread* thread, WabtStream* stream) {
- const uint8_t* istream = thread->env->istream.start;
+ const uint8_t* istream = (const uint8_t*)thread->env->istream.start;
const uint8_t* pc = &istream[thread->pc];
size_t value_stack_depth = thread->value_stack_top - thread->value_stack.data;
size_t call_stack_depth = thread->call_stack_top - thread->call_stack.data;
@@ -2054,7 +2066,7 @@ void wabt_disassemble(WabtInterpreterEnvironment* env,
return;
if (to > env->istream.size)
to = env->istream.size;
- const uint8_t* istream = env->istream.start;
+ const uint8_t* istream = (const uint8_t*)env->istream.start;
const uint8_t* pc = &istream[from];
while ((uint32_t)(pc - istream) < to) {
diff --git a/src/interpreter.h b/src/interpreter.h
index 71c2cec3..c3f69c1e 100644
--- a/src/interpreter.h
+++ b/src/interpreter.h
@@ -127,7 +127,7 @@ WABT_DEFINE_VECTOR(interpreter_typed_value, WabtInterpreterTypedValue);
typedef struct WabtInterpreterGlobal {
WabtInterpreterTypedValue typed_value;
- WabtBool mutable_;
+ bool mutable_;
uint32_t import_index; /* or INVALID_INDEX if not imported */
} WabtInterpreterGlobal;
WABT_DEFINE_VECTOR(interpreter_global, WabtInterpreterGlobal);
@@ -145,7 +145,7 @@ typedef struct WabtInterpreterImport {
} table, memory;
struct {
WabtType type;
- WabtBool mutable_;
+ bool mutable_;
} global;
};
} WabtInterpreterImport;
@@ -164,7 +164,7 @@ typedef WabtResult (*WabtInterpreterHostFuncCallback)(
typedef struct WabtInterpreterFunc {
uint32_t sig_index;
- WabtBool is_host;
+ bool is_host;
union {
struct {
uint32_t offset;
@@ -221,7 +221,7 @@ typedef struct WabtInterpreterModule {
WabtBindingHash export_bindings;
uint32_t memory_index; /* INVALID_INDEX if not defined */
uint32_t table_index; /* INVALID_INDEX if not defined */
- WabtBool is_host;
+ bool is_host;
union {
struct {
WabtInterpreterImportArray imports;
@@ -283,11 +283,11 @@ typedef struct WabtInterpreterThreadOptions {
} WabtInterpreterThreadOptions;
WABT_EXTERN_C_BEGIN
-WabtBool wabt_is_nan_f32(uint32_t f32_bits);
-WabtBool wabt_is_nan_f64(uint64_t f64_bits);
-WabtBool wabt_func_signatures_are_equal(WabtInterpreterEnvironment* env,
- uint32_t sig_index_0,
- uint32_t sig_index_1);
+bool wabt_is_nan_f32(uint32_t f32_bits);
+bool wabt_is_nan_f64(uint64_t f64_bits);
+bool wabt_func_signatures_are_equal(WabtInterpreterEnvironment* env,
+ uint32_t sig_index_0,
+ uint32_t sig_index_1);
void wabt_init_interpreter_environment(WabtInterpreterEnvironment* env);
void wabt_destroy_interpreter_environment(WabtInterpreterEnvironment* env);
diff --git a/src/literal.c b/src/literal.cc
index c6967583..2801b042 100644
--- a/src/literal.c
+++ b/src/literal.cc
@@ -67,12 +67,12 @@ WabtResult wabt_parse_hexdigit(char c, uint32_t* out) {
/* return 1 if the non-NULL-terminated string starting with |start| and ending
with |end| starts with the NULL-terminated string |prefix|. */
-static WabtBool string_starts_with(const char* start,
- const char* end,
- const char* prefix) {
+static bool string_starts_with(const char* start,
+ const char* end,
+ const char* prefix) {
while (start < end && *prefix) {
if (*start != *prefix)
- return WABT_FALSE;
+ return false;
start++;
prefix++;
}
@@ -119,12 +119,12 @@ WabtResult wabt_parse_int64(const char* s,
const char* end,
uint64_t* out,
WabtParseIntType parse_type) {
- WabtBool has_sign = WABT_FALSE;
+ bool has_sign = false;
if (*s == '-' || *s == '+') {
if (parse_type == WABT_PARSE_UNSIGNED_ONLY)
return WABT_ERROR;
if (*s == '-')
- has_sign = WABT_TRUE;
+ has_sign = true;
s++;
}
uint64_t value = 0;
@@ -143,12 +143,12 @@ WabtResult wabt_parse_int32(const char* s,
uint32_t* out,
WabtParseIntType parse_type) {
uint64_t value;
- WabtBool has_sign = WABT_FALSE;
+ bool has_sign = false;
if (*s == '-' || *s == '+') {
if (parse_type == WABT_PARSE_UNSIGNED_ONLY)
return WABT_ERROR;
if (*s == '-')
- has_sign = WABT_TRUE;
+ has_sign = true;
s++;
}
if (WABT_FAILED(wabt_parse_uint64(s, end, &value)))
@@ -167,7 +167,7 @@ WabtResult wabt_parse_int32(const char* s,
}
/* floats */
-static uint32_t make_float(WabtBool sign, int exp, uint32_t sig) {
+static uint32_t make_float(bool sign, int exp, uint32_t sig) {
assert(exp >= F32_MIN_EXP && exp <= F32_MAX_EXP);
assert(sig <= F32_SIG_MASK);
return ((uint32_t)sign << F32_SIGN_SHIFT) |
@@ -187,9 +187,9 @@ static uint32_t shift_float_and_round_to_nearest(uint32_t significand,
static WabtResult parse_float_nan(const char* s,
const char* end,
uint32_t* out_bits) {
- WabtBool is_neg = WABT_FALSE;
+ bool is_neg = false;
if (*s == '-') {
- is_neg = WABT_TRUE;
+ is_neg = true;
s++;
} else if (*s == '+') {
s++;
@@ -227,9 +227,9 @@ static WabtResult parse_float_nan(const char* s,
static void parse_float_hex(const char* s,
const char* end,
uint32_t* out_bits) {
- WabtBool is_neg = WABT_FALSE;
+ bool is_neg = false;
if (*s == '-') {
- is_neg = WABT_TRUE;
+ is_neg = true;
s++;
} else if (*s == '+') {
s++;
@@ -245,7 +245,7 @@ static void parse_float_hex(const char* s,
0x10000000.0p0 => significand = 1, significand_exponent = 28
0x0.000001p0 => significand = 1, significand_exponent = -24
*/
- WabtBool seen_dot = WABT_FALSE;
+ bool seen_dot = false;
uint32_t significand = 0;
/* how much to shift |significand| if a non-zero value is appended */
int significand_shift = 0;
@@ -257,7 +257,7 @@ static void parse_float_hex(const char* s,
if (significand != 0)
significand_exponent += significand_shift;
significand_shift = 0;
- seen_dot = WABT_TRUE;
+ seen_dot = true;
continue;
} else if (WABT_FAILED(wabt_parse_hexdigit(*s, &digit))) {
break;
@@ -290,13 +290,13 @@ static void parse_float_hex(const char* s,
assert(s < end);
int exponent = 0;
- WabtBool exponent_is_neg = WABT_FALSE;
+ bool exponent_is_neg = false;
/* exponent is always positive, but significand_exponent is signed.
significand_exponent_add is negated if exponent will be negative, so it can
be easily summed to see if the exponent is too large (see below) */
int significand_exponent_add = 0;
if (*s == '-') {
- exponent_is_neg = WABT_TRUE;
+ exponent_is_neg = true;
significand_exponent_add = -significand_exponent;
s++;
} else if (*s == '+') {
@@ -365,9 +365,9 @@ static void parse_float_hex(const char* s,
static void parse_float_infinity(const char* s,
const char* end,
uint32_t* out_bits) {
- WabtBool is_neg = WABT_FALSE;
+ bool is_neg = false;
if (*s == '-') {
- is_neg = WABT_TRUE;
+ is_neg = true;
s++;
} else if (*s == '+') {
s++;
@@ -420,7 +420,7 @@ void wabt_write_float_hex(char* out, size_t size, uint32_t bits) {
/* -infinity */
char buffer[WABT_MAX_FLOAT_HEX];
char* p = buffer;
- WabtBool is_neg = (bits >> F32_SIGN_SHIFT);
+ bool is_neg = (bits >> F32_SIGN_SHIFT);
int exp = ((bits >> F32_SIG_BITS) & F32_EXP_MASK) - F32_EXP_BIAS;
uint32_t sig = bits & F32_SIG_MASK;
@@ -452,7 +452,7 @@ void wabt_write_float_hex(char* out, size_t size, uint32_t bits) {
}
}
} else {
- WabtBool is_zero = sig == 0 && exp == F32_MIN_EXP;
+ bool is_zero = sig == 0 && exp == F32_MIN_EXP;
strcpy(p, "0x");
p += 2;
*p++ = is_zero ? '0' : '1';
@@ -503,7 +503,7 @@ void wabt_write_float_hex(char* out, size_t size, uint32_t bits) {
}
/* doubles */
-static uint64_t make_double(WabtBool sign, int exp, uint64_t sig) {
+static uint64_t make_double(bool sign, int exp, uint64_t sig) {
assert(exp >= F64_MIN_EXP && exp <= F64_MAX_EXP);
assert(sig <= F64_SIG_MASK);
return ((uint64_t)sign << F64_SIGN_SHIFT) |
@@ -523,9 +523,9 @@ static uint64_t shift_double_and_round_to_nearest(uint64_t significand,
static WabtResult parse_double_nan(const char* s,
const char* end,
uint64_t* out_bits) {
- WabtBool is_neg = WABT_FALSE;
+ bool is_neg = false;
if (*s == '-') {
- is_neg = WABT_TRUE;
+ is_neg = true;
s++;
} else if (*s == '+') {
s++;
@@ -564,9 +564,9 @@ static WabtResult parse_double_nan(const char* s,
static void parse_double_hex(const char* s,
const char* end,
uint64_t* out_bits) {
- WabtBool is_neg = WABT_FALSE;
+ bool is_neg = false;
if (*s == '-') {
- is_neg = WABT_TRUE;
+ is_neg = true;
s++;
} else if (*s == '+') {
s++;
@@ -575,7 +575,7 @@ static void parse_double_hex(const char* s,
s += 2;
/* see the similar comment in parse_float_hex */
- WabtBool seen_dot = WABT_FALSE;
+ bool seen_dot = false;
uint64_t significand = 0;
/* how much to shift |significand| if a non-zero value is appended */
int significand_shift = 0;
@@ -587,7 +587,7 @@ static void parse_double_hex(const char* s,
if (significand != 0)
significand_exponent += significand_shift;
significand_shift = 0;
- seen_dot = WABT_TRUE;
+ seen_dot = true;
continue;
} else if (WABT_FAILED(wabt_parse_hexdigit(*s, &digit))) {
break;
@@ -620,13 +620,13 @@ static void parse_double_hex(const char* s,
assert(s < end);
int exponent = 0;
- WabtBool exponent_is_neg = WABT_FALSE;
+ bool exponent_is_neg = false;
/* exponent is always positive, but significand_exponent is signed.
significand_exponent_add is negated if exponent will be negative, so it can
be easily summed to see if the exponent is too large (see below) */
int significand_exponent_add = 0;
if (*s == '-') {
- exponent_is_neg = WABT_TRUE;
+ exponent_is_neg = true;
significand_exponent_add = -significand_exponent;
s++;
} else if (*s == '+') {
@@ -695,9 +695,9 @@ static void parse_double_hex(const char* s,
static void parse_double_infinity(const char* s,
const char* end,
uint64_t* out_bits) {
- WabtBool is_neg = WABT_FALSE;
+ bool is_neg = false;
if (*s == '-') {
- is_neg = WABT_TRUE;
+ is_neg = true;
s++;
} else if (*s == '+') {
s++;
@@ -750,7 +750,7 @@ void wabt_write_double_hex(char* out, size_t size, uint64_t bits) {
/* -infinity */
char buffer[WABT_MAX_DOUBLE_HEX];
char* p = buffer;
- WabtBool is_neg = (bits >> F64_SIGN_SHIFT);
+ bool is_neg = (bits >> F64_SIGN_SHIFT);
int exp = ((bits >> F64_SIG_BITS) & F64_EXP_MASK) - F64_EXP_BIAS;
uint64_t sig = bits & F64_SIG_MASK;
@@ -782,7 +782,7 @@ void wabt_write_double_hex(char* out, size_t size, uint64_t bits) {
}
}
} else {
- WabtBool is_zero = sig == 0 && exp == F64_MIN_EXP;
+ bool is_zero = sig == 0 && exp == F64_MIN_EXP;
strcpy(p, "0x");
p += 2;
*p++ = is_zero ? '0' : '1';
diff --git a/src/option-parser.c b/src/option-parser.cc
index 19e564cb..98ccb59a 100644
--- a/src/option-parser.c
+++ b/src/option-parser.cc
@@ -122,7 +122,7 @@ void wabt_parse_options(WabtOptionParser* parser,
/* allow short names to be combined, e.g. "-d -v" => "-dv" */
for (k = 1; arg[k]; ++k) {
- WabtBool matched = WABT_FALSE;
+ bool matched = false;
for (j = 0; j < parser->num_options; ++j) {
WabtOption* option = &parser->options[j];
if (option->short_name && arg[k] == option->short_name) {
@@ -145,7 +145,7 @@ void wabt_parse_options(WabtOptionParser* parser,
option_argument = argv[i];
}
parser->on_option(parser, option, option_argument);
- matched = WABT_TRUE;
+ matched = true;
break;
}
}
@@ -191,7 +191,7 @@ void wabt_print_help(WabtOptionParser* parser, const char* program_name) {
}
size_t buffer_size = longest_name_length + 1;
- char* buffer = alloca(buffer_size);
+ char* buffer = (char*)alloca(buffer_size);
for (i = 0; i < parser->num_options; ++i) {
WabtOption* option = &parser->options[i];
diff --git a/src/prebuilt/ast-lexer-gen.c b/src/prebuilt/ast-lexer-gen.cc
index e6e20c8e..047f34d7 100644
--- a/src/prebuilt/ast-lexer-gen.c
+++ b/src/prebuilt/ast-lexer-gen.cc
@@ -1,5 +1,5 @@
/* Generated by re2c 0.16 */
-#line 1 "src/ast-lexer.c"
+#line 1 "src/ast-lexer.cc"
/*
* Copyright 2016 WebAssembly Community Group participants
*
@@ -115,7 +115,7 @@ static WabtResult fill(WabtLocation* loc,
/* TODO(binji): could just alloc instead, because we know we'll need to
* memmove below */
- char* new_buffer = wabt_realloc(lexer->buffer, new_buffer_size);
+ char* new_buffer = (char*)wabt_realloc(lexer->buffer, new_buffer_size);
if (new_buffer == NULL) {
wabt_ast_parser_error(loc, lexer, parser,
"unable to reallocate lexer buffer.");
@@ -159,7 +159,7 @@ static WabtResult fill(WabtLocation* loc,
* characters", that are not a lexeme nor a lexeme suffix. see
* http://re2c.org/examples/example_03.html */
if (lexer->limit < lexer->buffer + lexer->buffer_size - YYMAXFILL) {
- lexer->eof = WABT_TRUE;
+ lexer->eof = true;
memset(lexer->limit, 0, YYMAXFILL);
lexer->limit += YYMAXFILL;
}
@@ -181,7 +181,7 @@ int wabt_ast_lexer_lex(WABT_AST_PARSER_STYPE* lval,
for (;;) {
lexer->token = lexer->cursor;
-#line 185 "src/prebuilt/ast-lexer-gen.c"
+#line 185 "src/prebuilt/ast-lexer-gen.cc"
{
unsigned char yych;
if (cond < 2) {
@@ -220,32 +220,32 @@ YYCOND_BAD_TEXT:
}
}
++lexer->cursor;
-#line 233 "src/ast-lexer.c"
+#line 233 "src/ast-lexer.cc"
{ ERROR("unexpected EOF"); RETURN(EOF); }
-#line 226 "src/prebuilt/ast-lexer-gen.c"
+#line 226 "src/prebuilt/ast-lexer-gen.cc"
yy5:
++lexer->cursor;
yy6:
-#line 234 "src/ast-lexer.c"
+#line 234 "src/ast-lexer.cc"
{ ERROR("illegal character in string"); continue; }
-#line 232 "src/prebuilt/ast-lexer-gen.c"
+#line 232 "src/prebuilt/ast-lexer-gen.cc"
yy7:
++lexer->cursor;
BEGIN(YYCOND_i);
-#line 229 "src/ast-lexer.c"
+#line 229 "src/ast-lexer.cc"
{ ERROR("newline in string"); NEWLINE; continue; }
-#line 238 "src/prebuilt/ast-lexer-gen.c"
+#line 238 "src/prebuilt/ast-lexer-gen.cc"
yy9:
++lexer->cursor;
-#line 228 "src/ast-lexer.c"
+#line 228 "src/ast-lexer.cc"
{ continue; }
-#line 243 "src/prebuilt/ast-lexer-gen.c"
+#line 243 "src/prebuilt/ast-lexer-gen.cc"
yy11:
++lexer->cursor;
BEGIN(YYCOND_i);
-#line 232 "src/ast-lexer.c"
+#line 232 "src/ast-lexer.cc"
{ TEXT; RETURN(TEXT); }
-#line 249 "src/prebuilt/ast-lexer-gen.c"
+#line 249 "src/prebuilt/ast-lexer-gen.cc"
yy13:
yych = *++lexer->cursor;
if (yych <= '@') {
@@ -279,10 +279,10 @@ yy13:
yy14:
++lexer->cursor;
yy15:
-#line 230 "src/ast-lexer.c"
+#line 230 "src/ast-lexer.cc"
{ ERROR("bad escape \"%.*s\"", (int)yyleng, yytext);
continue; }
-#line 286 "src/prebuilt/ast-lexer-gen.c"
+#line 286 "src/prebuilt/ast-lexer-gen.cc"
yy16:
++lexer->cursor;
if ((yych = *lexer->cursor) <= '@') {
@@ -310,20 +310,20 @@ YYCOND_BLOCK_COMMENT:
}
yy19:
++lexer->cursor;
-#line 456 "src/ast-lexer.c"
+#line 456 "src/ast-lexer.cc"
{ ERROR("unexpected EOF"); RETURN(EOF); }
-#line 316 "src/prebuilt/ast-lexer-gen.c"
+#line 316 "src/prebuilt/ast-lexer-gen.cc"
yy21:
++lexer->cursor;
yy22:
-#line 457 "src/ast-lexer.c"
+#line 457 "src/ast-lexer.cc"
{ continue; }
-#line 322 "src/prebuilt/ast-lexer-gen.c"
+#line 322 "src/prebuilt/ast-lexer-gen.cc"
yy23:
++lexer->cursor;
-#line 455 "src/ast-lexer.c"
+#line 455 "src/ast-lexer.cc"
{ NEWLINE; continue; }
-#line 327 "src/prebuilt/ast-lexer-gen.c"
+#line 327 "src/prebuilt/ast-lexer-gen.cc"
yy25:
yych = *++lexer->cursor;
if (yych == ';') goto yy27;
@@ -334,16 +334,16 @@ yy26:
goto yy22;
yy27:
++lexer->cursor;
-#line 451 "src/ast-lexer.c"
+#line 451 "src/ast-lexer.cc"
{ COMMENT_NESTING++; continue; }
-#line 340 "src/prebuilt/ast-lexer-gen.c"
+#line 340 "src/prebuilt/ast-lexer-gen.cc"
yy29:
++lexer->cursor;
-#line 452 "src/ast-lexer.c"
+#line 452 "src/ast-lexer.cc"
{ if (--COMMENT_NESTING == 0)
BEGIN(YYCOND_INIT);
continue; }
-#line 347 "src/prebuilt/ast-lexer-gen.c"
+#line 347 "src/prebuilt/ast-lexer-gen.cc"
/* *********************************** */
YYCOND_LINE_COMMENT:
{
@@ -388,9 +388,9 @@ YYCOND_LINE_COMMENT:
}
goto yy36;
yy33:
-#line 449 "src/ast-lexer.c"
+#line 449 "src/ast-lexer.cc"
{ continue; }
-#line 394 "src/prebuilt/ast-lexer-gen.c"
+#line 394 "src/prebuilt/ast-lexer-gen.cc"
yy34:
++lexer->cursor;
if (lexer->limit <= lexer->cursor) FILL(1);
@@ -402,9 +402,9 @@ yy34:
yy36:
++lexer->cursor;
BEGIN(YYCOND_i);
-#line 448 "src/ast-lexer.c"
+#line 448 "src/ast-lexer.cc"
{ NEWLINE; continue; }
-#line 408 "src/prebuilt/ast-lexer-gen.c"
+#line 408 "src/prebuilt/ast-lexer-gen.cc"
}
/* *********************************** */
YYCOND_i:
@@ -546,15 +546,15 @@ YYCOND_i:
}
yy40:
++lexer->cursor;
-#line 463 "src/ast-lexer.c"
+#line 463 "src/ast-lexer.cc"
{ RETURN(EOF); }
-#line 552 "src/prebuilt/ast-lexer-gen.c"
+#line 552 "src/prebuilt/ast-lexer-gen.cc"
yy42:
++lexer->cursor;
yy43:
-#line 464 "src/ast-lexer.c"
+#line 464 "src/ast-lexer.cc"
{ ERROR("unexpected char"); continue; }
-#line 558 "src/prebuilt/ast-lexer-gen.c"
+#line 558 "src/prebuilt/ast-lexer-gen.cc"
yy44:
++lexer->cursor;
if (lexer->limit <= lexer->cursor) FILL(1);
@@ -562,14 +562,14 @@ yy44:
if (yybm[0+yych] & 8) {
goto yy44;
}
-#line 459 "src/ast-lexer.c"
+#line 459 "src/ast-lexer.cc"
{ continue; }
-#line 568 "src/prebuilt/ast-lexer-gen.c"
+#line 568 "src/prebuilt/ast-lexer-gen.cc"
yy47:
++lexer->cursor;
-#line 458 "src/ast-lexer.c"
+#line 458 "src/ast-lexer.cc"
{ NEWLINE; continue; }
-#line 573 "src/prebuilt/ast-lexer-gen.c"
+#line 573 "src/prebuilt/ast-lexer-gen.cc"
yy49:
++lexer->cursor;
if (lexer->limit <= lexer->cursor) FILL(1);
@@ -579,20 +579,20 @@ yy50:
goto yy49;
}
yy51:
-#line 460 "src/ast-lexer.c"
+#line 460 "src/ast-lexer.cc"
{ ERROR("unexpected token \"%.*s\"",
(int)yyleng, yytext);
continue; }
-#line 587 "src/prebuilt/ast-lexer-gen.c"
+#line 587 "src/prebuilt/ast-lexer-gen.cc"
yy52:
yych = *(lexer->marker = ++lexer->cursor);
if (yych <= 0x1F) goto yy53;
if (yych != 0x7F) goto yy83;
yy53:
BEGIN(YYCOND_BAD_TEXT);
-#line 227 "src/ast-lexer.c"
+#line 227 "src/ast-lexer.cc"
{ continue; }
-#line 596 "src/prebuilt/ast-lexer-gen.c"
+#line 596 "src/prebuilt/ast-lexer-gen.cc"
yy54:
yych = *++lexer->cursor;
if (yych <= ';') {
@@ -632,14 +632,14 @@ yy54:
yy55:
++lexer->cursor;
if ((yych = *lexer->cursor) == ';') goto yy91;
-#line 218 "src/ast-lexer.c"
+#line 218 "src/ast-lexer.cc"
{ RETURN(LPAR); }
-#line 638 "src/prebuilt/ast-lexer-gen.c"
+#line 638 "src/prebuilt/ast-lexer-gen.cc"
yy57:
++lexer->cursor;
-#line 219 "src/ast-lexer.c"
+#line 219 "src/ast-lexer.cc"
{ RETURN(RPAR); }
-#line 643 "src/prebuilt/ast-lexer-gen.c"
+#line 643 "src/prebuilt/ast-lexer-gen.cc"
yy59:
yych = *++lexer->cursor;
if (yych <= 'h') {
@@ -696,9 +696,9 @@ yy60:
}
}
yy61:
-#line 220 "src/ast-lexer.c"
+#line 220 "src/ast-lexer.cc"
{ LITERAL(INT); RETURN(NAT); }
-#line 702 "src/prebuilt/ast-lexer-gen.c"
+#line 702 "src/prebuilt/ast-lexer-gen.cc"
yy62:
++lexer->cursor;
if ((lexer->limit - lexer->cursor) < 3) FILL(3);
@@ -899,9 +899,9 @@ yy84:
goto yy53;
yy85:
++lexer->cursor;
-#line 226 "src/ast-lexer.c"
+#line 226 "src/ast-lexer.cc"
{ TEXT; RETURN(TEXT); }
-#line 905 "src/prebuilt/ast-lexer-gen.c"
+#line 905 "src/prebuilt/ast-lexer-gen.cc"
yy87:
++lexer->cursor;
if (lexer->limit <= lexer->cursor) FILL(1);
@@ -964,15 +964,15 @@ yy88:
}
}
yy90:
-#line 445 "src/ast-lexer.c"
+#line 445 "src/ast-lexer.cc"
{ TEXT; RETURN(VAR); }
-#line 970 "src/prebuilt/ast-lexer-gen.c"
+#line 970 "src/prebuilt/ast-lexer-gen.cc"
yy91:
++lexer->cursor;
BEGIN(YYCOND_BLOCK_COMMENT);
-#line 450 "src/ast-lexer.c"
+#line 450 "src/ast-lexer.cc"
{ COMMENT_NESTING = 1; continue; }
-#line 976 "src/prebuilt/ast-lexer-gen.c"
+#line 976 "src/prebuilt/ast-lexer-gen.cc"
yy93:
++lexer->cursor;
if ((yych = *lexer->cursor) <= 'D') {
@@ -1014,9 +1014,9 @@ yy93:
}
}
yy94:
-#line 221 "src/ast-lexer.c"
+#line 221 "src/ast-lexer.cc"
{ LITERAL(INT); RETURN(INT); }
-#line 1020 "src/prebuilt/ast-lexer-gen.c"
+#line 1020 "src/prebuilt/ast-lexer-gen.cc"
yy95:
++lexer->cursor;
if ((lexer->limit - lexer->cursor) < 3) FILL(3);
@@ -1113,9 +1113,9 @@ yy99:
}
}
yy101:
-#line 222 "src/ast-lexer.c"
+#line 222 "src/ast-lexer.cc"
{ LITERAL(FLOAT); RETURN(FLOAT); }
-#line 1119 "src/prebuilt/ast-lexer-gen.c"
+#line 1119 "src/prebuilt/ast-lexer-gen.cc"
yy102:
yych = *++lexer->cursor;
if (yych <= ',') {
@@ -1136,9 +1136,9 @@ yy103:
yy104:
++lexer->cursor;
BEGIN(YYCOND_LINE_COMMENT);
-#line 447 "src/ast-lexer.c"
+#line 447 "src/ast-lexer.cc"
{ continue; }
-#line 1142 "src/prebuilt/ast-lexer-gen.c"
+#line 1142 "src/prebuilt/ast-lexer-gen.cc"
yy106:
yych = *++lexer->cursor;
if (yych == 'i') goto yy156;
@@ -1190,9 +1190,9 @@ yy110:
}
}
yy111:
-#line 248 "src/ast-lexer.c"
+#line 248 "src/ast-lexer.cc"
{ RETURN(BR); }
-#line 1196 "src/prebuilt/ast-lexer-gen.c"
+#line 1196 "src/prebuilt/ast-lexer-gen.cc"
yy112:
yych = *++lexer->cursor;
if (yych == 'l') goto yy161;
@@ -1289,9 +1289,9 @@ yy127:
}
}
yy128:
-#line 243 "src/ast-lexer.c"
+#line 243 "src/ast-lexer.cc"
{ RETURN(IF); }
-#line 1295 "src/prebuilt/ast-lexer-gen.c"
+#line 1295 "src/prebuilt/ast-lexer-gen.cc"
yy129:
yych = *++lexer->cursor;
if (yych == 'p') goto yy184;
@@ -1556,9 +1556,9 @@ yy167:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 255 "src/ast-lexer.c"
+#line 255 "src/ast-lexer.cc"
{ RETURN(END); }
-#line 1562 "src/prebuilt/ast-lexer-gen.c"
+#line 1562 "src/prebuilt/ast-lexer-gen.cc"
yy169:
yych = *++lexer->cursor;
if (yych == 'o') goto yy235;
@@ -1597,9 +1597,9 @@ yy170:
}
}
yy171:
-#line 237 "src/ast-lexer.c"
+#line 237 "src/ast-lexer.cc"
{ TYPE(F32); RETURN(VALUE_TYPE); }
-#line 1603 "src/prebuilt/ast-lexer-gen.c"
+#line 1603 "src/prebuilt/ast-lexer-gen.cc"
yy172:
++lexer->cursor;
if ((yych = *lexer->cursor) <= ':') {
@@ -1634,9 +1634,9 @@ yy172:
}
}
yy173:
-#line 238 "src/ast-lexer.c"
+#line 238 "src/ast-lexer.cc"
{ TYPE(F64); RETURN(VALUE_TYPE); }
-#line 1640 "src/prebuilt/ast-lexer-gen.c"
+#line 1640 "src/prebuilt/ast-lexer-gen.cc"
yy174:
yych = *++lexer->cursor;
if (yych == 'c') goto yy238;
@@ -1676,9 +1676,9 @@ yy175:
}
}
yy176:
-#line 435 "src/ast-lexer.c"
+#line 435 "src/ast-lexer.cc"
{ RETURN(GET); }
-#line 1682 "src/prebuilt/ast-lexer-gen.c"
+#line 1682 "src/prebuilt/ast-lexer-gen.cc"
yy177:
yych = *++lexer->cursor;
if (yych == 'b') goto yy241;
@@ -1721,9 +1721,9 @@ yy179:
}
}
yy180:
-#line 235 "src/ast-lexer.c"
+#line 235 "src/ast-lexer.cc"
{ TYPE(I32); RETURN(VALUE_TYPE); }
-#line 1727 "src/prebuilt/ast-lexer-gen.c"
+#line 1727 "src/prebuilt/ast-lexer-gen.cc"
yy181:
++lexer->cursor;
if ((yych = *lexer->cursor) <= ':') {
@@ -1758,9 +1758,9 @@ yy181:
}
}
yy182:
-#line 236 "src/ast-lexer.c"
+#line 236 "src/ast-lexer.cc"
{ TYPE(I64); RETURN(VALUE_TYPE); }
-#line 1764 "src/prebuilt/ast-lexer-gen.c"
+#line 1764 "src/prebuilt/ast-lexer-gen.cc"
yy183:
yych = *++lexer->cursor;
if (yych == 'e') goto yy245;
@@ -1804,9 +1804,9 @@ yy185:
}
}
yy186:
-#line 224 "src/ast-lexer.c"
+#line 224 "src/ast-lexer.cc"
{ LITERAL(INFINITY); RETURN(FLOAT); }
-#line 1810 "src/prebuilt/ast-lexer-gen.c"
+#line 1810 "src/prebuilt/ast-lexer-gen.cc"
yy187:
yych = *++lexer->cursor;
if (yych == 'u') goto yy248;
@@ -1836,9 +1836,9 @@ yy193:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 240 "src/ast-lexer.c"
+#line 240 "src/ast-lexer.cc"
{ RETURN(MUT); }
-#line 1842 "src/prebuilt/ast-lexer-gen.c"
+#line 1842 "src/prebuilt/ast-lexer-gen.cc"
yy195:
++lexer->cursor;
if ((yych = *lexer->cursor) <= ';') {
@@ -1873,17 +1873,17 @@ yy195:
}
}
yy196:
-#line 225 "src/ast-lexer.c"
+#line 225 "src/ast-lexer.cc"
{ LITERAL(NAN); RETURN(FLOAT); }
-#line 1879 "src/prebuilt/ast-lexer-gen.c"
+#line 1879 "src/prebuilt/ast-lexer-gen.cc"
yy197:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 241 "src/ast-lexer.c"
+#line 241 "src/ast-lexer.cc"
{ RETURN(NOP); }
-#line 1887 "src/prebuilt/ast-lexer-gen.c"
+#line 1887 "src/prebuilt/ast-lexer-gen.cc"
yy199:
yych = *++lexer->cursor;
if (yych == 's') goto yy256;
@@ -2105,9 +2105,9 @@ yy224:
}
}
yy225:
-#line 251 "src/ast-lexer.c"
+#line 251 "src/ast-lexer.cc"
{ RETURN(CALL); }
-#line 2111 "src/prebuilt/ast-lexer-gen.c"
+#line 2111 "src/prebuilt/ast-lexer-gen.cc"
yy226:
yych = *++lexer->cursor;
if (yych == 'e') goto yy285;
@@ -2117,33 +2117,33 @@ yy227:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 429 "src/ast-lexer.c"
+#line 429 "src/ast-lexer.cc"
{ RETURN(DATA); }
-#line 2123 "src/prebuilt/ast-lexer-gen.c"
+#line 2123 "src/prebuilt/ast-lexer-gen.cc"
yy229:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 254 "src/ast-lexer.c"
+#line 254 "src/ast-lexer.cc"
{ RETURN(DROP); }
-#line 2131 "src/prebuilt/ast-lexer-gen.c"
+#line 2131 "src/prebuilt/ast-lexer-gen.cc"
yy231:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 428 "src/ast-lexer.c"
+#line 428 "src/ast-lexer.cc"
{ RETURN(ELEM); }
-#line 2139 "src/prebuilt/ast-lexer-gen.c"
+#line 2139 "src/prebuilt/ast-lexer-gen.cc"
yy233:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 246 "src/ast-lexer.c"
+#line 246 "src/ast-lexer.cc"
{ RETURN(ELSE); }
-#line 2147 "src/prebuilt/ast-lexer-gen.c"
+#line 2147 "src/prebuilt/ast-lexer-gen.cc"
yy235:
yych = *++lexer->cursor;
if (yych == 'r') goto yy286;
@@ -2188,9 +2188,9 @@ yy238:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 419 "src/ast-lexer.c"
+#line 419 "src/ast-lexer.cc"
{ RETURN(FUNC); }
-#line 2194 "src/prebuilt/ast-lexer-gen.c"
+#line 2194 "src/prebuilt/ast-lexer-gen.cc"
yy240:
yych = *++lexer->cursor;
if (yych == 'g') goto yy312;
@@ -2272,9 +2272,9 @@ yy251:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 247 "src/ast-lexer.c"
+#line 247 "src/ast-lexer.cc"
{ RETURN(LOOP); }
-#line 2278 "src/prebuilt/ast-lexer-gen.c"
+#line 2278 "src/prebuilt/ast-lexer-gen.cc"
yy253:
yych = *++lexer->cursor;
if (yych == 'r') goto yy353;
@@ -2337,17 +2337,17 @@ yy267:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 245 "src/ast-lexer.c"
+#line 245 "src/ast-lexer.cc"
{ RETURN(THEN); }
-#line 2343 "src/prebuilt/ast-lexer-gen.c"
+#line 2343 "src/prebuilt/ast-lexer-gen.cc"
yy269:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 418 "src/ast-lexer.c"
+#line 418 "src/ast-lexer.cc"
{ RETURN(TYPE); }
-#line 2351 "src/prebuilt/ast-lexer-gen.c"
+#line 2351 "src/prebuilt/ast-lexer-gen.cc"
yy271:
yych = *++lexer->cursor;
if (yych == 'a') goto yy371;
@@ -2393,9 +2393,9 @@ yy273:
}
}
yy275:
-#line 223 "src/ast-lexer.c"
+#line 223 "src/ast-lexer.cc"
{ LITERAL(HEXFLOAT); RETURN(FLOAT); }
-#line 2399 "src/prebuilt/ast-lexer-gen.c"
+#line 2399 "src/prebuilt/ast-lexer-gen.cc"
yy276:
yych = *++lexer->cursor;
if (yych == '=') goto yy372;
@@ -2413,17 +2413,17 @@ yy279:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 242 "src/ast-lexer.c"
+#line 242 "src/ast-lexer.cc"
{ RETURN(BLOCK); }
-#line 2419 "src/prebuilt/ast-lexer-gen.c"
+#line 2419 "src/prebuilt/ast-lexer-gen.cc"
yy281:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 249 "src/ast-lexer.c"
+#line 249 "src/ast-lexer.cc"
{ RETURN(BR_IF); }
-#line 2427 "src/prebuilt/ast-lexer-gen.c"
+#line 2427 "src/prebuilt/ast-lexer-gen.cc"
yy283:
yych = *++lexer->cursor;
if (yych == 'b') goto yy375;
@@ -2775,9 +2775,9 @@ yy348:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 443 "src/ast-lexer.c"
+#line 443 "src/ast-lexer.cc"
{ RETURN(INPUT); }
-#line 2781 "src/prebuilt/ast-lexer-gen.c"
+#line 2781 "src/prebuilt/ast-lexer-gen.cc"
yy350:
yych = *++lexer->cursor;
if (yych == 'e') goto yy499;
@@ -2787,9 +2787,9 @@ yy351:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 422 "src/ast-lexer.c"
+#line 422 "src/ast-lexer.cc"
{ RETURN(LOCAL); }
-#line 2793 "src/prebuilt/ast-lexer-gen.c"
+#line 2793 "src/prebuilt/ast-lexer-gen.cc"
yy353:
yych = *++lexer->cursor;
if (yych == 'y') goto yy501;
@@ -2815,9 +2815,9 @@ yy358:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 420 "src/ast-lexer.c"
+#line 420 "src/ast-lexer.cc"
{ RETURN(PARAM); }
-#line 2821 "src/prebuilt/ast-lexer-gen.c"
+#line 2821 "src/prebuilt/ast-lexer-gen.cc"
yy360:
yych = *++lexer->cursor;
if (yych == 't') goto yy510;
@@ -2847,17 +2847,17 @@ yy366:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 427 "src/ast-lexer.c"
+#line 427 "src/ast-lexer.cc"
{ RETURN(START); }
-#line 2853 "src/prebuilt/ast-lexer-gen.c"
+#line 2853 "src/prebuilt/ast-lexer-gen.cc"
yy368:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 425 "src/ast-lexer.c"
+#line 425 "src/ast-lexer.cc"
{ RETURN(TABLE); }
-#line 2861 "src/prebuilt/ast-lexer-gen.c"
+#line 2861 "src/prebuilt/ast-lexer-gen.cc"
yy370:
yych = *++lexer->cursor;
if (yych == 'o') goto yy519;
@@ -2899,9 +2899,9 @@ yy378:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 432 "src/ast-lexer.c"
+#line 432 "src/ast-lexer.cc"
{ RETURN(EXPORT); }
-#line 2905 "src/prebuilt/ast-lexer-gen.c"
+#line 2905 "src/prebuilt/ast-lexer-gen.cc"
yy380:
yych = *++lexer->cursor;
if (yych == 's') goto yy532;
@@ -2932,9 +2932,9 @@ yy386:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 377 "src/ast-lexer.c"
+#line 377 "src/ast-lexer.cc"
{ OPCODE(F32_EQ); RETURN(COMPARE); }
-#line 2938 "src/prebuilt/ast-lexer-gen.c"
+#line 2938 "src/prebuilt/ast-lexer-gen.cc"
yy388:
yych = *++lexer->cursor;
if (yych == 'o') goto yy542;
@@ -2944,25 +2944,25 @@ yy389:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 387 "src/ast-lexer.c"
+#line 387 "src/ast-lexer.cc"
{ OPCODE(F32_GE); RETURN(COMPARE); }
-#line 2950 "src/prebuilt/ast-lexer-gen.c"
+#line 2950 "src/prebuilt/ast-lexer-gen.cc"
yy391:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 385 "src/ast-lexer.c"
+#line 385 "src/ast-lexer.cc"
{ OPCODE(F32_GT); RETURN(COMPARE); }
-#line 2958 "src/prebuilt/ast-lexer-gen.c"
+#line 2958 "src/prebuilt/ast-lexer-gen.cc"
yy393:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 383 "src/ast-lexer.c"
+#line 383 "src/ast-lexer.cc"
{ OPCODE(F32_LE); RETURN(COMPARE); }
-#line 2966 "src/prebuilt/ast-lexer-gen.c"
+#line 2966 "src/prebuilt/ast-lexer-gen.cc"
yy395:
yych = *++lexer->cursor;
if (yych == 'a') goto yy543;
@@ -2972,9 +2972,9 @@ yy396:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 381 "src/ast-lexer.c"
+#line 381 "src/ast-lexer.cc"
{ OPCODE(F32_LT); RETURN(COMPARE); }
-#line 2978 "src/prebuilt/ast-lexer-gen.c"
+#line 2978 "src/prebuilt/ast-lexer-gen.cc"
yy398:
yych = *++lexer->cursor;
if (yych == 'x') goto yy544;
@@ -3023,9 +3023,9 @@ yy401:
}
}
yy402:
-#line 379 "src/ast-lexer.c"
+#line 379 "src/ast-lexer.cc"
{ OPCODE(F32_NE); RETURN(COMPARE); }
-#line 3029 "src/prebuilt/ast-lexer-gen.c"
+#line 3029 "src/prebuilt/ast-lexer-gen.cc"
yy403:
yych = *++lexer->cursor;
if (yych == 'i') goto yy553;
@@ -3072,9 +3072,9 @@ yy413:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 378 "src/ast-lexer.c"
+#line 378 "src/ast-lexer.cc"
{ OPCODE(F64_EQ); RETURN(COMPARE); }
-#line 3078 "src/prebuilt/ast-lexer-gen.c"
+#line 3078 "src/prebuilt/ast-lexer-gen.cc"
yy415:
yych = *++lexer->cursor;
if (yych == 'o') goto yy568;
@@ -3084,25 +3084,25 @@ yy416:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 388 "src/ast-lexer.c"
+#line 388 "src/ast-lexer.cc"
{ OPCODE(F64_GE); RETURN(COMPARE); }
-#line 3090 "src/prebuilt/ast-lexer-gen.c"
+#line 3090 "src/prebuilt/ast-lexer-gen.cc"
yy418:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 386 "src/ast-lexer.c"
+#line 386 "src/ast-lexer.cc"
{ OPCODE(F64_GT); RETURN(COMPARE); }
-#line 3098 "src/prebuilt/ast-lexer-gen.c"
+#line 3098 "src/prebuilt/ast-lexer-gen.cc"
yy420:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 384 "src/ast-lexer.c"
+#line 384 "src/ast-lexer.cc"
{ OPCODE(F64_LE); RETURN(COMPARE); }
-#line 3106 "src/prebuilt/ast-lexer-gen.c"
+#line 3106 "src/prebuilt/ast-lexer-gen.cc"
yy422:
yych = *++lexer->cursor;
if (yych == 'a') goto yy569;
@@ -3112,9 +3112,9 @@ yy423:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 382 "src/ast-lexer.c"
+#line 382 "src/ast-lexer.cc"
{ OPCODE(F64_LT); RETURN(COMPARE); }
-#line 3118 "src/prebuilt/ast-lexer-gen.c"
+#line 3118 "src/prebuilt/ast-lexer-gen.cc"
yy425:
yych = *++lexer->cursor;
if (yych == 'x') goto yy570;
@@ -3163,9 +3163,9 @@ yy428:
}
}
yy429:
-#line 380 "src/ast-lexer.c"
+#line 380 "src/ast-lexer.cc"
{ OPCODE(F64_NE); RETURN(COMPARE); }
-#line 3169 "src/prebuilt/ast-lexer-gen.c"
+#line 3169 "src/prebuilt/ast-lexer-gen.cc"
yy430:
yych = *++lexer->cursor;
if (yych == 'o') goto yy579;
@@ -3203,9 +3203,9 @@ yy438:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 423 "src/ast-lexer.c"
+#line 423 "src/ast-lexer.cc"
{ RETURN(GLOBAL); }
-#line 3209 "src/prebuilt/ast-lexer-gen.c"
+#line 3209 "src/prebuilt/ast-lexer-gen.cc"
yy440:
yych = *++lexer->cursor;
if (yych == 'e') goto yy588;
@@ -3269,9 +3269,9 @@ yy447:
}
}
yy448:
-#line 357 "src/ast-lexer.c"
+#line 357 "src/ast-lexer.cc"
{ OPCODE(I32_EQ); RETURN(COMPARE); }
-#line 3275 "src/prebuilt/ast-lexer-gen.c"
+#line 3275 "src/prebuilt/ast-lexer-gen.cc"
yy449:
yych = *++lexer->cursor;
if (yych == '_') goto yy601;
@@ -3301,17 +3301,17 @@ yy455:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 359 "src/ast-lexer.c"
+#line 359 "src/ast-lexer.cc"
{ OPCODE(I32_NE); RETURN(COMPARE); }
-#line 3307 "src/prebuilt/ast-lexer-gen.c"
+#line 3307 "src/prebuilt/ast-lexer-gen.cc"
yy457:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 329 "src/ast-lexer.c"
+#line 329 "src/ast-lexer.cc"
{ OPCODE(I32_OR); RETURN(BINARY); }
-#line 3315 "src/prebuilt/ast-lexer-gen.c"
+#line 3315 "src/prebuilt/ast-lexer-gen.cc"
yy459:
yych = *++lexer->cursor;
if (yych == 'p') goto yy608;
@@ -3409,9 +3409,9 @@ yy474:
}
}
yy475:
-#line 358 "src/ast-lexer.c"
+#line 358 "src/ast-lexer.cc"
{ OPCODE(I64_EQ); RETURN(COMPARE); }
-#line 3415 "src/prebuilt/ast-lexer-gen.c"
+#line 3415 "src/prebuilt/ast-lexer-gen.cc"
yy476:
yych = *++lexer->cursor;
if (yych == 't') goto yy634;
@@ -3445,17 +3445,17 @@ yy483:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 360 "src/ast-lexer.c"
+#line 360 "src/ast-lexer.cc"
{ OPCODE(I64_NE); RETURN(COMPARE); }
-#line 3451 "src/prebuilt/ast-lexer-gen.c"
+#line 3451 "src/prebuilt/ast-lexer-gen.cc"
yy485:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 330 "src/ast-lexer.c"
+#line 330 "src/ast-lexer.cc"
{ OPCODE(I64_OR); RETURN(BINARY); }
-#line 3459 "src/prebuilt/ast-lexer-gen.c"
+#line 3459 "src/prebuilt/ast-lexer-gen.cc"
yy487:
yych = *++lexer->cursor;
if (yych == 'p') goto yy642;
@@ -3499,9 +3499,9 @@ yy496:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 431 "src/ast-lexer.c"
+#line 431 "src/ast-lexer.cc"
{ RETURN(IMPORT); }
-#line 3505 "src/prebuilt/ast-lexer-gen.c"
+#line 3505 "src/prebuilt/ast-lexer-gen.cc"
yy498:
yych = *++lexer->cursor;
if (yych == 't') goto yy657;
@@ -3511,25 +3511,25 @@ yy499:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 434 "src/ast-lexer.c"
+#line 434 "src/ast-lexer.cc"
{ RETURN(INVOKE); }
-#line 3517 "src/prebuilt/ast-lexer-gen.c"
+#line 3517 "src/prebuilt/ast-lexer-gen.cc"
yy501:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 426 "src/ast-lexer.c"
+#line 426 "src/ast-lexer.cc"
{ RETURN(MEMORY); }
-#line 3525 "src/prebuilt/ast-lexer-gen.c"
+#line 3525 "src/prebuilt/ast-lexer-gen.cc"
yy503:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 424 "src/ast-lexer.c"
+#line 424 "src/ast-lexer.cc"
{ RETURN(MODULE); }
-#line 3533 "src/prebuilt/ast-lexer-gen.c"
+#line 3533 "src/prebuilt/ast-lexer-gen.cc"
yy505:
yych = *++lexer->cursor;
if (yych <= '@') {
@@ -3576,17 +3576,17 @@ yy506:
}
}
yy507:
-#line 430 "src/ast-lexer.c"
+#line 430 "src/ast-lexer.cc"
{ RETURN(OFFSET); }
-#line 3582 "src/prebuilt/ast-lexer-gen.c"
+#line 3582 "src/prebuilt/ast-lexer-gen.cc"
yy508:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 444 "src/ast-lexer.c"
+#line 444 "src/ast-lexer.cc"
{ RETURN(OUTPUT); }
-#line 3590 "src/prebuilt/ast-lexer-gen.c"
+#line 3590 "src/prebuilt/ast-lexer-gen.cc"
yy510:
yych = *++lexer->cursor;
if (yych == 'e') goto yy661;
@@ -3596,25 +3596,25 @@ yy511:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 421 "src/ast-lexer.c"
+#line 421 "src/ast-lexer.cc"
{ RETURN(RESULT); }
-#line 3602 "src/prebuilt/ast-lexer-gen.c"
+#line 3602 "src/prebuilt/ast-lexer-gen.cc"
yy513:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 256 "src/ast-lexer.c"
+#line 256 "src/ast-lexer.cc"
{ RETURN(RETURN); }
-#line 3610 "src/prebuilt/ast-lexer-gen.c"
+#line 3610 "src/prebuilt/ast-lexer-gen.cc"
yy515:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 414 "src/ast-lexer.c"
+#line 414 "src/ast-lexer.cc"
{ RETURN(SELECT); }
-#line 3618 "src/prebuilt/ast-lexer-gen.c"
+#line 3618 "src/prebuilt/ast-lexer-gen.cc"
yy517:
yych = *++lexer->cursor;
if (yych == 'o') goto yy662;
@@ -3667,9 +3667,9 @@ yy521:
}
}
yy522:
-#line 286 "src/ast-lexer.c"
+#line 286 "src/ast-lexer.cc"
{ TEXT_AT(6); RETURN(ALIGN_EQ_NAT); }
-#line 3673 "src/prebuilt/ast-lexer-gen.c"
+#line 3673 "src/prebuilt/ast-lexer-gen.cc"
yy523:
++lexer->cursor;
if (lexer->limit <= lexer->cursor) FILL(1);
@@ -3718,9 +3718,9 @@ yy525:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 239 "src/ast-lexer.c"
+#line 239 "src/ast-lexer.cc"
{ RETURN(ANYFUNC); }
-#line 3724 "src/prebuilt/ast-lexer-gen.c"
+#line 3724 "src/prebuilt/ast-lexer-gen.cc"
yy527:
yych = *++lexer->cursor;
switch (yych) {
@@ -3753,17 +3753,17 @@ yy532:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 301 "src/ast-lexer.c"
+#line 301 "src/ast-lexer.cc"
{ OPCODE(F32_ABS); RETURN(UNARY); }
-#line 3759 "src/prebuilt/ast-lexer-gen.c"
+#line 3759 "src/prebuilt/ast-lexer-gen.cc"
yy534:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 343 "src/ast-lexer.c"
+#line 343 "src/ast-lexer.cc"
{ OPCODE(F32_ADD); RETURN(BINARY); }
-#line 3767 "src/prebuilt/ast-lexer-gen.c"
+#line 3767 "src/prebuilt/ast-lexer-gen.cc"
yy536:
yych = *++lexer->cursor;
if (yych == 'l') goto yy678;
@@ -3786,9 +3786,9 @@ yy540:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 349 "src/ast-lexer.c"
+#line 349 "src/ast-lexer.cc"
{ OPCODE(F32_DIV); RETURN(BINARY); }
-#line 3792 "src/prebuilt/ast-lexer-gen.c"
+#line 3792 "src/prebuilt/ast-lexer-gen.cc"
yy542:
yych = *++lexer->cursor;
if (yych == 'o') goto yy684;
@@ -3802,25 +3802,25 @@ yy544:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 353 "src/ast-lexer.c"
+#line 353 "src/ast-lexer.cc"
{ OPCODE(F32_MAX); RETURN(BINARY); }
-#line 3808 "src/prebuilt/ast-lexer-gen.c"
+#line 3808 "src/prebuilt/ast-lexer-gen.cc"
yy546:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 351 "src/ast-lexer.c"
+#line 351 "src/ast-lexer.cc"
{ OPCODE(F32_MIN); RETURN(BINARY); }
-#line 3816 "src/prebuilt/ast-lexer-gen.c"
+#line 3816 "src/prebuilt/ast-lexer-gen.cc"
yy548:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 347 "src/ast-lexer.c"
+#line 347 "src/ast-lexer.cc"
{ OPCODE(F32_MUL); RETURN(BINARY); }
-#line 3824 "src/prebuilt/ast-lexer-gen.c"
+#line 3824 "src/prebuilt/ast-lexer-gen.cc"
yy550:
yych = *++lexer->cursor;
if (yych == 'r') goto yy687;
@@ -3830,9 +3830,9 @@ yy551:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 299 "src/ast-lexer.c"
+#line 299 "src/ast-lexer.cc"
{ OPCODE(F32_NEG); RETURN(UNARY); }
-#line 3836 "src/prebuilt/ast-lexer-gen.c"
+#line 3836 "src/prebuilt/ast-lexer-gen.cc"
yy553:
yych = *++lexer->cursor;
if (yych == 'n') goto yy688;
@@ -3850,9 +3850,9 @@ yy556:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 345 "src/ast-lexer.c"
+#line 345 "src/ast-lexer.cc"
{ OPCODE(F32_SUB); RETURN(BINARY); }
-#line 3856 "src/prebuilt/ast-lexer-gen.c"
+#line 3856 "src/prebuilt/ast-lexer-gen.cc"
yy558:
yych = *++lexer->cursor;
if (yych == 'n') goto yy692;
@@ -3862,17 +3862,17 @@ yy559:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 302 "src/ast-lexer.c"
+#line 302 "src/ast-lexer.cc"
{ OPCODE(F64_ABS); RETURN(UNARY); }
-#line 3868 "src/prebuilt/ast-lexer-gen.c"
+#line 3868 "src/prebuilt/ast-lexer-gen.cc"
yy561:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 344 "src/ast-lexer.c"
+#line 344 "src/ast-lexer.cc"
{ OPCODE(F64_ADD); RETURN(BINARY); }
-#line 3876 "src/prebuilt/ast-lexer-gen.c"
+#line 3876 "src/prebuilt/ast-lexer-gen.cc"
yy563:
yych = *++lexer->cursor;
if (yych == 'l') goto yy693;
@@ -3891,9 +3891,9 @@ yy566:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 350 "src/ast-lexer.c"
+#line 350 "src/ast-lexer.cc"
{ OPCODE(F64_DIV); RETURN(BINARY); }
-#line 3897 "src/prebuilt/ast-lexer-gen.c"
+#line 3897 "src/prebuilt/ast-lexer-gen.cc"
yy568:
yych = *++lexer->cursor;
if (yych == 'o') goto yy698;
@@ -3907,25 +3907,25 @@ yy570:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 354 "src/ast-lexer.c"
+#line 354 "src/ast-lexer.cc"
{ OPCODE(F64_MAX); RETURN(BINARY); }
-#line 3913 "src/prebuilt/ast-lexer-gen.c"
+#line 3913 "src/prebuilt/ast-lexer-gen.cc"
yy572:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 352 "src/ast-lexer.c"
+#line 352 "src/ast-lexer.cc"
{ OPCODE(F64_MIN); RETURN(BINARY); }
-#line 3921 "src/prebuilt/ast-lexer-gen.c"
+#line 3921 "src/prebuilt/ast-lexer-gen.cc"
yy574:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 348 "src/ast-lexer.c"
+#line 348 "src/ast-lexer.cc"
{ OPCODE(F64_MUL); RETURN(BINARY); }
-#line 3929 "src/prebuilt/ast-lexer-gen.c"
+#line 3929 "src/prebuilt/ast-lexer-gen.cc"
yy576:
yych = *++lexer->cursor;
if (yych == 'r') goto yy701;
@@ -3935,9 +3935,9 @@ yy577:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 300 "src/ast-lexer.c"
+#line 300 "src/ast-lexer.cc"
{ OPCODE(F64_NEG); RETURN(UNARY); }
-#line 3941 "src/prebuilt/ast-lexer-gen.c"
+#line 3941 "src/prebuilt/ast-lexer-gen.cc"
yy579:
yych = *++lexer->cursor;
if (yych == 'm') goto yy702;
@@ -3959,9 +3959,9 @@ yy583:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 346 "src/ast-lexer.c"
+#line 346 "src/ast-lexer.cc"
{ OPCODE(F64_SUB); RETURN(BINARY); }
-#line 3965 "src/prebuilt/ast-lexer-gen.c"
+#line 3965 "src/prebuilt/ast-lexer-gen.cc"
yy585:
yych = *++lexer->cursor;
if (yych == 'n') goto yy707;
@@ -3983,25 +3983,25 @@ yy589:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 313 "src/ast-lexer.c"
+#line 313 "src/ast-lexer.cc"
{ OPCODE(I32_ADD); RETURN(BINARY); }
-#line 3989 "src/prebuilt/ast-lexer-gen.c"
+#line 3989 "src/prebuilt/ast-lexer-gen.cc"
yy591:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 327 "src/ast-lexer.c"
+#line 327 "src/ast-lexer.cc"
{ OPCODE(I32_AND); RETURN(BINARY); }
-#line 3997 "src/prebuilt/ast-lexer-gen.c"
+#line 3997 "src/prebuilt/ast-lexer-gen.cc"
yy593:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 293 "src/ast-lexer.c"
+#line 293 "src/ast-lexer.cc"
{ OPCODE(I32_CLZ); RETURN(UNARY); }
-#line 4005 "src/prebuilt/ast-lexer-gen.c"
+#line 4005 "src/prebuilt/ast-lexer-gen.cc"
yy595:
yych = *++lexer->cursor;
if (yych == 's') goto yy711;
@@ -4011,9 +4011,9 @@ yy596:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 295 "src/ast-lexer.c"
+#line 295 "src/ast-lexer.cc"
{ OPCODE(I32_CTZ); RETURN(UNARY); }
-#line 4017 "src/prebuilt/ast-lexer-gen.c"
+#line 4017 "src/prebuilt/ast-lexer-gen.cc"
yy598:
yych = *++lexer->cursor;
if (yych == '_') goto yy712;
@@ -4023,9 +4023,9 @@ yy599:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 291 "src/ast-lexer.c"
+#line 291 "src/ast-lexer.cc"
{ OPCODE(I32_EQZ); RETURN(CONVERT); }
-#line 4029 "src/prebuilt/ast-lexer-gen.c"
+#line 4029 "src/prebuilt/ast-lexer-gen.cc"
yy601:
yych = *++lexer->cursor;
if (yych == 's') goto yy713;
@@ -4055,9 +4055,9 @@ yy606:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 317 "src/ast-lexer.c"
+#line 317 "src/ast-lexer.cc"
{ OPCODE(I32_MUL); RETURN(BINARY); }
-#line 4061 "src/prebuilt/ast-lexer-gen.c"
+#line 4061 "src/prebuilt/ast-lexer-gen.cc"
yy608:
yych = *++lexer->cursor;
if (yych == 'c') goto yy731;
@@ -4080,9 +4080,9 @@ yy612:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 333 "src/ast-lexer.c"
+#line 333 "src/ast-lexer.cc"
{ OPCODE(I32_SHL); RETURN(BINARY); }
-#line 4086 "src/prebuilt/ast-lexer-gen.c"
+#line 4086 "src/prebuilt/ast-lexer-gen.cc"
yy614:
yych = *++lexer->cursor;
if (yych == '_') goto yy738;
@@ -4096,9 +4096,9 @@ yy616:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 315 "src/ast-lexer.c"
+#line 315 "src/ast-lexer.cc"
{ OPCODE(I32_SUB); RETURN(BINARY); }
-#line 4102 "src/prebuilt/ast-lexer-gen.c"
+#line 4102 "src/prebuilt/ast-lexer-gen.cc"
yy618:
yych = *++lexer->cursor;
if (yych == 'n') goto yy740;
@@ -4112,33 +4112,33 @@ yy620:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 331 "src/ast-lexer.c"
+#line 331 "src/ast-lexer.cc"
{ OPCODE(I32_XOR); RETURN(BINARY); }
-#line 4118 "src/prebuilt/ast-lexer-gen.c"
+#line 4118 "src/prebuilt/ast-lexer-gen.cc"
yy622:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 314 "src/ast-lexer.c"
+#line 314 "src/ast-lexer.cc"
{ OPCODE(I64_ADD); RETURN(BINARY); }
-#line 4126 "src/prebuilt/ast-lexer-gen.c"
+#line 4126 "src/prebuilt/ast-lexer-gen.cc"
yy624:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 328 "src/ast-lexer.c"
+#line 328 "src/ast-lexer.cc"
{ OPCODE(I64_AND); RETURN(BINARY); }
-#line 4134 "src/prebuilt/ast-lexer-gen.c"
+#line 4134 "src/prebuilt/ast-lexer-gen.cc"
yy626:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 294 "src/ast-lexer.c"
+#line 294 "src/ast-lexer.cc"
{ OPCODE(I64_CLZ); RETURN(UNARY); }
-#line 4142 "src/prebuilt/ast-lexer-gen.c"
+#line 4142 "src/prebuilt/ast-lexer-gen.cc"
yy628:
yych = *++lexer->cursor;
if (yych == 's') goto yy742;
@@ -4148,9 +4148,9 @@ yy629:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 296 "src/ast-lexer.c"
+#line 296 "src/ast-lexer.cc"
{ OPCODE(I64_CTZ); RETURN(UNARY); }
-#line 4154 "src/prebuilt/ast-lexer-gen.c"
+#line 4154 "src/prebuilt/ast-lexer-gen.cc"
yy631:
yych = *++lexer->cursor;
if (yych == '_') goto yy743;
@@ -4160,9 +4160,9 @@ yy632:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 292 "src/ast-lexer.c"
+#line 292 "src/ast-lexer.cc"
{ OPCODE(I64_EQZ); RETURN(CONVERT); }
-#line 4166 "src/prebuilt/ast-lexer-gen.c"
+#line 4166 "src/prebuilt/ast-lexer-gen.cc"
yy634:
yych = *++lexer->cursor;
if (yych == 'e') goto yy744;
@@ -4196,9 +4196,9 @@ yy640:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 318 "src/ast-lexer.c"
+#line 318 "src/ast-lexer.cc"
{ OPCODE(I64_MUL); RETURN(BINARY); }
-#line 4202 "src/prebuilt/ast-lexer-gen.c"
+#line 4202 "src/prebuilt/ast-lexer-gen.cc"
yy642:
yych = *++lexer->cursor;
if (yych == 'c') goto yy763;
@@ -4221,9 +4221,9 @@ yy646:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 334 "src/ast-lexer.c"
+#line 334 "src/ast-lexer.cc"
{ OPCODE(I64_SHL); RETURN(BINARY); }
-#line 4227 "src/prebuilt/ast-lexer-gen.c"
+#line 4227 "src/prebuilt/ast-lexer-gen.cc"
yy648:
yych = *++lexer->cursor;
if (yych == '_') goto yy770;
@@ -4237,9 +4237,9 @@ yy650:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 316 "src/ast-lexer.c"
+#line 316 "src/ast-lexer.cc"
{ OPCODE(I64_SUB); RETURN(BINARY); }
-#line 4243 "src/prebuilt/ast-lexer-gen.c"
+#line 4243 "src/prebuilt/ast-lexer-gen.cc"
yy652:
yych = *++lexer->cursor;
if (yych == 'n') goto yy772;
@@ -4249,17 +4249,17 @@ yy653:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 332 "src/ast-lexer.c"
+#line 332 "src/ast-lexer.cc"
{ OPCODE(I64_XOR); RETURN(BINARY); }
-#line 4255 "src/prebuilt/ast-lexer-gen.c"
+#line 4255 "src/prebuilt/ast-lexer-gen.cc"
yy655:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 244 "src/ast-lexer.c"
+#line 244 "src/ast-lexer.cc"
{ RETURN(IF); }
-#line 4263 "src/prebuilt/ast-lexer-gen.c"
+#line 4263 "src/prebuilt/ast-lexer-gen.cc"
yy657:
yych = *++lexer->cursor;
if (yych == 'y') goto yy773;
@@ -4377,9 +4377,9 @@ yy673:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 250 "src/ast-lexer.c"
+#line 250 "src/ast-lexer.cc"
{ RETURN(BR_TABLE); }
-#line 4383 "src/prebuilt/ast-lexer-gen.c"
+#line 4383 "src/prebuilt/ast-lexer-gen.cc"
yy675:
yych = *++lexer->cursor;
if (yych == 'o') goto yy792;
@@ -4397,9 +4397,9 @@ yy678:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 305 "src/ast-lexer.c"
+#line 305 "src/ast-lexer.cc"
{ OPCODE(F32_CEIL); RETURN(UNARY); }
-#line 4403 "src/prebuilt/ast-lexer-gen.c"
+#line 4403 "src/prebuilt/ast-lexer-gen.cc"
yy680:
yych = *++lexer->cursor;
if (yych == 't') goto yy795;
@@ -4425,9 +4425,9 @@ yy685:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 264 "src/ast-lexer.c"
+#line 264 "src/ast-lexer.cc"
{ OPCODE(F32_LOAD); RETURN(LOAD); }
-#line 4431 "src/prebuilt/ast-lexer-gen.c"
+#line 4431 "src/prebuilt/ast-lexer-gen.cc"
yy687:
yych = *++lexer->cursor;
if (yych == 'e') goto yy802;
@@ -4441,9 +4441,9 @@ yy689:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 303 "src/ast-lexer.c"
+#line 303 "src/ast-lexer.cc"
{ OPCODE(F32_SQRT); RETURN(UNARY); }
-#line 4447 "src/prebuilt/ast-lexer-gen.c"
+#line 4447 "src/prebuilt/ast-lexer-gen.cc"
yy691:
yych = *++lexer->cursor;
if (yych == 'e') goto yy804;
@@ -4457,9 +4457,9 @@ yy693:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 306 "src/ast-lexer.c"
+#line 306 "src/ast-lexer.cc"
{ OPCODE(F64_CEIL); RETURN(UNARY); }
-#line 4463 "src/prebuilt/ast-lexer-gen.c"
+#line 4463 "src/prebuilt/ast-lexer-gen.cc"
yy695:
yych = *++lexer->cursor;
if (yych == 't') goto yy808;
@@ -4481,9 +4481,9 @@ yy699:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 265 "src/ast-lexer.c"
+#line 265 "src/ast-lexer.cc"
{ OPCODE(F64_LOAD); RETURN(LOAD); }
-#line 4487 "src/prebuilt/ast-lexer-gen.c"
+#line 4487 "src/prebuilt/ast-lexer-gen.cc"
yy701:
yych = *++lexer->cursor;
if (yych == 'e') goto yy814;
@@ -4501,9 +4501,9 @@ yy704:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 304 "src/ast-lexer.c"
+#line 304 "src/ast-lexer.cc"
{ OPCODE(F64_SQRT); RETURN(UNARY); }
-#line 4507 "src/prebuilt/ast-lexer-gen.c"
+#line 4507 "src/prebuilt/ast-lexer-gen.cc"
yy706:
yych = *++lexer->cursor;
if (yych == 'e') goto yy817;
@@ -4538,49 +4538,49 @@ yy713:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 373 "src/ast-lexer.c"
+#line 373 "src/ast-lexer.cc"
{ OPCODE(I32_GE_S); RETURN(COMPARE); }
-#line 4544 "src/prebuilt/ast-lexer-gen.c"
+#line 4544 "src/prebuilt/ast-lexer-gen.cc"
yy715:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 375 "src/ast-lexer.c"
+#line 375 "src/ast-lexer.cc"
{ OPCODE(I32_GE_U); RETURN(COMPARE); }
-#line 4552 "src/prebuilt/ast-lexer-gen.c"
+#line 4552 "src/prebuilt/ast-lexer-gen.cc"
yy717:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 369 "src/ast-lexer.c"
+#line 369 "src/ast-lexer.cc"
{ OPCODE(I32_GT_S); RETURN(COMPARE); }
-#line 4560 "src/prebuilt/ast-lexer-gen.c"
+#line 4560 "src/prebuilt/ast-lexer-gen.cc"
yy719:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 371 "src/ast-lexer.c"
+#line 371 "src/ast-lexer.cc"
{ OPCODE(I32_GT_U); RETURN(COMPARE); }
-#line 4568 "src/prebuilt/ast-lexer-gen.c"
+#line 4568 "src/prebuilt/ast-lexer-gen.cc"
yy721:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 365 "src/ast-lexer.c"
+#line 365 "src/ast-lexer.cc"
{ OPCODE(I32_LE_S); RETURN(COMPARE); }
-#line 4576 "src/prebuilt/ast-lexer-gen.c"
+#line 4576 "src/prebuilt/ast-lexer-gen.cc"
yy723:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 367 "src/ast-lexer.c"
+#line 367 "src/ast-lexer.cc"
{ OPCODE(I32_LE_U); RETURN(COMPARE); }
-#line 4584 "src/prebuilt/ast-lexer-gen.c"
+#line 4584 "src/prebuilt/ast-lexer-gen.cc"
yy725:
++lexer->cursor;
if ((yych = *lexer->cursor) <= '8') {
@@ -4616,25 +4616,25 @@ yy725:
}
}
yy726:
-#line 262 "src/ast-lexer.c"
+#line 262 "src/ast-lexer.cc"
{ OPCODE(I32_LOAD); RETURN(LOAD); }
-#line 4622 "src/prebuilt/ast-lexer-gen.c"
+#line 4622 "src/prebuilt/ast-lexer-gen.cc"
yy727:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 361 "src/ast-lexer.c"
+#line 361 "src/ast-lexer.cc"
{ OPCODE(I32_LT_S); RETURN(COMPARE); }
-#line 4630 "src/prebuilt/ast-lexer-gen.c"
+#line 4630 "src/prebuilt/ast-lexer-gen.cc"
yy729:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 363 "src/ast-lexer.c"
+#line 363 "src/ast-lexer.cc"
{ OPCODE(I32_LT_U); RETURN(COMPARE); }
-#line 4638 "src/prebuilt/ast-lexer-gen.c"
+#line 4638 "src/prebuilt/ast-lexer-gen.cc"
yy731:
yych = *++lexer->cursor;
if (yych == 'n') goto yy833;
@@ -4653,17 +4653,17 @@ yy734:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 339 "src/ast-lexer.c"
+#line 339 "src/ast-lexer.cc"
{ OPCODE(I32_ROTL); RETURN(BINARY); }
-#line 4659 "src/prebuilt/ast-lexer-gen.c"
+#line 4659 "src/prebuilt/ast-lexer-gen.cc"
yy736:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 341 "src/ast-lexer.c"
+#line 341 "src/ast-lexer.cc"
{ OPCODE(I32_ROTR); RETURN(BINARY); }
-#line 4667 "src/prebuilt/ast-lexer-gen.c"
+#line 4667 "src/prebuilt/ast-lexer-gen.cc"
yy738:
yych = *++lexer->cursor;
if (yych == 's') goto yy839;
@@ -4699,49 +4699,49 @@ yy745:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 374 "src/ast-lexer.c"
+#line 374 "src/ast-lexer.cc"
{ OPCODE(I64_GE_S); RETURN(COMPARE); }
-#line 4705 "src/prebuilt/ast-lexer-gen.c"
+#line 4705 "src/prebuilt/ast-lexer-gen.cc"
yy747:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 376 "src/ast-lexer.c"
+#line 376 "src/ast-lexer.cc"
{ OPCODE(I64_GE_U); RETURN(COMPARE); }
-#line 4713 "src/prebuilt/ast-lexer-gen.c"
+#line 4713 "src/prebuilt/ast-lexer-gen.cc"
yy749:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 370 "src/ast-lexer.c"
+#line 370 "src/ast-lexer.cc"
{ OPCODE(I64_GT_S); RETURN(COMPARE); }
-#line 4721 "src/prebuilt/ast-lexer-gen.c"
+#line 4721 "src/prebuilt/ast-lexer-gen.cc"
yy751:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 372 "src/ast-lexer.c"
+#line 372 "src/ast-lexer.cc"
{ OPCODE(I64_GT_U); RETURN(COMPARE); }
-#line 4729 "src/prebuilt/ast-lexer-gen.c"
+#line 4729 "src/prebuilt/ast-lexer-gen.cc"
yy753:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 366 "src/ast-lexer.c"
+#line 366 "src/ast-lexer.cc"
{ OPCODE(I64_LE_S); RETURN(COMPARE); }
-#line 4737 "src/prebuilt/ast-lexer-gen.c"
+#line 4737 "src/prebuilt/ast-lexer-gen.cc"
yy755:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 368 "src/ast-lexer.c"
+#line 368 "src/ast-lexer.cc"
{ OPCODE(I64_LE_U); RETURN(COMPARE); }
-#line 4745 "src/prebuilt/ast-lexer-gen.c"
+#line 4745 "src/prebuilt/ast-lexer-gen.cc"
yy757:
++lexer->cursor;
if ((yych = *lexer->cursor) <= '7') {
@@ -4781,25 +4781,25 @@ yy757:
}
}
yy758:
-#line 263 "src/ast-lexer.c"
+#line 263 "src/ast-lexer.cc"
{ OPCODE(I64_LOAD); RETURN(LOAD); }
-#line 4787 "src/prebuilt/ast-lexer-gen.c"
+#line 4787 "src/prebuilt/ast-lexer-gen.cc"
yy759:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 362 "src/ast-lexer.c"
+#line 362 "src/ast-lexer.cc"
{ OPCODE(I64_LT_S); RETURN(COMPARE); }
-#line 4795 "src/prebuilt/ast-lexer-gen.c"
+#line 4795 "src/prebuilt/ast-lexer-gen.cc"
yy761:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 364 "src/ast-lexer.c"
+#line 364 "src/ast-lexer.cc"
{ OPCODE(I64_LT_U); RETURN(COMPARE); }
-#line 4803 "src/prebuilt/ast-lexer-gen.c"
+#line 4803 "src/prebuilt/ast-lexer-gen.cc"
yy763:
yych = *++lexer->cursor;
if (yych == 'n') goto yy857;
@@ -4818,17 +4818,17 @@ yy766:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 340 "src/ast-lexer.c"
+#line 340 "src/ast-lexer.cc"
{ OPCODE(I64_ROTL); RETURN(BINARY); }
-#line 4824 "src/prebuilt/ast-lexer-gen.c"
+#line 4824 "src/prebuilt/ast-lexer-gen.cc"
yy768:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 342 "src/ast-lexer.c"
+#line 342 "src/ast-lexer.cc"
{ OPCODE(I64_ROTR); RETURN(BINARY); }
-#line 4832 "src/prebuilt/ast-lexer-gen.c"
+#line 4832 "src/prebuilt/ast-lexer-gen.cc"
yy770:
yych = *++lexer->cursor;
if (yych == 's') goto yy863;
@@ -4884,9 +4884,9 @@ yy774:
}
}
yy775:
-#line 285 "src/ast-lexer.c"
+#line 285 "src/ast-lexer.cc"
{ TEXT_AT(7); RETURN(OFFSET_EQ_NAT); }
-#line 4890 "src/prebuilt/ast-lexer-gen.c"
+#line 4890 "src/prebuilt/ast-lexer-gen.cc"
yy776:
++lexer->cursor;
if (lexer->limit <= lexer->cursor) FILL(1);
@@ -4935,9 +4935,9 @@ yy778:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 433 "src/ast-lexer.c"
+#line 433 "src/ast-lexer.cc"
{ RETURN(REGISTER); }
-#line 4941 "src/prebuilt/ast-lexer-gen.c"
+#line 4941 "src/prebuilt/ast-lexer-gen.cc"
yy780:
yych = *++lexer->cursor;
if (yych == 'a') goto yy871;
@@ -5041,9 +5041,9 @@ yy795:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 289 "src/ast-lexer.c"
+#line 289 "src/ast-lexer.cc"
{ TYPE(F32); RETURN(CONST); }
-#line 5047 "src/prebuilt/ast-lexer-gen.c"
+#line 5047 "src/prebuilt/ast-lexer-gen.cc"
yy797:
yych = *++lexer->cursor;
if (yych == 'r') goto yy886;
@@ -5061,9 +5061,9 @@ yy800:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 307 "src/ast-lexer.c"
+#line 307 "src/ast-lexer.cc"
{ OPCODE(F32_FLOOR); RETURN(UNARY); }
-#line 5067 "src/prebuilt/ast-lexer-gen.c"
+#line 5067 "src/prebuilt/ast-lexer-gen.cc"
yy802:
yych = *++lexer->cursor;
if (yych == 's') goto yy889;
@@ -5077,25 +5077,25 @@ yy804:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 268 "src/ast-lexer.c"
+#line 268 "src/ast-lexer.cc"
{ OPCODE(F32_STORE); RETURN(STORE); }
-#line 5083 "src/prebuilt/ast-lexer-gen.c"
+#line 5083 "src/prebuilt/ast-lexer-gen.cc"
yy806:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 309 "src/ast-lexer.c"
+#line 309 "src/ast-lexer.cc"
{ OPCODE(F32_TRUNC); RETURN(UNARY); }
-#line 5091 "src/prebuilt/ast-lexer-gen.c"
+#line 5091 "src/prebuilt/ast-lexer-gen.cc"
yy808:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 290 "src/ast-lexer.c"
+#line 290 "src/ast-lexer.cc"
{ TYPE(F64); RETURN(CONST); }
-#line 5099 "src/prebuilt/ast-lexer-gen.c"
+#line 5099 "src/prebuilt/ast-lexer-gen.cc"
yy810:
yych = *++lexer->cursor;
if (yych == 'r') goto yy891;
@@ -5109,9 +5109,9 @@ yy812:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 308 "src/ast-lexer.c"
+#line 308 "src/ast-lexer.cc"
{ OPCODE(F64_FLOOR); RETURN(UNARY); }
-#line 5115 "src/prebuilt/ast-lexer-gen.c"
+#line 5115 "src/prebuilt/ast-lexer-gen.cc"
yy814:
yych = *++lexer->cursor;
if (yych == 's') goto yy893;
@@ -5129,17 +5129,17 @@ yy817:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 269 "src/ast-lexer.c"
+#line 269 "src/ast-lexer.cc"
{ OPCODE(F64_STORE); RETURN(STORE); }
-#line 5135 "src/prebuilt/ast-lexer-gen.c"
+#line 5135 "src/prebuilt/ast-lexer-gen.cc"
yy819:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 310 "src/ast-lexer.c"
+#line 310 "src/ast-lexer.cc"
{ OPCODE(F64_TRUNC); RETURN(UNARY); }
-#line 5143 "src/prebuilt/ast-lexer-gen.c"
+#line 5143 "src/prebuilt/ast-lexer-gen.cc"
yy821:
yych = *++lexer->cursor;
if (yych == 'l') goto yy896;
@@ -5149,9 +5149,9 @@ yy822:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 257 "src/ast-lexer.c"
+#line 257 "src/ast-lexer.cc"
{ RETURN(GET_LOCAL); }
-#line 5155 "src/prebuilt/ast-lexer-gen.c"
+#line 5155 "src/prebuilt/ast-lexer-gen.cc"
yy824:
yych = *++lexer->cursor;
if (yych == 'r') goto yy898;
@@ -5161,25 +5161,25 @@ yy825:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 287 "src/ast-lexer.c"
+#line 287 "src/ast-lexer.cc"
{ TYPE(I32); RETURN(CONST); }
-#line 5167 "src/prebuilt/ast-lexer-gen.c"
+#line 5167 "src/prebuilt/ast-lexer-gen.cc"
yy827:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 319 "src/ast-lexer.c"
+#line 319 "src/ast-lexer.cc"
{ OPCODE(I32_DIV_S); RETURN(BINARY); }
-#line 5175 "src/prebuilt/ast-lexer-gen.c"
+#line 5175 "src/prebuilt/ast-lexer-gen.cc"
yy829:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 321 "src/ast-lexer.c"
+#line 321 "src/ast-lexer.cc"
{ OPCODE(I32_DIV_U); RETURN(BINARY); }
-#line 5183 "src/prebuilt/ast-lexer-gen.c"
+#line 5183 "src/prebuilt/ast-lexer-gen.cc"
yy831:
yych = *++lexer->cursor;
if (yych == '6') goto yy899;
@@ -5201,33 +5201,33 @@ yy835:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 323 "src/ast-lexer.c"
+#line 323 "src/ast-lexer.cc"
{ OPCODE(I32_REM_S); RETURN(BINARY); }
-#line 5207 "src/prebuilt/ast-lexer-gen.c"
+#line 5207 "src/prebuilt/ast-lexer-gen.cc"
yy837:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 325 "src/ast-lexer.c"
+#line 325 "src/ast-lexer.cc"
{ OPCODE(I32_REM_U); RETURN(BINARY); }
-#line 5215 "src/prebuilt/ast-lexer-gen.c"
+#line 5215 "src/prebuilt/ast-lexer-gen.cc"
yy839:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 335 "src/ast-lexer.c"
+#line 335 "src/ast-lexer.cc"
{ OPCODE(I32_SHR_S); RETURN(BINARY); }
-#line 5223 "src/prebuilt/ast-lexer-gen.c"
+#line 5223 "src/prebuilt/ast-lexer-gen.cc"
yy841:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 337 "src/ast-lexer.c"
+#line 337 "src/ast-lexer.cc"
{ OPCODE(I32_SHR_U); RETURN(BINARY); }
-#line 5231 "src/prebuilt/ast-lexer-gen.c"
+#line 5231 "src/prebuilt/ast-lexer-gen.cc"
yy843:
++lexer->cursor;
if ((yych = *lexer->cursor) <= '8') {
@@ -5263,9 +5263,9 @@ yy843:
}
}
yy844:
-#line 266 "src/ast-lexer.c"
+#line 266 "src/ast-lexer.cc"
{ OPCODE(I32_STORE); RETURN(STORE); }
-#line 5269 "src/prebuilt/ast-lexer-gen.c"
+#line 5269 "src/prebuilt/ast-lexer-gen.cc"
yy845:
yych = *++lexer->cursor;
if (yych == '_') goto yy907;
@@ -5279,25 +5279,25 @@ yy847:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 288 "src/ast-lexer.c"
+#line 288 "src/ast-lexer.cc"
{ TYPE(I64); RETURN(CONST); }
-#line 5285 "src/prebuilt/ast-lexer-gen.c"
+#line 5285 "src/prebuilt/ast-lexer-gen.cc"
yy849:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 320 "src/ast-lexer.c"
+#line 320 "src/ast-lexer.cc"
{ OPCODE(I64_DIV_S); RETURN(BINARY); }
-#line 5293 "src/prebuilt/ast-lexer-gen.c"
+#line 5293 "src/prebuilt/ast-lexer-gen.cc"
yy851:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 322 "src/ast-lexer.c"
+#line 322 "src/ast-lexer.cc"
{ OPCODE(I64_DIV_U); RETURN(BINARY); }
-#line 5301 "src/prebuilt/ast-lexer-gen.c"
+#line 5301 "src/prebuilt/ast-lexer-gen.cc"
yy853:
yych = *++lexer->cursor;
if (yych == 'd') goto yy909;
@@ -5327,33 +5327,33 @@ yy859:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 324 "src/ast-lexer.c"
+#line 324 "src/ast-lexer.cc"
{ OPCODE(I64_REM_S); RETURN(BINARY); }
-#line 5333 "src/prebuilt/ast-lexer-gen.c"
+#line 5333 "src/prebuilt/ast-lexer-gen.cc"
yy861:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 326 "src/ast-lexer.c"
+#line 326 "src/ast-lexer.cc"
{ OPCODE(I64_REM_U); RETURN(BINARY); }
-#line 5341 "src/prebuilt/ast-lexer-gen.c"
+#line 5341 "src/prebuilt/ast-lexer-gen.cc"
yy863:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 336 "src/ast-lexer.c"
+#line 336 "src/ast-lexer.cc"
{ OPCODE(I64_SHR_S); RETURN(BINARY); }
-#line 5349 "src/prebuilt/ast-lexer-gen.c"
+#line 5349 "src/prebuilt/ast-lexer-gen.cc"
yy865:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 338 "src/ast-lexer.c"
+#line 338 "src/ast-lexer.cc"
{ OPCODE(I64_SHR_U); RETURN(BINARY); }
-#line 5357 "src/prebuilt/ast-lexer-gen.c"
+#line 5357 "src/prebuilt/ast-lexer-gen.cc"
yy867:
++lexer->cursor;
if ((yych = *lexer->cursor) <= '7') {
@@ -5393,9 +5393,9 @@ yy867:
}
}
yy868:
-#line 267 "src/ast-lexer.c"
+#line 267 "src/ast-lexer.cc"
{ OPCODE(I64_STORE); RETURN(STORE); }
-#line 5399 "src/prebuilt/ast-lexer-gen.c"
+#line 5399 "src/prebuilt/ast-lexer-gen.cc"
yy869:
yych = *++lexer->cursor;
if (yych == '_') goto yy920;
@@ -5421,17 +5421,17 @@ yy872:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 258 "src/ast-lexer.c"
+#line 258 "src/ast-lexer.cc"
{ RETURN(SET_LOCAL); }
-#line 5427 "src/prebuilt/ast-lexer-gen.c"
+#line 5427 "src/prebuilt/ast-lexer-gen.cc"
yy874:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 259 "src/ast-lexer.c"
+#line 259 "src/ast-lexer.cc"
{ RETURN(TEE_LOCAL); }
-#line 5435 "src/prebuilt/ast-lexer-gen.c"
+#line 5435 "src/prebuilt/ast-lexer-gen.cc"
yy876:
yych = *++lexer->cursor;
if (yych == 'l') goto yy925;
@@ -5517,9 +5517,9 @@ yy896:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 260 "src/ast-lexer.c"
+#line 260 "src/ast-lexer.cc"
{ RETURN(GET_GLOBAL); }
-#line 5523 "src/prebuilt/ast-lexer-gen.c"
+#line 5523 "src/prebuilt/ast-lexer-gen.cc"
yy898:
yych = *++lexer->cursor;
if (yych == 'y') goto yy949;
@@ -5538,9 +5538,9 @@ yy901:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 297 "src/ast-lexer.c"
+#line 297 "src/ast-lexer.cc"
{ OPCODE(I32_POPCNT); RETURN(UNARY); }
-#line 5544 "src/prebuilt/ast-lexer-gen.c"
+#line 5544 "src/prebuilt/ast-lexer-gen.cc"
yy903:
yych = *++lexer->cursor;
if (yych == 'r') goto yy956;
@@ -5554,9 +5554,9 @@ yy905:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 280 "src/ast-lexer.c"
+#line 280 "src/ast-lexer.cc"
{ OPCODE(I32_STORE8); RETURN(STORE); }
-#line 5560 "src/prebuilt/ast-lexer-gen.c"
+#line 5560 "src/prebuilt/ast-lexer-gen.cc"
yy907:
yych = *++lexer->cursor;
if (yych == 's') goto yy959;
@@ -5588,9 +5588,9 @@ yy913:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 298 "src/ast-lexer.c"
+#line 298 "src/ast-lexer.cc"
{ OPCODE(I64_POPCNT); RETURN(UNARY); }
-#line 5594 "src/prebuilt/ast-lexer-gen.c"
+#line 5594 "src/prebuilt/ast-lexer-gen.cc"
yy915:
yych = *++lexer->cursor;
if (yych == 'r') goto yy969;
@@ -5608,9 +5608,9 @@ yy918:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 281 "src/ast-lexer.c"
+#line 281 "src/ast-lexer.cc"
{ OPCODE(I64_STORE8); RETURN(STORE); }
-#line 5614 "src/prebuilt/ast-lexer-gen.c"
+#line 5614 "src/prebuilt/ast-lexer-gen.cc"
yy920:
yych = *++lexer->cursor;
if (yych == 's') goto yy974;
@@ -5667,9 +5667,9 @@ yy923:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 261 "src/ast-lexer.c"
+#line 261 "src/ast-lexer.cc"
{ RETURN(SET_GLOBAL); }
-#line 5673 "src/prebuilt/ast-lexer-gen.c"
+#line 5673 "src/prebuilt/ast-lexer-gen.cc"
yy925:
yych = *++lexer->cursor;
if (yych == 'e') goto yy976;
@@ -5695,9 +5695,9 @@ yy930:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 441 "src/ast-lexer.c"
+#line 441 "src/ast-lexer.cc"
{ RETURN(ASSERT_TRAP); }
-#line 5701 "src/prebuilt/ast-lexer-gen.c"
+#line 5701 "src/prebuilt/ast-lexer-gen.cc"
yy932:
yych = *++lexer->cursor;
if (yych == 'n') goto yy982;
@@ -5707,9 +5707,9 @@ yy933:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 252 "src/ast-lexer.c"
+#line 252 "src/ast-lexer.cc"
{ RETURN(CALL_IMPORT); }
-#line 5713 "src/prebuilt/ast-lexer-gen.c"
+#line 5713 "src/prebuilt/ast-lexer-gen.cc"
yy935:
yych = *++lexer->cursor;
if (yych == 'c') goto yy983;
@@ -5735,9 +5735,9 @@ yy940:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 311 "src/ast-lexer.c"
+#line 311 "src/ast-lexer.cc"
{ OPCODE(F32_NEAREST); RETURN(UNARY); }
-#line 5741 "src/prebuilt/ast-lexer-gen.c"
+#line 5741 "src/prebuilt/ast-lexer-gen.cc"
yy942:
yych = *++lexer->cursor;
if (yych == 'p') goto yy989;
@@ -5755,9 +5755,9 @@ yy945:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 312 "src/ast-lexer.c"
+#line 312 "src/ast-lexer.cc"
{ OPCODE(F64_NEAREST); RETURN(UNARY); }
-#line 5761 "src/prebuilt/ast-lexer-gen.c"
+#line 5761 "src/prebuilt/ast-lexer-gen.cc"
yy947:
yych = *++lexer->cursor;
if (yych == '/') goto yy993;
@@ -5771,9 +5771,9 @@ yy949:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 417 "src/ast-lexer.c"
+#line 417 "src/ast-lexer.cc"
{ RETURN(GROW_MEMORY); }
-#line 5777 "src/prebuilt/ast-lexer-gen.c"
+#line 5777 "src/prebuilt/ast-lexer-gen.cc"
yy951:
yych = *++lexer->cursor;
if (yych == 's') goto yy995;
@@ -5784,17 +5784,17 @@ yy952:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 270 "src/ast-lexer.c"
+#line 270 "src/ast-lexer.cc"
{ OPCODE(I32_LOAD8_S); RETURN(LOAD); }
-#line 5790 "src/prebuilt/ast-lexer-gen.c"
+#line 5790 "src/prebuilt/ast-lexer-gen.cc"
yy954:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 272 "src/ast-lexer.c"
+#line 272 "src/ast-lexer.cc"
{ OPCODE(I32_LOAD8_U); RETURN(LOAD); }
-#line 5798 "src/prebuilt/ast-lexer-gen.c"
+#line 5798 "src/prebuilt/ast-lexer-gen.cc"
yy956:
yych = *++lexer->cursor;
if (yych == 'p') goto yy999;
@@ -5804,9 +5804,9 @@ yy957:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 282 "src/ast-lexer.c"
+#line 282 "src/ast-lexer.cc"
{ OPCODE(I32_STORE16); RETURN(STORE); }
-#line 5810 "src/prebuilt/ast-lexer-gen.c"
+#line 5810 "src/prebuilt/ast-lexer-gen.cc"
yy959:
yych = *++lexer->cursor;
if (yych == '/') goto yy1000;
@@ -5839,17 +5839,17 @@ yy965:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 271 "src/ast-lexer.c"
+#line 271 "src/ast-lexer.cc"
{ OPCODE(I64_LOAD8_S); RETURN(LOAD); }
-#line 5845 "src/prebuilt/ast-lexer-gen.c"
+#line 5845 "src/prebuilt/ast-lexer-gen.cc"
yy967:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 273 "src/ast-lexer.c"
+#line 273 "src/ast-lexer.cc"
{ OPCODE(I64_LOAD8_U); RETURN(LOAD); }
-#line 5853 "src/prebuilt/ast-lexer-gen.c"
+#line 5853 "src/prebuilt/ast-lexer-gen.cc"
yy969:
yych = *++lexer->cursor;
if (yych == 'p') goto yy1014;
@@ -5859,17 +5859,17 @@ yy970:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 283 "src/ast-lexer.c"
+#line 283 "src/ast-lexer.cc"
{ OPCODE(I64_STORE16); RETURN(STORE); }
-#line 5865 "src/prebuilt/ast-lexer-gen.c"
+#line 5865 "src/prebuilt/ast-lexer-gen.cc"
yy972:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 284 "src/ast-lexer.c"
+#line 284 "src/ast-lexer.cc"
{ OPCODE(I64_STORE32); RETURN(STORE); }
-#line 5873 "src/prebuilt/ast-lexer-gen.c"
+#line 5873 "src/prebuilt/ast-lexer-gen.cc"
yy974:
yych = *++lexer->cursor;
if (yych == '/') goto yy1015;
@@ -5883,9 +5883,9 @@ yy976:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 415 "src/ast-lexer.c"
+#line 415 "src/ast-lexer.cc"
{ RETURN(UNREACHABLE); }
-#line 5889 "src/prebuilt/ast-lexer-gen.c"
+#line 5889 "src/prebuilt/ast-lexer-gen.cc"
yy978:
yych = *++lexer->cursor;
if (yych == 's') goto yy1017;
@@ -5924,9 +5924,9 @@ yy986:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 355 "src/ast-lexer.c"
+#line 355 "src/ast-lexer.cc"
{ OPCODE(F32_COPYSIGN); RETURN(BINARY); }
-#line 5930 "src/prebuilt/ast-lexer-gen.c"
+#line 5930 "src/prebuilt/ast-lexer-gen.cc"
yy988:
yych = *++lexer->cursor;
if (yych == '6') goto yy1028;
@@ -5945,9 +5945,9 @@ yy991:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 356 "src/ast-lexer.c"
+#line 356 "src/ast-lexer.cc"
{ OPCODE(F64_COPYSIGN); RETURN(BINARY); }
-#line 5951 "src/prebuilt/ast-lexer-gen.c"
+#line 5951 "src/prebuilt/ast-lexer-gen.cc"
yy993:
yych = *++lexer->cursor;
if (yych == 'f') goto yy1032;
@@ -5961,17 +5961,17 @@ yy995:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 274 "src/ast-lexer.c"
+#line 274 "src/ast-lexer.cc"
{ OPCODE(I32_LOAD16_S); RETURN(LOAD); }
-#line 5967 "src/prebuilt/ast-lexer-gen.c"
+#line 5967 "src/prebuilt/ast-lexer-gen.cc"
yy997:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 276 "src/ast-lexer.c"
+#line 276 "src/ast-lexer.cc"
{ OPCODE(I32_LOAD16_U); RETURN(LOAD); }
-#line 5975 "src/prebuilt/ast-lexer-gen.c"
+#line 5975 "src/prebuilt/ast-lexer-gen.cc"
yy999:
yych = *++lexer->cursor;
if (yych == 'r') goto yy1034;
@@ -5989,9 +5989,9 @@ yy1002:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 391 "src/ast-lexer.c"
+#line 391 "src/ast-lexer.cc"
{ OPCODE(I32_WRAP_I64); RETURN(CONVERT); }
-#line 5995 "src/prebuilt/ast-lexer-gen.c"
+#line 5995 "src/prebuilt/ast-lexer-gen.cc"
yy1004:
yych = *++lexer->cursor;
if (yych == '/') goto yy1037;
@@ -6005,33 +6005,33 @@ yy1006:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 275 "src/ast-lexer.c"
+#line 275 "src/ast-lexer.cc"
{ OPCODE(I64_LOAD16_S); RETURN(LOAD); }
-#line 6011 "src/prebuilt/ast-lexer-gen.c"
+#line 6011 "src/prebuilt/ast-lexer-gen.cc"
yy1008:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 277 "src/ast-lexer.c"
+#line 277 "src/ast-lexer.cc"
{ OPCODE(I64_LOAD16_U); RETURN(LOAD); }
-#line 6019 "src/prebuilt/ast-lexer-gen.c"
+#line 6019 "src/prebuilt/ast-lexer-gen.cc"
yy1010:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 278 "src/ast-lexer.c"
+#line 278 "src/ast-lexer.cc"
{ OPCODE(I64_LOAD32_S); RETURN(LOAD); }
-#line 6027 "src/prebuilt/ast-lexer-gen.c"
+#line 6027 "src/prebuilt/ast-lexer-gen.cc"
yy1012:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 279 "src/ast-lexer.c"
+#line 279 "src/ast-lexer.cc"
{ OPCODE(I64_LOAD32_U); RETURN(LOAD); }
-#line 6035 "src/prebuilt/ast-lexer-gen.c"
+#line 6035 "src/prebuilt/ast-lexer-gen.cc"
yy1014:
yych = *++lexer->cursor;
if (yych == 'r') goto yy1039;
@@ -6091,9 +6091,9 @@ yy1020:
}
}
yy1021:
-#line 439 "src/ast-lexer.c"
+#line 439 "src/ast-lexer.cc"
{ RETURN(ASSERT_RETURN); }
-#line 6097 "src/prebuilt/ast-lexer-gen.c"
+#line 6097 "src/prebuilt/ast-lexer-gen.cc"
yy1022:
yych = *++lexer->cursor;
if (yych == 'a') goto yy1047;
@@ -6103,9 +6103,9 @@ yy1023:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 253 "src/ast-lexer.c"
+#line 253 "src/ast-lexer.cc"
{ RETURN(CALL_INDIRECT); }
-#line 6109 "src/prebuilt/ast-lexer-gen.c"
+#line 6109 "src/prebuilt/ast-lexer-gen.cc"
yy1025:
yych = *++lexer->cursor;
if (yych == 'y') goto yy1048;
@@ -6187,9 +6187,9 @@ yy1043:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 437 "src/ast-lexer.c"
+#line 437 "src/ast-lexer.cc"
{ RETURN(ASSERT_INVALID); }
-#line 6193 "src/prebuilt/ast-lexer-gen.c"
+#line 6193 "src/prebuilt/ast-lexer-gen.cc"
yy1045:
yych = *++lexer->cursor;
if (yych == 'e') goto yy1072;
@@ -6207,9 +6207,9 @@ yy1048:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 416 "src/ast-lexer.c"
+#line 416 "src/ast-lexer.cc"
{ RETURN(CURRENT_MEMORY); }
-#line 6213 "src/prebuilt/ast-lexer-gen.c"
+#line 6213 "src/prebuilt/ast-lexer-gen.cc"
yy1050:
yych = *++lexer->cursor;
if (yych == 'i') goto yy1075;
@@ -6223,9 +6223,9 @@ yy1052:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 409 "src/ast-lexer.c"
+#line 409 "src/ast-lexer.cc"
{ OPCODE(F32_DEMOTE_F64); RETURN(CONVERT); }
-#line 6229 "src/prebuilt/ast-lexer-gen.c"
+#line 6229 "src/prebuilt/ast-lexer-gen.cc"
yy1054:
yych = *++lexer->cursor;
if (yych == 't') goto yy1077;
@@ -6339,9 +6339,9 @@ yy1080:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 408 "src/ast-lexer.c"
+#line 408 "src/ast-lexer.cc"
{ OPCODE(F64_PROMOTE_F32); RETURN(CONVERT); }
-#line 6345 "src/prebuilt/ast-lexer-gen.c"
+#line 6345 "src/prebuilt/ast-lexer-gen.cc"
yy1082:
yych = *++lexer->cursor;
if (yych == '/') goto yy1117;
@@ -6355,33 +6355,33 @@ yy1084:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 392 "src/ast-lexer.c"
+#line 392 "src/ast-lexer.cc"
{ OPCODE(I32_TRUNC_S_F32); RETURN(CONVERT); }
-#line 6361 "src/prebuilt/ast-lexer-gen.c"
+#line 6361 "src/prebuilt/ast-lexer-gen.cc"
yy1086:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 394 "src/ast-lexer.c"
+#line 394 "src/ast-lexer.cc"
{ OPCODE(I32_TRUNC_S_F64); RETURN(CONVERT); }
-#line 6369 "src/prebuilt/ast-lexer-gen.c"
+#line 6369 "src/prebuilt/ast-lexer-gen.cc"
yy1088:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 396 "src/ast-lexer.c"
+#line 396 "src/ast-lexer.cc"
{ OPCODE(I32_TRUNC_U_F32); RETURN(CONVERT); }
-#line 6377 "src/prebuilt/ast-lexer-gen.c"
+#line 6377 "src/prebuilt/ast-lexer-gen.cc"
yy1090:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 398 "src/ast-lexer.c"
+#line 398 "src/ast-lexer.cc"
{ OPCODE(I32_TRUNC_U_F64); RETURN(CONVERT); }
-#line 6385 "src/prebuilt/ast-lexer-gen.c"
+#line 6385 "src/prebuilt/ast-lexer-gen.cc"
yy1092:
yych = *++lexer->cursor;
if (yych == '2') goto yy1119;
@@ -6399,33 +6399,33 @@ yy1095:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 393 "src/ast-lexer.c"
+#line 393 "src/ast-lexer.cc"
{ OPCODE(I64_TRUNC_S_F32); RETURN(CONVERT); }
-#line 6405 "src/prebuilt/ast-lexer-gen.c"
+#line 6405 "src/prebuilt/ast-lexer-gen.cc"
yy1097:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 395 "src/ast-lexer.c"
+#line 395 "src/ast-lexer.cc"
{ OPCODE(I64_TRUNC_S_F64); RETURN(CONVERT); }
-#line 6413 "src/prebuilt/ast-lexer-gen.c"
+#line 6413 "src/prebuilt/ast-lexer-gen.cc"
yy1099:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 397 "src/ast-lexer.c"
+#line 397 "src/ast-lexer.cc"
{ OPCODE(I64_TRUNC_U_F32); RETURN(CONVERT); }
-#line 6421 "src/prebuilt/ast-lexer-gen.c"
+#line 6421 "src/prebuilt/ast-lexer-gen.cc"
yy1101:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 399 "src/ast-lexer.c"
+#line 399 "src/ast-lexer.cc"
{ OPCODE(I64_TRUNC_U_F64); RETURN(CONVERT); }
-#line 6429 "src/prebuilt/ast-lexer-gen.c"
+#line 6429 "src/prebuilt/ast-lexer-gen.cc"
yy1103:
yych = *++lexer->cursor;
if (yych == 'n') goto yy1124;
@@ -6435,9 +6435,9 @@ yy1104:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 436 "src/ast-lexer.c"
+#line 436 "src/ast-lexer.cc"
{ RETURN(ASSERT_MALFORMED); }
-#line 6441 "src/prebuilt/ast-lexer-gen.c"
+#line 6441 "src/prebuilt/ast-lexer-gen.cc"
yy1106:
yych = *++lexer->cursor;
if (yych == 'n') goto yy1126;
@@ -6495,17 +6495,17 @@ yy1119:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 389 "src/ast-lexer.c"
+#line 389 "src/ast-lexer.cc"
{ OPCODE(I64_EXTEND_S_I32); RETURN(CONVERT); }
-#line 6501 "src/prebuilt/ast-lexer-gen.c"
+#line 6501 "src/prebuilt/ast-lexer-gen.cc"
yy1121:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 390 "src/ast-lexer.c"
+#line 390 "src/ast-lexer.cc"
{ OPCODE(I64_EXTEND_U_I32); RETURN(CONVERT); }
-#line 6509 "src/prebuilt/ast-lexer-gen.c"
+#line 6509 "src/prebuilt/ast-lexer-gen.cc"
yy1123:
yych = *++lexer->cursor;
if (yych == 'f') goto yy1149;
@@ -6515,57 +6515,57 @@ yy1124:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 442 "src/ast-lexer.c"
+#line 442 "src/ast-lexer.cc"
{ RETURN(ASSERT_EXHAUSTION); }
-#line 6521 "src/prebuilt/ast-lexer-gen.c"
+#line 6521 "src/prebuilt/ast-lexer-gen.cc"
yy1126:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 440 "src/ast-lexer.c"
+#line 440 "src/ast-lexer.cc"
{ RETURN(ASSERT_RETURN_NAN); }
-#line 6529 "src/prebuilt/ast-lexer-gen.c"
+#line 6529 "src/prebuilt/ast-lexer-gen.cc"
yy1128:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 438 "src/ast-lexer.c"
+#line 438 "src/ast-lexer.cc"
{ RETURN(ASSERT_UNLINKABLE); }
-#line 6537 "src/prebuilt/ast-lexer-gen.c"
+#line 6537 "src/prebuilt/ast-lexer-gen.cc"
yy1130:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 400 "src/ast-lexer.c"
+#line 400 "src/ast-lexer.cc"
{ OPCODE(F32_CONVERT_S_I32); RETURN(CONVERT); }
-#line 6545 "src/prebuilt/ast-lexer-gen.c"
+#line 6545 "src/prebuilt/ast-lexer-gen.cc"
yy1132:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 402 "src/ast-lexer.c"
+#line 402 "src/ast-lexer.cc"
{ OPCODE(F32_CONVERT_S_I64); RETURN(CONVERT); }
-#line 6553 "src/prebuilt/ast-lexer-gen.c"
+#line 6553 "src/prebuilt/ast-lexer-gen.cc"
yy1134:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 404 "src/ast-lexer.c"
+#line 404 "src/ast-lexer.cc"
{ OPCODE(F32_CONVERT_U_I32); RETURN(CONVERT); }
-#line 6561 "src/prebuilt/ast-lexer-gen.c"
+#line 6561 "src/prebuilt/ast-lexer-gen.cc"
yy1136:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 406 "src/ast-lexer.c"
+#line 406 "src/ast-lexer.cc"
{ OPCODE(F32_CONVERT_U_I64); RETURN(CONVERT); }
-#line 6569 "src/prebuilt/ast-lexer-gen.c"
+#line 6569 "src/prebuilt/ast-lexer-gen.cc"
yy1138:
yych = *++lexer->cursor;
if (yych == '3') goto yy1150;
@@ -6575,33 +6575,33 @@ yy1139:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 401 "src/ast-lexer.c"
+#line 401 "src/ast-lexer.cc"
{ OPCODE(F64_CONVERT_S_I32); RETURN(CONVERT); }
-#line 6581 "src/prebuilt/ast-lexer-gen.c"
+#line 6581 "src/prebuilt/ast-lexer-gen.cc"
yy1141:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 403 "src/ast-lexer.c"
+#line 403 "src/ast-lexer.cc"
{ OPCODE(F64_CONVERT_S_I64); RETURN(CONVERT); }
-#line 6589 "src/prebuilt/ast-lexer-gen.c"
+#line 6589 "src/prebuilt/ast-lexer-gen.cc"
yy1143:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 405 "src/ast-lexer.c"
+#line 405 "src/ast-lexer.cc"
{ OPCODE(F64_CONVERT_U_I32); RETURN(CONVERT); }
-#line 6597 "src/prebuilt/ast-lexer-gen.c"
+#line 6597 "src/prebuilt/ast-lexer-gen.cc"
yy1145:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 407 "src/ast-lexer.c"
+#line 407 "src/ast-lexer.cc"
{ OPCODE(F64_CONVERT_U_I64); RETURN(CONVERT); }
-#line 6605 "src/prebuilt/ast-lexer-gen.c"
+#line 6605 "src/prebuilt/ast-lexer-gen.cc"
yy1147:
yych = *++lexer->cursor;
if (yych == '6') goto yy1151;
@@ -6635,43 +6635,43 @@ yy1154:
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 410 "src/ast-lexer.c"
+#line 410 "src/ast-lexer.cc"
{ OPCODE(F32_REINTERPRET_I32); RETURN(CONVERT); }
-#line 6641 "src/prebuilt/ast-lexer-gen.c"
+#line 6641 "src/prebuilt/ast-lexer-gen.cc"
yy1156:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 412 "src/ast-lexer.c"
+#line 412 "src/ast-lexer.cc"
{ OPCODE(F64_REINTERPRET_I64); RETURN(CONVERT); }
-#line 6649 "src/prebuilt/ast-lexer-gen.c"
+#line 6649 "src/prebuilt/ast-lexer-gen.cc"
yy1158:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 411 "src/ast-lexer.c"
+#line 411 "src/ast-lexer.cc"
{ OPCODE(I32_REINTERPRET_F32); RETURN(CONVERT); }
-#line 6657 "src/prebuilt/ast-lexer-gen.c"
+#line 6657 "src/prebuilt/ast-lexer-gen.cc"
yy1160:
++lexer->cursor;
if (yybm[0+(yych = *lexer->cursor)] & 16) {
goto yy49;
}
-#line 413 "src/ast-lexer.c"
+#line 413 "src/ast-lexer.cc"
{ OPCODE(I64_REINTERPRET_F64); RETURN(CONVERT); }
-#line 6665 "src/prebuilt/ast-lexer-gen.c"
+#line 6665 "src/prebuilt/ast-lexer-gen.cc"
}
}
-#line 465 "src/ast-lexer.c"
+#line 465 "src/ast-lexer.cc"
}
}
static WabtAstLexer* wabt_new_lexer(WabtAstLexerSourceType type,
const char* filename) {
- WabtAstLexer* lexer = wabt_alloc_zero(sizeof(WabtAstLexer));
+ WabtAstLexer* lexer = (WabtAstLexer*)wabt_alloc_zero(sizeof(WabtAstLexer));
lexer->line = 1;
lexer->filename = filename;
lexer->source.type = type;
@@ -6722,7 +6722,7 @@ static WabtResult scan_forward_for_line_offset_in_buffer(
int line = buffer_line;
int line_offset = 0;
const char* p;
- WabtBool is_previous_carriage = 0;
+ bool is_previous_carriage = 0;
for (p = buffer_start; p < buffer_end; ++p) {
if (*p == '\n') {
if (find_position == WABT_LINE_OFFSET_POSITION_START) {
@@ -6812,7 +6812,7 @@ static WabtResult scan_forward_for_line_offset(
size_t* out_line_offset) {
assert(line <= find_line);
if (lexer->source.type == WABT_LEXER_SOURCE_TYPE_BUFFER) {
- const char* source_buffer = lexer->source.buffer.data;
+ const char* source_buffer = (const char*)lexer->source.buffer.data;
const char* buffer_start = source_buffer + line_start_offset;
const char* buffer_end = source_buffer + lexer->source.buffer.size;
return scan_forward_for_line_offset_in_buffer(
@@ -6917,8 +6917,8 @@ WabtResult wabt_ast_lexer_get_source_line(WabtAstLexer* lexer,
clamp_source_line_offsets_to_location(line_start, line_end, loc->first_column,
loc->last_column, line_max_length,
&new_line_start, &new_line_end);
- WabtBool has_start_ellipsis = line_start != new_line_start;
- WabtBool has_end_ellipsis = line_end != new_line_end;
+ bool has_start_ellipsis = line_start != new_line_start;
+ bool has_end_ellipsis = line_end != new_line_end;
char* write_start = line;
size_t line_length = new_line_end - new_line_start;
diff --git a/src/prebuilt/ast-parser-gen.c b/src/prebuilt/ast-parser-gen.cc
index be963467..f8544a3c 100644
--- a/src/prebuilt/ast-parser-gen.c
+++ b/src/prebuilt/ast-parser-gen.cc
@@ -85,16 +85,26 @@
#define INVALID_VAR_INDEX (-1)
-/* the default value for YYMAXDEPTH is 10000, which can be easily hit since our
- grammar is right-recursive.
+#define RELOCATE_STACK(type, array, stack_base, old_byte_size, new_size) \
+ do { \
+ if ((stack_base) == (array)) { \
+ (stack_base) = (type*)wabt_alloc((new_size) * sizeof(*(stack_base))); \
+ memcpy((stack_base), (array), old_byte_size); \
+ } else { \
+ (stack_base) = (type*)wabt_realloc((stack_base), \
+ (new_size) * sizeof(*(stack_base))); \
+ } \
+ /* Cache the pointer in the parser struct to be free'd later. */ \
+ parser->array = (stack_base); \
+ } while (0)
- we can increase YYMAXDEPTH, but the generated parser says that "results are
- undefined" if YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES(YYMAXDEPTH) with
- infinite-precision arithmetic. That's tricky to write a static assertion
- for, so let's "just" limit YYSTACK_BYTES(YYMAXDEPTH) to UINT32_MAX and use
- 64-bit arithmetic. this static assert is done at the end of the file, so all
- defines are available. */
-#define YYMAXDEPTH 10000000
+#define yyoverflow(message, ss, ss_size, vs, vs_size, ls, ls_size, new_size) \
+ do { \
+ *(new_size) *= 2; \
+ RELOCATE_STACK(yytype_int16, yyssa, *(ss), (ss_size), *(new_size)); \
+ RELOCATE_STACK(YYSTYPE, yyvsa, *(vs), (vs_size), *(new_size)); \
+ RELOCATE_STACK(YYLTYPE, yylsa, *(ls), (ls_size), *(new_size)); \
+ } while (0)
#define DUPTEXT(dst, src) \
(dst).start = wabt_strndup((src).start, (src).length); \
@@ -193,27 +203,27 @@ static WabtExprList join_exprs2(WabtLocation* loc, WabtExprList* expr1,
WabtExpr* expr2);
static WabtFuncField* new_func_field(void) {
- return wabt_alloc_zero(sizeof(WabtFuncField));
+ return (WabtFuncField*)wabt_alloc_zero(sizeof(WabtFuncField));
}
static WabtFunc* new_func(void) {
- return wabt_alloc_zero(sizeof(WabtFunc));
+ return (WabtFunc*)wabt_alloc_zero(sizeof(WabtFunc));
}
static WabtCommand* new_command(void) {
- return wabt_alloc_zero(sizeof(WabtCommand));
+ return (WabtCommand*)wabt_alloc_zero(sizeof(WabtCommand));
}
static WabtModule* new_module(void) {
- return wabt_alloc_zero(sizeof(WabtModule));
+ return (WabtModule*)wabt_alloc_zero(sizeof(WabtModule));
}
static WabtImport* new_import(void) {
- return wabt_alloc_zero(sizeof(WabtImport));
+ return (WabtImport*)wabt_alloc_zero(sizeof(WabtImport));
}
static WabtTextListNode* new_text_list_node(void) {
- return wabt_alloc_zero(sizeof(WabtTextListNode));
+ return (WabtTextListNode*)wabt_alloc_zero(sizeof(WabtTextListNode));
}
static WabtResult parse_const(WabtType type, WabtLiteralType literal_type,
@@ -221,7 +231,7 @@ static WabtResult parse_const(WabtType type, WabtLiteralType literal_type,
static void dup_text_list(WabtTextList * text_list, void** out_data,
size_t* out_size);
-static WabtBool is_empty_signature(WabtFuncSignature* sig);
+static bool is_empty_signature(WabtFuncSignature* sig);
static void append_implicit_func_declaration(WabtLocation*, WabtModule*,
WabtFuncDeclaration*);
@@ -238,7 +248,7 @@ static void on_read_binary_error(uint32_t offset, const char* error,
#define wabt_ast_parser_lex wabt_ast_lexer_lex
-#line 242 "src/prebuilt/ast-parser-gen.c" /* yacc.c:339 */
+#line 252 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:339 */
# ifndef YY_NULLPTR
# if defined __cplusplus && 201103L <= __cplusplus
@@ -385,7 +395,7 @@ int wabt_ast_parser_parse (WabtAstLexer* lexer, WabtAstParser* parser);
/* Copy the second part of user declarations. */
-#line 389 "src/prebuilt/ast-parser-gen.c" /* yacc.c:358 */
+#line 399 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:358 */
#ifdef short
# undef short
@@ -691,24 +701,24 @@ static const yytype_uint8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 295, 295, 301, 311, 312, 316, 334, 335, 341,
- 344, 349, 356, 359, 360, 364, 369, 376, 379, 382,
- 387, 394, 400, 411, 415, 419, 426, 431, 438, 439,
- 445, 446, 449, 453, 454, 458, 459, 469, 470, 481,
- 482, 483, 486, 489, 492, 495, 498, 502, 506, 511,
- 514, 518, 522, 526, 530, 534, 538, 542, 548, 554,
- 566, 570, 574, 578, 582, 585, 590, 596, 602, 608,
- 618, 626, 630, 633, 639, 645, 654, 660, 665, 671,
- 676, 682, 690, 691, 699, 700, 708, 713, 714, 720,
- 726, 736, 742, 748, 758, 812, 821, 828, 835, 845,
- 848, 852, 858, 869, 875, 895, 902, 914, 921, 941,
- 963, 970, 983, 990, 996, 1002, 1008, 1016, 1021, 1028,
- 1034, 1040, 1046, 1055, 1063, 1068, 1073, 1078, 1085, 1092,
- 1096, 1099, 1110, 1114, 1121, 1125, 1128, 1136, 1144, 1161,
- 1177, 1187, 1194, 1201, 1207, 1246, 1256, 1278, 1288, 1314,
- 1319, 1327, 1335, 1345, 1351, 1357, 1363, 1369, 1375, 1380,
- 1386, 1395, 1400, 1401, 1407, 1416, 1417, 1425, 1437, 1438,
- 1445, 1509
+ 0, 305, 305, 311, 321, 322, 326, 344, 345, 351,
+ 354, 359, 366, 369, 370, 374, 379, 386, 389, 392,
+ 397, 404, 410, 421, 425, 429, 436, 441, 448, 449,
+ 455, 456, 459, 463, 464, 468, 469, 479, 480, 491,
+ 492, 493, 496, 499, 502, 505, 508, 512, 516, 521,
+ 524, 528, 532, 536, 540, 544, 548, 552, 558, 564,
+ 576, 580, 584, 588, 592, 595, 600, 606, 612, 618,
+ 628, 636, 640, 643, 649, 655, 664, 670, 675, 681,
+ 686, 692, 700, 701, 709, 710, 718, 723, 724, 730,
+ 736, 746, 752, 758, 768, 822, 831, 838, 845, 855,
+ 858, 862, 868, 879, 885, 905, 912, 924, 931, 951,
+ 973, 980, 993, 1000, 1006, 1012, 1018, 1026, 1031, 1038,
+ 1044, 1050, 1056, 1065, 1073, 1078, 1083, 1088, 1095, 1102,
+ 1106, 1109, 1120, 1124, 1131, 1135, 1138, 1146, 1154, 1171,
+ 1187, 1197, 1204, 1211, 1217, 1256, 1266, 1288, 1298, 1324,
+ 1329, 1337, 1345, 1355, 1361, 1367, 1373, 1379, 1385, 1390,
+ 1396, 1405, 1410, 1411, 1417, 1426, 1427, 1435, 1447, 1448,
+ 1455, 1519
};
#endif
@@ -1647,333 +1657,333 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio
switch (yytype)
{
case 5: /* NAT */
-#line 256 "src/ast-parser.y" /* yacc.c:1257 */
+#line 266 "src/ast-parser.y" /* yacc.c:1257 */
{}
-#line 1653 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1663 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 6: /* INT */
-#line 256 "src/ast-parser.y" /* yacc.c:1257 */
+#line 266 "src/ast-parser.y" /* yacc.c:1257 */
{}
-#line 1659 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1669 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 7: /* FLOAT */
-#line 256 "src/ast-parser.y" /* yacc.c:1257 */
+#line 266 "src/ast-parser.y" /* yacc.c:1257 */
{}
-#line 1665 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1675 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 8: /* TEXT */
-#line 256 "src/ast-parser.y" /* yacc.c:1257 */
+#line 266 "src/ast-parser.y" /* yacc.c:1257 */
{}
-#line 1671 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1681 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 9: /* VAR */
-#line 256 "src/ast-parser.y" /* yacc.c:1257 */
+#line 266 "src/ast-parser.y" /* yacc.c:1257 */
{}
-#line 1677 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1687 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 35: /* OFFSET_EQ_NAT */
-#line 256 "src/ast-parser.y" /* yacc.c:1257 */
+#line 266 "src/ast-parser.y" /* yacc.c:1257 */
{}
-#line 1683 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1693 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 36: /* ALIGN_EQ_NAT */
-#line 256 "src/ast-parser.y" /* yacc.c:1257 */
+#line 266 "src/ast-parser.y" /* yacc.c:1257 */
{}
-#line 1689 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1699 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 75: /* non_empty_text_list */
-#line 279 "src/ast-parser.y" /* yacc.c:1257 */
+#line 289 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_text_list(&((*yyvaluep).text_list)); }
-#line 1695 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1705 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 76: /* text_list */
-#line 279 "src/ast-parser.y" /* yacc.c:1257 */
+#line 289 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_text_list(&((*yyvaluep).text_list)); }
-#line 1701 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1711 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 77: /* quoted_text */
-#line 278 "src/ast-parser.y" /* yacc.c:1257 */
+#line 288 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_string_slice(&((*yyvaluep).text)); }
-#line 1707 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1717 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 78: /* value_type_list */
-#line 280 "src/ast-parser.y" /* yacc.c:1257 */
+#line 290 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_type_vector(&((*yyvaluep).types)); }
-#line 1713 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1723 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 81: /* func_type */
-#line 270 "src/ast-parser.y" /* yacc.c:1257 */
+#line 280 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_func_signature(&((*yyvaluep).func_sig)); }
-#line 1719 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1729 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 82: /* func_sig */
-#line 270 "src/ast-parser.y" /* yacc.c:1257 */
+#line 280 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_func_signature(&((*yyvaluep).func_sig)); }
-#line 1725 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1735 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 86: /* type_use */
-#line 282 "src/ast-parser.y" /* yacc.c:1257 */
+#line 292 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_var(&((*yyvaluep).var)); }
-#line 1731 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1741 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 88: /* literal */
-#line 276 "src/ast-parser.y" /* yacc.c:1257 */
+#line 286 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_string_slice(&((*yyvaluep).literal).text); }
-#line 1737 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1747 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 89: /* var */
-#line 282 "src/ast-parser.y" /* yacc.c:1257 */
+#line 292 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_var(&((*yyvaluep).var)); }
-#line 1743 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1753 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 90: /* var_list */
-#line 281 "src/ast-parser.y" /* yacc.c:1257 */
+#line 291 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_var_vector_and_elements(&((*yyvaluep).vars)); }
-#line 1749 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1759 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 91: /* bind_var_opt */
-#line 278 "src/ast-parser.y" /* yacc.c:1257 */
+#line 288 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_string_slice(&((*yyvaluep).text)); }
-#line 1755 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1765 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 92: /* bind_var */
-#line 278 "src/ast-parser.y" /* yacc.c:1257 */
+#line 288 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_string_slice(&((*yyvaluep).text)); }
-#line 1761 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1771 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 93: /* labeling_opt */
-#line 278 "src/ast-parser.y" /* yacc.c:1257 */
+#line 288 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_string_slice(&((*yyvaluep).text)); }
-#line 1767 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1777 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 96: /* instr */
-#line 267 "src/ast-parser.y" /* yacc.c:1257 */
+#line 277 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_expr_list(((*yyvaluep).expr_list).first); }
-#line 1773 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1783 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 97: /* plain_instr */
-#line 266 "src/ast-parser.y" /* yacc.c:1257 */
+#line 276 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_expr(((*yyvaluep).expr)); }
-#line 1779 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1789 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 98: /* block_instr */
-#line 266 "src/ast-parser.y" /* yacc.c:1257 */
+#line 276 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_expr(((*yyvaluep).expr)); }
-#line 1785 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1795 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 99: /* block */
-#line 257 "src/ast-parser.y" /* yacc.c:1257 */
+#line 267 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_block(&((*yyvaluep).block)); }
-#line 1791 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1801 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 100: /* expr */
-#line 267 "src/ast-parser.y" /* yacc.c:1257 */
+#line 277 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_expr_list(((*yyvaluep).expr_list).first); }
-#line 1797 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1807 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 101: /* expr1 */
-#line 267 "src/ast-parser.y" /* yacc.c:1257 */
+#line 277 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_expr_list(((*yyvaluep).expr_list).first); }
-#line 1803 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1813 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 102: /* if_ */
-#line 267 "src/ast-parser.y" /* yacc.c:1257 */
+#line 277 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_expr_list(((*yyvaluep).expr_list).first); }
-#line 1809 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1819 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 103: /* instr_list */
-#line 267 "src/ast-parser.y" /* yacc.c:1257 */
+#line 277 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_expr_list(((*yyvaluep).expr_list).first); }
-#line 1815 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1825 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 104: /* expr_list */
-#line 267 "src/ast-parser.y" /* yacc.c:1257 */
+#line 277 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_expr_list(((*yyvaluep).expr_list).first); }
-#line 1821 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1831 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 105: /* const_expr */
-#line 267 "src/ast-parser.y" /* yacc.c:1257 */
+#line 277 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_expr_list(((*yyvaluep).expr_list).first); }
-#line 1827 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1837 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 106: /* func_fields */
-#line 268 "src/ast-parser.y" /* yacc.c:1257 */
+#line 278 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_func_fields(((*yyvaluep).func_fields)); }
-#line 1833 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1843 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 107: /* func_body */
-#line 268 "src/ast-parser.y" /* yacc.c:1257 */
+#line 278 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_func_fields(((*yyvaluep).func_fields)); }
-#line 1839 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1849 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 108: /* func_info */
-#line 269 "src/ast-parser.y" /* yacc.c:1257 */
+#line 279 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_func(((*yyvaluep).func)); wabt_free(((*yyvaluep).func)); }
-#line 1845 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1855 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 109: /* func */
-#line 263 "src/ast-parser.y" /* yacc.c:1257 */
+#line 273 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_exported_func(&((*yyvaluep).exported_func)); }
-#line 1851 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1861 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 110: /* offset */
-#line 267 "src/ast-parser.y" /* yacc.c:1257 */
+#line 277 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_expr_list(((*yyvaluep).expr_list).first); }
-#line 1857 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1867 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 111: /* elem */
-#line 261 "src/ast-parser.y" /* yacc.c:1257 */
+#line 271 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_elem_segment(&((*yyvaluep).elem_segment)); }
-#line 1863 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1873 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 112: /* table */
-#line 265 "src/ast-parser.y" /* yacc.c:1257 */
+#line 275 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_exported_table(&((*yyvaluep).exported_table)); }
-#line 1869 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1879 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 113: /* data */
-#line 273 "src/ast-parser.y" /* yacc.c:1257 */
+#line 283 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_data_segment(&((*yyvaluep).data_segment)); }
-#line 1875 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1885 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 114: /* memory */
-#line 264 "src/ast-parser.y" /* yacc.c:1257 */
+#line 274 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_exported_memory(&((*yyvaluep).exported_memory)); }
-#line 1881 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1891 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 116: /* import_kind */
-#line 272 "src/ast-parser.y" /* yacc.c:1257 */
+#line 282 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_import(((*yyvaluep).import)); wabt_free(((*yyvaluep).import)); }
-#line 1887 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1897 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 117: /* import */
-#line 272 "src/ast-parser.y" /* yacc.c:1257 */
+#line 282 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_import(((*yyvaluep).import)); wabt_free(((*yyvaluep).import)); }
-#line 1893 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1903 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 118: /* inline_import */
-#line 272 "src/ast-parser.y" /* yacc.c:1257 */
+#line 282 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_import(((*yyvaluep).import)); wabt_free(((*yyvaluep).import)); }
-#line 1899 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1909 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 119: /* export_kind */
-#line 262 "src/ast-parser.y" /* yacc.c:1257 */
+#line 272 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_export(&((*yyvaluep).export_)); }
-#line 1905 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1915 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 120: /* export */
-#line 262 "src/ast-parser.y" /* yacc.c:1257 */
+#line 272 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_export(&((*yyvaluep).export_)); }
-#line 1911 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1921 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 123: /* type_def */
-#line 271 "src/ast-parser.y" /* yacc.c:1257 */
+#line 281 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_func_type(&((*yyvaluep).func_type)); }
-#line 1917 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1927 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 124: /* start */
-#line 282 "src/ast-parser.y" /* yacc.c:1257 */
+#line 292 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_var(&((*yyvaluep).var)); }
-#line 1923 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1933 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 125: /* module_fields */
-#line 274 "src/ast-parser.y" /* yacc.c:1257 */
+#line 284 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_module(((*yyvaluep).module)); wabt_free(((*yyvaluep).module)); }
-#line 1929 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1939 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 126: /* raw_module */
-#line 275 "src/ast-parser.y" /* yacc.c:1257 */
+#line 285 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_raw_module(&((*yyvaluep).raw_module)); }
-#line 1935 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1945 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 127: /* module */
-#line 274 "src/ast-parser.y" /* yacc.c:1257 */
+#line 284 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_module(((*yyvaluep).module)); wabt_free(((*yyvaluep).module)); }
-#line 1941 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1951 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 128: /* script_var_opt */
-#line 282 "src/ast-parser.y" /* yacc.c:1257 */
+#line 292 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_var(&((*yyvaluep).var)); }
-#line 1947 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1957 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 130: /* assertion */
-#line 258 "src/ast-parser.y" /* yacc.c:1257 */
+#line 268 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_command(((*yyvaluep).command)); wabt_free(((*yyvaluep).command)); }
-#line 1953 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1963 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 131: /* cmd */
-#line 258 "src/ast-parser.y" /* yacc.c:1257 */
+#line 268 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_command(((*yyvaluep).command)); wabt_free(((*yyvaluep).command)); }
-#line 1959 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1969 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 132: /* cmd_list */
-#line 259 "src/ast-parser.y" /* yacc.c:1257 */
+#line 269 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_command_vector_and_elements(&((*yyvaluep).commands)); }
-#line 1965 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1975 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 134: /* const_list */
-#line 260 "src/ast-parser.y" /* yacc.c:1257 */
+#line 270 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_const_vector(&((*yyvaluep).consts)); }
-#line 1971 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1981 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
case 135: /* script */
-#line 277 "src/ast-parser.y" /* yacc.c:1257 */
+#line 287 "src/ast-parser.y" /* yacc.c:1257 */
{ wabt_destroy_script(&((*yyvaluep).script)); }
-#line 1977 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1257 */
+#line 1987 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1257 */
break;
@@ -2265,18 +2275,18 @@ yyreduce:
switch (yyn)
{
case 2:
-#line 295 "src/ast-parser.y" /* yacc.c:1646 */
+#line 305 "src/ast-parser.y" /* yacc.c:1646 */
{
WabtTextListNode* node = new_text_list_node();
DUPTEXT(node->text, (yyvsp[0].text));
node->next = NULL;
(yyval.text_list).first = (yyval.text_list).last = node;
}
-#line 2276 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2286 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 3:
-#line 301 "src/ast-parser.y" /* yacc.c:1646 */
+#line 311 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.text_list) = (yyvsp[-1].text_list);
WabtTextListNode* node = new_text_list_node();
@@ -2285,17 +2295,17 @@ yyreduce:
(yyval.text_list).last->next = node;
(yyval.text_list).last = node;
}
-#line 2289 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2299 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 4:
-#line 311 "src/ast-parser.y" /* yacc.c:1646 */
+#line 321 "src/ast-parser.y" /* yacc.c:1646 */
{ (yyval.text_list).first = (yyval.text_list).last = NULL; }
-#line 2295 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2305 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 6:
-#line 316 "src/ast-parser.y" /* yacc.c:1646 */
+#line 326 "src/ast-parser.y" /* yacc.c:1646 */
{
WabtTextListNode node;
node.text = (yyvsp[0].text);
@@ -2306,133 +2316,133 @@ yyreduce:
void* data;
size_t size;
dup_text_list(&text_list, &data, &size);
- (yyval.text).start = data;
+ (yyval.text).start = (const char*)data;
(yyval.text).length = size;
}
-#line 2313 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2323 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 7:
-#line 334 "src/ast-parser.y" /* yacc.c:1646 */
+#line 344 "src/ast-parser.y" /* yacc.c:1646 */
{ WABT_ZERO_MEMORY((yyval.types)); }
-#line 2319 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2329 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 8:
-#line 335 "src/ast-parser.y" /* yacc.c:1646 */
+#line 345 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.types) = (yyvsp[-1].types);
wabt_append_type_value(&(yyval.types), &(yyvsp[0].type));
}
-#line 2328 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2338 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 9:
-#line 341 "src/ast-parser.y" /* yacc.c:1646 */
+#line 351 "src/ast-parser.y" /* yacc.c:1646 */
{}
-#line 2334 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2344 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 10:
-#line 344 "src/ast-parser.y" /* yacc.c:1646 */
+#line 354 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.global));
(yyval.global).type = (yyvsp[0].type);
- (yyval.global).mutable_ = WABT_FALSE;
+ (yyval.global).mutable_ = false;
}
-#line 2344 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2354 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 11:
-#line 349 "src/ast-parser.y" /* yacc.c:1646 */
+#line 359 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.global));
(yyval.global).type = (yyvsp[-1].type);
- (yyval.global).mutable_ = WABT_TRUE;
+ (yyval.global).mutable_ = true;
}
-#line 2354 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2364 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 12:
-#line 356 "src/ast-parser.y" /* yacc.c:1646 */
+#line 366 "src/ast-parser.y" /* yacc.c:1646 */
{ (yyval.func_sig) = (yyvsp[-1].func_sig); }
-#line 2360 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2370 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 13:
-#line 359 "src/ast-parser.y" /* yacc.c:1646 */
+#line 369 "src/ast-parser.y" /* yacc.c:1646 */
{ WABT_ZERO_MEMORY((yyval.func_sig)); }
-#line 2366 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2376 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 14:
-#line 360 "src/ast-parser.y" /* yacc.c:1646 */
+#line 370 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.func_sig));
(yyval.func_sig).param_types = (yyvsp[-1].types);
}
-#line 2375 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2385 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 15:
-#line 364 "src/ast-parser.y" /* yacc.c:1646 */
+#line 374 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.func_sig));
(yyval.func_sig).param_types = (yyvsp[-5].types);
(yyval.func_sig).result_types = (yyvsp[-1].types);
}
-#line 2385 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2395 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 16:
-#line 369 "src/ast-parser.y" /* yacc.c:1646 */
+#line 379 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.func_sig));
(yyval.func_sig).result_types = (yyvsp[-1].types);
}
-#line 2394 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2404 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 17:
-#line 376 "src/ast-parser.y" /* yacc.c:1646 */
+#line 386 "src/ast-parser.y" /* yacc.c:1646 */
{ (yyval.table).elem_limits = (yyvsp[-1].limits); }
-#line 2400 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2410 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 18:
-#line 379 "src/ast-parser.y" /* yacc.c:1646 */
+#line 389 "src/ast-parser.y" /* yacc.c:1646 */
{ (yyval.memory).page_limits = (yyvsp[0].limits); }
-#line 2406 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2416 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 19:
-#line 382 "src/ast-parser.y" /* yacc.c:1646 */
+#line 392 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.limits).has_max = WABT_FALSE;
+ (yyval.limits).has_max = false;
(yyval.limits).initial = (yyvsp[0].u64);
(yyval.limits).max = 0;
}
-#line 2416 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2426 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 20:
-#line 387 "src/ast-parser.y" /* yacc.c:1646 */
+#line 397 "src/ast-parser.y" /* yacc.c:1646 */
{
- (yyval.limits).has_max = WABT_TRUE;
+ (yyval.limits).has_max = true;
(yyval.limits).initial = (yyvsp[-1].u64);
(yyval.limits).max = (yyvsp[0].u64);
}
-#line 2426 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2436 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 21:
-#line 394 "src/ast-parser.y" /* yacc.c:1646 */
+#line 404 "src/ast-parser.y" /* yacc.c:1646 */
{ (yyval.var) = (yyvsp[-1].var); }
-#line 2432 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2442 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 22:
-#line 400 "src/ast-parser.y" /* yacc.c:1646 */
+#line 410 "src/ast-parser.y" /* yacc.c:1646 */
{
if (WABT_FAILED(wabt_parse_uint64((yyvsp[0].literal).text.start,
(yyvsp[0].literal).text.start + (yyvsp[0].literal).text.length, &(yyval.u64)))) {
@@ -2441,97 +2451,97 @@ yyreduce:
WABT_PRINTF_STRING_SLICE_ARG((yyvsp[0].literal).text));
}
}
-#line 2445 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2455 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 23:
-#line 411 "src/ast-parser.y" /* yacc.c:1646 */
+#line 421 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.literal).type = (yyvsp[0].literal).type;
DUPTEXT((yyval.literal).text, (yyvsp[0].literal).text);
}
-#line 2454 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2464 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 24:
-#line 415 "src/ast-parser.y" /* yacc.c:1646 */
+#line 425 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.literal).type = (yyvsp[0].literal).type;
DUPTEXT((yyval.literal).text, (yyvsp[0].literal).text);
}
-#line 2463 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2473 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 25:
-#line 419 "src/ast-parser.y" /* yacc.c:1646 */
+#line 429 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.literal).type = (yyvsp[0].literal).type;
DUPTEXT((yyval.literal).text, (yyvsp[0].literal).text);
}
-#line 2472 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2482 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 26:
-#line 426 "src/ast-parser.y" /* yacc.c:1646 */
+#line 436 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.var).loc = (yylsp[0]);
(yyval.var).type = WABT_VAR_TYPE_INDEX;
(yyval.var).index = (yyvsp[0].u64);
}
-#line 2482 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2492 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 27:
-#line 431 "src/ast-parser.y" /* yacc.c:1646 */
+#line 441 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.var).loc = (yylsp[0]);
(yyval.var).type = WABT_VAR_TYPE_NAME;
DUPTEXT((yyval.var).name, (yyvsp[0].text));
}
-#line 2492 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2502 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 28:
-#line 438 "src/ast-parser.y" /* yacc.c:1646 */
+#line 448 "src/ast-parser.y" /* yacc.c:1646 */
{ WABT_ZERO_MEMORY((yyval.vars)); }
-#line 2498 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2508 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 29:
-#line 439 "src/ast-parser.y" /* yacc.c:1646 */
+#line 449 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.vars) = (yyvsp[-1].vars);
wabt_append_var_value(&(yyval.vars), &(yyvsp[0].var));
}
-#line 2507 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2517 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 30:
-#line 445 "src/ast-parser.y" /* yacc.c:1646 */
+#line 455 "src/ast-parser.y" /* yacc.c:1646 */
{ WABT_ZERO_MEMORY((yyval.text)); }
-#line 2513 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2523 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 32:
-#line 449 "src/ast-parser.y" /* yacc.c:1646 */
+#line 459 "src/ast-parser.y" /* yacc.c:1646 */
{ DUPTEXT((yyval.text), (yyvsp[0].text)); }
-#line 2519 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2529 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 33:
-#line 453 "src/ast-parser.y" /* yacc.c:1646 */
+#line 463 "src/ast-parser.y" /* yacc.c:1646 */
{ WABT_ZERO_MEMORY((yyval.text)); }
-#line 2525 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2535 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 35:
-#line 458 "src/ast-parser.y" /* yacc.c:1646 */
+#line 468 "src/ast-parser.y" /* yacc.c:1646 */
{ (yyval.u64) = 0; }
-#line 2531 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2541 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 36:
-#line 459 "src/ast-parser.y" /* yacc.c:1646 */
+#line 469 "src/ast-parser.y" /* yacc.c:1646 */
{
if (WABT_FAILED(wabt_parse_int64((yyvsp[0].text).start, (yyvsp[0].text).start + (yyvsp[0].text).length, &(yyval.u64),
WABT_PARSE_SIGNED_AND_UNSIGNED))) {
@@ -2540,17 +2550,17 @@ yyreduce:
WABT_PRINTF_STRING_SLICE_ARG((yyvsp[0].text)));
}
}
-#line 2544 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2554 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 37:
-#line 469 "src/ast-parser.y" /* yacc.c:1646 */
+#line 479 "src/ast-parser.y" /* yacc.c:1646 */
{ (yyval.u32) = USE_NATURAL_ALIGNMENT; }
-#line 2550 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2560 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 38:
-#line 470 "src/ast-parser.y" /* yacc.c:1646 */
+#line 480 "src/ast-parser.y" /* yacc.c:1646 */
{
if (WABT_FAILED(wabt_parse_int32((yyvsp[0].text).start, (yyvsp[0].text).start + (yyvsp[0].text).length, &(yyval.u32),
WABT_PARSE_UNSIGNED_ONLY))) {
@@ -2559,182 +2569,182 @@ yyreduce:
WABT_PRINTF_STRING_SLICE_ARG((yyvsp[0].text)));
}
}
-#line 2563 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2573 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 39:
-#line 481 "src/ast-parser.y" /* yacc.c:1646 */
+#line 491 "src/ast-parser.y" /* yacc.c:1646 */
{ (yyval.expr_list) = join_exprs1(&(yylsp[0]), (yyvsp[0].expr)); }
-#line 2569 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2579 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 40:
-#line 482 "src/ast-parser.y" /* yacc.c:1646 */
+#line 492 "src/ast-parser.y" /* yacc.c:1646 */
{ (yyval.expr_list) = join_exprs1(&(yylsp[0]), (yyvsp[0].expr)); }
-#line 2575 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2585 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 41:
-#line 483 "src/ast-parser.y" /* yacc.c:1646 */
+#line 493 "src/ast-parser.y" /* yacc.c:1646 */
{ (yyval.expr_list) = (yyvsp[0].expr_list); }
-#line 2581 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2591 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 42:
-#line 486 "src/ast-parser.y" /* yacc.c:1646 */
+#line 496 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_unreachable_expr();
}
-#line 2589 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2599 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 43:
-#line 489 "src/ast-parser.y" /* yacc.c:1646 */
+#line 499 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_nop_expr();
}
-#line 2597 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2607 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 44:
-#line 492 "src/ast-parser.y" /* yacc.c:1646 */
+#line 502 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_drop_expr();
}
-#line 2605 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2615 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 45:
-#line 495 "src/ast-parser.y" /* yacc.c:1646 */
+#line 505 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_select_expr();
}
-#line 2613 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2623 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 46:
-#line 498 "src/ast-parser.y" /* yacc.c:1646 */
+#line 508 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_br_expr();
(yyval.expr)->br.var = (yyvsp[0].var);
}
-#line 2622 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2632 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 47:
-#line 502 "src/ast-parser.y" /* yacc.c:1646 */
+#line 512 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_br_if_expr();
(yyval.expr)->br_if.var = (yyvsp[0].var);
}
-#line 2631 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2641 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 48:
-#line 506 "src/ast-parser.y" /* yacc.c:1646 */
+#line 516 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_br_table_expr();
(yyval.expr)->br_table.targets = (yyvsp[-1].vars);
(yyval.expr)->br_table.default_target = (yyvsp[0].var);
}
-#line 2641 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2651 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 49:
-#line 511 "src/ast-parser.y" /* yacc.c:1646 */
+#line 521 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_return_expr();
}
-#line 2649 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2659 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 50:
-#line 514 "src/ast-parser.y" /* yacc.c:1646 */
+#line 524 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_call_expr();
(yyval.expr)->call.var = (yyvsp[0].var);
}
-#line 2658 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2668 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 51:
-#line 518 "src/ast-parser.y" /* yacc.c:1646 */
+#line 528 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_call_indirect_expr();
(yyval.expr)->call_indirect.var = (yyvsp[0].var);
}
-#line 2667 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2677 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 52:
-#line 522 "src/ast-parser.y" /* yacc.c:1646 */
+#line 532 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_get_local_expr();
(yyval.expr)->get_local.var = (yyvsp[0].var);
}
-#line 2676 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2686 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 53:
-#line 526 "src/ast-parser.y" /* yacc.c:1646 */
+#line 536 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_set_local_expr();
(yyval.expr)->set_local.var = (yyvsp[0].var);
}
-#line 2685 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2695 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 54:
-#line 530 "src/ast-parser.y" /* yacc.c:1646 */
+#line 540 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_tee_local_expr();
(yyval.expr)->tee_local.var = (yyvsp[0].var);
}
-#line 2694 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2704 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 55:
-#line 534 "src/ast-parser.y" /* yacc.c:1646 */
+#line 544 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_get_global_expr();
(yyval.expr)->get_global.var = (yyvsp[0].var);
}
-#line 2703 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2713 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 56:
-#line 538 "src/ast-parser.y" /* yacc.c:1646 */
+#line 548 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_set_global_expr();
(yyval.expr)->set_global.var = (yyvsp[0].var);
}
-#line 2712 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2722 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 57:
-#line 542 "src/ast-parser.y" /* yacc.c:1646 */
+#line 552 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_load_expr();
(yyval.expr)->load.opcode = (yyvsp[-2].opcode);
(yyval.expr)->load.offset = (yyvsp[-1].u64);
(yyval.expr)->load.align = (yyvsp[0].u32);
}
-#line 2723 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2733 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 58:
-#line 548 "src/ast-parser.y" /* yacc.c:1646 */
+#line 558 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_store_expr();
(yyval.expr)->store.opcode = (yyvsp[-2].opcode);
(yyval.expr)->store.offset = (yyvsp[-1].u64);
(yyval.expr)->store.align = (yyvsp[0].u32);
}
-#line 2734 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2744 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 59:
-#line 554 "src/ast-parser.y" /* yacc.c:1646 */
+#line 564 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_const_expr();
(yyval.expr)->const_.loc = (yylsp[-1]);
@@ -2747,96 +2757,96 @@ yyreduce:
}
wabt_free((char*)(yyvsp[0].literal).text.start);
}
-#line 2751 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2761 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 60:
-#line 566 "src/ast-parser.y" /* yacc.c:1646 */
+#line 576 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_unary_expr();
(yyval.expr)->unary.opcode = (yyvsp[0].opcode);
}
-#line 2760 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2770 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 61:
-#line 570 "src/ast-parser.y" /* yacc.c:1646 */
+#line 580 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_binary_expr();
(yyval.expr)->binary.opcode = (yyvsp[0].opcode);
}
-#line 2769 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2779 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 62:
-#line 574 "src/ast-parser.y" /* yacc.c:1646 */
+#line 584 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_compare_expr();
(yyval.expr)->compare.opcode = (yyvsp[0].opcode);
}
-#line 2778 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2788 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 63:
-#line 578 "src/ast-parser.y" /* yacc.c:1646 */
+#line 588 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_convert_expr();
(yyval.expr)->convert.opcode = (yyvsp[0].opcode);
}
-#line 2787 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2797 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 64:
-#line 582 "src/ast-parser.y" /* yacc.c:1646 */
+#line 592 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_current_memory_expr();
}
-#line 2795 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2805 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 65:
-#line 585 "src/ast-parser.y" /* yacc.c:1646 */
+#line 595 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_grow_memory_expr();
}
-#line 2803 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2813 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 66:
-#line 590 "src/ast-parser.y" /* yacc.c:1646 */
+#line 600 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_block_expr();
(yyval.expr)->block = (yyvsp[-2].block);
(yyval.expr)->block.label = (yyvsp[-3].text);
CHECK_END_LABEL((yylsp[0]), (yyval.expr)->block.label, (yyvsp[0].text));
}
-#line 2814 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2824 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 67:
-#line 596 "src/ast-parser.y" /* yacc.c:1646 */
+#line 606 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_loop_expr();
(yyval.expr)->loop = (yyvsp[-2].block);
(yyval.expr)->loop.label = (yyvsp[-3].text);
CHECK_END_LABEL((yylsp[0]), (yyval.expr)->block.label, (yyvsp[0].text));
}
-#line 2825 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2835 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 68:
-#line 602 "src/ast-parser.y" /* yacc.c:1646 */
+#line 612 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_if_expr();
(yyval.expr)->if_.true_ = (yyvsp[-2].block);
(yyval.expr)->if_.true_.label = (yyvsp[-3].text);
CHECK_END_LABEL((yylsp[0]), (yyval.expr)->block.label, (yyvsp[0].text));
}
-#line 2836 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2846 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 69:
-#line 608 "src/ast-parser.y" /* yacc.c:1646 */
+#line 618 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr) = wabt_new_if_expr();
(yyval.expr)->if_.true_ = (yyvsp[-5].block);
@@ -2845,57 +2855,57 @@ yyreduce:
CHECK_END_LABEL((yylsp[-3]), (yyval.expr)->block.label, (yyvsp[-3].text));
CHECK_END_LABEL((yylsp[0]), (yyval.expr)->block.label, (yyvsp[0].text));
}
-#line 2849 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2859 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 70:
-#line 618 "src/ast-parser.y" /* yacc.c:1646 */
+#line 628 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.block));
(yyval.block).sig = (yyvsp[-1].types);
(yyval.block).first = (yyvsp[0].expr_list).first;
}
-#line 2859 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2869 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 71:
-#line 626 "src/ast-parser.y" /* yacc.c:1646 */
+#line 636 "src/ast-parser.y" /* yacc.c:1646 */
{ (yyval.expr_list) = (yyvsp[-1].expr_list); }
-#line 2865 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2875 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 72:
-#line 630 "src/ast-parser.y" /* yacc.c:1646 */
+#line 640 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr_list) = join_exprs2(&(yylsp[-1]), &(yyvsp[0].expr_list), (yyvsp[-1].expr));
}
-#line 2873 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2883 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 73:
-#line 633 "src/ast-parser.y" /* yacc.c:1646 */
+#line 643 "src/ast-parser.y" /* yacc.c:1646 */
{
WabtExpr* expr = wabt_new_block_expr();
expr->block = (yyvsp[0].block);
expr->block.label = (yyvsp[-1].text);
(yyval.expr_list) = join_exprs1(&(yylsp[-2]), expr);
}
-#line 2884 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2894 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 74:
-#line 639 "src/ast-parser.y" /* yacc.c:1646 */
+#line 649 "src/ast-parser.y" /* yacc.c:1646 */
{
WabtExpr* expr = wabt_new_loop_expr();
expr->loop = (yyvsp[0].block);
expr->loop.label = (yyvsp[-1].text);
(yyval.expr_list) = join_exprs1(&(yylsp[-2]), expr);
}
-#line 2895 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2905 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 75:
-#line 645 "src/ast-parser.y" /* yacc.c:1646 */
+#line 655 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr_list) = (yyvsp[0].expr_list);
WabtExpr* if_ = (yyvsp[0].expr_list).last;
@@ -2903,130 +2913,130 @@ yyreduce:
if_->if_.true_.label = (yyvsp[-2].text);
if_->if_.true_.sig = (yyvsp[-1].types);
}
-#line 2907 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2917 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 76:
-#line 654 "src/ast-parser.y" /* yacc.c:1646 */
+#line 664 "src/ast-parser.y" /* yacc.c:1646 */
{
WabtExpr* expr = wabt_new_if_expr();
expr->if_.true_.first = (yyvsp[-5].expr_list).first;
expr->if_.false_ = (yyvsp[-1].expr_list).first;
(yyval.expr_list) = join_exprs1(&(yylsp[-7]), expr);
}
-#line 2918 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2928 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 77:
-#line 660 "src/ast-parser.y" /* yacc.c:1646 */
+#line 670 "src/ast-parser.y" /* yacc.c:1646 */
{
WabtExpr* expr = wabt_new_if_expr();
expr->if_.true_.first = (yyvsp[-1].expr_list).first;
(yyval.expr_list) = join_exprs1(&(yylsp[-3]), expr);
}
-#line 2928 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2938 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 78:
-#line 665 "src/ast-parser.y" /* yacc.c:1646 */
+#line 675 "src/ast-parser.y" /* yacc.c:1646 */
{
WabtExpr* expr = wabt_new_if_expr();
expr->if_.true_.first = (yyvsp[-5].expr_list).first;
expr->if_.false_ = (yyvsp[-1].expr_list).first;
(yyval.expr_list) = join_exprs2(&(yylsp[-8]), &(yyvsp[-8].expr_list), expr);
}
-#line 2939 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2949 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 79:
-#line 671 "src/ast-parser.y" /* yacc.c:1646 */
+#line 681 "src/ast-parser.y" /* yacc.c:1646 */
{
WabtExpr* expr = wabt_new_if_expr();
expr->if_.true_.first = (yyvsp[-1].expr_list).first;
(yyval.expr_list) = join_exprs2(&(yylsp[-4]), &(yyvsp[-4].expr_list), expr);
}
-#line 2949 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2959 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 80:
-#line 676 "src/ast-parser.y" /* yacc.c:1646 */
+#line 686 "src/ast-parser.y" /* yacc.c:1646 */
{
WabtExpr* expr = wabt_new_if_expr();
expr->if_.true_.first = (yyvsp[-1].expr_list).first;
expr->if_.false_ = (yyvsp[0].expr_list).first;
(yyval.expr_list) = join_exprs2(&(yylsp[-2]), &(yyvsp[-2].expr_list), expr);
}
-#line 2960 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2970 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 81:
-#line 682 "src/ast-parser.y" /* yacc.c:1646 */
+#line 692 "src/ast-parser.y" /* yacc.c:1646 */
{
WabtExpr* expr = wabt_new_if_expr();
expr->if_.true_.first = (yyvsp[0].expr_list).first;
(yyval.expr_list) = join_exprs2(&(yylsp[-1]), &(yyvsp[-1].expr_list), expr);
}
-#line 2970 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2980 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 82:
-#line 690 "src/ast-parser.y" /* yacc.c:1646 */
+#line 700 "src/ast-parser.y" /* yacc.c:1646 */
{ WABT_ZERO_MEMORY((yyval.expr_list)); }
-#line 2976 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2986 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 83:
-#line 691 "src/ast-parser.y" /* yacc.c:1646 */
+#line 701 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr_list).first = (yyvsp[-1].expr_list).first;
(yyvsp[-1].expr_list).last->next = (yyvsp[0].expr_list).first;
(yyval.expr_list).last = (yyvsp[0].expr_list).last ? (yyvsp[0].expr_list).last : (yyvsp[-1].expr_list).last;
(yyval.expr_list).size = (yyvsp[-1].expr_list).size + (yyvsp[0].expr_list).size;
}
-#line 2987 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 2997 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 84:
-#line 699 "src/ast-parser.y" /* yacc.c:1646 */
+#line 709 "src/ast-parser.y" /* yacc.c:1646 */
{ WABT_ZERO_MEMORY((yyval.expr_list)); }
-#line 2993 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3003 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 85:
-#line 700 "src/ast-parser.y" /* yacc.c:1646 */
+#line 710 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr_list).first = (yyvsp[-1].expr_list).first;
(yyvsp[-1].expr_list).last->next = (yyvsp[0].expr_list).first;
(yyval.expr_list).last = (yyvsp[0].expr_list).last ? (yyvsp[0].expr_list).last : (yyvsp[-1].expr_list).last;
(yyval.expr_list).size = (yyvsp[-1].expr_list).size + (yyvsp[0].expr_list).size;
}
-#line 3004 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3014 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 88:
-#line 714 "src/ast-parser.y" /* yacc.c:1646 */
+#line 724 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func_fields) = new_func_field();
(yyval.func_fields)->type = WABT_FUNC_FIELD_TYPE_RESULT_TYPES;
(yyval.func_fields)->types = (yyvsp[-2].types);
(yyval.func_fields)->next = (yyvsp[0].func_fields);
}
-#line 3015 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3025 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 89:
-#line 720 "src/ast-parser.y" /* yacc.c:1646 */
+#line 730 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func_fields) = new_func_field();
(yyval.func_fields)->type = WABT_FUNC_FIELD_TYPE_PARAM_TYPES;
(yyval.func_fields)->types = (yyvsp[-2].types);
(yyval.func_fields)->next = (yyvsp[0].func_fields);
}
-#line 3026 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3036 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 90:
-#line 726 "src/ast-parser.y" /* yacc.c:1646 */
+#line 736 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func_fields) = new_func_field();
(yyval.func_fields)->type = WABT_FUNC_FIELD_TYPE_BOUND_PARAM;
@@ -3035,33 +3045,33 @@ yyreduce:
(yyval.func_fields)->bound_type.type = (yyvsp[-2].type);
(yyval.func_fields)->next = (yyvsp[0].func_fields);
}
-#line 3039 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3049 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 91:
-#line 736 "src/ast-parser.y" /* yacc.c:1646 */
+#line 746 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func_fields) = new_func_field();
(yyval.func_fields)->type = WABT_FUNC_FIELD_TYPE_EXPRS;
(yyval.func_fields)->first_expr = (yyvsp[0].expr_list).first;
(yyval.func_fields)->next = NULL;
}
-#line 3050 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3060 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 92:
-#line 742 "src/ast-parser.y" /* yacc.c:1646 */
+#line 752 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func_fields) = new_func_field();
(yyval.func_fields)->type = WABT_FUNC_FIELD_TYPE_LOCAL_TYPES;
(yyval.func_fields)->types = (yyvsp[-2].types);
(yyval.func_fields)->next = (yyvsp[0].func_fields);
}
-#line 3061 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3071 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 93:
-#line 748 "src/ast-parser.y" /* yacc.c:1646 */
+#line 758 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func_fields) = new_func_field();
(yyval.func_fields)->type = WABT_FUNC_FIELD_TYPE_BOUND_LOCAL;
@@ -3070,11 +3080,11 @@ yyreduce:
(yyval.func_fields)->bound_type.type = (yyvsp[-2].type);
(yyval.func_fields)->next = (yyvsp[0].func_fields);
}
-#line 3074 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3084 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 94:
-#line 758 "src/ast-parser.y" /* yacc.c:1646 */
+#line 768 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func) = new_func();
WabtFuncField* field = (yyvsp[0].func_fields);
@@ -3127,11 +3137,11 @@ yyreduce:
field = next;
}
}
-#line 3131 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3141 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 95:
-#line 812 "src/ast-parser.y" /* yacc.c:1646 */
+#line 822 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.exported_func));
(yyval.exported_func).func = (yyvsp[-1].func);
@@ -3140,11 +3150,11 @@ yyreduce:
(yyval.exported_func).func->name = (yyvsp[-4].text);
(yyval.exported_func).export_ = (yyvsp[-3].optional_export);
}
-#line 3144 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3154 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 96:
-#line 821 "src/ast-parser.y" /* yacc.c:1646 */
+#line 831 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.exported_func));
(yyval.exported_func).func = (yyvsp[-1].func);
@@ -3152,51 +3162,51 @@ yyreduce:
(yyval.exported_func).func->decl.type_var = (yyvsp[-2].var);
(yyval.exported_func).func->name = (yyvsp[-3].text);
}
-#line 3156 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3166 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 97:
-#line 828 "src/ast-parser.y" /* yacc.c:1646 */
+#line 838 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.exported_func));
(yyval.exported_func).func = (yyvsp[-1].func);
(yyval.exported_func).func->name = (yyvsp[-3].text);
(yyval.exported_func).export_ = (yyvsp[-2].optional_export);
}
-#line 3167 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3177 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 98:
-#line 835 "src/ast-parser.y" /* yacc.c:1646 */
+#line 845 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.exported_func));
(yyval.exported_func).func = (yyvsp[-1].func);
(yyval.exported_func).func->name = (yyvsp[-2].text);
}
-#line 3177 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3187 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 99:
-#line 845 "src/ast-parser.y" /* yacc.c:1646 */
+#line 855 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.expr_list) = (yyvsp[-1].expr_list);
}
-#line 3185 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3195 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 101:
-#line 852 "src/ast-parser.y" /* yacc.c:1646 */
+#line 862 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.elem_segment));
(yyval.elem_segment).table_var = (yyvsp[-3].var);
(yyval.elem_segment).offset = (yyvsp[-2].expr_list).first;
(yyval.elem_segment).vars = (yyvsp[-1].vars);
}
-#line 3196 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3206 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 102:
-#line 858 "src/ast-parser.y" /* yacc.c:1646 */
+#line 868 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.elem_segment));
(yyval.elem_segment).table_var.loc = (yylsp[-3]);
@@ -3205,22 +3215,22 @@ yyreduce:
(yyval.elem_segment).offset = (yyvsp[-2].expr_list).first;
(yyval.elem_segment).vars = (yyvsp[-1].vars);
}
-#line 3209 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3219 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 103:
-#line 869 "src/ast-parser.y" /* yacc.c:1646 */
+#line 879 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.exported_table).table = (yyvsp[-1].table);
(yyval.exported_table).table.name = (yyvsp[-3].text);
- (yyval.exported_table).has_elem_segment = WABT_FALSE;
+ (yyval.exported_table).has_elem_segment = false;
(yyval.exported_table).export_ = (yyvsp[-2].optional_export);
}
-#line 3220 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3230 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 104:
-#line 876 "src/ast-parser.y" /* yacc.c:1646 */
+#line 886 "src/ast-parser.y" /* yacc.c:1646 */
{
WabtExpr* expr = wabt_new_const_expr();
expr->loc = (yylsp[-8]);
@@ -3231,17 +3241,17 @@ yyreduce:
(yyval.exported_table).table.name = (yyvsp[-7].text);
(yyval.exported_table).table.elem_limits.initial = (yyvsp[-2].vars).size;
(yyval.exported_table).table.elem_limits.max = (yyvsp[-2].vars).size;
- (yyval.exported_table).table.elem_limits.has_max = WABT_TRUE;
- (yyval.exported_table).has_elem_segment = WABT_TRUE;
+ (yyval.exported_table).table.elem_limits.has_max = true;
+ (yyval.exported_table).has_elem_segment = true;
(yyval.exported_table).elem_segment.offset = expr;
(yyval.exported_table).elem_segment.vars = (yyvsp[-2].vars);
(yyval.exported_table).export_ = (yyvsp[-6].optional_export);
}
-#line 3241 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3251 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 105:
-#line 895 "src/ast-parser.y" /* yacc.c:1646 */
+#line 905 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.data_segment));
(yyval.data_segment).memory_var = (yyvsp[-3].var);
@@ -3249,11 +3259,11 @@ yyreduce:
dup_text_list(&(yyvsp[-1].text_list), &(yyval.data_segment).data, &(yyval.data_segment).size);
wabt_destroy_text_list(&(yyvsp[-1].text_list));
}
-#line 3253 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3263 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 106:
-#line 902 "src/ast-parser.y" /* yacc.c:1646 */
+#line 912 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.data_segment));
(yyval.data_segment).memory_var.loc = (yylsp[-3]);
@@ -3263,23 +3273,23 @@ yyreduce:
dup_text_list(&(yyvsp[-1].text_list), &(yyval.data_segment).data, &(yyval.data_segment).size);
wabt_destroy_text_list(&(yyvsp[-1].text_list));
}
-#line 3267 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3277 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 107:
-#line 914 "src/ast-parser.y" /* yacc.c:1646 */
+#line 924 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.exported_memory));
(yyval.exported_memory).memory = (yyvsp[-1].memory);
(yyval.exported_memory).memory.name = (yyvsp[-3].text);
- (yyval.exported_memory).has_data_segment = WABT_FALSE;
+ (yyval.exported_memory).has_data_segment = false;
(yyval.exported_memory).export_ = (yyvsp[-2].optional_export);
}
-#line 3279 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3289 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 108:
-#line 921 "src/ast-parser.y" /* yacc.c:1646 */
+#line 931 "src/ast-parser.y" /* yacc.c:1646 */
{
WabtExpr* expr = wabt_new_const_expr();
expr->loc = (yylsp[-7]);
@@ -3287,7 +3297,7 @@ yyreduce:
expr->const_.u32 = 0;
WABT_ZERO_MEMORY((yyval.exported_memory));
- (yyval.exported_memory).has_data_segment = WABT_TRUE;
+ (yyval.exported_memory).has_data_segment = true;
(yyval.exported_memory).data_segment.offset = expr;
dup_text_list(&(yyvsp[-2].text_list), &(yyval.exported_memory).data_segment.data, &(yyval.exported_memory).data_segment.size);
wabt_destroy_text_list(&(yyvsp[-2].text_list));
@@ -3296,14 +3306,14 @@ yyreduce:
(yyval.exported_memory).memory.name = (yyvsp[-6].text);
(yyval.exported_memory).memory.page_limits.initial = page_size;
(yyval.exported_memory).memory.page_limits.max = page_size;
- (yyval.exported_memory).memory.page_limits.has_max = WABT_TRUE;
+ (yyval.exported_memory).memory.page_limits.has_max = true;
(yyval.exported_memory).export_ = (yyvsp[-5].optional_export);
}
-#line 3303 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3313 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 109:
-#line 941 "src/ast-parser.y" /* yacc.c:1646 */
+#line 951 "src/ast-parser.y" /* yacc.c:1646 */
{
WabtExpr* expr = wabt_new_const_expr();
expr->loc = (yylsp[-6]);
@@ -3311,7 +3321,7 @@ yyreduce:
expr->const_.u32 = 0;
WABT_ZERO_MEMORY((yyval.exported_memory));
- (yyval.exported_memory).has_data_segment = WABT_TRUE;
+ (yyval.exported_memory).has_data_segment = true;
(yyval.exported_memory).data_segment.offset = expr;
dup_text_list(&(yyvsp[-2].text_list), &(yyval.exported_memory).data_segment.data, &(yyval.exported_memory).data_segment.size);
wabt_destroy_text_list(&(yyvsp[-2].text_list));
@@ -3320,14 +3330,14 @@ yyreduce:
(yyval.exported_memory).memory.name = (yyvsp[-5].text);
(yyval.exported_memory).memory.page_limits.initial = page_size;
(yyval.exported_memory).memory.page_limits.max = page_size;
- (yyval.exported_memory).memory.page_limits.has_max = WABT_TRUE;
- (yyval.exported_memory).export_.has_export = WABT_FALSE;
+ (yyval.exported_memory).memory.page_limits.has_max = true;
+ (yyval.exported_memory).export_.has_export = false;
}
-#line 3327 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3337 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 110:
-#line 963 "src/ast-parser.y" /* yacc.c:1646 */
+#line 973 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.exported_global));
(yyval.exported_global).global = (yyvsp[-2].global);
@@ -3335,23 +3345,23 @@ yyreduce:
(yyval.exported_global).global.init_expr = (yyvsp[-1].expr_list).first;
(yyval.exported_global).export_ = (yyvsp[-3].optional_export);
}
-#line 3339 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3349 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 111:
-#line 970 "src/ast-parser.y" /* yacc.c:1646 */
+#line 980 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.exported_global));
(yyval.exported_global).global = (yyvsp[-2].global);
(yyval.exported_global).global.name = (yyvsp[-3].text);
(yyval.exported_global).global.init_expr = (yyvsp[-1].expr_list).first;
- (yyval.exported_global).export_.has_export = WABT_FALSE;
+ (yyval.exported_global).export_.has_export = false;
}
-#line 3351 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3361 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 112:
-#line 983 "src/ast-parser.y" /* yacc.c:1646 */
+#line 993 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = new_import();
(yyval.import)->kind = WABT_EXTERNAL_KIND_FUNC;
@@ -3359,65 +3369,65 @@ yyreduce:
(yyval.import)->func.decl.flags = WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
(yyval.import)->func.decl.type_var = (yyvsp[-1].var);
}
-#line 3363 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3373 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 113:
-#line 990 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1000 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = new_import();
(yyval.import)->kind = WABT_EXTERNAL_KIND_FUNC;
(yyval.import)->func.name = (yyvsp[-2].text);
(yyval.import)->func.decl.sig = (yyvsp[-1].func_sig);
}
-#line 3374 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3384 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 114:
-#line 996 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1006 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = new_import();
(yyval.import)->kind = WABT_EXTERNAL_KIND_TABLE;
(yyval.import)->table = (yyvsp[-1].table);
(yyval.import)->table.name = (yyvsp[-2].text);
}
-#line 3385 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3395 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 115:
-#line 1002 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1012 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = new_import();
(yyval.import)->kind = WABT_EXTERNAL_KIND_MEMORY;
(yyval.import)->memory = (yyvsp[-1].memory);
(yyval.import)->memory.name = (yyvsp[-2].text);
}
-#line 3396 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3406 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 116:
-#line 1008 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1018 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = new_import();
(yyval.import)->kind = WABT_EXTERNAL_KIND_GLOBAL;
(yyval.import)->global = (yyvsp[-1].global);
(yyval.import)->global.name = (yyvsp[-2].text);
}
-#line 3407 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3417 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 117:
-#line 1016 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1026 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = (yyvsp[-1].import);
(yyval.import)->module_name = (yyvsp[-3].text);
(yyval.import)->field_name = (yyvsp[-2].text);
}
-#line 3417 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3427 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 118:
-#line 1021 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1031 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = (yyvsp[-2].import);
(yyval.import)->kind = WABT_EXTERNAL_KIND_FUNC;
@@ -3425,165 +3435,165 @@ yyreduce:
(yyval.import)->func.decl.flags = WABT_FUNC_DECLARATION_FLAG_HAS_FUNC_TYPE;
(yyval.import)->func.decl.type_var = (yyvsp[-1].var);
}
-#line 3429 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3439 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 119:
-#line 1028 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1038 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = (yyvsp[-2].import);
(yyval.import)->kind = WABT_EXTERNAL_KIND_FUNC;
(yyval.import)->func.name = (yyvsp[-3].text);
(yyval.import)->func.decl.sig = (yyvsp[-1].func_sig);
}
-#line 3440 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3450 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 120:
-#line 1034 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1044 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = (yyvsp[-2].import);
(yyval.import)->kind = WABT_EXTERNAL_KIND_TABLE;
(yyval.import)->table = (yyvsp[-1].table);
(yyval.import)->table.name = (yyvsp[-3].text);
}
-#line 3451 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3461 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 121:
-#line 1040 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1050 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = (yyvsp[-2].import);
(yyval.import)->kind = WABT_EXTERNAL_KIND_MEMORY;
(yyval.import)->memory = (yyvsp[-1].memory);
(yyval.import)->memory.name = (yyvsp[-3].text);
}
-#line 3462 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3472 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 122:
-#line 1046 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1056 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = (yyvsp[-2].import);
(yyval.import)->kind = WABT_EXTERNAL_KIND_GLOBAL;
(yyval.import)->global = (yyvsp[-1].global);
(yyval.import)->global.name = (yyvsp[-3].text);
}
-#line 3473 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3483 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 123:
-#line 1055 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1065 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.import) = new_import();
(yyval.import)->module_name = (yyvsp[-2].text);
(yyval.import)->field_name = (yyvsp[-1].text);
}
-#line 3483 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3493 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 124:
-#line 1063 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1073 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.export_));
(yyval.export_).kind = WABT_EXTERNAL_KIND_FUNC;
(yyval.export_).var = (yyvsp[-1].var);
}
-#line 3493 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3503 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 125:
-#line 1068 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1078 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.export_));
(yyval.export_).kind = WABT_EXTERNAL_KIND_TABLE;
(yyval.export_).var = (yyvsp[-1].var);
}
-#line 3503 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3513 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 126:
-#line 1073 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1083 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.export_));
(yyval.export_).kind = WABT_EXTERNAL_KIND_MEMORY;
(yyval.export_).var = (yyvsp[-1].var);
}
-#line 3513 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3523 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 127:
-#line 1078 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1088 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.export_));
(yyval.export_).kind = WABT_EXTERNAL_KIND_GLOBAL;
(yyval.export_).var = (yyvsp[-1].var);
}
-#line 3523 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3533 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 128:
-#line 1085 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1095 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.export_) = (yyvsp[-1].export_);
(yyval.export_).name = (yyvsp[-2].text);
}
-#line 3532 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3542 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 129:
-#line 1092 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1102 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.optional_export));
- (yyval.optional_export).has_export = WABT_FALSE;
+ (yyval.optional_export).has_export = false;
}
-#line 3541 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3551 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 131:
-#line 1099 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1109 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.optional_export));
- (yyval.optional_export).has_export = WABT_TRUE;
+ (yyval.optional_export).has_export = true;
(yyval.optional_export).export_.name = (yyvsp[-1].text);
}
-#line 3551 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3561 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 132:
-#line 1110 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1120 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.func_type));
(yyval.func_type).sig = (yyvsp[-1].func_sig);
}
-#line 3560 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3570 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 133:
-#line 1114 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1124 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.func_type).name = (yyvsp[-2].text);
(yyval.func_type).sig = (yyvsp[-1].func_sig);
}
-#line 3569 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3579 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 134:
-#line 1121 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1131 "src/ast-parser.y" /* yacc.c:1646 */
{ (yyval.var) = (yyvsp[-1].var); }
-#line 3575 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3585 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 135:
-#line 1125 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1135 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = new_module();
}
-#line 3583 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3593 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 136:
-#line 1128 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1138 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
WabtModuleField* field;
@@ -3592,11 +3602,11 @@ yyreduce:
&field->func_type);
INSERT_BINDING((yyval.module), func_type, func_types, (yylsp[0]), (yyvsp[0].func_type).name);
}
-#line 3596 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3606 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 137:
-#line 1136 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1146 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
WabtModuleField* field;
@@ -3605,11 +3615,11 @@ yyreduce:
INSERT_BINDING((yyval.module), global, globals, (yylsp[0]), (yyvsp[0].exported_global).global.name);
APPEND_INLINE_EXPORT((yyval.module), GLOBAL, (yylsp[0]), (yyvsp[0].exported_global), (yyval.module)->globals.size - 1);
}
-#line 3609 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3619 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 138:
-#line 1144 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1154 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
WabtModuleField* field;
@@ -3627,11 +3637,11 @@ yyreduce:
}
}
-#line 3631 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3641 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 139:
-#line 1161 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1171 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
WabtModuleField* field;
@@ -3648,11 +3658,11 @@ yyreduce:
&data_segment_field->data_segment);
}
}
-#line 3652 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3662 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 140:
-#line 1177 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1187 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
WabtModuleField* field;
@@ -3663,11 +3673,11 @@ yyreduce:
APPEND_INLINE_EXPORT((yyval.module), FUNC, (yylsp[0]), (yyvsp[0].exported_func), (yyval.module)->funcs.size - 1);
wabt_free((yyvsp[0].exported_func).func);
}
-#line 3667 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3677 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 141:
-#line 1187 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1197 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
WabtModuleField* field;
@@ -3675,11 +3685,11 @@ yyreduce:
APPEND_ITEM_TO_VECTOR((yyval.module), ElemSegment, elem_segment, elem_segments,
&field->elem_segment);
}
-#line 3679 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3689 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 142:
-#line 1194 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1204 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
WabtModuleField* field;
@@ -3687,22 +3697,22 @@ yyreduce:
APPEND_ITEM_TO_VECTOR((yyval.module), DataSegment, data_segment, data_segments,
&field->data_segment);
}
-#line 3691 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3701 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 143:
-#line 1201 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1211 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
WabtModuleField* field;
APPEND_FIELD_TO_LIST((yyval.module), field, START, start, (yylsp[0]), (yyvsp[0].var));
(yyval.module)->start = &field->start;
}
-#line 3702 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3712 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 144:
-#line 1207 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1217 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
WabtModuleField* field;
@@ -3742,11 +3752,11 @@ yyreduce:
wabt_free((yyvsp[0].import));
APPEND_ITEM_TO_VECTOR((yyval.module), Import, import, imports, &field->import);
}
-#line 3746 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3756 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 145:
-#line 1246 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1256 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.module) = (yyvsp[-1].module);
WabtModuleField* field = wabt_append_module_field((yyval.module));
@@ -3754,11 +3764,11 @@ yyreduce:
APPEND_ITEM_TO_VECTOR((yyval.module), Export, export, exports, &field->export_);
INSERT_BINDING((yyval.module), export, exports, (yylsp[0]), (yyvsp[0].export_).name);
}
-#line 3758 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3768 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 146:
-#line 1256 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1266 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.raw_module).type = WABT_RAW_MODULE_TYPE_TEXT;
(yyval.raw_module).text = (yyvsp[-1].module);
@@ -3781,11 +3791,11 @@ yyreduce:
}
}
}
-#line 3785 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3795 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 147:
-#line 1278 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1288 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.raw_module).type = WABT_RAW_MODULE_TYPE_BINARY;
(yyval.raw_module).binary.name = (yyvsp[-2].text);
@@ -3793,11 +3803,11 @@ yyreduce:
dup_text_list(&(yyvsp[-1].text_list), &(yyval.raw_module).binary.data, &(yyval.raw_module).binary.size);
wabt_destroy_text_list(&(yyvsp[-1].text_list));
}
-#line 3797 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3807 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 148:
-#line 1288 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1298 "src/ast-parser.y" /* yacc.c:1646 */
{
if ((yyvsp[0].raw_module).type == WABT_RAW_MODULE_TYPE_TEXT) {
(yyval.module) = (yyvsp[0].raw_module).text;
@@ -3819,31 +3829,31 @@ yyreduce:
(yyval.module)->loc = (yyvsp[0].raw_module).binary.loc;
}
}
-#line 3823 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3833 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 149:
-#line 1314 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1324 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.var));
(yyval.var).type = WABT_VAR_TYPE_INDEX;
(yyval.var).index = INVALID_VAR_INDEX;
}
-#line 3833 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3843 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 150:
-#line 1319 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1329 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.var));
(yyval.var).type = WABT_VAR_TYPE_NAME;
DUPTEXT((yyval.var).name, (yyvsp[0].text));
}
-#line 3843 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3853 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 151:
-#line 1327 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1337 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.action));
(yyval.action).loc = (yylsp[-4]);
@@ -3852,11 +3862,11 @@ yyreduce:
(yyval.action).invoke.name = (yyvsp[-2].text);
(yyval.action).invoke.args = (yyvsp[-1].consts);
}
-#line 3856 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3866 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 152:
-#line 1335 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1345 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.action));
(yyval.action).loc = (yylsp[-3]);
@@ -3864,119 +3874,119 @@ yyreduce:
(yyval.action).type = WABT_ACTION_TYPE_GET;
(yyval.action).invoke.name = (yyvsp[-1].text);
}
-#line 3868 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3878 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 153:
-#line 1345 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1355 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command();
(yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_MALFORMED;
(yyval.command)->assert_malformed.module = (yyvsp[-2].raw_module);
(yyval.command)->assert_malformed.text = (yyvsp[-1].text);
}
-#line 3879 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3889 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 154:
-#line 1351 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1361 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command();
(yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_INVALID;
(yyval.command)->assert_invalid.module = (yyvsp[-2].raw_module);
(yyval.command)->assert_invalid.text = (yyvsp[-1].text);
}
-#line 3890 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3900 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 155:
-#line 1357 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1367 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command();
(yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_UNLINKABLE;
(yyval.command)->assert_unlinkable.module = (yyvsp[-2].raw_module);
(yyval.command)->assert_unlinkable.text = (yyvsp[-1].text);
}
-#line 3901 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3911 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 156:
-#line 1363 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1373 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command();
(yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_UNINSTANTIABLE;
(yyval.command)->assert_uninstantiable.module = (yyvsp[-2].raw_module);
(yyval.command)->assert_uninstantiable.text = (yyvsp[-1].text);
}
-#line 3912 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3922 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 157:
-#line 1369 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1379 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command();
(yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_RETURN;
(yyval.command)->assert_return.action = (yyvsp[-2].action);
(yyval.command)->assert_return.expected = (yyvsp[-1].consts);
}
-#line 3923 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3933 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 158:
-#line 1375 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1385 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command();
(yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_RETURN_NAN;
(yyval.command)->assert_return_nan.action = (yyvsp[-1].action);
}
-#line 3933 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3943 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 159:
-#line 1380 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1390 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command();
(yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_TRAP;
(yyval.command)->assert_trap.action = (yyvsp[-2].action);
(yyval.command)->assert_trap.text = (yyvsp[-1].text);
}
-#line 3944 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3954 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 160:
-#line 1386 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1396 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command();
(yyval.command)->type = WABT_COMMAND_TYPE_ASSERT_EXHAUSTION;
(yyval.command)->assert_trap.action = (yyvsp[-2].action);
(yyval.command)->assert_trap.text = (yyvsp[-1].text);
}
-#line 3955 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3965 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 161:
-#line 1395 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1405 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command();
(yyval.command)->type = WABT_COMMAND_TYPE_ACTION;
(yyval.command)->action = (yyvsp[0].action);
}
-#line 3965 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3975 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 163:
-#line 1401 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1411 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command();
(yyval.command)->type = WABT_COMMAND_TYPE_MODULE;
(yyval.command)->module = *(yyvsp[0].module);
wabt_free((yyvsp[0].module));
}
-#line 3976 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3986 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 164:
-#line 1407 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1417 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.command) = new_command();
(yyval.command)->type = WABT_COMMAND_TYPE_REGISTER;
@@ -3984,27 +3994,27 @@ yyreduce:
(yyval.command)->register_.var = (yyvsp[-1].var);
(yyval.command)->register_.var.loc = (yylsp[-1]);
}
-#line 3988 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 3998 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 165:
-#line 1416 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1426 "src/ast-parser.y" /* yacc.c:1646 */
{ WABT_ZERO_MEMORY((yyval.commands)); }
-#line 3994 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 4004 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 166:
-#line 1417 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1427 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.commands) = (yyvsp[-1].commands);
wabt_append_command_value(&(yyval.commands), (yyvsp[0].command));
wabt_free((yyvsp[0].command));
}
-#line 4004 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 4014 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 167:
-#line 1425 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1435 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.const_).loc = (yylsp[-2]);
if (WABT_FAILED(parse_const((yyvsp[-2].type), (yyvsp[-1].literal).type, (yyvsp[-1].literal).text.start,
@@ -4015,26 +4025,26 @@ yyreduce:
}
wabt_free((char*)(yyvsp[-1].literal).text.start);
}
-#line 4019 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 4029 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 168:
-#line 1437 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1447 "src/ast-parser.y" /* yacc.c:1646 */
{ WABT_ZERO_MEMORY((yyval.consts)); }
-#line 4025 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 4035 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 169:
-#line 1438 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1448 "src/ast-parser.y" /* yacc.c:1646 */
{
(yyval.consts) = (yyvsp[-1].consts);
wabt_append_const_value(&(yyval.consts), &(yyvsp[0].const_));
}
-#line 4034 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 4044 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
case 170:
-#line 1445 "src/ast-parser.y" /* yacc.c:1646 */
+#line 1455 "src/ast-parser.y" /* yacc.c:1646 */
{
WABT_ZERO_MEMORY((yyval.script));
(yyval.script).commands = (yyvsp[0].commands);
@@ -4094,11 +4104,11 @@ yyreduce:
}
parser->script = (yyval.script);
}
-#line 4098 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 4108 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
break;
-#line 4102 "src/prebuilt/ast-parser-gen.c" /* yacc.c:1646 */
+#line 4112 "src/prebuilt/ast-parser-gen.cc" /* yacc.c:1646 */
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -4333,7 +4343,7 @@ yyreturn:
#endif
return yyresult;
}
-#line 1512 "src/ast-parser.y" /* yacc.c:1906 */
+#line 1522 "src/ast-parser.y" /* yacc.c:1906 */
static void append_expr_list(WabtExprList* expr_list, WabtExprList* expr) {
@@ -4462,7 +4472,7 @@ static void dup_text_list(WabtTextList* text_list,
size_t size = (end > src) ? (end - src) : 0;
total_size += size;
}
- char* result = wabt_alloc(total_size);
+ char* result = (char*)wabt_alloc(total_size);
char* dest = result;
for (node = text_list->first; node; node = node->next) {
size_t actual_size = copy_string_contents(&node->text, dest);
@@ -4472,7 +4482,7 @@ static void dup_text_list(WabtTextList* text_list,
*out_size = dest - result;
}
-static WabtBool is_empty_signature(WabtFuncSignature* sig) {
+static bool is_empty_signature(WabtFuncSignature* sig) {
return sig->result_types.size == 0 && sig->param_types.size == 0;
}
@@ -4502,13 +4512,16 @@ WabtResult wabt_parse_ast(WabtAstLexer* lexer,
WABT_ZERO_MEMORY(parser);
parser.error_handler = error_handler;
int result = wabt_ast_parser_parse(lexer, &parser);
+ wabt_free(parser.yyssa);
+ wabt_free(parser.yyvsa);
+ wabt_free(parser.yylsa);
*out_script = parser.script;
return result == 0 && parser.errors == 0 ? WABT_OK : WABT_ERROR;
}
static void on_read_binary_error(uint32_t offset, const char* error,
void* user_data) {
- BinaryErrorCallbackData* data = user_data;
+ BinaryErrorCallbackData* data = (BinaryErrorCallbackData*)user_data;
if (offset == WABT_UNKNOWN_OFFSET) {
wabt_ast_parser_error(data->loc, data->lexer, data->parser,
"error in binary module: %s", error);
@@ -4517,7 +4530,3 @@ static void on_read_binary_error(uint32_t offset, const char* error,
"error in binary module: @0x%08x: %s", offset, error);
}
}
-
-/* see comment above definition of YYMAXDEPTH at the top of this file */
-WABT_STATIC_ASSERT(YYSTACK_ALLOC_MAXIMUM >= UINT32_MAX);
-WABT_STATIC_ASSERT(YYSTACK_BYTES((uint64_t)YYMAXDEPTH) <= UINT32_MAX);
diff --git a/src/resolve-names.c b/src/resolve-names.cc
index 14de1016..a3d36f11 100644
--- a/src/resolve-names.c
+++ b/src/resolve-names.cc
@@ -62,7 +62,7 @@ typedef struct FindDuplicateBindingContext {
static void on_duplicate_binding(WabtBindingHashEntry* a,
WabtBindingHashEntry* b,
void* user_data) {
- FindDuplicateBindingContext* fdbc = user_data;
+ FindDuplicateBindingContext* fdbc = (FindDuplicateBindingContext*)user_data;
/* choose the location that is later in the file */
WabtLocation* a_loc = &a->binding.loc;
WabtLocation* b_loc = &b->binding.loc;
@@ -155,43 +155,43 @@ static void resolve_local_var(Context* ctx, WabtVar* var) {
}
static WabtResult begin_block_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
push_label(ctx, &expr->block.label);
return WABT_OK;
}
static WabtResult end_block_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
pop_label(ctx);
return WABT_OK;
}
static WabtResult begin_loop_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
push_label(ctx, &expr->loop.label);
return WABT_OK;
}
static WabtResult end_loop_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
pop_label(ctx);
return WABT_OK;
}
static WabtResult on_br_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
resolve_label_var(ctx, &expr->br.var);
return WABT_OK;
}
static WabtResult on_br_if_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
resolve_label_var(ctx, &expr->br_if.var);
return WABT_OK;
}
static WabtResult on_br_table_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
size_t i;
WabtVarVector* targets = &expr->br_table.targets;
for (i = 0; i < targets->size; ++i) {
@@ -204,55 +204,55 @@ static WabtResult on_br_table_expr(WabtExpr* expr, void* user_data) {
}
static WabtResult on_call_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
resolve_func_var(ctx, &expr->call.var);
return WABT_OK;
}
static WabtResult on_call_indirect_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
resolve_func_type_var(ctx, &expr->call_indirect.var);
return WABT_OK;
}
static WabtResult on_get_global_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
resolve_global_var(ctx, &expr->get_global.var);
return WABT_OK;
}
static WabtResult on_get_local_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
resolve_local_var(ctx, &expr->get_local.var);
return WABT_OK;
}
static WabtResult begin_if_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
push_label(ctx, &expr->if_.true_.label);
return WABT_OK;
}
static WabtResult end_if_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
pop_label(ctx);
return WABT_OK;
}
static WabtResult on_set_global_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
resolve_global_var(ctx, &expr->set_global.var);
return WABT_OK;
}
static WabtResult on_set_local_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
resolve_local_var(ctx, &expr->set_local.var);
return WABT_OK;
}
static WabtResult on_tee_local_expr(WabtExpr* expr, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
resolve_local_var(ctx, &expr->tee_local.var);
return WABT_OK;
}
@@ -269,22 +269,22 @@ static void visit_func(Context* ctx, WabtFunc* func) {
ctx->current_func = NULL;
}
-static void visit_export(Context* ctx, WabtExport* export) {
- switch (export->kind) {
+static void visit_export(Context* ctx, WabtExport* export_) {
+ switch (export_->kind) {
case WABT_EXTERNAL_KIND_FUNC:
- resolve_func_var(ctx, &export->var);
+ resolve_func_var(ctx, &export_->var);
break;
case WABT_EXTERNAL_KIND_TABLE:
- resolve_table_var(ctx, &export->var);
+ resolve_table_var(ctx, &export_->var);
break;
case WABT_EXTERNAL_KIND_MEMORY:
- resolve_memory_var(ctx, &export->var);
+ resolve_memory_var(ctx, &export_->var);
break;
case WABT_EXTERNAL_KIND_GLOBAL:
- resolve_global_var(ctx, &export->var);
+ resolve_global_var(ctx, &export_->var);
break;
case WABT_NUM_EXTERNAL_KINDS:
diff --git a/src/stream.c b/src/stream.cc
index 2bb3a6ac..9ec9e2a5 100644
--- a/src/stream.c
+++ b/src/stream.cc
@@ -125,7 +125,7 @@ void wabt_write_memory_dump(WabtStream* stream,
WabtPrintChars print_chars,
const char* prefix,
const char* desc) {
- const uint8_t* p = start;
+ const uint8_t* p = (const uint8_t*)start;
const uint8_t* end = p + size;
while (p < end) {
const uint8_t* line = p;
diff --git a/src/tools/wasm-interp.c b/src/tools/wasm-interp.cc
index 782e7190..76fd901f 100644
--- a/src/tools/wasm-interp.c
+++ b/src/tools/wasm-interp.cc
@@ -33,15 +33,15 @@
static const char* s_trap_strings[] = {FOREACH_INTERPRETER_RESULT(V)};
#undef V
-static WabtBool s_verbose;
+static int s_verbose;
static const char* s_infile;
static WabtReadBinaryOptions s_read_binary_options =
WABT_READ_BINARY_OPTIONS_DEFAULT;
static WabtInterpreterThreadOptions s_thread_options =
WABT_INTERPRETER_THREAD_OPTIONS_DEFAULT;
-static WabtBool s_trace;
-static WabtBool s_spec;
-static WabtBool s_run_all_exports;
+static bool s_trace;
+static bool s_spec;
+static bool s_run_all_exports;
static WabtStream* s_stdout_stream;
static WabtBinaryErrorHandler s_error_handler =
@@ -133,15 +133,15 @@ static void on_option(struct WabtOptionParser* parser,
break;
case FLAG_TRACE:
- s_trace = WABT_TRUE;
+ s_trace = true;
break;
case FLAG_SPEC:
- s_spec = WABT_TRUE;
+ s_spec = true;
break;
case FLAG_RUN_ALL_EXPORTS:
- s_run_all_exports = WABT_TRUE;
+ s_run_all_exports = true;
break;
}
}
@@ -378,16 +378,16 @@ static WabtInterpreterResult run_start_function(WabtInterpreterThread* thread,
static WabtInterpreterResult run_export(
WabtInterpreterThread* thread,
- const WabtInterpreterExport* export,
+ const WabtInterpreterExport* export_,
const WabtInterpreterTypedValueVector* args,
WabtInterpreterTypedValueVector* out_results) {
if (s_trace) {
printf(">>> running export \"" PRIstringslice "\":\n",
- WABT_PRINTF_STRING_SLICE_ARG(export->name));
+ WABT_PRINTF_STRING_SLICE_ARG(export_->name));
}
- assert(export->kind == WABT_EXTERNAL_KIND_FUNC);
- return run_function(thread, export->index, args, out_results);
+ assert(export_->kind == WABT_EXTERNAL_KIND_FUNC);
+ return run_function(thread, export_->index, args, out_results);
}
static WabtInterpreterResult run_export_by_name(
@@ -397,13 +397,13 @@ static WabtInterpreterResult run_export_by_name(
const WabtInterpreterTypedValueVector* args,
WabtInterpreterTypedValueVector* out_results,
RunVerbosity verbose) {
- WabtInterpreterExport* export =
+ WabtInterpreterExport* export_ =
wabt_get_interpreter_export_by_name(module, name);
- if (!export)
+ if (!export_)
return WABT_INTERPRETER_UNKNOWN_EXPORT;
- if (export->kind != WABT_EXTERNAL_KIND_FUNC)
+ if (export_->kind != WABT_EXTERNAL_KIND_FUNC)
return WABT_INTERPRETER_EXPORT_KIND_MISMATCH;
- return run_export(thread, export, args, out_results);
+ return run_export(thread, export_, args, out_results);
}
static WabtInterpreterResult get_global_export_by_name(
@@ -411,15 +411,15 @@ static WabtInterpreterResult get_global_export_by_name(
WabtInterpreterModule* module,
const WabtStringSlice* name,
WabtInterpreterTypedValueVector* out_results) {
- WabtInterpreterExport* export =
+ WabtInterpreterExport* export_ =
wabt_get_interpreter_export_by_name(module, name);
- if (!export)
+ if (!export_)
return WABT_INTERPRETER_UNKNOWN_EXPORT;
- if (export->kind != WABT_EXTERNAL_KIND_GLOBAL)
+ if (export_->kind != WABT_EXTERNAL_KIND_GLOBAL)
return WABT_INTERPRETER_EXPORT_KIND_MISMATCH;
- assert(export->index < thread->env->globals.size);
- WabtInterpreterGlobal* global = &thread->env->globals.data[export->index];
+ assert(export_->index < thread->env->globals.size);
+ WabtInterpreterGlobal* global = &thread->env->globals.data[export_->index];
/* Don't clear out the vector, in case it is being reused. Just reset the
* size to zero. */
@@ -437,10 +437,11 @@ static void run_all_exports(WabtInterpreterModule* module,
WABT_ZERO_MEMORY(results);
uint32_t i;
for (i = 0; i < module->exports.size; ++i) {
- WabtInterpreterExport* export = &module->exports.data[i];
- WabtInterpreterResult iresult = run_export(thread, export, &args, &results);
+ WabtInterpreterExport* export_ = &module->exports.data[i];
+ WabtInterpreterResult iresult =
+ run_export(thread, export_, &args, &results);
if (verbose) {
- print_call(wabt_empty_string_slice(), export->name, &args, &results,
+ print_call(wabt_empty_string_slice(), export_->name, &args, &results,
iresult);
}
}
@@ -529,7 +530,7 @@ static WabtResult spectest_import_table(WabtInterpreterImport* import,
WabtPrintErrorCallback callback,
void* user_data) {
if (wabt_string_slice_eq_cstr(&import->field_name, "table")) {
- table->limits.has_max = WABT_TRUE;
+ table->limits.has_max = true;
table->limits.initial = 10;
table->limits.max = 20;
return WABT_OK;
@@ -545,7 +546,7 @@ static WabtResult spectest_import_memory(WabtInterpreterImport* import,
WabtPrintErrorCallback callback,
void* user_data) {
if (wabt_string_slice_eq_cstr(&import->field_name, "memory")) {
- memory->page_limits.has_max = WABT_TRUE;
+ memory->page_limits.has_max = true;
memory->page_limits.initial = 1;
memory->page_limits.max = 2;
memory->byte_size = memory->page_limits.initial * WABT_MAX_PAGES;
@@ -647,7 +648,7 @@ typedef struct Context {
size_t json_offset;
WabtLocation loc;
WabtLocation prev_loc;
- WabtBool has_prev_loc;
+ bool has_prev_loc;
uint32_t command_line_number;
/* Test info */
@@ -697,7 +698,7 @@ static void putback_char(Context* ctx) {
assert(ctx->has_prev_loc);
ctx->json_offset--;
ctx->loc = ctx->prev_loc;
- ctx->has_prev_loc = WABT_FALSE;
+ ctx->has_prev_loc = false;
}
static int read_char(Context* ctx) {
@@ -711,7 +712,7 @@ static int read_char(Context* ctx) {
} else {
ctx->loc.first_column++;
}
- ctx->has_prev_loc = WABT_TRUE;
+ ctx->has_prev_loc = true;
return c;
}
@@ -734,7 +735,7 @@ static void skip_whitespace(Context* ctx) {
}
}
-static WabtBool match(Context* ctx, const char* s) {
+static bool match(Context* ctx, const char* s) {
skip_whitespace(ctx);
WabtLocation start_loc = ctx->loc;
size_t start_offset = ctx->json_offset;
@@ -742,11 +743,11 @@ static WabtBool match(Context* ctx, const char* s) {
s++;
if (*s == 0) {
- return WABT_TRUE;
+ return true;
} else {
ctx->json_offset = start_offset;
ctx->loc = start_loc;
- return WABT_FALSE;
+ return false;
}
}
@@ -762,7 +763,7 @@ static WabtResult expect(Context* ctx, const char* s) {
static WabtResult expect_key(Context* ctx, const char* key) {
size_t keylen = strlen(key);
size_t quoted_len = keylen + 2 + 1;
- char* quoted = alloca(quoted_len);
+ char* quoted = (char*)alloca(quoted_len);
wabt_snprintf(quoted, quoted_len, "\"%s\"", key);
EXPECT(quoted);
EXPECT(":");
@@ -901,13 +902,13 @@ static WabtResult parse_type_object(Context* ctx, WabtType* out_type) {
static WabtResult parse_type_vector(Context* ctx, WabtTypeVector* out_types) {
WABT_ZERO_MEMORY(*out_types);
EXPECT("[");
- WabtBool first = WABT_TRUE;
+ bool first = true;
while (!match(ctx, "]")) {
if (!first)
EXPECT(",");
WabtType type;
CHECK_RESULT(parse_type_object(ctx, &type));
- first = WABT_FALSE;
+ first = false;
wabt_append_type_value(out_types, &type);
}
return WABT_OK;
@@ -966,14 +967,14 @@ static WabtResult parse_const_vector(
WabtInterpreterTypedValueVector* out_values) {
WABT_ZERO_MEMORY(*out_values);
EXPECT("[");
- WabtBool first = WABT_TRUE;
+ bool first = true;
while (!match(ctx, "]")) {
if (!first)
EXPECT(",");
WabtInterpreterTypedValue value;
CHECK_RESULT(parse_const(ctx, &value));
wabt_append_interpreter_typed_value_value(out_values, &value);
- first = WABT_FALSE;
+ first = false;
}
return WABT_OK;
}
@@ -1009,7 +1010,7 @@ static char* create_module_path(Context* ctx, WabtStringSlice filename) {
const char* spec_json_filename = ctx->loc.filename;
WabtStringSlice dirname = get_dirname(spec_json_filename);
size_t path_len = dirname.length + 1 + filename.length + 1;
- char* path = wabt_alloc(path_len);
+ char* path = (char*)wabt_alloc(path_len);
if (dirname.length == 0) {
wabt_snprintf(path, path_len, PRIstringslice,
@@ -1124,19 +1125,20 @@ static WabtResult on_action_command(Context* ctx, Action* action) {
static WabtBinaryErrorHandler* new_custom_error_handler(Context* ctx,
const char* desc) {
size_t header_size = ctx->source_filename.length + strlen(desc) + 100;
- char* header = wabt_alloc(header_size);
+ char* header = (char*)wabt_alloc(header_size);
wabt_snprintf(header, header_size, PRIstringslice ":%d: %s passed",
WABT_PRINTF_STRING_SLICE_ARG(ctx->source_filename),
ctx->command_line_number, desc);
WabtDefaultErrorHandlerInfo* info =
- wabt_alloc_zero(sizeof(WabtDefaultErrorHandlerInfo));
+ (WabtDefaultErrorHandlerInfo*)wabt_alloc_zero(
+ sizeof(WabtDefaultErrorHandlerInfo));
info->header = header;
info->out_file = stdout;
info->print_header = WABT_PRINT_ERROR_HEADER_ONCE;
WabtBinaryErrorHandler* error_handler =
- wabt_alloc_zero(sizeof(WabtBinaryErrorHandler));
+ (WabtBinaryErrorHandler*)wabt_alloc_zero(sizeof(WabtBinaryErrorHandler));
error_handler->on_error = wabt_default_binary_error_callback;
error_handler->user_data = info;
return error_handler;
@@ -1144,7 +1146,8 @@ static WabtBinaryErrorHandler* new_custom_error_handler(Context* ctx,
static void destroy_custom_error_handler(
WabtBinaryErrorHandler* error_handler) {
- WabtDefaultErrorHandlerInfo* info = error_handler->user_data;
+ WabtDefaultErrorHandlerInfo* info =
+ (WabtDefaultErrorHandlerInfo*)error_handler->user_data;
wabt_free((void*)info->header);
wabt_free(info);
wabt_free(error_handler);
@@ -1295,17 +1298,17 @@ static WabtResult on_assert_uninstantiable_command(Context* ctx,
return result;
}
-static WabtBool typed_values_are_equal(const WabtInterpreterTypedValue* tv1,
+static bool typed_values_are_equal(const WabtInterpreterTypedValue* tv1,
const WabtInterpreterTypedValue* tv2) {
if (tv1->type != tv2->type)
- return WABT_FALSE;
+ return false;
switch (tv1->type) {
case WABT_TYPE_I32: return tv1->value.i32 == tv2->value.i32;
case WABT_TYPE_F32: return tv1->value.f32_bits == tv2->value.f32_bits;
case WABT_TYPE_I64: return tv1->value.i64 == tv2->value.i64;
case WABT_TYPE_F64: return tv1->value.f64_bits == tv2->value.f64_bits;
- default: assert(0); return WABT_FALSE;
+ default: assert(0); return false;
}
}
@@ -1618,12 +1621,12 @@ static WabtResult parse_commands(Context* ctx) {
EXPECT(",");
EXPECT_KEY("commands");
EXPECT("[");
- WabtBool first = WABT_TRUE;
+ bool first = true;
while (!match(ctx, "]")) {
if (!first)
EXPECT(",");
CHECK_RESULT(parse_command(ctx));
- first = WABT_FALSE;
+ first = false;
}
EXPECT("}");
return WABT_OK;
@@ -1650,7 +1653,7 @@ static WabtResult read_and_run_spec_json(const char* spec_json_filename) {
if (WABT_FAILED(result))
return WABT_ERROR;
- ctx.json_data = data;
+ ctx.json_data = (char*)data;
ctx.json_data_size = size;
result = parse_commands(&ctx);
diff --git a/src/tools/wasm-link.c b/src/tools/wasm-link.cc
index 1e65e0f8..7487bc15 100644
--- a/src/tools/wasm-link.c
+++ b/src/tools/wasm-link.cc
@@ -50,8 +50,8 @@ WABT_STATIC_ASSERT(NUM_FLAGS == WABT_ARRAY_SIZE(s_options));
typedef const char* String;
WABT_DEFINE_VECTOR(string, String);
-static WabtBool s_verbose;
-static WabtBool s_relocatable;
+static int s_verbose;
+static bool s_relocatable;
static const char* s_outfile = "a.wasm";
static StringVector s_infiles;
static WabtFileWriter s_log_stream_writer;
@@ -78,7 +78,7 @@ static void on_option(struct WabtOptionParser* parser,
break;
case FLAG_RELOCATABLE:
- s_relocatable = WABT_TRUE;
+ s_relocatable = true;
break;
case FLAG_HELP:
@@ -282,16 +282,16 @@ static void write_export_section(Context* ctx) {
for (i = 0; i < ctx->inputs.size; i++) {
WabtLinkerInputBinary* binary = &ctx->inputs.data[i];
for (j = 0; j < binary->exports.size; j++) {
- WabtExport* export = &binary->exports.data[j];
- write_slice(stream, export->name, "export name");
- wabt_write_u8(stream, export->kind, "export kind");
- uint32_t index = export->index;
- switch (export->kind) {
+ WabtExport* export_ = &binary->exports.data[j];
+ write_slice(stream, export_->name, "export name");
+ wabt_write_u8(stream, export_->kind, "export kind");
+ uint32_t index = export_->index;
+ switch (export_->kind) {
case WABT_EXTERNAL_KIND_FUNC:
index = relocate_func_index(binary, index);
break;
default:
- WABT_FATAL("unsupport export type: %d\n", export->kind);
+ WABT_FATAL("unsupport export type: %d\n", export_->kind);
break;
}
wabt_write_u32_leb128(stream, index, "export index");
@@ -339,7 +339,7 @@ static void write_memory_section(Context* ctx,
WabtLimits limits;
WABT_ZERO_MEMORY(limits);
- limits.has_max = WABT_TRUE;
+ limits.has_max = true;
size_t i;
for (i = 0; i < sections->size; i++) {
WabtSection* sec = sections->data[i];
@@ -366,7 +366,7 @@ static void write_global_import(Context* ctx, WabtGlobalImport* import) {
write_slice(&ctx->stream, import->name, "import field name");
wabt_write_u8(&ctx->stream, WABT_EXTERNAL_KIND_GLOBAL, "import kind");
wabt_write_type(&ctx->stream, import->type);
- wabt_write_u8(&ctx->stream, import->mutable, "global mutability");
+ wabt_write_u8(&ctx->stream, import->mutable_, "global mutability");
}
static void write_import_section(Context* ctx) {
@@ -541,11 +541,11 @@ static void write_reloc_section(Context* ctx,
FIXUP_SIZE(stream);
}
-static WabtBool write_combined_section(Context* ctx,
- WabtBinarySection section_code,
- WabtSectionPtrVector* sections) {
+static bool write_combined_section(Context* ctx,
+ WabtBinarySection section_code,
+ WabtSectionPtrVector* sections) {
if (!sections->size)
- return WABT_FALSE;
+ return false;
if (section_code == WABT_BINARY_SECTION_START && sections->size > 1) {
WABT_FATAL("Don't know how to combine sections of type: %s\n",
@@ -605,11 +605,11 @@ static WabtBool write_combined_section(Context* ctx,
}
}
- return WABT_TRUE;
+ return true;
}
typedef struct ExportInfo {
- WabtExport* export;
+ WabtExport* export_;
WabtLinkerInputBinary* binary;
} ExportInfo;
WABT_DEFINE_VECTOR(export_info, ExportInfo);
@@ -625,13 +625,13 @@ static void resolve_symbols(Context* ctx) {
for (i = 0; i < ctx->inputs.size; i++) {
WabtLinkerInputBinary* binary = &ctx->inputs.data[i];
for (j = 0; j < binary->exports.size; j++) {
- WabtExport* export = &binary->exports.data[j];
+ WabtExport* export_ = &binary->exports.data[j];
ExportInfo* info = wabt_append_export_info(&export_list);
- info->export = export;
+ info->export_ = export_;
info->binary = binary;
/* TODO(sbc): Handle duplicate names */
- WabtStringSlice name = wabt_dup_string_slice(export->name);
+ WabtStringSlice name = wabt_dup_string_slice(export_->name);
WabtBinding* binding = wabt_insert_binding(&export_map, &name);
binding->index = export_list.size - 1;
}
@@ -658,9 +658,9 @@ static void resolve_symbols(Context* ctx) {
ExportInfo* export_info = &export_list.data[export_index];
/* TODO(sbc): verify the foriegn function has the correct signature */
- import->active = WABT_FALSE;
+ import->active = false;
import->foreign_binary = export_info->binary;
- import->foreign_index = export_info->export->index;
+ import->foreign_index = export_info->export_->index;
binary->active_function_imports--;
}
}
@@ -742,14 +742,14 @@ static void write_binary(Context* ctx) {
/* Write known sections first */
for (i = FIRST_KNOWN_SECTION; i < WABT_NUM_BINARY_SECTIONS; i++) {
- write_combined_section(ctx, i, &sections[i]);
+ write_combined_section(ctx, (WabtBinarySection)i, &sections[i]);
}
write_names_section(ctx);
/* Generate a new set of reloction sections */
for (i = FIRST_KNOWN_SECTION; i < WABT_NUM_BINARY_SECTIONS; i++) {
- write_reloc_section(ctx, i, &sections[i]);
+ write_reloc_section(ctx, (WabtBinarySection)i, &sections[i]);
}
for (i = 0; i < WABT_NUM_BINARY_SECTIONS; i++) {
@@ -826,7 +826,7 @@ int main(int argc, char** argv) {
if (WABT_FAILED(result))
return result;
WabtLinkerInputBinary* b = wabt_append_binary(&context.inputs);
- b->data = data;
+ b->data = (uint8_t*)data;
b->size = size;
b->filename = input_filename;
result = wabt_read_binary_linker(b);
diff --git a/src/tools/wasm2wast.c b/src/tools/wasm2wast.cc
index 5015dbbd..4f701638 100644
--- a/src/tools/wasm2wast.c
+++ b/src/tools/wasm2wast.cc
@@ -34,8 +34,8 @@
static int s_verbose;
static const char* s_infile;
static const char* s_outfile;
-static WabtReadBinaryOptions s_read_binary_options = {NULL, WABT_TRUE};
-static WabtBool s_generate_names;
+static WabtReadBinaryOptions s_read_binary_options = {NULL, true};
+static bool s_generate_names;
static WabtBinaryErrorHandler s_error_handler =
WABT_BINARY_ERROR_HANDLER_DEFAULT;
@@ -100,11 +100,11 @@ static void on_option(struct WabtOptionParser* parser,
break;
case FLAG_NO_DEBUG_NAMES:
- s_read_binary_options.read_debug_names = WABT_FALSE;
+ s_read_binary_options.read_debug_names = false;
break;
case FLAG_GENERATE_NAMES:
- s_generate_names = WABT_TRUE;
+ s_generate_names = true;
break;
}
}
diff --git a/src/tools/wasmdump.c b/src/tools/wasmdump.cc
index fd1488e5..fdde4681 100644
--- a/src/tools/wasmdump.c
+++ b/src/tools/wasmdump.cc
@@ -74,26 +74,26 @@ static void on_option(struct WabtOptionParser* parser,
const char* argument) {
switch (option->id) {
case FLAG_HEADERS:
- s_objdump_options.headers = WABT_TRUE;
+ s_objdump_options.headers = true;
break;
case FLAG_RAW:
- s_objdump_options.raw = WABT_TRUE;
+ s_objdump_options.raw = true;
break;
case FLAG_DEBUG:
- s_objdump_options.debug = WABT_TRUE;
+ s_objdump_options.debug = true;
case FLAG_DISASSEMBLE:
- s_objdump_options.disassemble = WABT_TRUE;
+ s_objdump_options.disassemble = true;
break;
case FLAG_DETAILS:
- s_objdump_options.details = WABT_TRUE;
+ s_objdump_options.details = true;
break;
case FLAG_RELOCS:
- s_objdump_options.relocs = WABT_TRUE;
+ s_objdump_options.relocs = true;
break;
case FLAG_SECTION:
@@ -142,12 +142,15 @@ int main(int argc, char** argv) {
return 1;
}
- void* data;
+ void* void_data;
size_t size;
- WabtResult result = wabt_read_file(s_objdump_options.infile, &data, &size);
+ WabtResult result =
+ wabt_read_file(s_objdump_options.infile, &void_data, &size);
if (WABT_FAILED(result))
return result;
+ uint8_t* data = (uint8_t*)void_data;
+
// Perform serveral passed over the binary in order to print out different
// types of information.
s_objdump_options.print_header = 1;
diff --git a/src/tools/wasmopcodecnt.c b/src/tools/wasmopcodecnt.cc
index 5d6a4855..91cca58a 100644
--- a/src/tools/wasmopcodecnt.c
+++ b/src/tools/wasmopcodecnt.cc
@@ -161,7 +161,7 @@ typedef void (*display_name_fcn)(FILE* out, intmax_t value);
static void display_opcode_name(FILE* out, intmax_t opcode) {
if (opcode >= 0 && opcode < WABT_NUM_OPCODES)
- fprintf(out, "%s", wabt_get_opcode_name(opcode));
+ fprintf(out, "%s", wabt_get_opcode_name((WabtOpcode)opcode));
else
fprintf(out, "?(%" PRIdMAX ")", opcode);
}
@@ -226,12 +226,14 @@ static int opcode_counter_gt(WabtIntCounter* counter_1,
const char* name_1 = "?1";
const char* name_2 = "?2";
if (counter_1->value < WABT_NUM_OPCODES) {
- const char* opcode_name = wabt_get_opcode_name(counter_1->value);
+ const char* opcode_name =
+ wabt_get_opcode_name((WabtOpcode)counter_1->value);
if (opcode_name)
name_1 = opcode_name;
}
if (counter_2->value < WABT_NUM_OPCODES) {
- const char* opcode_name = wabt_get_opcode_name(counter_2->value);
+ const char* opcode_name =
+ wabt_get_opcode_name((WabtOpcode)counter_2->value);
if (opcode_name)
name_2 = opcode_name;
}
diff --git a/src/tools/wast-desugar.c b/src/tools/wast-desugar.cc
index 79d0e6cf..d3e9d931 100644
--- a/src/tools/wast-desugar.c
+++ b/src/tools/wast-desugar.cc
@@ -35,7 +35,7 @@
static const char* s_infile;
static const char* s_outfile;
-static WabtBool s_generate_names;
+static bool s_generate_names;
static WabtSourceErrorHandler s_error_handler =
WABT_SOURCE_ERROR_HANDLER_DEFAULT;
@@ -84,7 +84,7 @@ static void on_option(struct WabtOptionParser* parser,
break;
case FLAG_GENERATE_NAMES:
- s_generate_names = WABT_TRUE;
+ s_generate_names = true;
break;
}
}
diff --git a/src/tools/wast2wasm.c b/src/tools/wast2wasm.cc
index df2e481b..a5e3d3b8 100644
--- a/src/tools/wast2wasm.c
+++ b/src/tools/wast2wasm.cc
@@ -36,14 +36,14 @@
static const char* s_infile;
static const char* s_outfile;
-static WabtBool s_dump_module;
-static WabtBool s_verbose;
+static bool s_dump_module;
+static int s_verbose;
static WabtWriteBinaryOptions s_write_binary_options =
WABT_WRITE_BINARY_OPTIONS_DEFAULT;
static WabtWriteBinarySpecOptions s_write_binary_spec_options =
WABT_WRITE_BINARY_SPEC_OPTIONS_DEFAULT;
-static WabtBool s_spec;
-static WabtBool s_validate = WABT_TRUE;
+static bool s_spec;
+static bool s_validate = true;
static WabtSourceErrorHandler s_error_handler =
WABT_SOURCE_ERROR_HANDLER_DEFAULT;
@@ -121,7 +121,7 @@ static void on_option(struct WabtOptionParser* parser,
break;
case FLAG_DUMP_MODULE:
- s_dump_module = WABT_TRUE;
+ s_dump_module = true;
break;
case FLAG_OUTPUT:
@@ -129,23 +129,23 @@ static void on_option(struct WabtOptionParser* parser,
break;
case FLAG_RELOCATABLE:
- s_write_binary_options.relocatable = WABT_TRUE;
+ s_write_binary_options.relocatable = true;
break;
case FLAG_SPEC:
- s_spec = WABT_TRUE;
+ s_spec = true;
break;
case FLAG_NO_CANONICALIZE_LEB128S:
- s_write_binary_options.canonicalize_lebs = WABT_FALSE;
+ s_write_binary_options.canonicalize_lebs = false;
break;
case FLAG_DEBUG_NAMES:
- s_write_binary_options.write_debug_names = WABT_TRUE;
+ s_write_binary_options.write_debug_names = true;
break;
case FLAG_NO_CHECK:
- s_validate = WABT_FALSE;
+ s_validate = false;
break;
}
}
diff --git a/src/type-checker.c b/src/type-checker.cc
index e8935a27..63c0c2ad 100644
--- a/src/type-checker.c
+++ b/src/type-checker.cc
@@ -22,9 +22,9 @@
return WABT_ERROR; \
} while (0)
-#define COMBINE_RESULT(result_var, result) \
- do { \
- (result_var) |= (result); \
+#define COMBINE_RESULT(result_var, result) \
+ do { \
+ (result_var) = (WabtResult)((result_var) | (result)); \
} while (0)
static void WABT_PRINTF_FORMAT(2, 3)
@@ -54,10 +54,10 @@ static WabtResult top_label(WabtTypeChecker* tc,
return wabt_typechecker_get_label(tc, 0, out_label);
}
-WabtBool wabt_typechecker_is_unreachable(WabtTypeChecker* tc) {
+bool wabt_typechecker_is_unreachable(WabtTypeChecker* tc) {
WabtTypeCheckerLabel* label;
if (WABT_FAILED(top_label(tc, &label)))
- return WABT_TRUE;
+ return true;
return label->unreachable;
}
@@ -69,7 +69,7 @@ static void reset_type_stack_to_label(WabtTypeChecker* tc,
static WabtResult set_unreachable(WabtTypeChecker* tc) {
WabtTypeCheckerLabel* label;
CHECK_RESULT(top_label(tc, &label));
- label->unreachable = WABT_TRUE;
+ label->unreachable = true;
reset_type_stack_to_label(tc, label);
return WABT_OK;
}
@@ -82,7 +82,7 @@ static void push_label(WabtTypeChecker* tc,
label->label_type = label_type;
wabt_extend_types(&label->sig, sig);
label->type_stack_limit = tc->type_stack.size;
- label->unreachable = WABT_FALSE;
+ label->unreachable = false;
}
static void wabt_destroy_type_checker_label(WabtTypeCheckerLabel* label) {
@@ -411,7 +411,7 @@ WabtResult wabt_typechecker_on_else(WabtTypeChecker* tc) {
COMBINE_RESULT(result, check_type_stack_end(tc, "if true branch"));
reset_type_stack_to_label(tc, label);
label->label_type = WABT_LABEL_TYPE_ELSE;
- label->unreachable = WABT_FALSE;
+ label->unreachable = false;
return result;
}
diff --git a/src/type-checker.h b/src/type-checker.h
index 5e9f6629..31f80edb 100644
--- a/src/type-checker.h
+++ b/src/type-checker.h
@@ -34,7 +34,7 @@ typedef struct WabtTypeCheckerLabel {
WabtLabelType label_type;
WabtTypeVector sig;
size_t type_stack_limit;
- WabtBool unreachable;
+ bool unreachable;
} WabtTypeCheckerLabel;
WABT_DEFINE_VECTOR(type_checker_label, WabtTypeCheckerLabel);
@@ -51,7 +51,7 @@ WABT_EXTERN_C_BEGIN
void wabt_destroy_typechecker(WabtTypeChecker*);
-WabtBool wabt_typechecker_is_unreachable(WabtTypeChecker* tc);
+bool wabt_typechecker_is_unreachable(WabtTypeChecker* tc);
WabtResult wabt_typechecker_get_label(WabtTypeChecker* tc,
size_t depth,
WabtTypeCheckerLabel** out_label);
diff --git a/src/type-vector.h b/src/type-vector.h
index 94b822cf..54627cdd 100644
--- a/src/type-vector.h
+++ b/src/type-vector.h
@@ -24,17 +24,17 @@ WABT_DEFINE_VECTOR(type, WabtType)
WABT_EXTERN_C_BEGIN
-static WABT_INLINE WabtBool
-wabt_type_vectors_are_equal(const WabtTypeVector* types1,
- const WabtTypeVector* types2) {
+static WABT_INLINE bool wabt_type_vectors_are_equal(
+ const WabtTypeVector* types1,
+ const WabtTypeVector* types2) {
if (types1->size != types2->size)
- return WABT_FALSE;
+ return false;
size_t i;
for (i = 0; i < types1->size; ++i) {
if (types1->data[i] != types2->data[i])
- return WABT_FALSE;
+ return false;
}
- return WABT_TRUE;
+ return true;
}
WABT_EXTERN_C_END
diff --git a/src/validator.c b/src/validator.cc
index 8b76afa8..8e3d5d97 100644
--- a/src/validator.c
+++ b/src/validator.cc
@@ -67,11 +67,11 @@ static void WABT_PRINTF_FORMAT(3, 4)
}
static void on_typechecker_error(const char* msg, void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
print_error(ctx, ctx->expr_loc, "%s", msg);
}
-static WabtBool is_power_of_two(uint32_t x) {
+static bool is_power_of_two(uint32_t x) {
return x && ((x & (x - 1)) == 0);
}
@@ -757,7 +757,7 @@ static void check_export(Context* ctx, const WabtExport* export_) {
static void on_duplicate_binding(WabtBindingHashEntry* a,
WabtBindingHashEntry* b,
void* user_data) {
- Context* ctx = user_data;
+ Context* ctx = (Context*)user_data;
/* choose the location that is later in the file */
WabtLocation* a_loc = &a->binding.loc;
WabtLocation* b_loc = &b->binding.loc;
@@ -773,7 +773,7 @@ static void check_duplicate_export_bindings(Context* ctx,
}
static void check_module(Context* ctx, const WabtModule* module) {
- WabtBool seen_start = WABT_FALSE;
+ bool seen_start = false;
ctx->current_module = module;
ctx->current_table_index = 0;
@@ -839,7 +839,7 @@ static void check_module(Context* ctx, const WabtModule* module) {
"start function must not return anything");
}
}
- seen_start = WABT_TRUE;
+ seen_start = true;
break;
}
}
@@ -863,15 +863,15 @@ static const WabtTypeVector* check_invoke(Context* ctx,
return NULL;
}
- WabtExport* export = wabt_get_export_by_name(module, &invoke->name);
- if (!export) {
+ WabtExport* export_ = wabt_get_export_by_name(module, &invoke->name);
+ if (!export_) {
print_error(ctx, &action->loc,
"unknown function export \"" PRIstringslice "\"",
WABT_PRINTF_STRING_SLICE_ARG(invoke->name));
return NULL;
}
- WabtFunc* func = wabt_get_func_by_var(module, &export->var);
+ WabtFunc* func = wabt_get_func_by_var(module, &export_->var);
if (!func) {
/* this error will have already been reported, just skip it */
return NULL;
@@ -907,15 +907,15 @@ static WabtResult check_get(Context* ctx,
return WABT_ERROR;
}
- WabtExport* export = wabt_get_export_by_name(module, &get->name);
- if (!export) {
+ WabtExport* export_ = wabt_get_export_by_name(module, &get->name);
+ if (!export_) {
print_error(ctx, &action->loc,
"unknown global export \"" PRIstringslice "\"",
WABT_PRINTF_STRING_SLICE_ARG(get->name));
return WABT_ERROR;
}
- WabtGlobal* global = wabt_get_global_by_var(module, &export->var);
+ WabtGlobal* global = wabt_get_global_by_var(module, &export_->var);
if (!global) {
/* this error will have already been reported, just skip it */
return WABT_ERROR;
diff --git a/src/vector.c b/src/vector.cc
index b7135e67..b7135e67 100644
--- a/src/vector.c
+++ b/src/vector.cc
diff --git a/src/wasm-link.h b/src/wasm-link.h
index 90d0fc34..11ce629d 100644
--- a/src/wasm-link.h
+++ b/src/wasm-link.h
@@ -28,7 +28,7 @@ struct WabtLinkerInputBinary;
typedef struct WabtFunctionImport {
WabtStringSlice name;
uint32_t sig_index;
- WabtBool active; /* Is this import present in the linked binary */
+ bool active; /* Is this import present in the linked binary */
struct WabtLinkerInputBinary* foreign_binary;
uint32_t foreign_index;
} WabtFunctionImport;
@@ -37,7 +37,7 @@ WABT_DEFINE_VECTOR(function_import, WabtFunctionImport);
typedef struct WabtGlobalImport {
WabtStringSlice name;
WabtType type;
- WabtBool mutable;
+ bool mutable_;
} WabtGlobalImport;
WABT_DEFINE_VECTOR(global_import, WabtGlobalImport);
diff --git a/src/writer.c b/src/writer.cc
index 2833b207..e50999eb 100644
--- a/src/writer.c
+++ b/src/writer.cc
@@ -34,7 +34,7 @@ static WabtResult write_data_to_file(size_t offset,
void* user_data) {
if (size == 0)
return WABT_OK;
- WabtFileWriter* writer = user_data;
+ WabtFileWriter* writer = (WabtFileWriter*)user_data;
if (offset != writer->offset) {
if (fseek(writer->file, offset, SEEK_SET) != 0) {
ERROR("fseek offset=%" PRIzd " failed, errno=%d\n", size, errno);
@@ -108,7 +108,7 @@ static WabtResult write_data_to_output_buffer(size_t offset,
const void* data,
size_t size,
void* user_data) {
- WabtMemoryWriter* writer = user_data;
+ WabtMemoryWriter* writer = (WabtMemoryWriter*)user_data;
size_t end = offset + size;
ensure_output_buffer_capacity(&writer->buf, end);
memcpy((void*)((size_t)writer->buf.start + offset), data, size);
@@ -121,7 +121,7 @@ static WabtResult move_data_in_output_buffer(size_t dst_offset,
size_t src_offset,
size_t size,
void* user_data) {
- WabtMemoryWriter* writer = user_data;
+ WabtMemoryWriter* writer = (WabtMemoryWriter*)user_data;
size_t src_end = src_offset + size;
size_t dst_end = dst_offset + size;
size_t end = src_end > dst_end ? src_end : dst_end;