For example, we need to figure out what to do if: typedef Foo = Bar; operator Foo(Baz); operator Bar(Baz); The following should also probably work (maybe?) typedef Foo = Bar[] operator Foo(Baz);
And of course, what about operator Foo[](Bar);
operator T<T>(T);
Created attachment 319966 [details] WIP
Created attachment 319976 [details] WIP
Created attachment 319980 [details] Patch
I guess I could test this more if I add operator bool<><T>(T x) { T defaultValue; return x != defaultValue; } Then I could test that !7 is false and !0 is true.
(In reply to Myles C. Maxfield from comment #6) > I guess I could test this more if I add > > operator bool<><T>(T x) { > T defaultValue; > return x != defaultValue; > } > > Then I could test that !7 is false and !0 is true. Actually, it looks like I can't do this unless I add some sort of Comparable protocol. It would have to be: protocol Equatable { bool operator==(Equatable, Equatable); } operator bool<><T:Comparable>(T x) { T defaultValue; return x != defaultValue; }
(In reply to Myles C. Maxfield from comment #7) > (In reply to Myles C. Maxfield from comment #6) > > I guess I could test this more if I add > > > > operator bool<><T>(T x) { > > T defaultValue; > > return x != defaultValue; > > } > > > > Then I could test that !7 is false and !0 is true. > > Actually, it looks like I can't do this unless I add some sort of Comparable > protocol. It would have to be: > > protocol Equatable { > bool operator==(Equatable, Equatable); > } > > operator bool<><T:Comparable>(T x) { > T defaultValue; > return x != defaultValue; > } Whoops, got this wrong: protocol Equatable { bool operator==(Equatable, Equatable); } operator bool<><T:Equatable>(T x) { T defaultValue; return x != defaultValue; }
Created attachment 319982 [details] Patch
Created attachment 319985 [details] Patch
Comment on attachment 319985 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=319985&action=review r=me with comments > Tools/WebGPUShadingLanguageRI/Checker.js:237 > + checkCastOrCallExpression(node, cast) Let's make "cast" not be a boolean. It seems that the only use of cast is to deal with the returnType. What if you replaced "cast" with "returnType", and visitCastExpression would pass node.returnType while visitCallExpression passes null. > Tools/WebGPUShadingLanguageRI/ResolveOverloadImpl.js:68 > + if (returnType) { > + if (!returnType.unify(unificationContext, func.returnType)) { > + failures.push(new OverloadResolutionFailure(func, "Return type " + func.returnType + " does not match " + returnType)); > + continue; > + } > + } Nice > Tools/WebGPUShadingLanguageRI/StandardLibrary.js:75 > +const standardLibraryEpilogue = ` > +operator bool<><T:Equatable>(T x) { > + T defaultValue; > + return x != defaultValue; > +} > +`; Maybe move this to StandardLibraryEpilogue, so that the start line number of it doesn't depend on the length of the prologue?
Committed r221686: <http://trac.webkit.org/changeset/221686>
<rdar://problem/34693661>
Migrated to https://github.com/gpuweb/WHLSL/issues/155