summaryrefslogtreecommitdiff
path: root/iseq.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-04 07:07:49 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-04 07:07:49 +0000
commite743a35314275a8afce2ea57c21ca67df60f106b (patch)
treedb528b9d4296215785220eb2db0de22c5433cf00 /iseq.c
parent1e4be7a8527e0dff1c0172c53737f5d755149d21 (diff)
iseq.c: Refactor out rb_iseq_new_ifunc from rb_iseq_new_with_opt
It is too error-prone to pass IMEMO_IFUNC object as NODE*. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.c')
-rw-r--r--iseq.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/iseq.c b/iseq.c
index 70cacbff6b..9ffe709eea 100644
--- a/iseq.c
+++ b/iseq.c
@@ -519,11 +519,9 @@ rb_iseq_new_with_opt(const NODE *node, VALUE name, VALUE path, VALUE realpath,
{
/* TODO: argument check */
rb_iseq_t *iseq = iseq_alloc();
- const rb_code_range_t *code_range = NULL;
if (!option) option = &COMPILE_OPTION_DEFAULT;
- if (node && !imemo_type_p((VALUE)node, imemo_ifunc)) code_range = &node->nd_loc;
- prepare_iseq_build(iseq, name, path, realpath, first_lineno, code_range, parent, type, option);
+ prepare_iseq_build(iseq, name, path, realpath, first_lineno, node ? &node->nd_loc : NULL, parent, type, option);
rb_iseq_compile_node(iseq, node);
finish_iseq_build(iseq);
@@ -531,6 +529,23 @@ rb_iseq_new_with_opt(const NODE *node, VALUE name, VALUE path, VALUE realpath,
return iseq_translate(iseq);
}
+rb_iseq_t *
+rb_iseq_new_ifunc(const struct vm_ifunc *ifunc, VALUE name, VALUE path, VALUE realpath,
+ VALUE first_lineno, const rb_iseq_t *parent,
+ enum iseq_type type, const rb_compile_option_t *option)
+{
+ /* TODO: argument check */
+ rb_iseq_t *iseq = iseq_alloc();
+
+ if (!option) option = &COMPILE_OPTION_DEFAULT;
+ prepare_iseq_build(iseq, name, path, realpath, first_lineno, NULL, parent, type, option);
+
+ rb_iseq_compile_ifunc(iseq, ifunc);
+ finish_iseq_build(iseq);
+
+ return iseq_translate(iseq);
+}
+
const rb_iseq_t *
rb_iseq_load_iseq(VALUE fname)
{