Skip to content

Commit

Permalink
examples/app: use expr_end
Browse files Browse the repository at this point in the history
  • Loading branch information
yamt committed Jun 28, 2024
1 parent 7104abb commit 419a6c5
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions examples/app/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ main(int argc, char **argv)
uint32_t funcidx_with_largest_type_annotations = UINT32_MAX;
uint32_t largest_type_annotations = 0;
#endif
#if defined(TOYWASM_ENABLE_WRITER)
uint32_t funcidx_with_max_code_size = UINT32_MAX;
uint32_t max_code_size = 0;
#endif
for (i = 0; i < m->nfuncs; i++) {
const struct func *func = &m->funcs[i];
const struct localtype *lt = &func->localtype;
Expand Down Expand Up @@ -93,14 +91,12 @@ main(int argc, char **argv)
largest_type_annotations = ei->type_annotations.ntypes;
}
#endif
#if defined(TOYWASM_ENABLE_WRITER)
uint32_t code_size = func->e.end - func->e.start;
uint32_t code_size = expr_end(&func->e) - func->e.start;
if (funcidx_with_max_code_size == UINT32_MAX ||
code_size > max_code_size) {
funcidx_with_max_code_size = i;
max_code_size = code_size;
}
#endif
}

struct nametable table;
Expand Down Expand Up @@ -155,7 +151,6 @@ main(int argc, char **argv)
funcidx, CSTR(&func_name), largest_type_annotations);
}
#endif
#if defined(TOYWASM_ENABLE_WRITER)
if (funcidx_with_max_code_size != UINT32_MAX) {
uint32_t funcidx =
m->nimportedfuncs + funcidx_with_max_code_size;
Expand All @@ -165,7 +160,6 @@ main(int argc, char **argv)
" bytes) in this module.\n",
funcidx, CSTR(&func_name), max_code_size);
}
#endif
nametable_clear(&table);
module_destroy(&mctx, m);
mem_context_clear(&mctx);
Expand Down

0 comments on commit 419a6c5

Please sign in to comment.