diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-binary-reader.c | 36 | ||||
-rw-r--r-- | src/wasm-binary-writer.c | 18 | ||||
-rw-r--r-- | src/wasm-binary.h | 38 |
3 files changed, 46 insertions, 46 deletions
diff --git a/src/wasm-binary-reader.c b/src/wasm-binary-reader.c index 8edd856b..e95edb0c 100644 --- a/src/wasm-binary-reader.c +++ b/src/wasm-binary-reader.c @@ -403,9 +403,9 @@ WasmResult wasm_read_binary(WasmAllocator* allocator, in_u32(&ctx, &version, "version"); RAISE_ERROR_UNLESS(&ctx, version == WASM_BINARY_VERSION, "version mismatch"); - /* signatures */ + /* type */ uint32_t num_signatures = 0; - if (skip_until_section(&ctx, WASM_SECTION_INDEX_SIGNATURES)) { + if (skip_until_section(&ctx, WASM_SECTION_INDEX_TYPE)) { CALLBACK0(&ctx, begin_signature_section); uint32_t i; in_u32_leb128(&ctx, &num_signatures, "signature count"); @@ -439,9 +439,9 @@ WasmResult wasm_read_binary(WasmAllocator* allocator, CALLBACK0(&ctx, end_signature_section); } - /* import_table */ + /* import */ uint32_t num_imports = 0; - if (skip_until_section(&ctx, WASM_SECTION_INDEX_IMPORT_TABLE)) { + if (skip_until_section(&ctx, WASM_SECTION_INDEX_IMPORT)) { CALLBACK0(&ctx, begin_import_section); uint32_t i; in_u32_leb128(&ctx, &num_imports, "import count"); @@ -463,9 +463,9 @@ WasmResult wasm_read_binary(WasmAllocator* allocator, CALLBACK0(&ctx, end_import_section); } - /* function_signatures */ + /* function */ uint32_t num_function_signatures = 0; - if (skip_until_section(&ctx, WASM_SECTION_INDEX_FUNCTION_SIGNATURES)) { + if (skip_until_section(&ctx, WASM_SECTION_INDEX_FUNCTION)) { CALLBACK0(&ctx, begin_function_signatures_section); uint32_t i; in_u32_leb128(&ctx, &num_function_signatures, "function signature count"); @@ -480,9 +480,9 @@ WasmResult wasm_read_binary(WasmAllocator* allocator, CALLBACK0(&ctx, end_function_signatures_section); } - /* function_table */ + /* table */ uint32_t num_function_table_entries; - if (skip_until_section(&ctx, WASM_SECTION_INDEX_FUNCTION_TABLE)) { + if (skip_until_section(&ctx, WASM_SECTION_INDEX_TABLE)) { CALLBACK0(&ctx, begin_function_table_section); uint32_t i; in_u32_leb128(&ctx, &num_function_table_entries, @@ -519,9 +519,9 @@ WasmResult wasm_read_binary(WasmAllocator* allocator, CALLBACK0(&ctx, end_memory_section); } - /* export_table */ + /* export */ uint32_t num_exports = 0; - if (skip_until_section(&ctx, WASM_SECTION_INDEX_EXPORT_TABLE)) { + if (skip_until_section(&ctx, WASM_SECTION_INDEX_EXPORT)) { CALLBACK0(&ctx, begin_export_section); uint32_t i; in_u32_leb128(&ctx, &num_exports, "export count"); @@ -540,8 +540,8 @@ WasmResult wasm_read_binary(WasmAllocator* allocator, CALLBACK0(&ctx, end_export_section); } - /* start_function */ - if (skip_until_section(&ctx, WASM_SECTION_INDEX_START_FUNCTION)) { + /* start */ + if (skip_until_section(&ctx, WASM_SECTION_INDEX_START)) { CALLBACK0(&ctx, begin_start_section); uint32_t func_index; in_u32_leb128(&ctx, &func_index, "start function index"); @@ -551,9 +551,9 @@ WasmResult wasm_read_binary(WasmAllocator* allocator, CALLBACK0(&ctx, end_start_section); } - /* function_bodies */ + /* code */ uint32_t num_function_bodies = 0; - if (skip_until_section(&ctx, WASM_SECTION_INDEX_FUNCTION_BODIES)) { + if (skip_until_section(&ctx, WASM_SECTION_INDEX_CODE)) { CALLBACK0(&ctx, begin_function_bodies_section); uint32_t i; in_u32_leb128(&ctx, &num_function_bodies, "function body count"); @@ -932,8 +932,8 @@ WasmResult wasm_read_binary(WasmAllocator* allocator, CALLBACK0(&ctx, end_function_bodies_section); } - /* data_segments */ - if (skip_until_section(&ctx, WASM_SECTION_INDEX_DATA_SEGMENTS)) { + /* data */ + if (skip_until_section(&ctx, WASM_SECTION_INDEX_DATA)) { RAISE_ERROR_UNLESS(&ctx, seen_memory_section, "data segment section without memory section"); CALLBACK0(&ctx, begin_data_segment_section); @@ -953,9 +953,9 @@ WasmResult wasm_read_binary(WasmAllocator* allocator, CALLBACK0(&ctx, end_data_segment_section); } - /* names */ + /* name */ if (options->read_debug_names && - skip_until_section(&ctx, WASM_SECTION_INDEX_NAMES)) { + skip_until_section(&ctx, WASM_SECTION_INDEX_NAME)) { CALLBACK0(&ctx, begin_names_section); uint32_t i, num_functions; in_u32_leb128(&ctx, &num_functions, "function name count"); diff --git a/src/wasm-binary-writer.c b/src/wasm-binary-writer.c index 7c4234bc..4a33a8a7 100644 --- a/src/wasm-binary-writer.c +++ b/src/wasm-binary-writer.c @@ -784,7 +784,7 @@ static void write_module(WasmContext* ctx, const WasmModule* module) { WASM_ZERO_MEMORY(sigs); get_func_signatures(ctx, module, &sigs); if (sigs.size) { - begin_section(ctx, WASM_SECTION_NAME_SIGNATURES, leb_size_guess); + begin_section(ctx, WASM_SECTION_NAME_TYPE, leb_size_guess); write_u32_leb128(&ctx->stream, sigs.size, "num signatures"); for (i = 0; i < sigs.size; ++i) { const WasmFuncSignature* sig = &sigs.data[i]; @@ -799,7 +799,7 @@ static void write_module(WasmContext* ctx, const WasmModule* module) { } if (module->imports.size) { - begin_section(ctx, WASM_SECTION_NAME_IMPORT_TABLE, leb_size_guess); + begin_section(ctx, WASM_SECTION_NAME_IMPORT, leb_size_guess); write_u32_leb128(&ctx->stream, module->imports.size, "num imports"); for (i = 0; i < module->imports.size; ++i) { @@ -817,7 +817,7 @@ static void write_module(WasmContext* ctx, const WasmModule* module) { } if (module->funcs.size) { - begin_section(ctx, WASM_SECTION_NAME_FUNCTION_SIGNATURES, leb_size_guess); + begin_section(ctx, WASM_SECTION_NAME_FUNCTION, leb_size_guess); write_u32_leb128(&ctx->stream, module->funcs.size, "num functions"); for (i = 0; i < module->funcs.size; ++i) { @@ -830,7 +830,7 @@ static void write_module(WasmContext* ctx, const WasmModule* module) { } if (module->table && module->table->size) { - begin_section(ctx, WASM_SECTION_NAME_FUNCTION_TABLE, leb_size_guess); + begin_section(ctx, WASM_SECTION_NAME_TABLE, leb_size_guess); write_u32_leb128(&ctx->stream, module->table->size, "num function table entries"); for (i = 0; i < module->table->size; ++i) { @@ -852,7 +852,7 @@ static void write_module(WasmContext* ctx, const WasmModule* module) { } if (module->exports.size) { - begin_section(ctx, WASM_SECTION_NAME_EXPORT_TABLE, leb_size_guess); + begin_section(ctx, WASM_SECTION_NAME_EXPORT, leb_size_guess); write_u32_leb128(&ctx->stream, module->exports.size, "num exports"); for (i = 0; i < module->exports.size; ++i) { @@ -869,14 +869,14 @@ static void write_module(WasmContext* ctx, const WasmModule* module) { if (module->start) { int start_func_index = wasm_get_func_index_by_var(module, module->start); if (start_func_index != -1) { - begin_section(ctx, WASM_SECTION_NAME_START_FUNCTION, leb_size_guess); + begin_section(ctx, WASM_SECTION_NAME_START, leb_size_guess); write_u32_leb128(&ctx->stream, start_func_index, "start func index"); end_section(ctx); } } if (module->funcs.size) { - begin_section(ctx, WASM_SECTION_NAME_FUNCTION_BODIES, leb_size_guess); + begin_section(ctx, WASM_SECTION_NAME_CODE, leb_size_guess); write_u32_leb128(&ctx->stream, module->funcs.size, "num functions"); for (i = 0; i < module->funcs.size; ++i) { @@ -895,7 +895,7 @@ static void write_module(WasmContext* ctx, const WasmModule* module) { } if (module->memory && module->memory->segments.size) { - begin_section(ctx, WASM_SECTION_NAME_DATA_SEGMENTS, leb_size_guess); + begin_section(ctx, WASM_SECTION_NAME_DATA, leb_size_guess); write_u32_leb128(&ctx->stream, module->memory->segments.size, "num data segments"); for (i = 0; i < module->memory->segments.size; ++i) { @@ -915,7 +915,7 @@ static void write_module(WasmContext* ctx, const WasmModule* module) { WASM_ZERO_MEMORY(index_to_name); char desc[100]; - begin_section(ctx, WASM_SECTION_NAME_NAMES, leb_size_guess); + begin_section(ctx, WASM_SECTION_NAME_NAME, leb_size_guess); write_u32_leb128(&ctx->stream, module->funcs.size, "num functions"); for (i = 0; i < module->funcs.size; ++i) { const WasmFunc* func = module->funcs.data[i]; diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 75525d9f..2d2d30fa 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -18,29 +18,29 @@ #define WASM_BINARY_H_ #define WASM_BINARY_MAGIC 0x6d736100 -#define WASM_BINARY_VERSION 0x0a +#define WASM_BINARY_VERSION 0x0b -#define WASM_SECTION_NAME_SIGNATURES "signatures" -#define WASM_SECTION_NAME_IMPORT_TABLE "import_table" -#define WASM_SECTION_NAME_FUNCTION_SIGNATURES "function_signatures" -#define WASM_SECTION_NAME_FUNCTION_TABLE "function_table" +#define WASM_SECTION_NAME_TYPE "type" +#define WASM_SECTION_NAME_IMPORT "import" +#define WASM_SECTION_NAME_FUNCTION "function" +#define WASM_SECTION_NAME_TABLE "table" #define WASM_SECTION_NAME_MEMORY "memory" -#define WASM_SECTION_NAME_EXPORT_TABLE "export_table" -#define WASM_SECTION_NAME_START_FUNCTION "start_function" -#define WASM_SECTION_NAME_FUNCTION_BODIES "function_bodies" -#define WASM_SECTION_NAME_DATA_SEGMENTS "data_segments" -#define WASM_SECTION_NAME_NAMES "names" +#define WASM_SECTION_NAME_EXPORT "export" +#define WASM_SECTION_NAME_START "start" +#define WASM_SECTION_NAME_CODE "code" +#define WASM_SECTION_NAME_DATA "data" +#define WASM_SECTION_NAME_NAME "name" #define WASM_FOREACH_SECTION(V) \ - V(SIGNATURES) \ - V(IMPORT_TABLE) \ - V(FUNCTION_SIGNATURES) \ - V(FUNCTION_TABLE) \ + V(TYPE) \ + V(IMPORT) \ + V(FUNCTION) \ + V(TABLE) \ V(MEMORY) \ - V(EXPORT_TABLE) \ - V(START_FUNCTION) \ - V(FUNCTION_BODIES) \ - V(DATA_SEGMENTS) \ - V(NAMES) + V(EXPORT) \ + V(START) \ + V(CODE) \ + V(DATA) \ + V(NAME) #endif /* WASM_BINARY_H_ */ |