Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
class method
RubyVM::InstructionSequence.compile_prism
compile_prism(p1, *args, p3 = {})
iseq.c
View on GitHub ↗
static VALUE
iseqw_s_compile_prism(int argc, VALUE *argv, VALUE self)
{
VALUE src, file = Qnil, path = Qnil, line = Qnil, opt = Qnil;
int i;
i = rb_scan_args(argc, argv, "1*:", &src, NULL, &opt);
if (i > 4+NIL_P(opt)) rb_error_arity(argc, 1, 5);
switch (i) {
case 5: opt = argv[--i];
case 4: line = argv[--i];
case 3: path = argv[--i];
case 2: file = argv[--i];
}
if (NIL_P(file)) file = rb_fstring_lit("<compiled>");
if (NIL_P(path)) path = file;
if (NIL_P(line)) line = INT2FIX(1);
Check_Type(path, T_STRING);
Check_Type(file, T_STRING);
pm_options_t options = { 0 };
pm_options_filepath_set(&options, RSTRING_PTR(file));
int start_line = NUM2INT(line);
pm_options_line_set(&options, start_line);
pm_parser_t parser;
if (RB_TYPE_P(src, T_FILE)) {
FilePathValue(src);
file = rb_fstring(src); /* rb_io_t->pathv gets frozen anyways */
pm_string_t input;
pm_string_mapped_init(&input, RSTRING_PTR(file));
pm_parser_init(&parser, pm_string_source(&input), pm_string_length(&input), &options);
}
else {
pm_parser_init(&parser, (const uint8_t *) RSTRING_PTR(src), RSTRING_LEN(src), &options);
}
rb_iseq_t *iseq = iseq_alloc();
iseqw_s_compile_prism_compile(&parser, opt, iseq, file, path, start_line);
pm_parser_free(&parser);
pm_options_free(&options);
return iseqw_new(iseq);
}
No documentation available