Skip to content

Commit

Permalink
New gcc dislikes partial template specialization inside classes
Browse files Browse the repository at this point in the history
  • Loading branch information
aardappel committed Jun 17, 2023
1 parent b74f00c commit c76dc22
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
47 changes: 23 additions & 24 deletions dev/src/lobster/idents.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,30 @@ struct Function : Named {
}
};

inline string TypeName(TypeRef type, int flen = 0);
template<typename T> void Unregister(const T *x, unordered_map<string_view, T *> &dict) {
auto it = dict.find(x->name);
if (it != dict.end()) dict.erase(it);
}

template<typename T> void ErasePrivate(unordered_map<string_view, T *> &dict) {
auto it = dict.begin();
while (it != dict.end()) {
auto n = it->second;
it++;
if (n->isprivate) Unregister(n, dict);
}
}

template<> void ErasePrivate(unordered_map<string_view, UDT *> &dict) {
auto it = dict.begin();
while (it != dict.end()) {
auto n = it->second;
it++;
if (n->g.isprivate) Unregister(n, dict);
}
}

inline string TypeName(TypeRef type, int flen = 0);

struct SymbolTable {
Lex &lex;
Expand Down Expand Up @@ -764,29 +786,6 @@ struct SymbolTable {
}
}

template<typename T> void Unregister(const T *x, unordered_map<string_view, T *> &dict) {
auto it = dict.find(x->name);
if (it != dict.end()) dict.erase(it);
}

template<typename T> void ErasePrivate(unordered_map<string_view, T *> &dict) {
auto it = dict.begin();
while (it != dict.end()) {
auto n = it->second;
it++;
if (n->isprivate) Unregister(n, dict);
}
}

template<> void ErasePrivate(unordered_map<string_view, UDT *> &dict) {
auto it = dict.begin();
while (it != dict.end()) {
auto n = it->second;
it++;
if (n->g.isprivate) Unregister(n, dict);
}
}

void StartOfInclude() {
namespace_stack.push_back(current_namespace);
current_namespace = {};
Expand Down
6 changes: 3 additions & 3 deletions dev/src/lobster/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ struct Parser {
// See also Block::TypeCheck
for (auto def : list->children) {
if (auto er = Is<EnumRef>(def)) {
st.Unregister(er->e, st.enums);
Unregister(er->e, st.enums);
} else if (auto sr = Is<GUDTRef>(def)) {
if (sr->gudt->predeclaration)
Error("pre-declared struct ", Q(sr->gudt->name), " never defined");
st.Unregister(sr->gudt, st.gudts);
Unregister(sr->gudt, st.gudts);
} else if (auto sr = Is<UDTRef>(def)) {
st.Unregister(sr->udt, st.udts);
Unregister(sr->udt, st.udts);
} else if (auto fr = Is<FunRef>(def)) {
auto f = fr->sf->parent;
if (!f->anonymous) st.Unregister(f);
Expand Down

0 comments on commit c76dc22

Please sign in to comment.