diff --git a/src/base/loader/symtab.hh b/src/base/loader/symtab.hh index 45e55fcee7..654064c9db 100644 --- a/src/base/loader/symtab.hh +++ b/src/base/loader/symtab.hh @@ -176,6 +176,22 @@ class SymbolTable return filter(filt); } + /** + * Generate a new table by applying a filter that only accepts the symbols + * whose type matches the given symbol type. + * + * @param The type that must be matched. + * @return A new table, filtered by type. + */ + SymbolTablePtr + filterBySymbolType(const Symbol::SymbolType& symbol_type) const + { + auto filt = [symbol_type](const Symbol &symbol) { + return symbol.type == symbol_type; + }; + return filter(filt); + } + public: typedef SymbolVector::iterator iterator; typedef SymbolVector::const_iterator const_iterator; @@ -302,6 +318,17 @@ class SymbolTable return filterByBinding(Symbol::Binding::Weak); } + /** + * Generates a new symbol table containing only function symbols. + * + * @return The new table. + */ + SymbolTablePtr + functionSymbols() const + { + return filterBySymbolType(Symbol::SymbolType::Function); + } + /** * Serialize the table's contents. *