diff options
author | Ben Smith <binji@chromium.org> | 2016-09-22 17:39:20 -0700 |
---|---|---|
committer | Ben Smith <binji@chromium.org> | 2016-09-29 11:37:27 -0700 |
commit | b4d2bc2f3fe925a78a7e1ea061106b1f01e8dba2 (patch) | |
tree | f6ae9ce3def03e9945cf2108221b0ab2138fa42a /src/wasm-ast-writer.c | |
parent | cca0d93b8ba2a6ea101f18927eddfbe5ec726dd0 (diff) | |
download | wabt-b4d2bc2f3fe925a78a7e1ea061106b1f01e8dba2.tar.gz wabt-b4d2bc2f3fe925a78a7e1ea061106b1f01e8dba2.tar.bz2 wabt-b4d2bc2f3fe925a78a7e1ea061106b1f01e8dba2.zip |
parse tests for {im,ex}porting tables, etc.
Diffstat (limited to 'src/wasm-ast-writer.c')
-rw-r--r-- | src/wasm-ast-writer.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/wasm-ast-writer.c b/src/wasm-ast-writer.c index abbda8d0..01170ad7 100644 --- a/src/wasm-ast-writer.c +++ b/src/wasm-ast-writer.c @@ -513,11 +513,13 @@ static void write_expr_list(Context* ctx, const WasmExpr* first) { } static void write_init_expr(Context* ctx, const WasmExpr* expr) { - write_puts(ctx, "(", NEXT_CHAR_NONE); - write_expr(ctx, expr); - /* clear the next char, so we don't write a newline after the expr */ - ctx->next_char = NEXT_CHAR_NONE; - write_puts(ctx, ")", NEXT_CHAR_SPACE); + if (expr) { + write_puts(ctx, "(", NEXT_CHAR_NONE); + write_expr(ctx, expr); + /* clear the next char, so we don't write a newline after the expr */ + ctx->next_char = NEXT_CHAR_NONE; + write_puts(ctx, ")", NEXT_CHAR_SPACE); + } } static void write_type_bindings(Context* ctx, @@ -582,11 +584,15 @@ static void write_func(Context* ctx, static void write_begin_global(Context* ctx, const WasmGlobal* global) { write_open_space(ctx, "global"); - if (global->mutable_) - write_puts(ctx, "mut", NEXT_CHAR_SPACE); write_string_slice_or_index(ctx, &global->name, ctx->global_index++, NEXT_CHAR_SPACE); - write_type(ctx, global->type, NEXT_CHAR_SPACE); + if (global->mutable_) { + write_open_space(ctx, "mut"); + write_type(ctx, global->type, NEXT_CHAR_SPACE); + write_close_space(ctx); + } else { + write_type(ctx, global->type, NEXT_CHAR_SPACE); + } } static void write_global(Context* ctx, const WasmGlobal* global) { @@ -654,12 +660,13 @@ static void write_import(Context* ctx, const WasmImport* import) { assert(0); break; } - write_string_slice_or_index(ctx, &import->name, index, NEXT_CHAR_SPACE); write_quoted_string_slice(ctx, &import->module_name, NEXT_CHAR_SPACE); write_quoted_string_slice(ctx, &import->field_name, NEXT_CHAR_SPACE); switch (import->kind) { case WASM_EXTERNAL_KIND_FUNC: write_open_space(ctx, "func"); + write_string_slice_or_index(ctx, &import->func.name, index, + NEXT_CHAR_SPACE); if (wasm_decl_has_func_type(&import->func.decl)) { write_open_space(ctx, "type"); write_var(ctx, &import->func.decl.type_var, NEXT_CHAR_NONE); @@ -671,15 +678,11 @@ static void write_import(Context* ctx, const WasmImport* import) { break; case WASM_EXTERNAL_KIND_TABLE: - write_open_space(ctx, "table"); write_table(ctx, &import->table); - write_close_space(ctx); break; case WASM_EXTERNAL_KIND_MEMORY: - write_open_space(ctx, "memory"); write_memory(ctx, &import->memory); - write_close_space(ctx); break; case WASM_EXTERNAL_KIND_GLOBAL: |