1
2
3
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::namespaceSymbol, span_, sourceModuleId_, name_)
14 {
15 }
16
17 void NamespaceSymbol::Import(NamespaceSymbol* that, SymbolTable& symbolTable)
18 {
19 NamespaceSymbol* ns = symbolTable.BeginNamespace(that->Name(), that->GetSpan(), that->SourceModuleId());
20 symbolTable.MapNs(that, ns);
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(thatNs, symbolTable);
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 } }