mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mrb format should be portable among configurations (e.g. MRB_NAN_BOXING)
This commit is contained in:
+3
-2
@@ -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++) {
|
||||
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])) {
|
||||
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);
|
||||
char_ptr = RSTRING_PTR(str);
|
||||
len = RSTRING_LEN(str);
|
||||
break;
|
||||
|
||||
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]));
|
||||
char_ptr = &char_buf[0];
|
||||
break;
|
||||
|
||||
case MRB_TT_STRING:
|
||||
cur += uint8_to_bin(IREP_TT_STRING, cur); /* data type */
|
||||
char_ptr = RSTRING_PTR(irep->pool[pool_no]);
|
||||
len = RSTRING_LEN(irep->pool[pool_no]);
|
||||
break;
|
||||
|
||||
+3
-3
@@ -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);
|
||||
src += pool_data_len;
|
||||
switch (tt) { //pool data
|
||||
case MRB_TT_FIXNUM:
|
||||
case IREP_TT_FIXNUM:
|
||||
irep->pool[i] = mrb_str_to_inum(mrb, s, 10, FALSE);
|
||||
break;
|
||||
|
||||
case MRB_TT_FLOAT:
|
||||
case IREP_TT_FLOAT:
|
||||
irep->pool[i] = mrb_float_value(mrb, mrb_str_to_dbl(mrb, s, FALSE));
|
||||
break;
|
||||
|
||||
case MRB_TT_STRING:
|
||||
case IREP_TT_STRING:
|
||||
irep->pool[i] = mrb_str_dup_static(mrb, s);
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user