From 5a1be55f5a50c1df5cdce6412a589bafa5fab1df Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Mon, 24 Oct 2016 14:02:18 -0700 Subject: Use a new format for the spec JSON writer/parser The previous spec JSON format was defined around modules. This is because the previous spec tests would only run assertions on the most recently read module. In addition, the previous spec writer would write the assertions as new exported functions in the module, and run those. The primary reason for doing this was to allow for passing/returning i64 values, which was necessary to test in a JavaScript host. Now that the primary host for running the spec tests is wasm-interp, we no longer need do bundle assertions into the module. Also, some of the new spec tests allow running exported functions on a module that is not the most-recently-read module. The new spec test format is now defined around commands. The commands map directly to the spec format commands, e.g. `module`, `assert_invalid`, `assert_trap`, etc. --- src/wasm-binary-writer-spec.h | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) (limited to 'src/wasm-binary-writer-spec.h') diff --git a/src/wasm-binary-writer-spec.h b/src/wasm-binary-writer-spec.h index 7991a019..1c2629ce 100644 --- a/src/wasm-binary-writer-spec.h +++ b/src/wasm-binary-writer-spec.h @@ -18,39 +18,24 @@ #define WASM_BINARY_WRITER_SPEC_H_ #include "wasm-ast.h" +#include "wasm-binary-writer.h" #include "wasm-common.h" struct WasmAllocator; -struct WasmWriteBinaryOptions; struct WasmWriter; #define WASM_WRITE_BINARY_SPEC_OPTIONS_DEFAULT \ - { NULL, NULL, NULL, NULL, NULL, NULL, NULL } + { NULL, WASM_WRITE_BINARY_OPTIONS_DEFAULT } typedef struct WasmWriteBinarySpecOptions { - /* callbacks for writing multiple modules */ - void (*on_script_begin)(void* user_data); - void (*on_module_begin)(uint32_t index, - void* user_data); - void (*on_command)(uint32_t index, - WasmCommandType type, - const WasmStringSlice* name, - const WasmLocation* loc, - void* user_data); - void (*on_module_before_write)(uint32_t index, - struct WasmWriter** out_writer, - void* user_data); - void (*on_module_end)(uint32_t index, WasmResult result, void* user_data); - void (*on_script_end)(void* user_data); - - void* user_data; + const char* json_filename; + WasmWriteBinaryOptions write_binary_options; } WasmWriteBinarySpecOptions; WASM_EXTERN_C_BEGIN -/* this function modifies the AST */ WasmResult wasm_write_binary_spec_script(struct WasmAllocator*, struct WasmScript*, - const struct WasmWriteBinaryOptions*, + const char* source_filename, const WasmWriteBinarySpecOptions*); WASM_EXTERN_C_END -- cgit v1.2.3