diff options
author | Kevin Newton <[email protected]> | 2024-08-29 14:26:08 -0400 |
---|---|---|
committer | Kevin Newton <[email protected]> | 2024-08-29 20:27:01 -0400 |
commit | 371432b2d7a5f4a21876434047192e680a688780 () | |
tree | 49f8664abca10899bf63cf9d67718aa960ceb92b /prism_compile.c | |
parent | 554098303dd70adbe611eac5507277560bfa299a (diff) |
[PRISM] Handle RubyVM.keep_script_lines
Notes: Merged: https://.com/ruby/ruby/pull/11501
-rw-r--r-- | prism_compile.c | 37 |
1 files changed, 26 insertions, 11 deletions
@@ -3107,6 +3107,7 @@ pm_scope_node_init(const pm_node_t *node, pm_scope_node_t *scope, pm_scope_node_ scope->filepath_encoding = previous->filepath_encoding; scope->constants = previous->constants; scope->coverage_enabled = previous->coverage_enabled; } switch (PM_NODE_TYPE(node)) { @@ -10379,7 +10380,7 @@ pm_parse_process_error(const pm_parse_result_t *result) * result object is zeroed out. */ static VALUE -pm_parse_process(pm_parse_result_t *result, pm_node_t *node) { pm_parser_t *parser = &result->parser; @@ -10397,6 +10398,20 @@ pm_parse_process(pm_parse_result_t *result, pm_node_t *node) scope_node->coverage_enabled = coverage_enabled; // Emit all of the various warnings from the parse. const pm_diagnostic_t *warning; const char *warning_filepath = (const char *) pm_string_source(&parser->filepath); @@ -10663,7 +10678,7 @@ pm_load_file(pm_parse_result_t *result, VALUE filepath, bool load_error) * is zeroed out. */ VALUE -pm_parse_file(pm_parse_result_t *result, VALUE filepath) { result->node.filepath_encoding = rb_enc_get(filepath); pm_options_filepath_set(&result->options, RSTRING_PTR(filepath)); @@ -10672,7 +10687,7 @@ pm_parse_file(pm_parse_result_t *result, VALUE filepath) pm_parser_init(&result->parser, pm_string_source(&result->input), pm_string_length(&result->input), &result->options); pm_node_t *node = pm_parse(&result->parser); - VALUE error = pm_parse_process(result, node); // If we're parsing a filepath, then we need to potentially support the // SCRIPT_LINES__ constant, which can be a hash that has an array of lines @@ -10680,10 +10695,10 @@ pm_parse_file(pm_parse_result_t *result, VALUE filepath) ID id_script_lines = rb_intern("SCRIPT_LINES__"); if (rb_const_defined_at(rb_cObject, id_script_lines)) { - VALUE script_lines = rb_const_get_at(rb_cObject, id_script_lines); - if (RB_TYPE_P(script_lines, T_HASH)) { - rb_hash_aset(script_lines, filepath, pm_parse_file_script_lines(&result->node, &result->parser)); } } @@ -10695,11 +10710,11 @@ pm_parse_file(pm_parse_result_t *result, VALUE filepath) * cannot be read or if it cannot be parsed properly. */ VALUE -pm_load_parse_file(pm_parse_result_t *result, VALUE filepath) { VALUE error = pm_load_file(result, filepath, false); if (NIL_P(error)) { - error = pm_parse_file(result, filepath); } return error; @@ -10712,7 +10727,7 @@ pm_load_parse_file(pm_parse_result_t *result, VALUE filepath) * error is returned. */ VALUE -pm_parse_string(pm_parse_result_t *result, VALUE source, VALUE filepath) { rb_encoding *encoding = rb_enc_get(source); if (!rb_enc_asciicompat(encoding)) { @@ -10730,7 +10745,7 @@ pm_parse_string(pm_parse_result_t *result, VALUE source, VALUE filepath) pm_parser_init(&result->parser, pm_string_source(&result->input), pm_string_length(&result->input), &result->options); pm_node_t *node = pm_parse(&result->parser); - return pm_parse_process(result, node); } /** @@ -10780,7 +10795,7 @@ pm_parse_stdin(pm_parse_result_t *result) // we went through an IO object to be visible to the user. rb_reset_argf_lineno(0); - return pm_parse_process(result, node); } #undef NEW_ISEQ |