@@ -1205,9 +1205,9 @@ static std::unique_ptr<Statement> block_for_case(SwitchStatement* switchStatemen
12051205 // We have to be careful to not move any of the pointers until after we're sure we're going to
12061206 // succeed, so before we make any changes at all, we check the switch-cases to decide on a plan
12071207 // of action. First, find the switch-case we are interested in.
1208- auto iter = switchStatement->fCases .begin ();
1209- for (; iter != switchStatement->fCases .end (); ++iter) {
1210- if (iter-> get () == caseToCapture) {
1208+ auto iter = switchStatement->cases () .begin ();
1209+ for (; iter != switchStatement->cases () .end (); ++iter) {
1210+ if (&* iter == caseToCapture) {
12111211 break ;
12121212 }
12131213 }
@@ -1217,8 +1217,8 @@ static std::unique_ptr<Statement> block_for_case(SwitchStatement* switchStatemen
12171217 // statements that we can use for simplification.
12181218 auto startIter = iter;
12191219 Statement* unconditionalBreakStmt = nullptr ;
1220- for (; iter != switchStatement->fCases .end (); ++iter) {
1221- for (std::unique_ptr<Statement>& stmt : (* iter)-> fStatements ) {
1220+ for (; iter != switchStatement->cases () .end (); ++iter) {
1221+ for (std::unique_ptr<Statement>& stmt : iter-> statements () ) {
12221222 if (contains_conditional_break (*stmt)) {
12231223 // We can't reduce switch-cases to a block when they have conditional breaks.
12241224 return nullptr ;
@@ -1243,7 +1243,7 @@ static std::unique_ptr<Statement> block_for_case(SwitchStatement* switchStatemen
12431243
12441244 // We can move over most of the statements as-is.
12451245 while (startIter != iter) {
1246- for (std::unique_ptr<Statement>& stmt : (* startIter)-> fStatements ) {
1246+ for (std::unique_ptr<Statement>& stmt : startIter-> statements () ) {
12471247 caseStmts.push_back (std::move (stmt));
12481248 }
12491249 ++startIter;
@@ -1252,7 +1252,7 @@ static std::unique_ptr<Statement> block_for_case(SwitchStatement* switchStatemen
12521252 // If we found an unconditional break at the end, we need to move what we can while avoiding
12531253 // that break.
12541254 if (unconditionalBreakStmt != nullptr ) {
1255- for (std::unique_ptr<Statement>& stmt : (* startIter)-> fStatements ) {
1255+ for (std::unique_ptr<Statement>& stmt : startIter-> statements () ) {
12561256 if (stmt.get () == unconditionalBreakStmt) {
12571257 move_all_but_break (stmt, &caseStmts);
12581258 unconditionalBreakStmt = nullptr ;
@@ -1266,7 +1266,7 @@ static std::unique_ptr<Statement> block_for_case(SwitchStatement* switchStatemen
12661266 SkASSERT (unconditionalBreakStmt == nullptr ); // Verify that we fixed the unconditional break.
12671267
12681268 // Return our newly-synthesized block.
1269- return std::make_unique<Block>(/* offset=*/ -1 , std::move (caseStmts), switchStatement->fSymbols );
1269+ return std::make_unique<Block>(/* offset=*/ -1 , std::move (caseStmts), switchStatement->symbols () );
12701270}
12711271
12721272void Compiler::simplifyStatement (DefinitionMap& definitions,
@@ -1334,28 +1334,30 @@ void Compiler::simplifyStatement(DefinitionMap& definitions,
13341334 case Statement::Kind::kSwitch : {
13351335 SwitchStatement& s = stmt->as <SwitchStatement>();
13361336 int64_t switchValue;
1337- if (fIRGenerator ->getConstantInt (*s.fValue , &switchValue)) {
1337+ if (fIRGenerator ->getConstantInt (*s.value () , &switchValue)) {
13381338 // switch is constant, replace it with the case that matches
13391339 bool found = false ;
13401340 SwitchCase* defaultCase = nullptr ;
1341- for (const std::unique_ptr< SwitchCase> & c : s.fCases ) {
1342- if (!c-> fValue ) {
1343- defaultCase = c. get () ;
1341+ for (SwitchCase& c : s.cases () ) {
1342+ if (!c. value () ) {
1343+ defaultCase = &c ;
13441344 continue ;
13451345 }
13461346 int64_t caseValue;
1347- SkAssertResult (fIRGenerator ->getConstantInt (*c-> fValue , &caseValue));
1347+ SkAssertResult (fIRGenerator ->getConstantInt (*c. value () , &caseValue));
13481348 if (caseValue == switchValue) {
1349- std::unique_ptr<Statement> newBlock = block_for_case (&s, c. get () );
1349+ std::unique_ptr<Statement> newBlock = block_for_case (&s, &c );
13501350 if (newBlock) {
13511351 (*iter)->setStatement (std::move (newBlock));
13521352 found = true ;
13531353 break ;
13541354 } else {
1355- if (s.fIsStatic && !(fFlags & kPermitInvalidStaticTests_Flag )) {
1355+ if (s.isStatic () && !(fFlags & kPermitInvalidStaticTests_Flag ) &&
1356+ optimizationContext->fSilences .find (&s) ==
1357+ optimizationContext->fSilences .end ()) {
13561358 this ->error (s.fOffset ,
13571359 " static switch contains non-static conditional break" );
1358- s. fIsStatic = false ;
1360+ optimizationContext-> fSilences . insert (&s) ;
13591361 }
13601362 return ; // can't simplify
13611363 }
@@ -1368,10 +1370,12 @@ void Compiler::simplifyStatement(DefinitionMap& definitions,
13681370 if (newBlock) {
13691371 (*iter)->setStatement (std::move (newBlock));
13701372 } else {
1371- if (s.fIsStatic && !(fFlags & kPermitInvalidStaticTests_Flag )) {
1373+ if (s.isStatic () && !(fFlags & kPermitInvalidStaticTests_Flag ) &&
1374+ optimizationContext->fSilences .find (&s) ==
1375+ optimizationContext->fSilences .end ()) {
13721376 this ->error (s.fOffset ,
13731377 " static switch contains non-static conditional break" );
1374- s. fIsStatic = false ;
1378+ optimizationContext-> fSilences . insert (&s) ;
13751379 }
13761380 return ; // can't simplify
13771381 }
@@ -1498,8 +1502,10 @@ bool Compiler::scanCFG(FunctionDefinition& f) {
14981502 ++iter;
14991503 break ;
15001504 case Statement::Kind::kSwitch :
1501- if (s.as <SwitchStatement>().fIsStatic &&
1502- !(fFlags & kPermitInvalidStaticTests_Flag )) {
1505+ if (s.as <SwitchStatement>().isStatic () &&
1506+ !(fFlags & kPermitInvalidStaticTests_Flag ) &&
1507+ optimizationContext.fSilences .find (&s) ==
1508+ optimizationContext.fSilences .end ()) {
15031509 this ->error (s.fOffset , " static switch has non-static test" );
15041510 }
15051511 ++iter;
0 commit comments