Commit b644328b authored by phlo's avatar phlo

added static instruction type tests

parent e9eca300
......@@ -105,20 +105,32 @@ std::unique_ptr<Instruction::memory_factory_map> Instruction::memory_factory;
// static member functions
//------------------------------------------------------------------------------
// Instruction::contains -------------------------------------------------------
// Instruction::is_nullary -----------------------------------------------------
//
bool Instruction::contains (const std::string & symbol)
bool Instruction::is_nullary (const std::string & symbol)
{
if (nullary_factory->find(symbol) != nullary_factory->end())
return true;
return nullary_factory->find(symbol) != nullary_factory->end();
}
if (unary_factory->find(symbol) != unary_factory->end())
return true;
// Instruction::is_unary -------------------------------------------------------
//
bool Instruction::is_unary (const std::string & symbol)
{
return unary_factory->find(symbol) != unary_factory->end();
}
if (memory_factory->find(symbol) != memory_factory->end())
return true;
// Instruction::is_memory ------------------------------------------------------
//
bool Instruction::is_memory (const std::string & symbol)
{
return memory_factory->find(symbol) != memory_factory->end();
}
return false;
// Instruction::contains -------------------------------------------------------
//
bool Instruction::contains (const std::string & symbol)
{
return is_nullary(symbol) || is_unary(symbol) || is_memory(symbol);
}
// Instruction::add_nullary ----------------------------------------------------
......
......@@ -85,6 +85,10 @@ struct Instruction
// static member functions
//----------------------------------------------------------------------------
static bool is_nullary (const std::string & symbol);
static bool is_unary (const std::string & symbol);
static bool is_memory (const std::string & symbol);
static bool contains (const std::string & symbol);
template <class POD>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment