1
2
3
4
5
6 #ifndef CPP2CM_CPP2CM_MAP_INCLUDED
7 #define CPP2CM_CPP2CM_MAP_INCLUDED
8 #include <cpp2cm/cpp2cm/Context.hpp>
9 #include <sngcm/ast/Specifier.hpp>
10 #include <sngcm/ast/Node.hpp>
11 #include <sngcpp/ast/Specifier.hpp>
12 #include <sngcpp/symbols/SymbolTable.hpp>
13 #include <sngxml/dom/Document.hpp>
14 #include <string>
15 #include <unordered_map>
16
17 namespace cpp2cm {
18
19 std::u32string GetFullName(sngcm::ast::Node* node);
20 sngcm::ast::Node* MakeQualifiedIdNode(const std::u32string& fullName);
21
22 class Map
23 {
24 public:
25 Map();
26 void InitNameNodeTypeMap();
27 void InitSimpleTypeMap();
28 sngcm::ast::Node* CreateNode(const std::u32string& name);
29 sngcm::ast::Node* CreateNode(sngcm::ast::NodeType nodeType);
30 void MapNs(const std::u32string& source, const std::u32string& target);
31 std::u32string GetNs(const std::u32string& source) const;
32 void AddSourceXmlDoc(sngxml::dom::Document* sourceXmlDoc, const std::u32string& projectName);
33 void SetSymbolTable(sngcpp::symbols::SymbolTable* symbolTable_);
34 sngcm::ast::NodeType MapSimpleType(sngcpp::ast::SimpleTypeSpecifierFlags flags);
35 sngcm::ast::NodeType MapSimpleType(sngcpp::symbols::SimpleTypeSymbol* simpleTypeSymbol);
36 sngcm::ast::Node* MakeDerivedType(sngcm::ast::Node* node, const std::std::vector<sngcpp::symbols::Derivation>&derivations);
37 sngcm::ast::IdentifierNode* MapFullTypeName(sngcpp::symbols::TypeSymbol* type);
38 sngcm::ast::Node* MapType(sngcpp::symbols::TypeSymbol* type, sngxml::dom::Document*& sourceXmlDoc);
39 sngcm::ast::IdentifierNode* MapMemberSymbol(sngcpp::symbols::Symbol* memberSymbol, std::u32string& args);
40 sngcm::ast::IdentifierNode* MapFunctionSymbol(sngcpp::symbols::CallableSymbol* callableSymbol, std::u32string& args);
41 std::u32string RemoveNamespace(const std::u32string& qid);
42 void ClearNamespaceImports();
43 const std::std::set<std::u32string>&NamespaceImports() const{returnnamespaceImports;}
44 void SetCurrentContext(Context* context) { currentContext = context; }
45 void SetCurrentProjectName(const std::u32string& projectName) { currentProjectName = projectName; }
46 const std::u32string& CurrentProjectName() const { return currentProjectName; }
47 private:
48 std::unordered_map<std::u32string, std::u32string> nsMap;
49 std::vector<sngxml::dom::Document*> sourceXmlDocs;
50 sngcpp::symbols::SymbolTable* symbolTable;
51 std::unordered_map<std::u32string, sngxml::dom::Document*> projectSourceXmlDocMap;
52 std::unordered_map<std::u32string, sngcm::ast::NodeType> nameNodeTypeMap;
53 std::unordered_map<sngcpp::ast::SimpleTypeSpecifierFlags, sngcm::ast::NodeType> simpleTypeMap;
54 std::set<std::u32string> namespaceImports;
55 Context* currentContext;
56 std::u32string currentProjectName;
57 };
58
59 sngcm::ast::Specifiers MapSpecifiers(sngcpp::ast::Specifier specifiers);
60 sngcm::ast::Specifiers MapAccess(sngcpp::symbols::SymbolAccess access);
61
62 }
63
64 #endif // CPP2CM_CPP2CM_MAP_INCLUDED