<commit_before>#include "example_common.h"
#include "iroha/iroha.h"

using namespace iroha;

IModule *create_module(IDesign *design, const string &name) {
  IModule *mod = new IModule(design, name);
  ITable *table = new ITable(mod);
  mod->tables_.push_back(table);
  IState *st1 = new IState(table);
  table->states_.push_back(st1);
  table->SetInitialState(st1);
  return mod;
}

IModule *create_sub_module(IDesign *design) {
  IModule *mod = create_module(design, "M_sub");
  ITable *tab = mod->tables_[0];
  IResource *r = DesignTool::GetResource(tab, resource::kChannelRead);
  design->channels_[0]->SetReader(r);
  IInsn *insn = new IInsn(r);
  IState *st1 = tab->states_[0];
  st1->insns_.push_back(insn);
  // Write to external.
  IResource *ext_write = DesignTool::GetResource(tab, resource::kChannelWrite);
  design->channels_[1]->SetWriter(ext_write);
  IInsn *write_insn = new IInsn(ext_write);
  st1->insns_.push_back(write_insn);
  return mod;
}

IModule *create_root_module(IModule *sub_module) {
  IModule *mod = create_module(sub_module->GetDesign(), "M_top");
  ITable *tab = mod->tables_[0];
  IResource *w = DesignTool::GetResource(tab, resource::kChannelWrite);
  sub_module->GetDesign()->channels_[0]->SetWriter(w);
  IInsn *insn = new IInsn(w);
  IState *st1 = tab->states_[0];
  st1->insns_.push_back(insn);
  return mod;<commit_msg>Add read/write params to channel example.<commit_after>#include "example_common.h"
#include "iroha/iroha.h"

using namespace iroha;

IModule *create_module(IDesign *design, const string &name) {
  IModule *mod = new IModule(design, name);
  ITable *table = new ITable(mod);
  mod->tables_.push_back(table);
  IState *st1 = new IState(table);
  table->states_.push_back(st1);
  table->SetInitialState(st1);
  return mod;
}

IModule *create_sub_module(IDesign *design) {
  IModule *mod = create_module(design, "M_sub");
  ITable *tab = mod->tables_[0];
  IResource *r = DesignTool::GetResource(tab, resource::kChannelRead);
  design->channels_[0]->SetReader(r);
  IInsn *read_insn = new IInsn(r);
  IState *st1 = tab->states_[0];
  IRegister *reg = DesignTool::AllocRegister(tab, "tmp_reg", 32);
  read_insn->outputs_.push_back(reg);
  st1->insns_.push_back(read_insn);
  // Write to external.
  IResource *ext_write = DesignTool::GetResource(tab, resource::kChannelWrite);
  design->channels_[1]->SetWriter(ext_write);
  IInsn *write_insn = new IInsn(ext_write);
  write_insn->inputs_.push_back(reg);
  st1->insns_.push_back(write_insn);
  return mod;
}

IModule *create_root_module(IModule *sub_module) {
  IModule *mod = create_module(sub_module->GetDesign(), "M_top");
  ITable *tab = mod->tables_[0];
  IResource *w = DesignTool::GetResource(tab, resource::kChannelWrite);
  sub_module->GetDesign()->channels_[0]->SetWriter(w);
  IInsn *insn = new IInsn(w);
  IRegister *write_data = DesignTool::AllocConstNum(tab, 32, 123);
  insn->inputs_.push_back(write_data);
  IState *st1 = tab->states_[0];
  st1->insns_.push_back(insn);
  return mod;
{'fraction_non_alphanumeric': 0.1552298467688208, 'fraction_numerical': 0.012325116588940706, 'mean_word_length': 5.748314606741573, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 42, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '470266', 'n_tokens_mistral': 1102, 'n_tokens_neox': 1123, 'n_words': 205}