1 // =================================
 2 // Copyright (c) 2021 Seppo Laakko
 3 // Distributed under the MIT license
 4 // =================================
 5 
 6 #include <cmajor/symbols/NamespaceSymbol.hpp>
 7 #include <cmajor/symbols/Module.hpp>
 8 #include <cmajor/symbols/SymbolTable.hpp>
 9 
10 namespace cmajor { namespace symbols {
11 
12 NamespaceSymbol::NamespaceSymbol(const Span& span_const boost::uuids::uuid& sourceModuleId_const std::u32string& name_) :
13     ContainerSymbol(SymbolType::namespaceSymbolspan_sourceModuleId_name_)
14 {
15 }
16 
17 void NamespaceSymbol::Import(NamespaceSymbol* thatSymbolTable& symbolTable)
18 {
19     NamespaceSymbol* ns = symbolTable.BeginNamespace(that->Name()that->GetSpan()that->SourceModuleId());
20     symbolTable.MapNs(thatns);
21     for (const std::std::unique_ptr<Symbol>&symbol : that->Members())
22     {
23         if (symbol->GetSymbolType() == SymbolType::namespaceSymbol)
24         {
25             NamespaceSymbol* thatNs = static_cast<NamespaceSymbol*>(symbol.get());
26             Import(thatNssymbolTable);
27         }
28         else
29         {
30             if (symbol->GetSymbolType() == SymbolType::functionGroupSymbol)
31             {
32                 continue;
33             }
34             if (symbol->GetSymbolType() == SymbolType::conceptGroupSymbol)
35             {
36                 continue;
37             }
38             if (symbol->GetSymbolType() == SymbolType::classGroupTypeSymbol)
39             {
40                 continue;
41             }
42             if (symbol->GetSymbolType() == SymbolType::globalVariableGroupSymbol)
43             {
44                 continue;
45             }
46             symbolTable.Container()->AddOwnedMember(symbol.get());
47         }
48     }
49     symbolTable.EndNamespace();
50 }
51 
52 std::std::unique_ptr<sngxml::dom::Element>NamespaceSymbol::CreateDomElement(TypeMap&typeMap)
53 {
54     if (HasProjectMembers() && Access() != SymbolAccess::private_)
55     {
56         return std::unique_ptr<sngxml::dom::Element>(new sngxml::dom::Element(U"NamespaceSymbol"));
57     }
58     else
59     {
60         return std::unique_ptr<sngxml::dom::Element>();
61     }
62 }
63 
64 } } // namespace cmajor::symbols