4#include <unordered_map>
82 RuleSet(
const std::string&
name =
"",
const std::vector<Rule>&
rules = std::vector<Rule>(),
const Program& termination_cond =
Program{
"never terminate", {}},
128 std::unordered_map<
QNodeAddr, std::vector<RuleId>>& partner_rules);
The Program is a list of Instructions with metadata. The Runtime can execute the Program.
Definition RuleSet.h:17
Program(const std::string &name, const std::vector< InstructionTypes > &opcodes, bool debugging=false)
Definition RuleSet.cc:11
bool debugging
if it's true, show instruction and runtime state in each step.
Definition RuleSet.h:34
LabelMap label_map
the map to find instruction index (pc) by label.
Definition RuleSet.h:28
std::string name
the Program name for debugging purpose.
Definition RuleSet.h:31
std::vector< InstructionTypes > opcodes
Definition RuleSet.h:21
The Runtime executable Rule in a RuleSet.
Definition RuleSet.h:40
Rule(const Program &condition, const Program &action, bool debugging=false)
Definition RuleSet.h:42
int send_tag
the shared tag for identify a rule across QNodes in a connection.
Definition RuleSet.h:53
Program action
The action for the Rule in the RuleSet.
Definition RuleSet.h:66
Rule(const std::string &name, int send_tag, int receive_tag, const Program &condition, const Program &action, bool debugging=false)
Definition RuleSet.h:43
int receive_tag
Definition RuleSet.h:54
std::string name
the RuleSet name for debugging
Definition RuleSet.h:47
bool debugging
if it's true, the Runtime shows debug info in each step.
Definition RuleSet.h:69
Program condition
The condition for the Rule. The Runtime executes the following. action if this condition passed....
Definition RuleSet.h:63
The RuleSet.
Definition RuleSet.h:80
std::unordered_map< std::pair< QNodeAddr, RuleId >, RuleId > next_rule_table
contains the next rule ids corresponding to the current partner and rule id like: (partner_addr,...
Definition RuleSet.h:104
Program termination_condition
the Program to check the RuleSet is terminated or not.
Definition RuleSet.h:119
bool debugging
Definition RuleSet.h:120
unsigned long id
the RuleSet id
Definition RuleSet.h:107
RuleSet(const std::string &name="", const std::vector< Rule > &rules=std::vector< Rule >(), const Program &termination_cond=Program{"never terminate", {}}, bool debugging=false)
Definition RuleSet.h:82
std::string name
the RuleSet name for debugging.
Definition RuleSet.h:113
void finalize()
analyzes its rules and instructions to collect informations for execution.
Definition RuleSet.cc:22
static void collectPartners(const RuleId rule_id, const InstructionTypes &instr, std::set< QNodeAddr > &partners, std::unordered_map< QNodeAddr, std::vector< RuleId > > &partner_rules)
an internal method to traverse the given Rule's whole Program to collect their partners.
Definition RuleSet.cc:54
std::set< QNodeAddr > partners
the partner(connection participating nodes) QNodeAddrs used in this RuleSet.
Definition RuleSet.h:90
std::unordered_map< QNodeAddr, RuleId > partner_initial_rule_table
This contains a list of pairs of the rule_id and partner's QNodeAddr.
Definition RuleSet.h:98
std::vector< Rule > rules
the Rules in this RuleSet. Each Rule has Condition and Action.
Definition RuleSet.h:116
int owner_addr
the owner's QNode address.
Definition RuleSet.h:110
Definition InstructionVisitor.cc:7
std::variant< #define INSTR(Opcode,...) #define INSTR_LAST(Opcode,...) # 1 "/github/workspace/quisp/runtime/def_instructions.h" 1 # 87 "/github/workspace/quisp/runtime/opcode.h" 2 > InstructionTypes
a variant that is capable of storing all instructions
Definition opcode.h:84
int RuleId
Definition types.h:18
std::unordered_map< Label, int > LabelMap
utility type for storing a label and corresponding instruction index.
Definition types.h:113
this file contains the definitions of all the user-defined types widely used alongside the runtime::R...
internal class to describe QNode's address.
Definition types.h:70