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:
parent
bad77a862e
commit
97628bff12
2 changed files with 16 additions and 3 deletions
10
compile.c
10
compile.c
|
@ -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
9
iseq.c
|
@ -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));
|
||||||
|
|
Loading…
Reference in a new issue