109 {
111 bool isVardeclBlockInitializer = !isSimpleInitializer &&
113
114 if (!isSimpleInitializer && !isVardeclBlockInitializer) {
115 context.fErrors->error(
initializer->fPosition,
"invalid for loop initializer");
116 return nullptr;
117 }
118
120 test = context.fTypes.fBool->coerceExpression(std::move(
test), context);
122 return nullptr;
123 }
124 }
125
126
127
128 if (
next &&
next->isIncomplete(context)) {
129 return nullptr;
130 }
131
133 if (context.fConfig->strictES2Mode()) {
134
138 return nullptr;
139 }
140 } else {
141
142
145 }
146
148 return nullptr;
149 }
150
151 if (isVardeclBlockInitializer) {
152
153
154
155
156
157
158 std::unique_ptr<SymbolTable> hoistedSymbols = symbolTable->insertNewParent();
160 symbolTable.get(), hoistedSymbols.get());
165 positions,
166 nullptr,
171 std::move(symbolTable)));
173 std::move(scope),
174 Block::Kind::kBracedScope,
175 std::move(hoistedSymbols));
176 }
177
180 positions,
186 std::move(symbolTable));
187}
static std::unique_ptr< Statement > Make(Position pos, StatementArray statements, Kind kind=Kind::kBracedScope, std::unique_ptr< SymbolTable > symbols=nullptr)
static std::unique_ptr< Statement > Make(const Context &context, Position pos, ForLoopPositions forLoopPositions, std::unique_ptr< Statement > initializer, std::unique_ptr< Expression > test, std::unique_ptr< Expression > next, std::unique_ptr< Statement > statement, std::unique_ptr< LoopUnrollInfo > unrollInfo, std::unique_ptr< SymbolTable > symbolTable)
std::unique_ptr< LoopUnrollInfo > GetLoopUnrollInfo(const Context &context, Position pos, const ForLoopPositions &positions, const Statement *loopInitializer, std::unique_ptr< Expression > *loopTestPtr, const Expression *loopNext, const Statement *loopStatement, ErrorReporter *errors)
bool DetectVarDeclarationWithoutScope(const Statement &stmt, ErrorReporter *errors=nullptr)
static bool is_vardecl_block_initializer(const Statement *stmt)
skia_private::STArray< 2, std::unique_ptr< Statement > > StatementArray
static bool is_simple_initializer(const Statement *stmt)
static void hoist_vardecl_symbols_into_outer_scope(const Context &context, const Block &initBlock, SymbolTable *innerSymbols, SymbolTable *hoistedSymbols)