зеркало из https://github.com/github/ruby.git
[PRISM] Use Prism for `eval` if enabled
This commit is contained in:
Родитель
068b19bd53
Коммит
fd3f776a05
8
iseq.c
8
iseq.c
|
@ -925,6 +925,14 @@ rb_iseq_new_eval(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE realpat
|
|||
parent, isolated_depth, ISEQ_TYPE_EVAL, &COMPILE_OPTION_DEFAULT);
|
||||
}
|
||||
|
||||
rb_iseq_t *
|
||||
pm_iseq_new_eval(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath,
|
||||
int first_lineno, const rb_iseq_t *parent, int isolated_depth)
|
||||
{
|
||||
return pm_iseq_new_with_opt(node, name, path, realpath, first_lineno,
|
||||
parent, isolated_depth, ISEQ_TYPE_EVAL, &COMPILE_OPTION_DEFAULT);
|
||||
}
|
||||
|
||||
static inline rb_iseq_t *
|
||||
iseq_translate(rb_iseq_t *iseq)
|
||||
{
|
||||
|
|
31
vm_eval.c
31
vm_eval.c
|
@ -1642,10 +1642,41 @@ get_eval_default_path(void)
|
|||
return eval_default_path;
|
||||
}
|
||||
|
||||
static const rb_iseq_t *
|
||||
pm_eval_make_iseq(VALUE src, VALUE fname, int line,
|
||||
const struct rb_block *base_block)
|
||||
{
|
||||
rb_iseq_t *iseq = NULL;
|
||||
const rb_iseq_t *const parent = vm_block_iseq(base_block);
|
||||
const rb_iseq_t *iseq = parent;
|
||||
VALUE name = rb_fstring_lit("<compiled>");
|
||||
fname = rb_fstring_lit("<compiled>");
|
||||
|
||||
pm_parse_result_t result = { 0 };
|
||||
VALUE error;
|
||||
|
||||
|
||||
error = pm_parse_string(&result, src, fname);
|
||||
|
||||
if (error == Qnil) {
|
||||
iseq = pm_iseq_new_eval(&result.node, name, fname, fname, ln, parent, 0);
|
||||
pm_parse_result_free(&result);
|
||||
}
|
||||
else {
|
||||
pm_parse_result_free(&result);
|
||||
rb_exc_raise(error);
|
||||
}
|
||||
|
||||
return iseq;
|
||||
}
|
||||
|
||||
static const rb_iseq_t *
|
||||
eval_make_iseq(VALUE src, VALUE fname, int line,
|
||||
const struct rb_block *base_block)
|
||||
{
|
||||
if (*rb_ruby_prism_ptr()) {
|
||||
return pm_eval_make_iseq(src, fname, line, base_block);
|
||||
}
|
||||
const VALUE parser = rb_parser_new();
|
||||
const rb_iseq_t *const parent = vm_block_iseq(base_block);
|
||||
rb_iseq_t *iseq = NULL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче