• Home
  • Raw
  • Download

Lines Matching full:scope

20 #include "binder/scope.h"
105 …variable declare like 'var ##var_1;' to nearest statements in namespace function or top level scope in AddVariableToNearestStatements()
106 …* Record the variable name and scope in tempVarDeclStatements_ and will push the VariableDeclarat… in AddVariableToNearestStatements()
109 auto currentScope = Scope(); in AddVariableToNearestStatements()
149 auto *scope = it.second; in PushVariablesToNearestStatements() local
150 if (scope == nullptr) { in PushVariablesToNearestStatements()
151 auto scopeCtx = binder::LexicalScope<binder::Scope>::Enter(Binder(), ast->Scope()); in PushVariablesToNearestStatements()
154 } else if (scope->IsFunctionScope() || scope->IsTSModuleScope()) { in PushVariablesToNearestStatements()
155 auto *body = scope->Node()->AsScriptFunction()->Body(); in PushVariablesToNearestStatements()
157 auto scopeCtx = binder::LexicalScope<binder::Scope>::Enter(Binder(), scope); in PushVariablesToNearestStatements()
164 binder::Scope *Transformer::FindExportVariableInTsModuleScope(util::StringView name) const in FindExportVariableInTsModuleScope()
167 auto currentScope = Scope(); in FindExportVariableInTsModuleScope()
216 auto scope = FindEnumMemberScope(name); in VisitTSNode() local
217 if (scope) { in VisitTSNode()
218 return CreateMemberExpressionFromIdentifier(scope, ident); in VisitTSNode()
222 auto scope = FindExportVariableInTsModuleScope(name); in VisitTSNode() local
223 if (scope) { in VisitTSNode()
224 return CreateMemberExpressionFromIdentifier(scope, ident); in VisitTSNode()
324 ResetParentScope(res, Scope()); in VisitTSNode()
526 auto *scope = Scope(); in GetClassReference() local
527 while (scope != nullptr) { in GetClassReference()
528 auto *v = scope->FindLocal(name, binder::ResolveBindingOptions::BINDINGS); in GetClassReference()
539 scope = scope->Parent(); in GetClassReference()
700 … = binder::LexicalScope<binder::FunctionScope>::Enter(Binder(), node->Ctor()->Function()->Scope()); in VisitInstanceProperty()
723 ResetParentScopeForAstNode(assignment, Scope()); in VisitInstanceProperty()
918 auto *scope = Binder()->Allocator()->New<binder::FunctionScope>(Allocator(), paramScope); in AddMethodToClass() local
919 CHECK_NOT_NULL(scope); in AddMethodToClass()
920 paramScope->BindFunctionScope(scope); in AddMethodToClass()
921 auto *body = AllocNode<ir::BlockStatement>(scope, std::move(statements)); in AddMethodToClass()
922 auto *func = AllocNode<ir::ScriptFunction>(scope, std::move(params), nullptr, body, nullptr, in AddMethodToClass()
924 scope->BindNode(func); in AddMethodToClass()
925 scope->BindParamScope(paramScope); in AddMethodToClass()
1126 auto scopeCtx = binder::LexicalScope<binder::Scope>::Enter(Binder(), in VisitClassDeclaration()
1127 hasPrivateIdentifier ? staticBlock->GetBody()->Scope() : Scope()); in VisitClassDeclaration()
1252 … staticInitializer->Function()->Scope()); in CreateClassStaticBlock()
1634 if (!IsInstantiatedImportEquals(node, Scope())) { in VisitTsImportEqualsDeclaration()
1662 …::IsInstantiatedImportEquals(const ir::TSImportEqualsDeclaration *node, binder::Scope *scope) const in IsInstantiatedImportEquals()
1668 auto *var = FindTSModuleVariable(node->ModuleReference(), scope, &isType); in IsInstantiatedImportEquals()
1679 const binder::Scope *scope, in FindTSModuleVariable() argument
1687 auto *var = FindTSModuleVariable(tsQualifiedName->Left(), scope, isType); in FindTSModuleVariable()
1715 auto *currentScope = scope; in FindTSModuleVariable()
1752 binder::Variable *Transformer::FindTSVariable(const binder::Scope *scope, const util::StringView &n… in FindTSVariable() argument
1754 binder::Variable *res = scope->FindLocalTSVariable<type>(name); in FindTSVariable()
1755 if (res == nullptr && scope->IsTSModuleScope()) { in FindTSVariable()
1756 res = scope->AsTSModuleScope()->FindExportTSVariable<type>(name); in FindTSVariable()
1825 void Transformer::ResetParentScope(ir::UpdateNodes res, binder::Scope *parentScope) const in ResetParentScope()
1903 auto scope = node->AsTSModuleDeclaration()->Scope(); in GetParamName() local
1904 if (scope && !scope->HasVariableName(name)) { in GetParamName()
1909 auto scope = node->AsTSEnumDeclaration()->Scope(); in GetParamName() local
1910 if (scope && !scope->HasDeclarationName(name)) { in GetParamName()
1925 binder::FunctionScope *funcScope = node->Scope(); in CreateCallExpressionForTsModule()
1999 auto findRes = Scope()->FindLocal(name, binder::ResolveBindingOptions::BINDINGS); in VisitTsModuleDeclaration()
2024 …auto findRes = Scope()->FindLocal(name); // Find if the variable with the same name is already de… in VisitTsEnumDeclaration()
2039 … auto flag = Scope()->Parent() == nullptr ? VariableParsingFlags::VAR : VariableParsingFlags::LET; in CreateVariableDeclarationForTSEnumOrTSModule()
2064 binder::FunctionScope *funcScope = node->Scope(); in CreateCallExpressionForTsEnum()
2136 binder::Variable *enumVar = Scope()->AsTSEnumScope()->FindEnumMemberVariable(enumMemberName); in CreateTsEnumMember()
2141 isStringInit = IsStringInitForEnumMember(node->Init(), Scope()); in CreateTsEnumMember()
2240 bool Transformer::IsStringInitForEnumMember(const ir::Expression *expr, binder::Scope *scope) const in IsStringInitForEnumMember()
2256 ASSERT(scope && scope->IsTSEnumScope()); in IsStringInitForEnumMember()
2257 binder::Variable *v = scope->AsTSEnumScope()->FindEnumMemberVariable(identName); in IsStringInitForEnumMember()
2263 if (IsStringInitForEnumMember(initExpr, scope)) { in IsStringInitForEnumMember()
2275 return IsStringForMemberExpression(expr->AsMemberExpression(), scope); in IsStringInitForEnumMember()
2281 IsStringInitForEnumMember(right, scope) && IsStringInitForEnumMember(left, scope)) { in IsStringInitForEnumMember()
2293 …er::IsStringForMemberExpression(const ir::MemberExpression *memberExpr, binder::Scope *scope) const in IsStringForMemberExpression()
2314 …nder::Variable *> findRes = FindFrontIdentifierTSVariables(members.front()->AsIdentifier(), scope); in IsStringForMemberExpression()
2326 … binder::Scope *scope) const in FindFrontIdentifierTSVariables()
2331 while (scope != nullptr) { in FindFrontIdentifierTSVariables()
2333 if (scope->IsTSEnumScope()) { in FindFrontIdentifierTSVariables()
2334 v = scope->AsTSEnumScope()->FindEnumMemberVariable(name); in FindFrontIdentifierTSVariables()
2344 FindLocalTSVariables(scope, name, types, findRes); in FindFrontIdentifierTSVariables()
2346 if (scope->IsTSModuleScope()) { in FindFrontIdentifierTSVariables()
2347 FindExportTSVariables(scope, name, types, findRes); in FindFrontIdentifierTSVariables()
2355 v = scope->FindLocal(name); in FindFrontIdentifierTSVariables()
2357 … if (scope->IsTSModuleScope() || scope->IsTSEnumScope()) { // v may be converted from ts variable in FindFrontIdentifierTSVariables()
2358 v = scope->Parent()->FindLocal(name); in FindFrontIdentifierTSVariables()
2366 if (scope->IsTSModuleScope()) { in FindFrontIdentifierTSVariables()
2367 v = scope->AsTSModuleScope()->FindExportVariable(name); in FindFrontIdentifierTSVariables()
2373 if (scope->IsTSModuleScope() || scope->IsTSEnumScope()) { in FindFrontIdentifierTSVariables()
2374 scope = scope->Parent(); in FindFrontIdentifierTSVariables()
2376 scope = scope->Parent(); in FindFrontIdentifierTSVariables()
2396 void Transformer::FindLocalTSVariables(binder::Scope *scope, const util::StringView name, in FindLocalTSVariables() argument
2404 v = scope->FindLocalTSVariable<binder::TSBindingType::NAMESPACE>(name); in FindLocalTSVariables()
2411 v = scope->FindLocalTSVariable<binder::TSBindingType::ENUMLITERAL>(name); in FindLocalTSVariables()
2415 v = scope->FindLocalTSVariable<binder::TSBindingType::IMPORT_EQUALS>(name); in FindLocalTSVariables()
2418 Parent()->AsTSImportEqualsDeclaration(), scope)) { in FindLocalTSVariables()
2432 void Transformer::FindExportTSVariables(binder::Scope *scope, const util::StringView name, in FindExportTSVariables() argument
2440 … v = scope->AsTSModuleScope()->FindExportTSVariable<binder::TSBindingType::NAMESPACE>(name); in FindExportTSVariables()
2447 … v = scope->AsTSModuleScope()->FindExportTSVariable<binder::TSBindingType::ENUMLITERAL>(name); in FindExportTSVariables()
2451 … v = scope->AsTSModuleScope()->FindExportTSVariable<binder::TSBindingType::IMPORT_EQUALS>(name); in FindExportTSVariables()
2454 Parent()->AsTSImportEqualsDeclaration(), scope)) { in FindExportTSVariables()
2485 auto *scope = enumMemberVar->AsEnumVariable()->Declaration()-> in VerifyMemberExpressionDeque() local
2486 Node()->Parent()->AsTSEnumDeclaration()->Scope(); in VerifyMemberExpressionDeque()
2488 if (IsStringInitForEnumMember(initExpr, scope)) { in VerifyMemberExpressionDeque()
2578 binder::Scope *Transformer::FindEnumMemberScope(const util::StringView name) const in FindEnumMemberScope()
2581 auto scope = Scope(); in FindEnumMemberScope() local
2582 while (scope != nullptr) { in FindEnumMemberScope()
2583 if (scope->InLocalTSBindings(name)) { in FindEnumMemberScope()
2586 if (scope->IsTSModuleScope() && scope->AsTSModuleScope()->InExportBindings(name)) { in FindEnumMemberScope()
2589 if (scope->IsTSEnumScope() && scope->AsTSEnumScope()->FindEnumMemberVariable(name)) { in FindEnumMemberScope()
2590 return scope; in FindEnumMemberScope()
2592 if (scope->FindLocal(name)) { in FindEnumMemberScope()
2596 if (scope->IsTSModuleScope() || scope->IsTSEnumScope()) { in FindEnumMemberScope()
2597 scope = scope->Parent(); in FindEnumMemberScope()
2599 scope = scope->Parent(); in FindEnumMemberScope()
2605 ir::MemberExpression *Transformer::CreateMemberExpressionFromIdentifier(binder::Scope *scope, ir::I… in CreateMemberExpressionFromIdentifier() argument
2608 …auto moduleName = scope->IsTSEnumScope() ? FindTSEnumNameByScope(scope) : FindTSModuleNameByScope( in CreateMemberExpressionFromIdentifier()
2655 void Transformer::ResetParentScopeForAstNodes(const ir::AstNode *parent, binder::Scope *parentScope… in ResetParentScopeForAstNodes()
2660 void Transformer::ResetParentScopeForAstNode(ir::AstNode *childNode, binder::Scope *parentScope) co… in ResetParentScopeForAstNode()
2664 auto scope = childNode->AsScriptFunction()->Scope(); in ResetParentScopeForAstNode() local
2665 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2666 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2670 auto scope = childNode->AsCatchClause()->Scope(); in ResetParentScopeForAstNode() local
2671 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2672 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2676 auto scope = childNode->AsClassDefinition()->Scope(); in ResetParentScopeForAstNode() local
2677 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2678 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2682 auto scope = childNode->AsBlockStatement()->Scope(); in ResetParentScopeForAstNode() local
2683 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2684 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2688 auto scope = childNode->AsDoWhileStatement()->Scope(); in ResetParentScopeForAstNode() local
2689 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2690 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2694 auto scope = childNode->AsWhileStatement()->Scope(); in ResetParentScopeForAstNode() local
2695 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2696 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2700 auto scope = childNode->AsForInStatement()->Scope(); in ResetParentScopeForAstNode() local
2701 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2702 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2706 auto scope = childNode->AsForOfStatement()->Scope(); in ResetParentScopeForAstNode() local
2707 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2708 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2712 auto scope = childNode->AsForUpdateStatement()->Scope(); in ResetParentScopeForAstNode() local
2713 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2714 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2718 auto scope = childNode->AsSwitchStatement()->Scope(); in ResetParentScopeForAstNode() local
2719 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2720 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2724 auto scope = childNode->AsTSEnumDeclaration()->Scope(); in ResetParentScopeForAstNode() local
2725 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2726 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2730 auto scope = childNode->AsTSInterfaceDeclaration()->Scope(); in ResetParentScopeForAstNode() local
2731 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2732 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2736 auto scope = childNode->AsTSMethodSignature()->Scope(); in ResetParentScopeForAstNode() local
2737 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2738 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2742 auto scope = childNode->AsTSModuleDeclaration()->Scope(); in ResetParentScopeForAstNode() local
2743 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2744 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2748 auto scope = childNode->AsTSSignatureDeclaration()->Scope(); in ResetParentScopeForAstNode() local
2749 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2750 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2754 auto scope = childNode->AsTSTypeParameterDeclaration()->Scope(); in ResetParentScopeForAstNode() local
2755 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2756 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2760 auto scope = childNode->AsTSConstructorType()->Scope(); in ResetParentScopeForAstNode() local
2761 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2762 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2766 auto scope = childNode->AsTSFunctionType()->Scope(); in ResetParentScopeForAstNode() local
2767 ASSERT(scope != nullptr); in ResetParentScopeForAstNode()
2768 scope->SetParent(parentScope); in ResetParentScopeForAstNode()
2780 auto scope = Scope(); in IsValueReference() local
2781 ASSERT(scope != nullptr); in IsValueReference()
2785 if (scope->FindLocal(name, binder::ResolveBindingOptions::BINDINGS) != nullptr || in IsValueReference()
2786 scope->FindLocalTSVariable<binder::TSBindingType::ENUMLITERAL>(name) != nullptr) { in IsValueReference()
2792 var = scope->FindLocalTSVariable<binder::TSBindingType::NAMESPACE>(name); in IsValueReference()
2798 var = scope->FindLocalTSVariable<binder::TSBindingType::IMPORT_EQUALS>(name); in IsValueReference()
2801 return IsInstantiatedImportEquals(node, scope); in IsValueReference()