38 for (
const auto& child :
b.children()) {
52 std::string
result(
"for (");
60 result += this->
test()->description();
64 result += this->
next()->description();
66 result +=
") " + this->
statement()->description();
71 const Block& initBlock,
78 , fInnerSymbols(innerSym)
79 , fHoistedSymbols(hoistSym) {}
81 bool visitStatement(
const Statement& stmt)
override {
88 fInnerSymbols->moveSymbolTo(fHoistedSymbols, var,
fContext);
99 SymbolHoister{context, innerSymbols, hoistedSymbols}.visitStatement(initBlock);
106 std::unique_ptr<Expression>
test,
107 std::unique_ptr<Expression>
next,
108 std::unique_ptr<Statement> statement,
109 std::unique_ptr<SymbolTable> symbolTable) {
111 bool isVardeclBlockInitializer = !isSimpleInitializer &&
114 if (!isSimpleInitializer && !isVardeclBlockInitializer) {
128 if (
next &&
next->isIncomplete(context)) {
151 if (isVardeclBlockInitializer) {
158 std::unique_ptr<SymbolTable> hoistedSymbols = symbolTable->insertNewParent();
160 symbolTable.get(), hoistedSymbols.get());
171 std::move(symbolTable)));
174 Block::Kind::kBracedScope,
175 std::move(hoistedSymbols));
186 std::move(symbolTable));
191 std::unique_ptr<Expression>
test,
192 std::unique_ptr<Statement> statement) {
211 std::unique_ptr<Expression>
test,
212 std::unique_ptr<Expression>
next,
213 std::unique_ptr<Statement> statement,
214 std::unique_ptr<LoopUnrollInfo> unrollInfo,
215 std::unique_ptr<SymbolTable> symbolTable) {
232 return std::make_unique<ForStatement>(
pos,
239 std::move(symbolTable));
static struct Initializer initializer
static float next(float f)
static std::unique_ptr< Statement > Make(Position pos, StatementArray statements, Kind kind=Kind::kBracedScope, std::unique_ptr< SymbolTable > symbols=nullptr)
const std::unique_ptr< Type > fBool
const BuiltinTypes & fTypes
void error(Position position, std::string_view msg)
static std::unique_ptr< Statement > ConvertWhile(const Context &context, Position pos, std::unique_ptr< Expression > test, std::unique_ptr< Statement > statement)
static std::unique_ptr< Statement > Convert(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< SymbolTable > symbolTable)
std::unique_ptr< Statement > & statement()
std::unique_ptr< Expression > & next()
std::string description() const override
std::unique_ptr< Expression > & test()
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< Statement > & initializer()
const LoopUnrollInfo * unrollInfo() const
static std::unique_ptr< Statement > Make()
virtual bool isEmpty() const
virtual bool visitStatement(typename T::Statement &statement)
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)
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)
bool strictES2Mode() const