diff --git a/ets2panda/compiler/core/emitter.cpp b/ets2panda/compiler/core/emitter.cpp index 42a9e1593868f1dfd6651a73876e1250091b5ac7..3e44eed810a18e1bb84164c7e68da7918404c67c 100644 --- a/ets2panda/compiler/core/emitter.cpp +++ b/ets2panda/compiler/core/emitter.cpp @@ -312,8 +312,10 @@ void FunctionEmitter::GenScopeVariableInfo(pandasm::Function *func, const varbin GenLocalVariableInfo(variable_debug, param, start, vars_length, cg_->TotalRegsNum(), extension); } } - - for (const auto &[_, variable] : scope->Bindings()) { + const auto &unsorted_bindings = scope->Bindings(); + std::map bindings(unsorted_bindings.begin(), + unsorted_bindings.end()); + for (const auto &[_, variable] : bindings) { (void)_; if (!variable->IsLocalVariable() || variable->LexicalBound() || variable->Declaration()->IsParameterDecl() || variable->Declaration()->IsTypeAliasDecl()) { @@ -347,7 +349,6 @@ void FunctionEmitter::GenVariablesDebugInfo(pandasm::Function *func) Emitter::Emitter(const CompilerContext *context) : context_(context) { prog_ = new pandasm::Program(); - prog_->function_table.reserve(context->VarBinder()->Functions().size()); } Emitter::~Emitter() diff --git a/ets2panda/parser/parserImpl.h b/ets2panda/parser/parserImpl.h index 21c674b2e6d56b19aeb6cc03885a5bde0e9b866a..f2c74eab8ae28b2d07499610f6d0fd9284aead30 100644 --- a/ets2panda/parser/parserImpl.h +++ b/ets2panda/parser/parserImpl.h @@ -797,7 +797,7 @@ protected: return varbinder_; } - varbinder::Scope::VariableMap SavedBindings() const + const varbinder::Scope::VariableMap &SavedBindings() const { return saved_bindings_; } diff --git a/ets2panda/varbinder/scope.cpp b/ets2panda/varbinder/scope.cpp index 8999d8cb9eb5e294fd1bbcdaacb90b8f39c38759..7d1e614da8bbcaec66a418514e48f1aa1ffdeb9c 100644 --- a/ets2panda/varbinder/scope.cpp +++ b/ets2panda/varbinder/scope.cpp @@ -480,7 +480,7 @@ Scope::InsertResult GlobalScope::InsertImpl(const util::StringView &name, Variab if (const bool exported = node->IsClassDefinition() ? node->Parent()->IsExported() : node->IsExported(); !exported) { if (!node->IsDefaultExported()) { - return Scope::InsertResult {{}, false}; + return Scope::InsertResult {Bindings().end(), false}; } } } diff --git a/ets2panda/varbinder/scope.h b/ets2panda/varbinder/scope.h index 644e49e5c4fb8212c5cfd4d348301a37ac194a26..c1c11520e3e6ff59618c14635b6bc1fe5159d3ca 100644 --- a/ets2panda/varbinder/scope.h +++ b/ets2panda/varbinder/scope.h @@ -73,7 +73,7 @@ public: NO_MOVE_SEMANTIC(Scope); using VariableMap = ArenaUnorderedMap; - using InsertResult = std::pair; + using InsertResult = std::pair; virtual ScopeType Type() const = 0;