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 (patch) | |
tree | fc0b1638f528bafd00fce2e09bab32d5977c0947 /iseq.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
Diffstat (limited to 'iseq.c')
-rw-r--r-- | iseq.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -1487,6 +1487,22 @@ iseqw_s_compile_file_prism(int argc, VALUE *argv, VALUE self) return iseqw_new(iseq); } +rb_iseq_t * +rb_iseq_new_main_prism(pm_string_t *input, pm_options_t *options, VALUE path) { + pm_parser_t parser; + pm_parser_init(&parser, pm_string_source(input), pm_string_length(input), options); + + if (NIL_P(path)) path = rb_fstring_lit("<compiled>"); + int start_line = 0; + pm_options_line_set(options, start_line); + + rb_iseq_t *iseq = iseq_alloc(); + iseqw_s_compile_prism_compile(&parser, Qnil, iseq, path, path, start_line); + + pm_parser_free(&parser); + return iseq; +} + /* * call-seq: * InstructionSequence.compile_file(file[, options]) -> iseq |