Open fitzgen opened 5 years ago
Oh, this should also (optionally?) canonicalize the AST to using all indices for referencing things instead of string labels.
Do you consider supporting type-checking when validating? By type-checking, I mean: The following Web IDL is valid:
type $hello_webidl_type
(func
(result ByteString))
func-binding $hello_webidl_binding export $hello_wasm_type $hello_webidl_type
(result
(utf8-cstr ByteString 0))
… whilst the following is invalid:
type $hello_webidl_type
(func
(result DOMString))
func-binding $hello_webidl_binding export $hello_wasm_type $hello_webidl_type
(result
(utf8-cstr ByteString 0))
… because the $hello_webidl_type
type defines a function that returns a DOMString
and $hello_webidl_binding
represents a function binding that returns a ByteString
through the utf8-cstr
constructor.
I've a very naive algorithm that works with the AST only. If this is something required, I can improve the code and open a PR.
Yes, validation would do type checking. I'm not quite ready for a PR for this yet though, I need to think about it a bit more and talk with the folks writing the standards and things like that to make sure it helps push that side of things forward.
OK. Please ping me to keep me in the discussions.
Should be able to take an AST and some extra wasm typing context (probably expressed as a trait) and validate that the bindings described by the AST are well-formed.