diff options
Diffstat (limited to 'template')
-rw-r--r-- | template/Makefile.in | 10 | ||||
-rw-r--r-- | template/prelude.c.tmpl | 57 |
2 files changed, 57 insertions, 10 deletions
diff --git a/template/Makefile.in b/template/Makefile.in index 813a727cf9..abb4469777 100644 --- a/template/Makefile.in +++ b/template/Makefile.in @@ -89,6 +89,7 @@ cflags = @cflags@ optflags = @optflags@ debugflags = @debugflags@ warnflags = @warnflags@ @strict_warnflags@ +hardenflags = @hardenflags@ cppflags = @cppflags@ incflags = @incflags@ RUBY_DEVEL = @RUBY_DEVEL@ # "yes" or empty @@ -493,9 +494,8 @@ clean-local:: enc/encinit.c enc/encinit.$(OBJEXT) $(pkgconfig_DATA) \ ruby-runner.$(OBJEXT) ruby-runner.h \ || $(NULLCMD) - @$(RM) $(ALLOBJS:.$(OBJEXT)=.bc) - @$(RM) $(ALLOBJS:.$(OBJEXT)=.i) - @$(RM) $(ALLOBJS:.$(OBJEXT)=.s) + $(Q)find . ! -type d \( -name '*.bc' -o -name '*.[is]' \) -exec rm -f {} + || true + distclean-local:: $(Q)$(RM) \ @@ -688,3 +688,7 @@ yes-test-syntax-suggest: $(PREPARE_SYNTAX_SUGGEST) $(RSPECOPTS) spec/syntax_suggest/$(SYNTAX_SUGGEST_SPECS) $(ACTIONS_ENDGROUP) no-test-syntax-suggest: + +yesterday: + $(GIT) -C $(srcdir) reset --hard \ + `$(GIT) -C $(srcdir) log -1 --before=00:00+0900 --format=%H` diff --git a/template/prelude.c.tmpl b/template/prelude.c.tmpl index e17a75da79..af493dfaca 100644 --- a/template/prelude.c.tmpl +++ b/template/prelude.c.tmpl @@ -154,6 +154,18 @@ prelude_ast_value(VALUE name, VALUE code, int line) return ast_value; } +static void +pm_prelude_load(pm_parse_result_t *result, VALUE name, VALUE code, int line) +{ + pm_options_line_set(&result->options, line); + VALUE error = pm_parse_string(result, code, name); + + if (!NIL_P(error)) { + pm_parse_result_free(result); + rb_exc_raise(error); + } +} + % end % if @builtin_count > 0 #define PRELUDE_VAST(n, name_str, start_line) \ @@ -176,6 +188,28 @@ rb_builtin_ast_value(const char *feature_name, VALUE *name_str) return ast_value; } +bool +pm_builtin_ast_value(pm_parse_result_t *result, const char *feature_name, VALUE *name_str) +{ + const size_t prefix_len = rb_strlen_lit("<internal:"); + size_t namelen = strlen(feature_name); + +% @preludes.each_value do |i, prelude, lines, sub, start_line| +% if sub + if ( + (sizeof(prelude_name<%= i %>) - prefix_len - 2 == namelen) && + (strncmp(prelude_name<%= i %> + prefix_len, feature_name, namelen) == 0) + ) { + *name_str = PRELUDE_NAME(<%= i %>); + pm_prelude_load(result, *name_str, PRELUDE_CODE(<%= i %>), <%= start_line %>); + return true; + } +% end +% end + + return false; +} + % end % if @prelude_count > 0 COMPILER_WARNING_PUSH @@ -198,13 +232,22 @@ prelude_eval(VALUE code, VALUE name, int line) 0, /* int debug_level; */ }; - rb_ast_t *ast; - VALUE ast_value = prelude_ast_value(name, code, line); - ast = rb_ruby_ast_data_get(ast_value); - rb_iseq_eval(rb_iseq_new_with_opt(ast_value, name, name, Qnil, line, - NULL, 0, ISEQ_TYPE_TOP, &optimization, - Qnil)); - rb_ast_dispose(ast); + if (*rb_ruby_prism_ptr()) { + pm_parse_result_t result = { 0 }; + pm_prelude_load(&result, name, code, line); + rb_iseq_eval(pm_iseq_new_with_opt(&result.node, name, name, Qnil, line, + NULL, 0, ISEQ_TYPE_TOP, &optimization)); + pm_parse_result_free(&result); + } + else { + rb_ast_t *ast; + VALUE ast_value = prelude_ast_value(name, code, line); + ast = rb_ruby_ast_data_get(ast_value); + rb_iseq_eval(rb_iseq_new_with_opt(ast_value, name, name, Qnil, line, + NULL, 0, ISEQ_TYPE_TOP, &optimization, + Qnil)); + rb_ast_dispose(ast); + } } COMPILER_WARNING_POP |