Verified Commit f279ce02 authored by nagayama15's avatar nagayama15

count import functions

parent 62b48497
...@@ -48,17 +48,27 @@ int main(int argc, char* argv[]) { ...@@ -48,17 +48,27 @@ int main(int argc, char* argv[]) {
wasm::Module module{}; wasm::Module module{};
wasm::ModuleReader{}.read(input, module); wasm::ModuleReader{}.read(input, module);
std::size_t num_imports = 0;
for (const auto& f : module.functions) {
if (f->body == nullptr) {
num_imports += 1;
}
}
if (!quiet) { if (!quiet) {
fmt::print( fmt::print(
"functions: {}\n" "functions: {}\n"
"exports: {}\n", "exports: {}\n"
"imports: {}\n",
module.functions.size(), module.functions.size(),
module.exports.size()); module.exports.size(),
num_imports);
} else { } else {
fmt::print( fmt::print(
"{}\t{}\n", "{}\t{}\t{}\n",
module.functions.size(), module.functions.size(),
module.exports.size()); module.exports.size(),
num_imports);
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
fmt::print(std::cerr, "error: {}\n", e.what()); fmt::print(std::cerr, "error: {}\n", e.what());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment