Program Listing for File JumpIfNot.hpp¶
↰ Return to documentation for file (include/sgpl/operations/flow_local/JumpIfNot.hpp)
#pragma once
#ifndef SGPL_OPERATIONS_FLOW_LOCAL_JUMPIFNOT_HPP_INCLUDE
#define SGPL_OPERATIONS_FLOW_LOCAL_JUMPIFNOT_HPP_INCLUDE
#include <map>
#include <set>
#include <string>
#include "../../../../third-party/conduit/include/uit_emp/tools/hash_namify.hpp"
#include "../../../../third-party/conduit/include/uit_emp/tools/string_utils.hpp"
#include "../../hardware/Core.hpp"
#include "../../program/Instruction.hpp"
#include "../../program/Program.hpp"
namespace sgpl {
namespace local {
struct JumpIfNot {
template<typename Spec>
static void run(
sgpl::Core<Spec>& core,
const sgpl::Instruction<Spec>& inst,
const sgpl::Program<Spec>&,
typename Spec::peripheral_t&
) noexcept {
if ( !core.registers[ inst.args[0] ] ) {
core.JumpToLocalAnchorMatch( inst.tag );
}
}
static std::string name() { return "Local Jump If Not"; }
static size_t prevalence() { return 1; }
template<typename Spec>
static auto descriptors( const sgpl::Instruction<Spec>& inst ) {
using tag_t = typename Spec::tag_t;
return std::map<std::string, std::string>{
{ "argument a", uit_emp::to_string( static_cast<int>( inst.args[0] ) ) },
{ "tag bits", uit_emp::to_string( inst.tag ) },
{ "tag moniker", uit_emp::hash_namify( std::hash< tag_t >{}( inst.tag ) ) },
{ "summary", "if !a, goto tag match local anchor" },
};
}
template<typename Spec>
static std::set<std::string> categories(const sgpl::Instruction<Spec>&) {
return {
"flow",
"local flow",
"intrinsic",
"op",
};
}
};
} // namespace local
} // namespace sgpl
#endif // #ifndef SGPL_OPERATIONS_FLOW_LOCAL_JUMPIFNOT_HPP_INCLUDE