diff options
author | HParker <[email protected]> | 2023-12-01 13:25:41 -0800 |
---|---|---|
committer | Jemma Issroff <[email protected]> | 2023-12-05 12:17:14 -0500 |
commit | 9b76c7fc89460ed8e9be40e4037c1d68395c0f6d () | |
tree | fc0b1638f528bafd00fce2e09bab32d5977c0947 /load.c | |
parent | 19114014faf9e22c29c105df4d0b7af84c257366 (diff) |
allow enabling Prism via flag or env var
Enable Prism using either --prism ruby --prism test.rb or via env var RUBY_PRISM=1 ruby test.rb
-rw-r--r-- | load.c | 48 |
1 files changed, 32 insertions, 16 deletions
@@ -16,6 +16,7 @@ #include "probes.h" #include "darray.h" #include "ruby/encoding.h" #include "ruby/util.h" static VALUE ruby_dln_librefs; @@ -717,23 +718,38 @@ static inline void load_iseq_eval(rb_execution_context_t *ec, VALUE fname) { const rb_iseq_t *iseq = rb_iseq_load_iseq(fname); - if (!iseq) { - rb_execution_context_t *ec = GET_EC(); - VALUE v = rb_vm_push_frame_fname(ec, fname); - rb_ast_t *ast; - VALUE parser = rb_parser_new(); - rb_parser_set_context(parser, NULL, FALSE); - ast = (rb_ast_t *)rb_parser_load_file(parser, fname); - - rb_thread_t *th = rb_ec_thread_ptr(ec); - VALUE realpath_map = get_loaded_features_realpath_map(th->vm); - - iseq = rb_iseq_new_top(&ast->body, rb_fstring_lit("<top (required)>"), - fname, realpath_internal_cached(realpath_map, fname), NULL); - rb_ast_dispose(ast); - rb_vm_pop_frame(ec); - RB_GC_GUARD(v); } rb_exec_event_hook_script_compiled(ec, iseq, Qnil); rb_iseq_eval(iseq); |