static size_t write_lineno_record(mrb_state *mrb, mrb_irep *irep, uint8_t* bin) { size_t i; size_t rlen, size = 0; rlen = write_lineno_record_1(mrb, irep, bin); bin += rlen; size += rlen; for (i=0; i<irep->rlen; i++) { rlen = write_lineno_record(mrb, irep, bin); bin += rlen; size += rlen; } return size; }
static int write_section_lineno(mrb_state *mrb, mrb_irep *irep, uint8_t *bin) { uint32_t section_size = 0, rlen = 0; /* size of irep record */ uint8_t *cur = bin; if (mrb == NULL || bin == NULL) { return MRB_DUMP_INVALID_ARGUMENT; } cur += sizeof(struct rite_section_lineno_header); section_size += sizeof(struct rite_section_lineno_header); rlen = write_lineno_record(mrb, irep, cur); cur += rlen; section_size += rlen; write_section_lineno_header(mrb, section_size, bin); return MRB_DUMP_OK; }
static int mrb_write_section_lineno(mrb_state *mrb, int start_index, uint8_t *bin) { int irep_no; uint32_t section_size = 0, rlen = 0; /* size of irep record */ uint8_t *cur = bin; if (mrb == NULL || start_index < 0 || start_index >= mrb->irep_len || bin == NULL) { return MRB_DUMP_INVALID_ARGUMENT; } cur += sizeof(struct rite_section_lineno_header); section_size += sizeof(struct rite_section_lineno_header); for (irep_no = start_index; irep_no < mrb->irep_len; irep_no++) { rlen = write_lineno_record(mrb, mrb->irep[irep_no], cur); cur += rlen; section_size += rlen; } mrb_write_section_lineno_header(mrb, section_size, mrb->irep_len - start_index, start_index, bin); return MRB_DUMP_OK; }