diff --git a/include/mruby/irep.h b/include/mruby/irep.h index 3fd3bdb4f..924e72260 100644 --- a/include/mruby/irep.h +++ b/include/mruby/irep.h @@ -27,7 +27,7 @@ enum irep_pool_type { #define IREP_TT_NFLAG 1 /* number (non string) flag */ #define IREP_TT_SFLAG 2 /* static string flag */ -typedef struct mrb_pool_value { +typedef struct mrb_irep_pool { uint32_t tt; /* packed type and length (for string) */ union { const char *str; @@ -37,7 +37,7 @@ typedef struct mrb_pool_value { mrb_float f; #endif } u; -} mrb_pool_value; +} mrb_irep_pool; enum mrb_catch_type { MRB_CATCH_RESCUE = 0, @@ -65,7 +65,7 @@ struct mrb_irep { * structure from bloating. The catch handler table can be obtained with * `mrb_irep_catch_handler_table(irep)`. */ - const mrb_pool_value *pool; + const mrb_irep_pool *pool; const mrb_sym *syms; const struct mrb_irep *const *reps; diff --git a/mrbgems/mruby-compiler/core/codegen.c b/mrbgems/mruby-compiler/core/codegen.c index a920ad216..fc4d5e466 100644 --- a/mrbgems/mruby-compiler/core/codegen.c +++ b/mrbgems/mruby-compiler/core/codegen.c @@ -70,7 +70,7 @@ typedef struct scope { uint32_t icapa; mrb_irep *irep; - mrb_pool_value *pool; + mrb_irep_pool *pool; mrb_sym *syms; mrb_irep **reps; struct mrb_irep_catch_handler *catch_table; @@ -126,9 +126,9 @@ codegen_error(codegen_scope *s, const char *message) if (s->irep) { mrb_free(s->mrb, s->iseq); for (int i=0; iirep->plen; i++) { - mrb_pool_value *pv = &s->pool[i]; - if ((pv->tt & 0x3) == IREP_TT_STR || pv->tt == IREP_TT_BIGINT) { - mrb_free(s->mrb, (void*)pv->u.str); + mrb_irep_pool *p = &s->pool[i]; + if ((p->tt & 0x3) == IREP_TT_STR || p->tt == IREP_TT_BIGINT) { + mrb_free(s->mrb, (void*)p->u.str); } } mrb_free(s->mrb, s->pool); @@ -776,14 +776,14 @@ get_int_operand(codegen_scope *s, struct mrb_insn_data *data, mrb_int *n) case OP_LOADL: { - mrb_pool_value *pv = &s->pool[data->b]; + mrb_irep_pool *p = &s->pool[data->b]; - if (pv->tt == IREP_TT_INT32) { - *n = (mrb_int)pv->u.i32; + if (p->tt == IREP_TT_INT32) { + *n = (mrb_int)p->u.i32; } #ifdef MRB_INT64 - else if (pv->tt == IREP_TT_INT64) { - *n = (mrb_int)pv->u.i64; + else if (p->tt == IREP_TT_INT64) { + *n = (mrb_int)p->u.i64; } #endif else { @@ -989,12 +989,12 @@ pop_n_(codegen_scope *s, int n) #define pop_n(n) pop_n_(s,n) #define cursp() (s->sp) -static mrb_pool_value* +static mrb_irep_pool* lit_pool_extend(codegen_scope *s) { if (s->irep->plen == s->pcapa) { s->pcapa *= 2; - s->pool = (mrb_pool_value*)codegen_realloc(s, s->pool, sizeof(mrb_pool_value)*s->pcapa); + s->pool = (mrb_irep_pool*)codegen_realloc(s, s->pool, sizeof(mrb_irep_pool)*s->pcapa); } return &s->pool[s->irep->plen++]; @@ -1005,7 +1005,7 @@ new_litbint(codegen_scope *s, const char *p, int base, mrb_bool neg) { int i; size_t plen; - mrb_pool_value *pv; + mrb_irep_pool *pv; plen = strlen(p); if (plen > 255) { @@ -1039,30 +1039,30 @@ static int new_lit_str(codegen_scope *s, const char *str, mrb_int len) { int i; - mrb_pool_value *pv; + mrb_irep_pool *pool; for (i=0; iirep->plen; i++) { - pv = &s->pool[i]; - if (pv->tt & IREP_TT_NFLAG) continue; - mrb_int plen = pv->tt>>2; + pool = &s->pool[i]; + if (pool->tt & IREP_TT_NFLAG) continue; + mrb_int plen = pool->tt>>2; if (len != plen) continue; - if (memcmp(pv->u.str, str, plen) == 0) + if (memcmp(pool->u.str, str, plen) == 0) return i; } - pv = lit_pool_extend(s); + pool = lit_pool_extend(s); if (mrb_ro_data_p(str)) { - pv->tt = (uint32_t)(len<<2) | IREP_TT_SSTR; - pv->u.str = str; + pool->tt = (uint32_t)(len<<2) | IREP_TT_SSTR; + pool->u.str = str; } else { char *p; - pv->tt = (uint32_t)(len<<2) | IREP_TT_STR; + pool->tt = (uint32_t)(len<<2) | IREP_TT_STR; p = (char*)codegen_realloc(s, NULL, len+1); memcpy(p, str, len); p[len] = '\0'; - pv->u.str = p; + pool->u.str = p; } return i; @@ -1078,29 +1078,29 @@ static int new_lit_int(codegen_scope *s, mrb_int num) { int i; - mrb_pool_value *pv; + mrb_irep_pool *pool; for (i=0; iirep->plen; i++) { - pv = &s->pool[i]; - if (pv->tt == IREP_TT_INT32) { - if (num == pv->u.i32) return i; + pool = &s->pool[i]; + if (pool->tt == IREP_TT_INT32) { + if (num == pool->u.i32) return i; } #ifdef MRB_64BIT - else if (pv->tt == IREP_TT_INT64) { - if (num == pv->u.i64) return i; + else if (pool->tt == IREP_TT_INT64) { + if (num == pool->u.i64) return i; } continue; #endif } - pv = lit_pool_extend(s); + pool = lit_pool_extend(s); #ifdef MRB_INT64 - pv->tt = IREP_TT_INT64; - pv->u.i64 = num; + pool->tt = IREP_TT_INT64; + pool->u.i64 = num; #else - pv->tt = IREP_TT_INT32; - pv->u.i32 = num; + pool->tt = IREP_TT_INT32; + pool->u.i32 = num; #endif return i; @@ -1111,20 +1111,20 @@ static int new_lit_float(codegen_scope *s, mrb_float num) { int i; - mrb_pool_value *pv; + mrb_irep_pool *pool; for (i=0; iirep->plen; i++) { mrb_float f; - pv = &s->pool[i]; - if (pv->tt != IREP_TT_FLOAT) continue; - f = pv->u.f; + pool = &s->pool[i]; + if (pool->tt != IREP_TT_FLOAT) continue; + f = pool->u.f; if (f == num && !signbit(f) == !signbit(num)) return i; } - pv = lit_pool_extend(s); + pool = lit_pool_extend(s); - pv->tt = IREP_TT_FLOAT; - pv->u.f = num; + pool->tt = IREP_TT_FLOAT; + pool->u.f = num; return i; } @@ -3862,7 +3862,7 @@ scope_new(mrb_state *mrb, codegen_scope *prev, node *nlv) s->iseq = (mrb_code*)mrb_malloc(mrb, sizeof(mrb_code)*s->icapa); s->pcapa = 32; - s->pool = (mrb_pool_value*)mrb_malloc(mrb, sizeof(mrb_pool_value)*s->pcapa); + s->pool = (mrb_irep_pool*)mrb_malloc(mrb, sizeof(mrb_irep_pool)*s->pcapa); s->scapa = 256; s->syms = (mrb_sym*)mrb_malloc(mrb, sizeof(mrb_sym)*s->scapa); @@ -3928,7 +3928,7 @@ scope_finish(codegen_scope *s) } mrb_free(s->mrb, s->catch_table); s->catch_table = NULL; - irep->pool = (const mrb_pool_value*)codegen_realloc(s, s->pool, sizeof(mrb_pool_value)*irep->plen); + irep->pool = (const mrb_irep_pool*)codegen_realloc(s, s->pool, sizeof(mrb_irep_pool)*irep->plen); irep->syms = (const mrb_sym*)codegen_realloc(s, s->syms, sizeof(mrb_sym)*irep->slen); irep->reps = (const mrb_irep**)codegen_realloc(s, s->reps, sizeof(mrb_irep*)*irep->rlen); if (s->filename_sym) { diff --git a/mrbgems/mruby-os-memsize/src/memsize.c b/mrbgems/mruby-os-memsize/src/memsize.c index 1347211a8..61ae10370 100644 --- a/mrbgems/mruby-os-memsize/src/memsize.c +++ b/mrbgems/mruby-os-memsize/src/memsize.c @@ -17,12 +17,12 @@ static size_t os_memsize_of_irep(mrb_state* state, const struct mrb_irep *irep) { size_t size = (irep->slen * sizeof(mrb_sym)) + - (irep->plen * sizeof(mrb_pool_value)) + + (irep->plen * sizeof(mrb_irep_pool)) + (irep->ilen * sizeof(mrb_code)) + (irep->rlen * sizeof(struct mrb_irep*)); for (int i = 0; i < irep->plen; i++) { - const mrb_pool_value *p = &irep->pool[i]; + const mrb_irep_pool *p = &irep->pool[i]; if ((p->tt & IREP_TT_NFLAG) == 0) { /* string pool value */ size += (p->tt>>2); } diff --git a/src/cdump.c b/src/cdump.c index 9d3795ce9..fcb9e75aa 100644 --- a/src/cdump.c +++ b/src/cdump.c @@ -21,7 +21,7 @@ #endif static int -cdump_pool(mrb_state *mrb, const mrb_pool_value *p, FILE *fp) +cdump_pool(mrb_state *mrb, const mrb_irep_pool *p, FILE *fp) { if (p->tt & IREP_TT_NFLAG) { /* number */ switch (p->tt) { @@ -352,7 +352,7 @@ cdump_irep_struct(mrb_state *mrb, const mrb_irep *irep, uint8_t flags, FILE *fp, /* dump pool */ if (irep->pool) { len=irep->plen; - fprintf(fp, "static const mrb_pool_value %s_pool_%d[%d] = {\n", name, n, len); + fprintf(fp, "static const mrb_irep_pool %s_pool_%d[%d] = {\n", name, n, len); for (i=0; ipool[i], fp) != MRB_DUMP_OK) return MRB_DUMP_INVALID_ARGUMENT; diff --git a/src/load.c b/src/load.c index 3008a4cd1..cd30f020d 100644 --- a/src/load.c +++ b/src/load.c @@ -67,7 +67,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, const uint8_t *end, size_ ptrdiff_t diff; uint16_t tt, pool_data_len, snl; int plen; - mrb_pool_value *pool; + mrb_irep_pool *pool; mrb_sym *syms; int ai = mrb_gc_arena_save(mrb); mrb_irep *irep = mrb_add_irep(mrb); @@ -124,7 +124,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, const uint8_t *end, size_ if (SIZE_ERROR_MUL(plen, sizeof(mrb_value))) { return FALSE; } - irep->pool = pool = (mrb_pool_value*)mrb_calloc(mrb, sizeof(mrb_pool_value), plen); + irep->pool = pool = (mrb_irep_pool*)mrb_calloc(mrb, sizeof(mrb_irep_pool), plen); for (i = 0; i < plen; i++) { mrb_bool st = (flags & FLAG_SRC_MALLOC)==0;