const AST::Type* resolveAliasType(AST::Alias& alias) { if (alias.type() != nullptr) { return alias.type(); } assert(resolveMap_.find(&alias) != resolveMap_.end()); auto& resolveInfo = resolveMap_.at(&alias); if (resolveInfo.isResolving()) { context_.issueDiag(AliasDependsOnItselfDiag(alias.fullName().copy()), alias.location()); const auto voidType = context_.typeBuilder().getVoidType(); alias.setType(voidType); return voidType; } resolveInfo.setIsResolving(); SwapScopeStack swapScopeStack(context_.scopeStack(), resolveInfo.scopeStack()); alias.setValue(ConvertValue(context_, alias.valueDecl())); return alias.type(); }
void CheckTemplateInstantiationsPass(Context& context) { auto& templateInsts = context.templateInstantiations(); // std::tuple<ScopeStack, SEM::TemplateVarMap, const SEM::HasRequiresPredicate*, Name, Debug::SourceLocation> for (auto& inst: templateInsts) { auto& savedScopeStack = inst.scopeStack(); const auto& variableAssignments = inst.templateVarMap(); const auto& templatedObject = inst.templatedObject(); const auto& location = inst.location(); // Swap the current scope stack with the saved stack so we // can reproduce the environment of the template instantiation // (and then swap them back afterwards). SwapScopeStack swapScopeStack(context.scopeStack(), savedScopeStack); CheckTemplateInstantiation(context, templatedObject, variableAssignments, location); } templateInsts.clear(); context.setTemplateRequirementsComplete(); }