Changeset 247499 in webkit
- Timestamp:
- Jul 16, 2019 4:10:17 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 18 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r247493 r247499 1 2019-07-16 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r247493. 4 https://bugs.webkit.org/show_bug.cgi?id=199841 5 6 "The new whlsl-for-loop.html test is failing on the bots" 7 (Requested by rmorisset on #webkit). 8 9 Reverted changeset: 10 11 "[WHLSL] Desugar for loops and while loops" 12 https://bugs.webkit.org/show_bug.cgi?id=199726 13 https://trac.webkit.org/changeset/247493 14 1 15 2019-07-16 Robin Morisset <rmorisset@apple.com> 2 16 -
trunk/LayoutTests/webgpu/whlsl-return-spec-tests.html
r247493 r247499 112 112 } 113 113 `); 114 await checkFail( 115 ` 116 int foo(int x) 117 { 118 int y = 6; 119 if (x == 7) 120 int y = 8; 121 return y; 122 } 123 `); 114 115 program = ` 116 int foo(int x) 117 { 118 int y = 6; 119 if (x == 7) 120 int y = 8; 121 return y; 122 } 123 `; 124 assert_equals(await callIntFunction(program, "foo", [makeInt(7)]), 6); 124 125 }; 125 126 -
trunk/Source/WebCore/ChangeLog
r247498 r247499 1 2019-07-16 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, rolling out r247493. 4 https://bugs.webkit.org/show_bug.cgi?id=199841 5 6 "The new whlsl-for-loop.html test is failing on the bots" 7 (Requested by rmorisset on #webkit). 8 9 Reverted changeset: 10 11 "[WHLSL] Desugar for loops and while loops" 12 https://bugs.webkit.org/show_bug.cgi?id=199726 13 https://trac.webkit.org/changeset/247493 14 1 15 2019-07-16 Per Arne Vollan <pvollan@apple.com> 2 16 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLAST.h
r247493 r247499 102 102 #include "WHLSLVariableDeclarationsStatement.h" 103 103 #include "WHLSLVariableReference.h" 104 #include "WHLSLWhileLoop.h" 104 105 105 106 #endif -
trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLForLoop.h
r247493 r247499 45 45 class ForLoop : public Statement { 46 46 public: 47 ForLoop(CodeLocation location, UniqueRef<Expression>&& condition, UniqueRef<Expression>&& increment, UniqueRef<Statement>&& body)47 ForLoop(CodeLocation location, Variant<UniqueRef<Statement>, UniqueRef<Expression>>&& initialization, std::unique_ptr<Expression>&& condition, std::unique_ptr<Expression>&& increment, UniqueRef<Statement>&& body) 48 48 : Statement(location) 49 , m_initialization(WTFMove(initialization)) 49 50 , m_condition(WTFMove(condition)) 50 51 , m_increment(WTFMove(increment)) … … 53 54 } 54 55 55 virtual ~ForLoop() = default; 56 virtual ~ForLoop() 57 { 58 } 56 59 57 60 ForLoop(const ForLoop&) = delete; … … 60 63 bool isForLoop() const override { return true; } 61 64 62 Expression& condition() { return m_condition; } 63 Expression& increment() { return m_increment; } 65 Variant<UniqueRef<Statement>, UniqueRef<Expression>>& initialization() { return m_initialization; } 66 Expression* condition() { return m_condition.get(); } 67 Expression* increment() { return m_increment.get(); } 64 68 Statement& body() { return m_body; } 65 69 66 70 private: 67 UniqueRef<Expression> m_condition; 68 UniqueRef<Expression> m_increment; 71 Variant<UniqueRef<Statement>, UniqueRef<Expression>> m_initialization; 72 std::unique_ptr<Expression> m_condition; 73 std::unique_ptr<Expression> m_increment; 69 74 UniqueRef<Statement> m_body; 70 75 }; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLStatement.h
r247493 r247499 63 63 virtual bool isTrap() const { return false; } 64 64 virtual bool isVariableDeclarationsStatement() const { return false; } 65 virtual bool isWhileLoop() const { return false; } 65 66 66 67 CodeLocation codeLocation() const { return m_codeLocation; } -
trunk/Source/WebCore/Modules/webgpu/WHLSL/AST/WHLSLWhileLoop.h
r247498 r247499 31 31 #include "WHLSLLexer.h" 32 32 #include "WHLSLStatement.h" 33 #include "WHLSLVariableDeclarationsStatement.h"34 #include <memory>35 33 #include <wtf/UniqueRef.h> 36 #include <wtf/Variant.h>37 #include <wtf/Vector.h>38 34 39 35 namespace WebCore { … … 43 39 namespace AST { 44 40 45 class ForLoop : public Statement {41 class WhileLoop : public Statement { 46 42 public: 47 ForLoop(CodeLocation location, UniqueRef<Expression>&& condition, UniqueRef<Expression>&& increment, UniqueRef<Statement>&& body)43 WhileLoop(CodeLocation location, UniqueRef<Expression>&& conditional, UniqueRef<Statement>&& body) 48 44 : Statement(location) 49 , m_condition(WTFMove(condition)) 50 , m_increment(WTFMove(increment)) 45 , m_conditional(WTFMove(conditional)) 51 46 , m_body(WTFMove(body)) 52 47 { 53 48 } 54 49 55 virtual ~ ForLoop() = default;50 virtual ~WhileLoop() = default; 56 51 57 ForLoop(const ForLoop&) = delete;58 ForLoop(ForLoop&&) = default;52 WhileLoop(const WhileLoop&) = delete; 53 WhileLoop(WhileLoop&&) = default; 59 54 60 bool is ForLoop() const override { return true; }55 bool isWhileLoop() const override { return true; } 61 56 62 Expression& condition() { return m_condition; } 63 Expression& increment() { return m_increment; } 57 Expression& conditional() { return m_conditional; } 64 58 Statement& body() { return m_body; } 65 59 66 60 private: 67 UniqueRef<Expression> m_condition; 68 UniqueRef<Expression> m_increment; 61 UniqueRef<Expression> m_conditional; 69 62 UniqueRef<Statement> m_body; 70 63 }; … … 76 69 } 77 70 78 SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT( ForLoop, isForLoop())71 SPECIALIZE_TYPE_TRAITS_WHLSL_STATEMENT(WhileLoop, isWhileLoop()) 79 72 80 73 #endif -
trunk/Source/WebCore/Modules/webgpu/WHLSL/Metal/WHLSLFunctionWriter.cpp
r247493 r247499 129 129 void visit(AST::Trap&) override; 130 130 void visit(AST::VariableDeclarationsStatement&) override; 131 void visit(AST::WhileLoop&) override; 131 132 void visit(AST::IntegerLiteral&) override; 132 133 void visit(AST::UnsignedIntegerLiteral&) override; … … 350 351 } 351 352 353 void FunctionDefinitionWriter::visit(AST::WhileLoop& whileLoop) 354 { 355 emitLoop(LoopConditionLocation::BeforeBody, &whileLoop.conditional(), nullptr, whileLoop.body()); 356 } 357 352 358 void FunctionDefinitionWriter::visit(AST::ForLoop& forLoop) 353 359 { 354 emitLoop(LoopConditionLocation::BeforeBody, &forLoop.condition(), &forLoop.increment(), forLoop.body()); 360 m_stringBuilder.append("{\n"); 361 362 WTF::visit(WTF::makeVisitor([&](AST::Statement& statement) { 363 checkErrorAndVisit(statement); 364 }, [&](UniqueRef<AST::Expression>& expression) { 365 checkErrorAndVisit(expression); 366 takeLastValue(); // We don't need to do anything with the result. 367 }), forLoop.initialization()); 368 369 emitLoop(LoopConditionLocation::BeforeBody, forLoop.condition(), forLoop.increment(), forLoop.body()); 370 m_stringBuilder.append("}\n"); 355 371 } 356 372 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDumper.cpp
r247493 r247499 394 394 } 395 395 396 void ASTDumper::visit(AST::WhileLoop& whileLoop) 397 { 398 m_out.print("while ("); 399 visit(whileLoop.conditional()); 400 m_out.print(")"); 401 visit(whileLoop.body()); 402 } 403 396 404 void ASTDumper::visit(AST::DoWhileLoop& doWhileLoop) 397 405 { … … 405 413 void ASTDumper::visit(AST::ForLoop& forLoop) 406 414 { 407 m_out.print("for (; "); 408 visit(forLoop.condition()); 415 m_out.print("for ("); 416 WTF::visit(WTF::makeVisitor([&](UniqueRef<AST::Statement>& statement) { 417 visit(statement); 418 }, [&](UniqueRef<AST::Expression>& expression) { 419 visit(expression); 420 }), forLoop.initialization()); 409 421 m_out.print("; "); 410 visit(forLoop.increment()); 422 if (forLoop.condition()) 423 visit(*forLoop.condition()); 424 m_out.print("; "); 425 if (forLoop.increment()) 426 visit(*forLoop.increment()); 411 427 m_out.print(") "); 412 428 visit(forLoop.body()); -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLASTDumper.h
r247493 r247499 101 101 void visit(AST::Trap&) override; 102 102 void visit(AST::VariableDeclarationsStatement&) override; 103 void visit(AST::WhileLoop&) override; 103 104 void visit(AST::VariableDeclaration&) override; 104 105 void visit(AST::AssignmentExpression&) override; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLChecker.cpp
r247493 r247499 58 58 #include "WHLSLTernaryExpression.h" 59 59 #include "WHLSLVisitor.h" 60 #include "WHLSLWhileLoop.h" 60 61 #include <wtf/HashMap.h> 61 62 #include <wtf/HashSet.h> … … 501 502 void visit(AST::LogicalExpression&) override; 502 503 void visit(AST::IfStatement&) override; 504 void visit(AST::WhileLoop&) override; 503 505 void visit(AST::DoWhileLoop&) override; 504 506 void visit(AST::ForLoop&) override; … … 1246 1248 } 1247 1249 1250 void Checker::visit(AST::WhileLoop& whileLoop) 1251 { 1252 if (!recurseAndRequireBoolType(whileLoop.conditional())) 1253 return; 1254 checkErrorAndVisit(whileLoop.body()); 1255 } 1256 1248 1257 void Checker::visit(AST::DoWhileLoop& doWhileLoop) 1249 1258 { … … 1254 1263 void Checker::visit(AST::ForLoop& forLoop) 1255 1264 { 1256 if (!recurseAndRequireBoolType(forLoop.condition())) 1257 return; 1258 checkErrorAndVisit(forLoop.increment()); 1265 WTF::visit(WTF::makeVisitor([&](UniqueRef<AST::Statement>& statement) { 1266 checkErrorAndVisit(statement); 1267 }, [&](UniqueRef<AST::Expression>& expression) { 1268 checkErrorAndVisit(expression); 1269 }), forLoop.initialization()); 1270 if (error()) 1271 return; 1272 if (forLoop.condition()) { 1273 if (!recurseAndRequireBoolType(*forLoop.condition())) 1274 return; 1275 } 1276 if (forLoop.increment()) 1277 checkErrorAndVisit(*forLoop.increment()); 1259 1278 checkErrorAndVisit(forLoop.body()); 1260 1279 } … … 1416 1435 void Checker::visit(AST::CommaExpression& commaExpression) 1417 1436 { 1418 ASSERT( !commaExpression.list().isEmpty());1437 ASSERT(commaExpression.list().size() > 0); 1419 1438 Visitor::visit(commaExpression); 1420 1439 if (error()) -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.cpp
r247493 r247499 44 44 #include "WHLSLVariableDeclaration.h" 45 45 #include "WHLSLVariableReference.h" 46 #include "WHLSLWhileLoop.h" 46 47 47 48 namespace WebCore { … … 120 121 return; 121 122 122 checkErrorAndVisit(ifStatement.body()); 123 if (error()) 124 return; 125 126 if (ifStatement.elseBody()) 127 checkErrorAndVisit(*ifStatement.elseBody()); 123 { 124 NameContext nameContext(&m_nameContext); 125 NameResolver newNameResolver(*this, nameContext); 126 newNameResolver.checkErrorAndVisit(ifStatement.body()); 127 } 128 if (error()) 129 return; 130 131 if (ifStatement.elseBody()) { 132 NameContext nameContext(&m_nameContext); 133 NameResolver newNameResolver(*this, nameContext); 134 newNameResolver.checkErrorAndVisit(*ifStatement.elseBody()); 135 } 136 } 137 138 void NameResolver::visit(AST::WhileLoop& whileLoop) 139 { 140 checkErrorAndVisit(whileLoop.conditional()); 141 if (error()) 142 return; 143 144 NameContext nameContext(&m_nameContext); 145 NameResolver newNameResolver(*this, nameContext); 146 newNameResolver.checkErrorAndVisit(whileLoop.body()); 128 147 } 129 148 130 149 void NameResolver::visit(AST::DoWhileLoop& whileLoop) 131 150 { 132 checkErrorAndVisit(whileLoop.body()); 133 if (error()) 134 return; 151 { 152 NameContext nameContext(&m_nameContext); 153 NameResolver newNameResolver(*this, nameContext); 154 newNameResolver.checkErrorAndVisit(whileLoop.body()); 155 } 135 156 136 157 checkErrorAndVisit(whileLoop.conditional()); … … 139 160 void NameResolver::visit(AST::ForLoop& forLoop) 140 161 { 141 checkErrorAndVisit(forLoop.condition()); 142 if (error()) 143 return; 144 checkErrorAndVisit(forLoop.increment()); 145 if (error()) 146 return; 147 148 checkErrorAndVisit(forLoop.body()); 162 NameContext nameContext(&m_nameContext); 163 NameResolver newNameResolver(*this, nameContext); 164 newNameResolver.Visitor::visit(forLoop); 149 165 } 150 166 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLNameResolver.h
r247493 r247499 51 51 void visit(AST::Block&) override; 52 52 void visit(AST::IfStatement&) override; 53 void visit(AST::WhileLoop&) override; 53 54 void visit(AST::DoWhileLoop&) override; 54 55 void visit(AST::ForLoop&) override; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.cpp
r247493 r247499 1064 1064 AST::Statements statements; 1065 1065 while (!peekTypes<Token::Type::RightCurlyBracket, Token::Type::Case, Token::Type::Default>()) { 1066 bool allowVariableDeclarations = true; 1067 PARSE(statement, Statement, allowVariableDeclarations); 1066 PARSE(statement, Statement); 1068 1067 statements.append(WTFMove(*statement)); 1069 1068 } … … 1144 1143 } 1145 1144 1146 auto Parser::parseForLoop() -> Expected<AST:: Block, Error>1145 auto Parser::parseForLoop() -> Expected<AST::ForLoop, Error> 1147 1146 { 1148 1147 CONSUME_TYPE(origin, For); 1149 1148 CONSUME_TYPE(leftParenthesis, LeftParenthesis); 1150 1149 1150 auto parseRemainder = [&](Variant<UniqueRef<AST::Statement>, UniqueRef<AST::Expression>>&& initialization) -> Expected<AST::ForLoop, Error> { 1151 CONSUME_TYPE(semicolon, Semicolon); 1152 1153 std::unique_ptr<AST::Expression> condition(nullptr); 1154 if (!tryType(Token::Type::Semicolon)) { 1155 if (auto expression = parseExpression()) 1156 condition = (*expression).moveToUniquePtr(); 1157 else 1158 return Unexpected<Error>(expression.error()); 1159 CONSUME_TYPE(secondSemicolon, Semicolon); 1160 } 1161 1162 std::unique_ptr<AST::Expression> increment(nullptr); 1163 if (!tryType(Token::Type::RightParenthesis)) { 1164 if (auto expression = parseExpression()) 1165 increment = (*expression).moveToUniquePtr(); 1166 else 1167 return Unexpected<Error>(expression.error()); 1168 CONSUME_TYPE(rightParenthesis, RightParenthesis); 1169 } 1170 1171 PARSE(body, Statement); 1172 AST::CodeLocation location(origin->codeLocation, (*body)->codeLocation()); 1173 return AST::ForLoop(location, WTFMove(initialization), WTFMove(condition), WTFMove(increment), WTFMove(*body)); 1174 }; 1151 1175 1152 1176 auto variableDeclarations = backtrackingScope<Expected<AST::VariableDeclarationsStatement, Error>>([&]() { 1153 1177 return parseVariableDeclarations(); 1154 1178 }); 1155 Optional<UniqueRef<AST::Statement>> initialization; 1156 if (variableDeclarations) 1157 initialization = static_cast<UniqueRef<AST::Statement>>(makeUniqueRef<AST::VariableDeclarationsStatement>(WTFMove(*variableDeclarations))); 1158 else { 1159 PARSE(effectfulExpression, EffectfulExpression); 1160 initialization = WTFMove(*effectfulExpression); 1161 } 1162 1163 CONSUME_TYPE(semicolon, Semicolon); 1164 1165 Optional<UniqueRef<AST::Expression>> condition; 1166 auto secondSemicolon = tryType(Token::Type::Semicolon); 1167 if (!secondSemicolon) { 1168 PARSE(expression, Expression); 1169 condition = WTFMove(*expression); 1170 CONSUME_TYPE(secondSemicolon, Semicolon); 1171 } else 1172 condition = static_cast<UniqueRef<AST::Expression>>(makeUniqueRef<AST::BooleanLiteral>(*secondSemicolon, true)); 1173 1174 Optional<UniqueRef<AST::Expression>> increment; 1175 auto rightParenthesis = tryType(Token::Type::RightParenthesis); 1176 if (!rightParenthesis) { 1177 PARSE(expression, Expression); 1178 increment = WTFMove(*expression); 1179 CONSUME_TYPE(rightParenthesis, RightParenthesis); 1180 } else 1181 increment = static_cast<UniqueRef<AST::Expression>>(makeUniqueRef<AST::BooleanLiteral>(*origin, true)); // FIXME: NullLiteral would make more sense, but is buggy right now. Anything side-effect free is fine. 1182 1183 PARSE(body, Statement); 1184 AST::CodeLocation location(origin->codeLocation, (*body)->codeLocation()); 1185 1186 auto forLoop = makeUniqueRef<AST::ForLoop>(location, WTFMove(*condition), WTFMove(*increment), WTFMove(*body)); 1187 AST::Statements statements = Vector<UniqueRef<AST::Statement>>::from(WTFMove(*initialization), WTFMove(forLoop)); 1188 return AST::Block(location, WTFMove(statements)); 1189 } 1190 1191 auto Parser::parseWhileLoop() -> Expected<AST::ForLoop, Error> 1179 if (variableDeclarations) { 1180 UniqueRef<AST::Statement> declarationStatement = makeUniqueRef<AST::VariableDeclarationsStatement>(WTFMove(*variableDeclarations)); 1181 return parseRemainder(WTFMove(declarationStatement)); 1182 } 1183 1184 PARSE(effectfulExpression, EffectfulExpression); 1185 1186 return parseRemainder(WTFMove(*effectfulExpression)); 1187 } 1188 1189 auto Parser::parseWhileLoop() -> Expected<AST::WhileLoop, Error> 1192 1190 { 1193 1191 CONSUME_TYPE(origin, While); … … 1198 1196 1199 1197 AST::CodeLocation location(origin->codeLocation, (*body)->codeLocation()); 1200 auto increment = makeUniqueRef<AST::BooleanLiteral>(*origin, true); // FIXME: NullLiteral would make more sense, but is buggy right now. Anything side-effect free is fine. 1201 return AST::ForLoop(location, WTFMove(*conditional), WTFMove(increment), WTFMove(*body)); 1198 return AST::WhileLoop(location, WTFMove(*conditional), WTFMove(*body)); 1202 1199 } 1203 1200 … … 1258 1255 } 1259 1256 1260 auto Parser::parseStatement( bool allowVariableDeclarations) -> Expected<UniqueRef<AST::Statement>, Error>1257 auto Parser::parseStatement() -> Expected<UniqueRef<AST::Statement>, Error> 1261 1258 { 1262 1259 PEEK(token); … … 1276 1273 case Token::Type::For: { 1277 1274 PARSE(forLoop, ForLoop); 1278 return { makeUniqueRef<AST:: Block>(WTFMove(*forLoop)) };1275 return { makeUniqueRef<AST::ForLoop>(WTFMove(*forLoop)) }; 1279 1276 } 1280 1277 case Token::Type::While: { 1281 1278 PARSE(whileLoop, WhileLoop); 1282 return { makeUniqueRef<AST:: ForLoop>(WTFMove(*whileLoop)) };1279 return { makeUniqueRef<AST::WhileLoop>(WTFMove(*whileLoop)) }; 1283 1280 } 1284 1281 case Token::Type::Do: { … … 1350 1347 1351 1348 { 1352 auto effectfulExpression Statement = backtrackingScope<Expected<UniqueRef<AST::Statement>, Error>>([&]() -> Expected<UniqueRef<AST::Statement>, Error> {1349 auto effectfulExpression = backtrackingScope<Expected<UniqueRef<AST::Expression>, Error>>([&]() -> Expected<UniqueRef<AST::Expression>, Error> { 1353 1350 PARSE(result, EffectfulExpression); 1354 1351 CONSUME_TYPE(semicolon, Semicolon); 1355 1352 return result; 1356 1353 }); 1357 if (effectfulExpressionStatement) 1358 return effectfulExpressionStatement; 1359 } 1360 1361 if (allowVariableDeclarations) { 1362 PARSE(variableDeclarations, VariableDeclarations); 1363 CONSUME_TYPE(semicolon, Semicolon); 1364 return { makeUniqueRef<AST::VariableDeclarationsStatement>(WTFMove(*variableDeclarations)) }; 1365 } 1366 1367 return Unexpected<Error>("A variable declaration is only valid inside a block"); 1368 } 1369 1370 auto Parser::parseEffectfulExpression() -> Expected<UniqueRef<AST::Statement>, Error> 1354 if (effectfulExpression) 1355 return { makeUniqueRef<AST::EffectfulExpressionStatement>(WTFMove(*effectfulExpression)) }; 1356 } 1357 1358 PARSE(variableDeclarations, VariableDeclarations); 1359 CONSUME_TYPE(semicolon, Semicolon); 1360 return { makeUniqueRef<AST::VariableDeclarationsStatement>(WTFMove(*variableDeclarations)) }; 1361 } 1362 1363 auto Parser::parseEffectfulExpression() -> Expected<UniqueRef<AST::Expression>, Error> 1371 1364 { 1372 1365 PEEK(origin); 1373 if (origin->type == Token::Type::Semicolon) {1374 AST::Statements statements;1375 return { makeUniqueRef<AST::Block>(*origin, WTFMove(statements)) };1376 }1377 1378 1366 Vector<UniqueRef<AST::Expression>> expressions; 1367 if (origin->type == Token::Type::Semicolon) 1368 return { makeUniqueRef<AST::CommaExpression>(*origin, WTFMove(expressions)) }; 1369 1379 1370 PARSE(effectfulExpression, EffectfulAssignment); 1380 1371 expressions.append(WTFMove(*effectfulExpression)); … … 1386 1377 1387 1378 if (expressions.size() == 1) 1388 return { makeUniqueRef<AST::EffectfulExpressionStatement>(WTFMove(expressions[0])) };1379 return WTFMove(expressions[0]); 1389 1380 unsigned endOffset = m_lexer.peek().startOffset(); 1390 1381 AST::CodeLocation location(origin->startOffset(), endOffset); 1391 auto expression = makeUniqueRef<AST::CommaExpression>(location, WTFMove(expressions)); 1392 return { makeUniqueRef<AST::EffectfulExpressionStatement>(WTFMove(expression)) }; 1382 return { makeUniqueRef<AST::CommaExpression>(location, WTFMove(expressions)) }; 1393 1383 } 1394 1384 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLParser.h
r247493 r247499 92 92 #include "WHLSLVariableDeclarationsStatement.h" 93 93 #include "WHLSLVariableReference.h" 94 #include "WHLSLWhileLoop.h" 94 95 #include <wtf/Expected.h> 95 96 #include <wtf/Optional.h> … … 203 204 Expected<AST::SwitchStatement, Error> parseSwitchStatement(); 204 205 Expected<AST::SwitchCase, Error> parseSwitchCase(); 205 Expected<AST:: Block, Error> parseForLoop();206 Expected<AST:: ForLoop, Error> parseWhileLoop();206 Expected<AST::ForLoop, Error> parseForLoop(); 207 Expected<AST::WhileLoop, Error> parseWhileLoop(); 207 208 Expected<AST::DoWhileLoop, Error> parseDoWhileLoop(); 208 209 Expected<AST::VariableDeclaration, Error> parseVariableDeclaration(UniqueRef<AST::UnnamedType>&&); 209 210 Expected<AST::VariableDeclarationsStatement, Error> parseVariableDeclarations(); 210 Expected<UniqueRef<AST::Statement>, Error> parseStatement( bool allowVariableDeclaration = false);211 212 Expected<UniqueRef<AST:: Statement>, Error> parseEffectfulExpression();211 Expected<UniqueRef<AST::Statement>, Error> parseStatement(); 212 213 Expected<UniqueRef<AST::Expression>, Error> parseEffectfulExpression(); 213 214 Expected<UniqueRef<AST::Expression>, Error> parseEffectfulAssignment(); 214 215 struct SuffixExpression { -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLStatementBehaviorChecker.cpp
r247493 r247499 45 45 #include "WHLSLVariableDeclarationsStatement.h" 46 46 #include "WHLSLVisitor.h" 47 #include "WHLSLWhileLoop.h" 47 48 #include <cstdint> 48 49 #include <wtf/OptionSet.h> … … 109 110 void visit(AST::ForLoop& forLoop) override 110 111 { 112 // The initialization always has a behavior of Nothing, which we already add unconditionally below, 113 // so we can just ignore the initialization. 114 111 115 checkErrorAndVisit(forLoop.body()); 116 if (error()) 117 return; 118 auto b = m_stack.takeLast(); 119 b.remove(Behavior::Break); 120 b.remove(Behavior::Continue); 121 b.add(Behavior::Nothing); 122 m_stack.append(b); 123 } 124 125 void visit(AST::WhileLoop& whileLoop) override 126 { 127 checkErrorAndVisit(whileLoop.body()); 112 128 if (error()) 113 129 return; -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.cpp
r247493 r247499 332 332 else if (is<AST::Trap>(statement)) 333 333 checkErrorAndVisit(downcast<AST::Trap>(statement)); 334 else { 335 ASSERT(is<AST::VariableDeclarationsStatement>(statement)); 334 else if (is<AST::VariableDeclarationsStatement>(statement)) 336 335 checkErrorAndVisit(downcast<AST::VariableDeclarationsStatement>(statement)); 337 } 336 else 337 checkErrorAndVisit(downcast<AST::WhileLoop>(statement)); 338 338 } 339 339 … … 428 428 void Visitor::visit(AST::ForLoop& forLoop) 429 429 { 430 checkErrorAndVisit(forLoop.condition()); 431 checkErrorAndVisit(forLoop.increment()); 430 WTF::visit(WTF::makeVisitor([&](UniqueRef<AST::Statement>& statement) { 431 checkErrorAndVisit(statement); 432 }, [&](UniqueRef<AST::Expression>& expression) { 433 checkErrorAndVisit(expression); 434 }), forLoop.initialization()); 435 if (forLoop.condition()) 436 checkErrorAndVisit(*forLoop.condition()); 437 if (forLoop.increment()) 438 checkErrorAndVisit(*forLoop.increment()); 432 439 checkErrorAndVisit(forLoop.body()); 433 440 } … … 469 476 for (auto& variableDeclaration : variableDeclarationsStatement.variableDeclarations()) 470 477 checkErrorAndVisit(variableDeclaration.get()); 478 } 479 480 void Visitor::visit(AST::WhileLoop& whileLoop) 481 { 482 checkErrorAndVisit(whileLoop.conditional()); 483 checkErrorAndVisit(whileLoop.body()); 471 484 } 472 485 -
trunk/Source/WebCore/Modules/webgpu/WHLSL/WHLSLVisitor.h
r247493 r247499 86 86 class Trap; 87 87 class VariableDeclarationsStatement; 88 class WhileLoop; 88 89 class VariableDeclaration; 89 90 class AssignmentExpression; … … 166 167 virtual void visit(AST::Trap&); 167 168 virtual void visit(AST::VariableDeclarationsStatement&); 169 virtual void visit(AST::WhileLoop&); 168 170 virtual void visit(AST::VariableDeclaration&); 169 171 virtual void visit(AST::AssignmentExpression&); -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r247493 r247499 13257 13257 C21BF70221CD89C400227979 /* WHLSLEnumerationMemberLiteral.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLEnumerationMemberLiteral.h; sourceTree = "<group>"; }; 13258 13258 C21BF70321CD89C500227979 /* WHLSLReturn.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLReturn.h; sourceTree = "<group>"; }; 13259 C21BF70421CD89C600227979 /* WHLSLWhileLoop.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLWhileLoop.h; sourceTree = "<group>"; }; 13259 13260 C21BF70521CD89C700227979 /* WHLSLFunctionAttribute.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLFunctionAttribute.h; sourceTree = "<group>"; }; 13260 13261 C21BF70621CD89C700227979 /* WHLSLCommaExpression.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WHLSLCommaExpression.h; sourceTree = "<group>"; }; … … 17132 17133 C21BF71421CD89D300227979 /* WHLSLVariableDeclarationsStatement.h */, 17133 17134 C21BF71321CD89D200227979 /* WHLSLVariableReference.h */, 17135 C21BF70421CD89C600227979 /* WHLSLWhileLoop.h */, 17134 17136 ); 17135 17137 path = AST;
Note: See TracChangeset
for help on using the changeset viewer.