mirror of
https://github.com/verilator/verilator.git
synced 2025-04-30 04:26:55 +00:00
Internals: Make V3LanguageWords a singleton.
This commit is contained in:
parent
b3eab9d78a
commit
d1ee6689c4
@ -30,25 +30,29 @@
|
||||
|
||||
class V3LanguageWords {
|
||||
// List of common reserved keywords
|
||||
|
||||
private:
|
||||
typedef std::map<string,string> KeywordMap;
|
||||
KeywordMap m_kwdMap; // List of keywords, and what language applies
|
||||
|
||||
struct Singleton {
|
||||
KeywordMap s_kwdMap; // List of keywords, and what language applies
|
||||
Singleton() { init(); }
|
||||
void addKwd(const string& kwd, const string& why) {
|
||||
m_kwdMap.insert(make_pair(kwd, why));
|
||||
s_kwdMap.insert(make_pair(kwd, why));
|
||||
}
|
||||
void init();
|
||||
};
|
||||
public:
|
||||
string isKeyword(const string& kwd) {
|
||||
KeywordMap::iterator it = m_kwdMap.find(kwd);
|
||||
if (it == m_kwdMap.end()) return "";
|
||||
// METHODS
|
||||
static string isKeyword(const string& kwd) {
|
||||
KeywordMap::iterator it = s().s_kwdMap.find(kwd);
|
||||
if (it == s().s_kwdMap.end()) return "";
|
||||
return it->second;
|
||||
}
|
||||
private:
|
||||
static Singleton& s() { static Singleton s_s; return s_s; }
|
||||
};
|
||||
|
||||
public:
|
||||
V3LanguageWords() {
|
||||
inline void V3LanguageWords::Singleton::init() {
|
||||
// C++ keywords
|
||||
// C++
|
||||
addKwd("NULL", "C++ common word");
|
||||
addKwd("abort", "C++ common word");
|
||||
addKwd("alignas", "C++11 keyword");
|
||||
@ -184,6 +188,5 @@ class V3LanguageWords {
|
||||
addKwd("sensitive_neg", "SystemC common word");
|
||||
addKwd("sensitive_pos", "SystemC common word");
|
||||
}
|
||||
};
|
||||
|
||||
#endif // Guard
|
||||
|
Loading…
Reference in New Issue
Block a user