rustwasm / wasm-webidl-bindings

Read, write, and manipulate the Wasm WebIDL bindings custom section
Apache License 2.0
38 stars 9 forks source link

Validation #7

Open fitzgen opened 5 years ago

fitzgen commented 5 years ago

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.

fitzgen commented 5 years ago

Oh, this should also (optionally?) canonicalize the AST to using all indices for referencing things instead of string labels.

Hywan commented 5 years ago

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.

fitzgen commented 5 years ago

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.

Hywan commented 5 years ago

OK. Please ping me to keep me in the discussions.