1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

compile.c: wrap funcptr

* compile.c (iseq_build_from_ary_body): enclose funcptr with
  Integer as raw pointer cannot appear in an Array.

* iseq.c (iseq_data_to_ary): extract funcptr from Integer.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-12-16 05:54:32 +00:00
parent bad77a862e
commit 97628bff12
2 changed files with 16 additions and 3 deletions

View file

@ -5964,8 +5964,14 @@ iseq_build_from_ary_body(rb_iseq_t *iseq, LINK_ANCHOR *anchor,
} }
break; break;
case TS_FUNCPTR: case TS_FUNCPTR:
if (!RTEST(op)) rb_raise(rb_eArgError, "cannot load funcptr"); {
argv[j] = op; #if SIZEOF_VALUE <= SIZEOF_LONG
long funcptr = NUM2LONG(op);
#else
LONG_LONG funcptr = NUM2LL(op);
#endif
argv[j] = (VALUE)funcptr;
}
break; break;
default: default:
rb_raise(rb_eSyntaxError, "unknown operand: %c", insn_op_type((VALUE)insn_id, j)); rb_raise(rb_eSyntaxError, "unknown operand: %c", insn_op_type((VALUE)insn_id, j));

9
iseq.c
View file

@ -1987,7 +1987,14 @@ iseq_data_to_ary(rb_iseq_t *iseq)
} }
break; break;
case TS_FUNCPTR: case TS_FUNCPTR:
rb_ary_push(ary, Qnil); {
#if SIZEOF_VALUE <= SIZEOF_LONG
VALUE val = LONG2NUM((SIGNED_VALUE)*seq);
#else
VALUE val = LL2NUM((SIGNED_VALUE)*seq);
#endif
rb_ary_push(ary, val);
}
break; break;
default: default:
rb_bug("unknown operand: %c", insn_op_type(insn, j)); rb_bug("unknown operand: %c", insn_op_type(insn, j));