diff options
author | Ben Smith <binjimin@gmail.com> | 2016-08-04 20:15:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-04 20:15:18 -0700 |
commit | 2d375e8d502327e814d62a08f22da9d9b6b675dc (patch) | |
tree | fbac644d0498c0fdf368935593f4894d3817ab2d /src/wasm-ast-parser-lexer-shared.c | |
parent | 31dcad7ff987455bae219b31e4d6c76d78634315 (diff) | |
download | wabt-2d375e8d502327e814d62a08f22da9d9b6b675dc.tar.gz wabt-2d375e8d502327e814d62a08f22da9d9b6b675dc.tar.bz2 wabt-2d375e8d502327e814d62a08f22da9d9b6b675dc.zip |
update testsuite, handle implicit func types (#96)
Change 7c482b1a of the spec repo now requires that implicit function
types are created when creating a new func or import, but only when the
type is not explicitly specified, and the have not been specified. For
example:
```
(func (param i32))
(import "foo" "bar" (result i32)
```
This was previously done in sexpr-wasm when writing the binary, but now
these types can be referenced by `call_import`, so it has to be handled
earlier.
Since all signatures are now defined in the module, I made it so the
function signature is shared with the module function types. The tricky
part here is when a function type and an explicit signature are both
specified:
```
(func (type $t) (param f32) ...)
```
In this case, we need to keep the explicit signature around long enough
to be checked against the function type, so it must be owned by the
function. The WASM_FUNC_DECLARATION_FLAG_SHARED_SIGNATURE flag specifies
this case.
To simplify code that uses the AST, I reverted many of the
changes introduced in 73e5bc7d. Now the function declaration's signature
is always valid to access, and will have been resolved if it was
specified with a func type instead of an explicit signature.
Some other changes:
* There was a bug in the interpreter's `f32.demote/f64` rounding when
given a value that is very close to positive or negative F32_MAX
* Added `update-spec-tests.py` to more easily update the spec tests in
`test/interp/spec/*.txt` from the files in
`third_party/testsuite/*.wast`. Previously I would just do it
manually.
Diffstat (limited to 'src/wasm-ast-parser-lexer-shared.c')
-rw-r--r-- | src/wasm-ast-parser-lexer-shared.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/wasm-ast-parser-lexer-shared.c b/src/wasm-ast-parser-lexer-shared.c index 63eb44e7..cd29172a 100644 --- a/src/wasm-ast-parser-lexer-shared.c +++ b/src/wasm-ast-parser-lexer-shared.c @@ -86,3 +86,34 @@ void wasm_destroy_text_list(WasmAllocator* allocator, WasmTextList* text_list) { node = next; } } + +void wasm_destroy_func_fields(struct WasmAllocator* allocator, + WasmFuncField* func_field) { + /* destroy the entire linked-list */ + while (func_field) { + WasmFuncField* next_func_field = func_field->next; + + switch (func_field->type) { + case WASM_FUNC_FIELD_TYPE_EXPRS: + wasm_destroy_expr_list(allocator, func_field->first_expr); + break; + + case WASM_FUNC_FIELD_TYPE_PARAM_TYPES: + case WASM_FUNC_FIELD_TYPE_LOCAL_TYPES: + wasm_destroy_type_vector(allocator, &func_field->types); + break; + + case WASM_FUNC_FIELD_TYPE_BOUND_PARAM: + case WASM_FUNC_FIELD_TYPE_BOUND_LOCAL: + wasm_destroy_string_slice(allocator, &func_field->bound_type.name); + break; + + case WASM_FUNC_FIELD_TYPE_RESULT_TYPE: + /* nothing to free */ + break; + } + + wasm_free(allocator, func_field); + func_field = next_func_field; + } +} |