mrb format should be portable among configurations (e.g. MRB_NAN_BOXING)

parent d73dfa87
...@@ -118,21 +118,22 @@ write_pool_block(mrb_state *mrb, mrb_irep *irep, uint8_t *buf) ...@@ -118,21 +118,22 @@ write_pool_block(mrb_state *mrb, mrb_irep *irep, uint8_t *buf)
for (pool_no = 0; pool_no < irep->plen; pool_no++) { for (pool_no = 0; pool_no < irep->plen; pool_no++) {
int ai = mrb_gc_arena_save(mrb); int ai = mrb_gc_arena_save(mrb);
cur += uint8_to_bin(mrb_type(irep->pool[pool_no]), cur); /* data type */
switch (mrb_type(irep->pool[pool_no])) { switch (mrb_type(irep->pool[pool_no])) {
case MRB_TT_FIXNUM: case MRB_TT_FIXNUM:
cur += uint8_to_bin(IREP_TT_FIXNUM, cur); /* data type */
str = mrb_fixnum_to_str(mrb, irep->pool[pool_no], 10); str = mrb_fixnum_to_str(mrb, irep->pool[pool_no], 10);
char_ptr = RSTRING_PTR(str); char_ptr = RSTRING_PTR(str);
len = RSTRING_LEN(str); len = RSTRING_LEN(str);
break; break;
case MRB_TT_FLOAT: case MRB_TT_FLOAT:
cur += uint8_to_bin(IREP_TT_FLOAT, cur); /* data type */
len = mrb_float_to_str(char_buf, mrb_float(irep->pool[pool_no])); len = mrb_float_to_str(char_buf, mrb_float(irep->pool[pool_no]));
char_ptr = &char_buf[0]; char_ptr = &char_buf[0];
break; break;
case MRB_TT_STRING: case MRB_TT_STRING:
cur += uint8_to_bin(IREP_TT_STRING, cur); /* data type */
char_ptr = RSTRING_PTR(irep->pool[pool_no]); char_ptr = RSTRING_PTR(irep->pool[pool_no]);
len = RSTRING_LEN(irep->pool[pool_no]); len = RSTRING_LEN(irep->pool[pool_no]);
break; break;
......
...@@ -101,15 +101,15 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, uint32_t *len) ...@@ -101,15 +101,15 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, uint32_t *len)
s = mrb_str_new(mrb, (char *)src, pool_data_len); s = mrb_str_new(mrb, (char *)src, pool_data_len);
src += pool_data_len; src += pool_data_len;
switch (tt) { //pool data switch (tt) { //pool data
case MRB_TT_FIXNUM: case IREP_TT_FIXNUM:
irep->pool[i] = mrb_str_to_inum(mrb, s, 10, FALSE); irep->pool[i] = mrb_str_to_inum(mrb, s, 10, FALSE);
break; break;
case MRB_TT_FLOAT: case IREP_TT_FLOAT:
irep->pool[i] = mrb_float_value(mrb, mrb_str_to_dbl(mrb, s, FALSE)); irep->pool[i] = mrb_float_value(mrb, mrb_str_to_dbl(mrb, s, FALSE));
break; break;
case MRB_TT_STRING: case IREP_TT_STRING:
irep->pool[i] = mrb_str_dup_static(mrb, s); irep->pool[i] = mrb_str_dup_static(mrb, s);
break; break;
......
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