Add a Visitor class
Created attachment 357603 [details] Patch
Created attachment 357930 [details] Patch
Created attachment 358011 [details] Patch
Created attachment 358882 [details] Patch
Created attachment 358911 [details] Patch
Comment on attachment 358911 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=358911&action=review > Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp:621 > +void Visitor::checkErrorAndVisit(Program& program) These look very repetitive. Would the following fail for some reason? ``` template<typename T> void Visitor::checkErrorAndVisist(T& x) { if (!error) visit(x); } ```
Comment on attachment 358911 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=358911&action=review > Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp:2 > + * Copyright (C) 2018 Apple Inc. All rights reserved. 2019 > Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp:105 > + // These visiting functions might add new global statements, so don't use foreach syntax. :( > Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp:357 > + WTF::visit(WTF::makeVisitor([&](AST::NumThreadsFunctionAttribute& numThreadsFunctionAttribute) { > + checkErrorAndVisit(numThreadsFunctionAttribute); > + }), functionAttribute); Why not call it directly since there is only one object to visit? > Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.h:2 > + * Copyright (C) 2018 Apple Inc. All rights reserved. 2019 > Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.h:179 > + void checkErrorAndVisit(Program&); Could these be private/protected?
Comment on attachment 358911 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=358911&action=review >> Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp:621 >> +void Visitor::checkErrorAndVisit(Program& program) > > These look very repetitive. Would the following fail for some reason? > ``` > template<typename T> void Visitor::checkErrorAndVisist(T& x) > { > if (!error) > visit(x); > } > ``` Yes! Good idea.
Committed r239893: <https://trac.webkit.org/changeset/239893>
<rdar://problem/47227226>