void DeclarationAnalyzer::visitTypeAlias(const TypeAliasPtr& node) { if(isLazyDeclared(node)) return; TypePtr type; SymbolScope* currentScope = symbolRegistry->getCurrentScope(); if(currentScope->isSymbolDefined(node->getName())) { error(node, Errors::E_INVALID_REDECLARATION_1, node->getName()); return; } //type = currentScope->getForwardDeclaration(node->getName()); if(ctx->currentType && ctx->currentType->getCategory() == Type::Protocol && !node->getType()) { //register a type place holder for protocol type = Type::newTypeAlias(node->getName(), nullptr, nullptr); } else { shared_ptr<TypeResolver> typeResolver(new TypeResolver(symbolRegistry, semanticAnalyzer, this, ctx, true)); type = resolveType(node->getType(), true); assert(type != nullptr && "Cannot resolve type"); //TypeBuilderPtr builder = static_pointer_cast<TypeBuilder>(type); //builder->setInnerType(type); //builder->initAlias(node->getType(), typeResolver); } validateDeclarationModifiers(node); declarationFinished(node->getName(), type, node); currentScope->addSymbol(node->getName(), type); }
/*! * Check if a symbol is defined. This will not use LazySymbolResolver to resolve it if it's undefined */ bool SymbolRegistry::isSymbolDefined(const std::wstring& name) const { SymbolScope* s = currentScope; for(; s; s = s->parent) { if(s->isSymbolDefined(name)) return true; } return false; }