protoverse

A metaverse protocol
git clone git://jb55.com/protoverse
Log | Files | Refs | README | LICENSE

commit 58363be5add8a0cc92a69d6776a4c00543413281
parent da7f3ddb69721a7acde39c08030d8631cb39960a
Author: William Casarin <jb55@jb55.com>
Date:   Mon,  5 Jul 2021 10:30:21 -0700

print_table_section

Diffstat:
MMakefile | 2+-
Msrc/wasm.c | 37+++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile @@ -1,5 +1,5 @@ -CFLAGS = -Wno-error=unused-function -O2 -g -std=gnu90 -Wall -Wextra -Werror \ +CFLAGS = -Wno-error=unused-function -DDEBUG -O2 -g -std=gnu90 -Wall -Wextra -Werror \ -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes \ -Wmissing-declarations -Wdeclaration-after-statement diff --git a/src/wasm.c b/src/wasm.c @@ -317,6 +317,42 @@ static void print_import_section(struct importsec *importsec) } } +static void print_limits(struct limits *limits) +{ + switch (limits->type) { + case limit_min: + debug("%d", limits->min); + break; + case limit_min_max: + debug("%d-%d", limits->min, limits->max); + break; + } +} + +static const char *reftype_name(enum reftype reftype) +{ + switch (reftype) { + case funcref: return "funcref"; + case externref: return "externref"; + } + return "unknown_reftype"; +} + +static void print_table_section(struct tablesec *section) +{ + int i; + struct table *table; + + debug("%d tables:\n", section->num_tables); + for (i = 0; i < section->num_tables; i++) { + table = &section->tables[i]; + debug(" "); + debug("%s: ", reftype_name(table->reftype)); + print_limits(&table->limits); + debug("\n"); + } +} + static void print_export_section(struct exportsec *exportsec) { int i; @@ -362,6 +398,7 @@ static void print_module(struct module *module) //print_func_section(&module->func_section); print_import_section(&module->import_section); print_export_section(&module->export_section); + print_table_section(&module->table_section); //print_code_section(&module->code_section); }