base: Add ability to generate SymbolTable by filtering SymbolType
This allows filtering out non function symbols. Change-Id: I518c2842a6f04c4475240126ad64070a6de09df9 Signed-off-by: Hoa Nguyen <hn@hnpl.org>
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user