From 0c68198cc49431c683ffb9915e67cd05f625553a Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 27 Sep 2015 06:44:02 +0000 Subject: fronzen-string-literal pragma * compile.c (iseq_compile_each): override compile option by option given by pragma. * iseq.c (rb_iseq_make_compile_option): extract a function to overwrite rb_compile_option_t. * parse.y (parser_set_compile_option_flag): introduce pragma to override compile options. * parse.y (magic_comments): new pragma "fronzen-string-literal". [Feature #8976] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51953 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- compile.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compile.c') diff --git a/compile.c b/compile.c index 9f9fcb66d8..9928aaa44c 100644 --- a/compile.c +++ b/compile.c @@ -5588,8 +5588,15 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) break; } case NODE_PRELUDE:{ + const rb_compile_option_t *orig_opt = iseq->compile_data->option; + if (node->nd_orig) { + rb_compile_option_t new_opt = *orig_opt; + rb_iseq_make_compile_option(&new_opt, node->nd_orig); + iseq->compile_data->option = &new_opt; + } COMPILE_POPED(ret, "prelude", node->nd_head); COMPILE_(ret, "body", node->nd_body, poped); + iseq->compile_data->option = orig_opt; break; } case NODE_LAMBDA:{ -- cgit v1.2.3