49 lines
946 B
C++
49 lines
946 B
C++
#include <fxos/symbols.h>
|
|
|
|
namespace FxOS {
|
|
|
|
SymbolTable::SymbolTable(std::string os, std::string mpu):
|
|
m_os_constraint(os), m_mpu_constraint(mpu)
|
|
{
|
|
}
|
|
|
|
bool SymbolTable::is_usable_on(OS &os) const noexcept
|
|
{
|
|
std::string constraint = (os.type == OS::FX) ? "fx" : "cg";
|
|
return (m_os_constraint == "" || m_os_constraint == constraint);
|
|
}
|
|
|
|
bool SymbolTable::is_usable_on(Target &target) const noexcept
|
|
{
|
|
return m_mpu_constraint == "" || target.mpu == "" ||
|
|
m_mpu_constraint == target.mpu;
|
|
}
|
|
|
|
void SymbolTable::add(Symbol s)
|
|
{
|
|
symbols.push_back(s);
|
|
}
|
|
|
|
std::optional<std::string> SymbolTable::query(Symbol::Type type,
|
|
uint32_t value) const
|
|
{
|
|
for(auto &sym: symbols)
|
|
{
|
|
if(sym.type == type && sym.value == value) return sym.name;
|
|
}
|
|
|
|
return std::nullopt;
|
|
}
|
|
|
|
std::optional<Symbol> SymbolTable::lookup(std::string name) const
|
|
{
|
|
for(auto &sym: symbols)
|
|
{
|
|
if(sym.name == name) return sym;
|
|
}
|
|
|
|
return std::nullopt;
|
|
}
|
|
|
|
} /* namespace FxOS */
|