From 73e5bc7dd4a4e5bc7fcb842a35b91ad587f80fcb Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Mon, 18 Jul 2016 16:34:12 -0700 Subject: WasmFuncDeclaration does not always set `sig` (#93) Prior to this change, the AST parser would always set `sig`, even if the function had no explicit signature (i.e. it used a function type variable instead). This is OK, but it makes the flag confusing. `WASM_FUNC_DECLARATION_FLAG_HAS_SIGNATURE` will be clear and `wasm_decl_has_signature` will return false, but `sig` will be valid. This change makes it so `sig` is only set when there is an explicit signature. The correct way to get the function signature is to call `wasm_decl_get_signature`, which will check whether there is a func type, and if not, will check for an explicit function signature. --- src/wasm-binary-reader-ast.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/wasm-binary-reader-ast.c') diff --git a/src/wasm-binary-reader-ast.c b/src/wasm-binary-reader-ast.c index b29c06e8..50513774 100644 --- a/src/wasm-binary-reader-ast.c +++ b/src/wasm-binary-reader-ast.c @@ -53,7 +53,7 @@ do { \ assert(wasm_decl_has_func_type(&ctx->current_func->decl)); \ uint32_t max_local_index = \ - wasm_get_num_params_and_locals(ctx->current_func); \ + wasm_get_num_params_and_locals(ctx->module, ctx->current_func); \ if ((local_index) >= max_local_index) { \ print_error(ctx, "invalid local_index: %d (max %d)", (local_index), \ max_local_index); \ @@ -990,7 +990,7 @@ static WasmResult on_local_names_count(uint32_t index, WasmModule* module = ctx->module; assert(index < module->funcs.size); WasmFunc* func = module->funcs.data[index]; - uint32_t num_params_and_locals = wasm_get_num_params_and_locals(func); + uint32_t num_params_and_locals = wasm_get_num_params_and_locals(module, func); if (count > num_params_and_locals) { print_error(ctx, "expected local name count (%d) <= local count (%d)", count, num_params_and_locals); @@ -1006,7 +1006,7 @@ static WasmResult on_local_name(uint32_t func_index, Context* ctx = user_data; WasmModule* module = ctx->module; WasmFunc* func = module->funcs.data[func_index]; - uint32_t num_params = wasm_get_num_params(func); + uint32_t num_params = wasm_get_num_params(module, func); WasmStringSlice new_name; dup_name(ctx, &name, &new_name); WasmBindingHash* bindings; -- cgit v1.2.3