aboutsummaryrefslogtreecommitdiffstats
path: root/iseq.c
diff options
context:
space:
mode:
authorHParker <HParker@github.com>2023-12-01 13:25:41 -0800
committerJemma Issroff <jemmaissroff@gmail.com>2023-12-05 12:17:14 -0500
commit9b76c7fc89460ed8e9be40e4037c1d68395c0f6d (patch)
treefc0b1638f528bafd00fce2e09bab32d5977c0947 /iseq.c
parent19114014faf9e22c29c105df4d0b7af84c257366 (diff)
downloadruby-9b76c7fc89460ed8e9be40e4037c1d68395c0f6d.tar.gz
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.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/iseq.c b/iseq.c
index 47d19a98f3..38c6f7150e 100644
--- a/iseq.c
+++ b/iseq.c
@@ -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