summaryrefslogtreecommitdiff
path: root/src/wasm-binary-reader-ast.c
diff options
context:
space:
mode:
authorBen Smith <binjimin@gmail.com>2016-07-18 16:34:12 -0700
committerGitHub <noreply@github.com>2016-07-18 16:34:12 -0700
commit73e5bc7dd4a4e5bc7fcb842a35b91ad587f80fcb (patch)
treef510be5fdeaaca527d76350e80643a9dc042e5e3 /src/wasm-binary-reader-ast.c
parentb487574ba29dd85c64be6aa1406b58084b14b8b4 (diff)
downloadwabt-73e5bc7dd4a4e5bc7fcb842a35b91ad587f80fcb.tar.gz
wabt-73e5bc7dd4a4e5bc7fcb842a35b91ad587f80fcb.tar.bz2
wabt-73e5bc7dd4a4e5bc7fcb842a35b91ad587f80fcb.zip
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.
Diffstat (limited to 'src/wasm-binary-reader-ast.c')
-rw-r--r--src/wasm-binary-reader-ast.c6
1 files changed, 3 insertions, 3 deletions
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;