Lines Matching +full:allocator +full:-
7 * http://www.apache.org/licenses/LICENSE-2.0
29 if (iter->IsVariableScope()) { in EnclosingVariableScope()
30 return iter->AsVariableScope(); in EnclosingVariableScope()
33 iter = iter->Parent(); in EnclosingVariableScope()
43 if (iter->IsFunctionVariableScope()) { in EnclosingFunctionVariableScope()
44 return iter->AsFunctionVariableScope(); in EnclosingFunctionVariableScope()
47 iter = iter->Parent(); in EnclosingFunctionVariableScope()
60 return res->second; in FindLocal()
73 return res->second; in FindLocal()
79 auto *funcVariableScope = scope->GetFunctionScope(); in CalculateLevelInCorrespondingFunctionScope()
85 if (funcVariableScope->NeedLexEnv()) { in CalculateLevelInCorrespondingFunctionScope()
89 if (funcVariableScope->NeedSendableEnv()) { in CalculateLevelInCorrespondingFunctionScope()
108 bool functionScopeNotIterated = iter->IsFunctionParamScope() && prevScopeNotFunctionScope; in Find()
109 Variable *v = iter->FindLocal(name, options); in Find()
115 if (iter->IsFunctionVariableScope() && !lexical) { in Find()
119 if (iter->IsFunctionScope() && !concurrentFunc) { in Find()
120 if (iter->Node()->AsScriptFunction()->IsConcurrent()) { in Find()
121 concurrentFunc = const_cast<ir::ScriptFunction *>(iter->Node()->AsScriptFunction()); in Find()
125 if (iter->IsVariableScope()) { in Find()
130 if (iter->AsVariableScope()->NeedLexEnv()) { in Find()
134 if (iter->AsVariableScope()->NeedSendableEnv()) { in Find()
139 … CalculateLevelInCorrespondingFunctionScope(iter->AsFunctionParamScope(), lexLevel, sendableLevel); in Find()
142 prevScopeNotFunctionScope = !iter->IsFunctionVariableScope(); in Find()
143 iter = iter->Parent(); in Find()
155 if (iter->Type() == ScopeType::CLASS) { in Find()
159 return {lexLevel, iter->AsClassScope()->GetSlot(expr)}; in Find()
162 if (iter->IsVariableScope()) { in Find()
163 if (iter->AsVariableScope()->NeedLexEnv()) { in Find()
167 iter = iter->Parent(); in Find()
175 // sendable class does not need a lexical env, handle it's scope as a non-variable scope in IsVariableScope()
176 return !node_->AsClassDefinition()->IsSendable(); in IsVariableScope()
190 slot = privateNames_.find(name)->second; in GetPrivateProperty()
198 slot = accessor.find(name)->second; in GetPrivateProperty()
202 slot = unexpectedAccessor.find(name)->second; in GetPrivateProperty()
224 if (stmt->IsClassProperty()) { in AddPrivateName()
225 … privateNames_[stmt->AsClassProperty()->Key()->AsPrivateIdentifier()->Name()] = slotIndex_++; in AddPrivateName()
228 ASSERT(stmt->IsMethodDefinition()); in AddPrivateName()
229 auto *methodDef = stmt->AsMethodDefinition(); in AddPrivateName()
230 … uint32_t *start = methodDef->IsStatic() ? &staticPrivateMethodSlot : &instancePrivateMethodSlot; in AddPrivateName()
231 auto name = methodDef->Key()->AsPrivateIdentifier()->Name(); in AddPrivateName()
232 switch (methodDef->Kind()) { in AddPrivateName()
266 if (node_ && node_->IsClassDefinition() && node_->AsClassDefinition()->Ident()) { in GetSelfScopeName()
267 util::StringView selfName = node_->AsClassDefinition()->Ident()->Name(); in GetSelfScopeName()
272 if (node_ && node_->Parent() && node_->Parent()->Parent()) { in GetSelfScopeName()
273 scopeName << util::Helpers::GetName(allocator_, node_->Parent()->Parent()); in GetSelfScopeName()
291 if (iter->Type() == ScopeType::CLASS) { in FindPrivateName()
292 const auto *classScope = iter->AsClassScope(); in FindPrivateName()
293 if (name.Is("#method") || classScope->HasPrivateName(name)) { in FindPrivateName()
294 return {lexLevel, classScope->GetPrivateProperty(name, isSetter)}; in FindPrivateName()
298 if (iter->IsVariableScope()) { in FindPrivateName()
299 if (iter->AsVariableScope()->NeedLexEnv()) { in FindPrivateName()
303 iter = iter->Parent(); in FindPrivateName()
312 if (it->Name() == name) { in FindDecl()
323 if (it->Name() == name && it->IsVarDecl()) { in HasVarDecl()
336 auto *v = iter->FindLocal(name); in IterateShadowedVariables()
342 if (iter->IsFunctionVariableScope()) { in IterateShadowedVariables()
346 iter = iter->Parent(); in IterateShadowedVariables()
367 fullScopeName << parent->GetFullScopeName() << in SetFullScopeNames()
382 auto it = topScope_->scopeNames_.find(selfScopeName_); in OptimizeSelfScopeName()
383 if (it == topScope_->scopeNames_.end()) { in OptimizeSelfScopeName()
385 …indexScopeName << util::Helpers::INDEX_NAME_SPICIFIER << std::hex << topScope_->scopeNames_.size(); in OptimizeSelfScopeName()
387 topScope_->scopeNames_.insert( in OptimizeSelfScopeName()
388 {selfScopeName_, (int32_t)topScope_->scopeNames_.size()} in OptimizeSelfScopeName()
394 selfScopeStream << util::Helpers::INDEX_NAME_SPICIFIER << std::hex << it->second; in OptimizeSelfScopeName()
403 bool Scope::AddLocal(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, in AddLocal() argument
407 switch (newDecl->Type()) { in AddLocal()
410 newDecl->Name(), [](const Variable *v) { return !v->HasFlag(VariableFlags::VAR); }); in AddLocal()
417 if (scope->IsGlobalScope()) { in AddLocal()
418 … scope->Bindings().insert({newDecl->Name(), allocator->New<GlobalVariable>(newDecl, varFlags)}); in AddLocal()
420 … scope->PropagateBinding<LocalVariable>(allocator, newDecl->Name(), newDecl, varFlags); in AddLocal()
427 … newDecl->Name(), allocator->New<EnumLiteralVariable>(newDecl, VariableFlags::ENUM_LITERAL)); in AddLocal()
430 …bindings_.insert({newDecl->Name(), allocator->New<LocalVariable>(newDecl, VariableFlags::INTERFACE… in AddLocal()
442 if (HasVarDecl(newDecl->Name())) { in AddLocal()
446 bindings_.insert({newDecl->Name(), allocator->New<LocalVariable>(newDecl, flags)}); in AddLocal()
452 bool ParamScope::AddParam(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, Vari… in AddParam() argument
455 ASSERT(newDecl->IsParameterDecl()); in AddParam()
461 auto *param = allocator->New<LocalVariable>(newDecl, flags); in AddParam()
464 bindings_.insert({newDecl->Name(), param}); in AddParam()
468 std::tuple<ParameterDecl *, const ir::AstNode *> ParamScope::AddParamDecl(ArenaAllocator *allocator, in AddParamDecl() argument
471 const auto [name, pattern] = util::Helpers::ParamName(allocator, param, params_.size()); in AddParamDecl()
473 auto *decl = NewDecl<ParameterDecl>(allocator, name); in AddParamDecl()
476 if (!AddParam(allocator, FindLocal(name), decl, VariableFlags::VAR)) { in AddParamDecl()
481 decl->BindNode(param); in AddParamDecl()
488 auto *varDecl = NewDecl<VarDecl>(allocator, binding->Name()); in AddParamDecl()
490 varDecl->BindNode(binding); in AddParamDecl()
492 if (FindLocal(varDecl->Name())) { in AddParamDecl()
496 auto *paramVar = allocator->New<LocalVariable>(varDecl, VariableFlags::VAR); in AddParamDecl()
497 bindings_.insert({varDecl->Name(), paramVar}); in AddParamDecl()
503 void FunctionParamScope::BindName(ArenaAllocator *allocator, util::StringView name) in BindName() argument
505 nameVar_ = AddDecl<ConstDecl, LocalVariable>(allocator, name, VariableFlags::INITIALIZED); in BindName()
506 functionScope_->Bindings().insert({name, nameVar_}); in BindName()
509 bool FunctionParamScope::AddBinding([[maybe_unused]] ArenaAllocator *allocator, in AddBinding() argument
519 return functionScope_->GetFullScopeName(); in GetFullScopeName()
525 return parent_->GetFullScopeName(); in GetFullScopeName()
534 return functionScope_->GetDuplicateScopeIndex(childScopeName); in GetDuplicateScopeIndex()
538 return parent_->GetDuplicateScopeIndex(childScopeName); in GetDuplicateScopeIndex()
552 internalName << parent->GetFullScopeName(); in BindNameWithScopeInfo()
562 bool FunctionScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, in AddBinding() argument
565 switch (newDecl->Type()) { in AddBinding()
567 return AddVar<LocalVariable>(allocator, currentVariable, newDecl); in AddBinding()
570 return AddFunction<LocalVariable>(allocator, currentVariable, newDecl, extension); in AddBinding()
573 return AddClass<LocalVariable>(allocator, currentVariable, newDecl); in AddBinding()
576 … return AddTSBinding<EnumLiteralVariable>(allocator, newDecl, VariableFlags::ENUM_LITERAL); in AddBinding()
579 return AddTSBinding<NamespaceVariable>(allocator, newDecl, VariableFlags::NAMESPACE); in AddBinding()
582 … return AddTSBinding<ImportEqualsVariable>(allocator, newDecl, VariableFlags::IMPORT_EQUALS); in AddBinding()
585 … return AddTSBinding<LocalVariable>(allocator, currentVariable, newDecl, VariableFlags::INTERFACE); in AddBinding()
588 return AddLexical<LocalVariable>(allocator, currentVariable, newDecl); in AddBinding()
596 paramScope_->selfScopeName_ = selfScopeName_; in SetSelfScopeName()
597 paramScope_->hasSelfScopeNameSet_ = true; in SetSelfScopeName()
603 …if (IsFunctionScope() && (node_->IsScriptFunction() && node_->AsScriptFunction()->IsConstructor())… in GetScopeTag()
606 if (parent_ && parent_->Parent() && parent_->Parent()->IsClassScope()) { in GetScopeTag()
607 bool hasNodeParent = node_ && node_->Parent() && node_->Parent()->Parent(); in GetScopeTag()
608 const ir::AstNode *nodeParent = hasNodeParent ? node_->Parent()->Parent() : nullptr; in GetScopeTag()
609 …if (nodeParent && nodeParent->IsMethodDefinition() && nodeParent->AsMethodDefinition()->IsStatic()… in GetScopeTag()
623 if (node_ && node_->IsScriptFunction()) { in GetSelfScopeName()
624 auto selfName = util::Helpers::FunctionName(allocator_, node_->AsScriptFunction()); in GetSelfScopeName()
645 bool TSEnumScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, in AddBinding() argument
648 ASSERT(newDecl->Type() == DeclType::ENUM); in AddBinding()
649 …return enumMemberBindings_->insert({newDecl->Name(), allocator->New<EnumVariable>(newDecl, false)}… in AddBinding()
666 if (node_ && node_->IsScriptFunction()) { in GetSelfScopeName()
667 auto scriptFunction = node_->AsScriptFunction(); in GetSelfScopeName()
668 if (scriptFunction->Params().size() > 0 && scriptFunction->Params()[0]->IsIdentifier()) { in GetSelfScopeName()
669 scopeName << scriptFunction->Params()[0]->AsIdentifier()->Name(); in GetSelfScopeName()
680 bool GlobalScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, in AddBinding() argument
683 switch (newDecl->Type()) { in AddBinding()
685 return AddVar<GlobalVariable>(allocator, currentVariable, newDecl); in AddBinding()
688 return AddFunction<GlobalVariable>(allocator, currentVariable, newDecl, extension); in AddBinding()
691 return AddClass<LocalVariable>(allocator, currentVariable, newDecl); in AddBinding()
694 … return AddTSBinding<EnumLiteralVariable>(allocator, newDecl, VariableFlags::ENUM_LITERAL); in AddBinding()
697 return AddTSBinding<NamespaceVariable>(allocator, newDecl, VariableFlags::NAMESPACE); in AddBinding()
700 … return AddTSBinding<ImportEqualsVariable>(allocator, newDecl, VariableFlags::IMPORT_EQUALS); in AddBinding()
703 … return AddTSBinding<LocalVariable>(allocator, currentVariable, newDecl, VariableFlags::INTERFACE); in AddBinding()
706 return AddLexical<LocalVariable>(allocator, currentVariable, newDecl); in AddBinding()
720 void ModuleScope::ConvertLocalVariableToModuleVariable(ArenaAllocator *allocator, util::StringView … in ConvertLocalVariableToModuleVariable() argument
726 if (!res->second->IsModuleVariable()) { in ConvertLocalVariableToModuleVariable()
727 auto *decl = res->second->Declaration(); in ConvertLocalVariableToModuleVariable()
728 decl->AddFlag(DeclarationFlags::EXPORT); in ConvertLocalVariableToModuleVariable()
729 VariableFlags flags = res->second->Flags(); in ConvertLocalVariableToModuleVariable()
730 res->second = allocator->New<ModuleVariable>(decl, flags | VariableFlags::LOCAL_EXPORT); in ConvertLocalVariableToModuleVariable()
738 ASSERT(moduleVar->IsModuleVariable()); in AssignIndexToModuleVariable()
739 moduleVar->AsModuleVariable()->AssignIndex(index); in AssignIndexToModuleVariable()
742 bool ModuleScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, in AddBinding() argument
745 switch (newDecl->Type()) { in AddBinding()
748 newDecl->Name(), [](const Variable *v) { return !v->HasFlag(VariableFlags::VAR); }); in AddBinding()
753 return newDecl->IsImportOrExportDecl() ? in AddBinding()
754 AddVar<ModuleVariable>(allocator, currentVariable, newDecl) : in AddBinding()
755 AddVar<LocalVariable>(allocator, currentVariable, newDecl); in AddBinding()
759 auto decl = currentVariable->Declaration(); in AddBinding()
760 if (!decl->IsClassDecl() || !decl->AsClassDecl()->IsDeclare()) { in AddBinding()
764 return newDecl->IsImportOrExportDecl() ? in AddBinding()
765 AddFunction<ModuleVariable>(allocator, currentVariable, newDecl, extension) : in AddBinding()
766 AddFunction<LocalVariable>(allocator, currentVariable, newDecl, extension); in AddBinding()
769 return newDecl->IsImportOrExportDecl() ? in AddBinding()
770 AddClass<ModuleVariable>(allocator, currentVariable, newDecl) : in AddBinding()
771 AddClass<LocalVariable>(allocator, currentVariable, newDecl); in AddBinding()
774 … return AddTSBinding<EnumLiteralVariable>(allocator, newDecl, VariableFlags::ENUM_LITERAL); in AddBinding()
777 return AddTSBinding<NamespaceVariable>(allocator, newDecl, VariableFlags::NAMESPACE); in AddBinding()
780 … return AddTSBinding<ImportEqualsVariable>(allocator, newDecl, VariableFlags::IMPORT_EQUALS); in AddBinding()
783 … return AddTSBinding<LocalVariable>(allocator, currentVariable, newDecl, VariableFlags::INTERFACE); in AddBinding()
789 return newDecl->IsImportOrExportDecl() ? in AddBinding()
790 AddLexical<ModuleVariable>(allocator, currentVariable, newDecl) : in AddBinding()
791 AddLexical<LocalVariable>(allocator, currentVariable, newDecl); in AddBinding()
803 bool LocalScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, in AddBinding() argument
806 return AddLocal(allocator, currentVariable, newDecl, extension); in AddBinding()
812 if (!var->Declaration()->IsLetOrConstOrClassDecl()) { in InitVariable()
816 var->AddFlag(VariableFlags::INITIALIZED); in InitVariable()
817 if (var->LexicalBound()) { in InitVariable()
818 var->AddFlag(VariableFlags::PER_ITERATION); in InitVariable()
823 bool CatchParamScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDec… in AddBinding() argument
826 return AddParam(allocator, currentVariable, newDecl, VariableFlags::INITIALIZED); in AddBinding()
829 bool CatchScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, in AddBinding() argument
832 if (!newDecl->IsVarDecl() && paramScope_->FindLocal(newDecl->Name())) { in AddBinding()
836 return AddLocal(allocator, currentVariable, newDecl, extension); in AddBinding()