Clarify the use of `MRB_64BIT` and `MRB_INT64` in `dump.c` and `load.c`.

- `MRB_64BIT`: the size of a pointer is 64 bits
- `MRB_INT64`: the size of `mrb_int` is 64 bits
parent f0c11269
......@@ -32,7 +32,7 @@ typedef struct mrb_pool_value {
union {
const char *str;
int32_t i32;
#ifdef MRB_INT64
#ifdef MRB_64BIT
int64_t i64;
#endif
mrb_float f;
......
......@@ -588,7 +588,7 @@ new_lit(codegen_scope *s, mrb_value val)
if (pv->tt == IREP_TT_INT32) {
if (v == pv->u.i32) return i;
}
#ifdef MRB_INT64
#ifdef MRB_64BIT
else if (pv->tt == IREP_TT_INT64) {
if (v == pv->u.i64) return i;
}
......
......@@ -122,7 +122,7 @@ codedump(mrb_state *mrb, const mrb_irep *irep)
case IREP_TT_INT32:
printf("OP_LOADL\tR%d\tL(%d)\t; %" PRId32, a, b, irep->pool[b].u.i32);
break;
#ifdef MRB_INT64
#ifdef MRB_64BIT
case IREP_TT_INT64:
printf("OP_LOADL\tR%d\tL(%d)\t; %" PRId64, a, b, irep->pool[b].u.i64);
break;
......
......@@ -113,7 +113,7 @@ get_pool_block_size(mrb_state *mrb, const mrb_irep *irep)
switch (irep->pool[pool_no].tt) {
case IREP_TT_INT64:
#ifdef MRB_INT64
#ifdef MRB_64BIT
{
int64_t i = irep->pool[pool_no].u.i64;
......@@ -169,7 +169,7 @@ write_pool_block(mrb_state *mrb, const mrb_irep *irep, uint8_t *buf)
int ai = mrb_gc_arena_save(mrb);
switch (irep->pool[pool_no].tt) {
#ifdef MRB_INT64
#ifdef MRB_64BIT
case IREP_TT_INT64:
{
int64_t i = irep->pool[pool_no].u.i64;
......@@ -938,7 +938,7 @@ dump_pool(mrb_state *mrb, const mrb_pool_value *p, FILE *fp)
case IREP_TT_INT32:
fprintf(fp, "{IREP_TT_INT32, {.i32=%"PRId32"}},\n", p->u.i32);
break;
#ifdef MRB_INT64
#ifdef MRB_64BIT
case IREP_TT_INT64:
fprintf(fp, "{IREP_TT_INT64, {.i64=%"PRId64"}},\n", p->u.i64);
break;
......
......@@ -137,7 +137,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag
{
mrb_int v = (int32_t)bin_to_uint32(src);
src += sizeof(uint32_t);
#ifdef MRB_INT64
#ifdef MRB_64BIT
pool[i].tt = IREP_TT_INT64;
pool[i].u.i64 = (int64_t)v;
#else
......@@ -147,7 +147,7 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag
}
break;
case IREP_TT_INT64:
#ifdef MRB_INT64
#ifdef MRB_64BIT
{
uint64_t i = bin_to_uint32(src);
src += sizeof(uint32_t);
......@@ -156,10 +156,10 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag
src += sizeof(uint32_t);
pool[i].u.i64 = (int64_t)i;
}
break;
#else
return NULL; /* INT64 not supported on MRB_INT32 */
return NULL; /* INT64 not supported on MRB_32BIT */
#endif
break;
case IREP_TT_FLOAT:
#ifndef MRB_WITHOUT_FLOAT
......
......@@ -1017,10 +1017,16 @@ RETRY_TRY_BLOCK:
case IREP_TT_INT32:
regs[a] = mrb_fixnum_value((mrb_int)pool[b].u.i32);
break;
#ifdef MRB_INT64
case IREP_TT_INT64:
#if defined(MRB_INT64) && defined(MRB_64BIT)
regs[a] = mrb_fixnum_value((mrb_int)pool[b].u.i64);
break;
#else
{
mrb_value exc = mrb_exc_new_str_lit(mrb, E_RUNTIME_ERROR, "integer overflow");
mrb_exc_set(mrb, exc);
}
goto L_RAISE;
#endif
#ifndef MRB_WITHOUT_FLOAT
case IREP_TT_FLOAT:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment