Lines Matching defs:newDecl
255 Variable *Scope::AddLocalVar(ArenaAllocator *allocator, Decl *newDecl)
258 IterateShadowedVariables(newDecl->Name(), [](const Variable *v) { return !v->HasFlag(VariableFlags::VAR); });
266 return scope->InsertBinding(newDecl->Name(), allocator->New<GlobalVariable>(newDecl, varFlags)).first->second;
269 return scope->PropagateBinding<LocalVariable>(allocator, newDecl->Name(), newDecl, varFlags);
272 Variable *Scope::AddLocal(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl,
276 switch (newDecl->Type()) {
278 return AddLocalVar(allocator, newDecl);
281 return bindings_.insert({newDecl->Name(), allocator->New<EnumVariable>(newDecl, false)}).first->second;
285 .insert({newDecl->Name(), allocator->New<LocalVariable>(newDecl, VariableFlags::ENUM_LITERAL)})
289 return bindings_.insert({newDecl->Name(), allocator->New<LocalVariable>(newDecl, VariableFlags::INTERFACE)})
293 return bindings_.insert({newDecl->Name(), allocator->New<LocalVariable>(newDecl, VariableFlags::CLASS)})
298 .insert({newDecl->Name(), allocator->New<LocalVariable>(newDecl, VariableFlags::TYPE_PARAMETER)})
311 newDecl->Name(), [](const Variable *v) { return v->HasFlag(VariableFlags::LEXICAL_VAR); });
318 return bindings_.insert({newDecl->Name(), allocator->New<LocalVariable>(newDecl, flags)}).first->second;
382 Variable *ParamScope::AddParam(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl, VariableFlags flags)
384 ASSERT(newDecl->IsParameterDecl());
390 auto *param = allocator->New<LocalVariable>(newDecl, flags);
394 InsertBinding(newDecl->Name(), param);
442 [[maybe_unused]] Variable *currentVariable, [[maybe_unused]] Decl *newDecl,
448 Variable *FunctionScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl,
453 switch (newDecl->Type()) {
455 return AddVar<LocalVariable>(allocator, currentVariable, newDecl);
458 return AddFunction<LocalVariable>(allocator, currentVariable, newDecl, extension);
461 return InsertBinding(newDecl->Name(), allocator->New<EnumVariable>(newDecl, false)).first->second;
464 return AddTSBinding<LocalVariable>(allocator, currentVariable, newDecl, VariableFlags::ENUM_LITERAL);
468 ident = newDecl->Node()->AsTSInterfaceDeclaration()->Id();
469 auto interfaceVar = allocator->New<LocalVariable>(newDecl, VariableFlags::INTERFACE);
470 var = InsertBinding(newDecl->Name(), interfaceVar).first->second;
474 ident = newDecl->Node()->AsClassDefinition()->Ident();
475 auto classVar = allocator->New<LocalVariable>(newDecl, VariableFlags::CLASS);
476 var = InsertBinding(newDecl->Name(), classVar).first->second;
480 ident = newDecl->Node()->AsTSTypeAliasDeclaration()->Id();
481 var = typeAliasScope_->AddBinding(allocator, currentVariable, newDecl, extension);
485 return AddLexical<LocalVariable>(allocator, currentVariable, newDecl);
497 Variable *GlobalScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl,
500 switch (newDecl->Type()) {
502 return AddVar<GlobalVariable>(allocator, currentVariable, newDecl);
505 return AddFunction<GlobalVariable>(allocator, currentVariable, newDecl, extension);
508 return InsertBinding(newDecl->Name(), allocator->New<EnumVariable>(newDecl, false)).first->second;
511 return AddTSBinding<LocalVariable>(allocator, currentVariable, newDecl, VariableFlags::ENUM_LITERAL);
514 return AddTSBinding<LocalVariable>(allocator, currentVariable, newDecl, VariableFlags::INTERFACE);
517 return AddLexical<LocalVariable>(allocator, currentVariable, newDecl);
595 Variable *ModuleScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl,
598 switch (newDecl->Type()) {
600 return AddVar<LocalVariable>(allocator, currentVariable, newDecl);
603 return AddFunction<LocalVariable>(allocator, currentVariable, newDecl, extension);
606 return InsertBinding(newDecl->Name(), allocator->New<EnumVariable>(newDecl, false)).first->second;
609 return AddTSBinding<LocalVariable>(allocator, currentVariable, newDecl, VariableFlags::ENUM_LITERAL);
612 return AddTSBinding<LocalVariable>(allocator, currentVariable, newDecl, VariableFlags::INTERFACE);
615 return AddImport(allocator, currentVariable, newDecl);
618 return allocator->New<LocalVariable>(newDecl, VariableFlags::NONE);
621 return AddLexical<LocalVariable>(allocator, currentVariable, newDecl);
654 Variable *ModuleScope::AddImport(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl)
660 if (newDecl->Node()->IsImportNamespaceSpecifier()) {
661 return InsertBinding(newDecl->Name(), allocator->New<LocalVariable>(newDecl, VariableFlags::READONLY))
665 auto *variable = allocator->New<ModuleVariable>(newDecl, VariableFlags::NONE);
666 variable->ExoticName() = newDecl->AsImportDecl()->ImportName();
667 InsertBinding(newDecl->Name(), variable);
758 Variable *LocalScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl,
761 return AddLocal(allocator, currentVariable, newDecl, extension);
764 Variable *LocalScopeWithTypeAlias::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl,
767 if (newDecl->IsTypeAliasDecl()) {
768 auto *ident = newDecl->Node()->AsTSTypeAliasDeclaration()->Id();
769 auto *var = typeAliasScope_->AddBinding(allocator, currentVariable, newDecl, extension);
778 return AddLocal(allocator, currentVariable, newDecl, extension);
870 void ClassScope::SetBindingProps(Decl *newDecl, BindingProps *props, bool isStatic)
872 switch (newDecl->Type()) {
876 props->SetBindingProps(VariableFlags::PROPERTY, newDecl->Node()->AsClassProperty()->Id(),
881 props->SetBindingProps(VariableFlags::INTERFACE, newDecl->Node()->AsTSInterfaceDeclaration()->Id(),
886 props->SetBindingProps(VariableFlags::CLASS, newDecl->Node()->AsClassDefinition()->Ident(),
891 props->SetBindingProps(VariableFlags::ENUM_LITERAL, newDecl->Node()->AsTSEnumDeclaration()->Key(),
896 props->SetBindingProps(VariableFlags::TYPE_ALIAS, newDecl->Node()->AsTSTypeAliasDeclaration()->Id(),
907 Variable *ClassScope::AddBinding(ArenaAllocator *allocator, [[maybe_unused]] Variable *currentVariable, Decl *newDecl,
910 bool isStatic = newDecl->Node()->IsStatic();
917 SetBindingProps(newDecl, &props, isStatic);
919 auto options = newDecl->Type() != DeclType::TYPE_ALIAS ? ResolveBindingOptions::ALL_NON_TYPE
922 const auto *foundVar = FindLocal(newDecl->Name(), options);
924 if (!newDecl->IsLetOrConstDecl()) {
928 foundVar = FindLocal(newDecl->Name(),
936 auto *var = props.GetTargetScope()->AddBinding(allocator, nullptr, newDecl, extension);
941 if (auto node = newDecl->Node();
1011 Variable *CatchParamScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl,
1014 return AddParam(allocator, currentVariable, newDecl, VariableFlags::INITIALIZED);
1017 Variable *CatchScope::AddBinding(ArenaAllocator *allocator, Variable *currentVariable, Decl *newDecl,
1020 if (!newDecl->IsVarDecl() &&
1021 (paramScope_->FindLocal(newDecl->Name(), varbinder::ResolveBindingOptions::BINDINGS) != nullptr)) {
1025 if (newDecl->IsTypeAliasDecl()) {
1026 auto *ident = newDecl->Node()->AsTSTypeAliasDeclaration()->Id();
1027 auto *var = TypeAliasScope()->AddBinding(allocator, currentVariable, newDecl, extension);
1037 return AddLocal(allocator, currentVariable, newDecl, extension);