Refactor WebIDL code generation

This commit refactors WebIDL code generation to walk over the fields of
`FirstPassRecord` instead of walking the AST again. This helps remove
redundancies like checking `is_chrome_only` as well as revisiting partial
interfaces and such. This should make it more clear that the first pass's job is
to walk the AST and collect all relevant information, while the codegen pass is
purely about appending items to a `Program`.

Additionally this refactoring will also soon be used to prepare different data
structures for operation overloadings, avoiding the need to walk those ASTs
twice.
This commit is contained in:
Alex Crichton
2018-08-28 16:32:31 -07:00
parent d358fa0987
commit b9dc937d73
8 changed files with 622 additions and 933 deletions

View File

@ -142,3 +142,7 @@ global.MixinFoo = class MixinFoo {
this._bar += other;
}
};
global.Overloads = class {
foo() {}
};

View File

@ -114,3 +114,11 @@ fn mixin() {
f.add_to_bar(MixinFoo::default_bar());
assert_eq!(f.bar(), 8);
}
#[wasm_bindgen_test]
fn overload_naming() {
let o = Overloads::new().unwrap();
o.foo();
o.foo_with_arg("x");
o.foo_with_arg_and_a("x", 3);
}

View File

@ -88,3 +88,10 @@ partial interface mixin MixinBar {
};
MixinFoo includes MixinBar;
[Constructor()]
interface Overloads {
void foo();
void foo(DOMString arg, optional long a);
void foo(DOMString arg, (float or short) b);
};