Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ PRISM_FILES = prism/api_node.$(OBJEXT) \
prism/util/pm_char.$(OBJEXT) \
prism/util/pm_constant_pool.$(OBJEXT) \
prism/util/pm_integer.$(OBJEXT) \
prism/util/pm_line_offset_list.$(OBJEXT) \
prism/util/pm_list.$(OBJEXT) \
prism/util/pm_memchr.$(OBJEXT) \
prism/util/pm_newline_list.$(OBJEXT) \
prism/util/pm_string.$(OBJEXT) \
prism/util/pm_strncasecmp.$(OBJEXT) \
prism/util/pm_strpbrk.$(OBJEXT) \
Expand Down
84 changes: 42 additions & 42 deletions depend

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ rb_iseq_new_top(const VALUE ast_value, VALUE name, VALUE path, VALUE realpath, c
rb_iseq_t *
pm_iseq_new_top(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath, const rb_iseq_t *parent, int *error_state)
{
iseq_new_setup_coverage(path, (int) (node->parser->newline_list.size - 1));
iseq_new_setup_coverage(path, (int) (node->parser->line_offsets.size - 1));

return pm_iseq_new_with_opt(node, name, path, realpath, 0, parent, 0,
ISEQ_TYPE_TOP, &COMPILE_OPTION_DEFAULT, error_state);
Expand All @@ -1006,7 +1006,7 @@ rb_iseq_new_main(const VALUE ast_value, VALUE path, VALUE realpath, const rb_ise
rb_iseq_t *
pm_iseq_new_main(pm_scope_node_t *node, VALUE path, VALUE realpath, const rb_iseq_t *parent, int opt, int *error_state)
{
iseq_new_setup_coverage(path, (int) (node->parser->newline_list.size - 1));
iseq_new_setup_coverage(path, (int) (node->parser->line_offsets.size - 1));

return pm_iseq_new_with_opt(node, rb_fstring_lit("<main>"),
path, realpath, 0,
Expand Down Expand Up @@ -1035,7 +1035,7 @@ pm_iseq_new_eval(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath,
if (rb_get_coverage_mode() & COVERAGE_TARGET_EVAL) {
VALUE coverages = rb_get_coverages();
if (RTEST(coverages) && RTEST(path) && !RTEST(rb_hash_has_key(coverages, path))) {
iseq_setup_coverage(coverages, path, ((int) (node->parser->newline_list.size - 1)) + first_lineno - 1);
iseq_setup_coverage(coverages, path, ((int) (node->parser->line_offsets.size - 1)) + first_lineno - 1);
}
}

Expand Down Expand Up @@ -1145,8 +1145,8 @@ pm_iseq_new_with_opt(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpa
pm_location_t *location = &node->base.location;
int32_t start_line = node->parser->start_line;

pm_line_column_t start = pm_newline_list_line_column(&node->parser->newline_list, location->start, start_line);
pm_line_column_t end = pm_newline_list_line_column(&node->parser->newline_list, location->start + location->length, start_line);
pm_line_column_t start = pm_line_offset_list_line_column(&node->parser->line_offsets, location->start, start_line);
pm_line_column_t end = pm_line_offset_list_line_column(&node->parser->line_offsets, location->start + location->length, start_line);

rb_code_location_t code_location = (rb_code_location_t) {
.beg_pos = { .lineno = (int) start.line, .column = (int) start.column },
Expand Down
6 changes: 4 additions & 2 deletions lib/prism/prism.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Gem::Specification.new do |spec|
"docs/serialization.md",
"docs/testing.md",
"ext/prism/api_node.c",
"ext/prism/depend",
"ext/prism/extconf.rb",
"ext/prism/extension.c",
"ext/prism/extension.h",
"include/prism.h",
Expand All @@ -61,7 +63,7 @@ Gem::Specification.new do |spec|
"include/prism/util/pm_integer.h",
"include/prism/util/pm_list.h",
"include/prism/util/pm_memchr.h",
"include/prism/util/pm_newline_list.h",
"include/prism/util/pm_line_offset_list.h",
"include/prism/util/pm_strncasecmp.h",
"include/prism/util/pm_string.h",
"include/prism/util/pm_strpbrk.h",
Expand Down Expand Up @@ -154,7 +156,7 @@ Gem::Specification.new do |spec|
"src/util/pm_integer.c",
"src/util/pm_list.c",
"src/util/pm_memchr.c",
"src/util/pm_newline_list.c",
"src/util/pm_line_offset_list.c",
"src/util/pm_string.c",
"src/util/pm_strncasecmp.c",
"src/util/pm_strpbrk.c"
Expand Down
2 changes: 2 additions & 0 deletions prism/depend
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$(OBJS): $(HDRS) $(ruby_headers)
$(OBJS): $(srcdir)/../../config.yml
6 changes: 3 additions & 3 deletions prism/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ parse_lex_input(pm_string_t *input, const pm_options_t *options, bool return_nod
pm_parser_register_encoding_changed_callback(&parser, parse_lex_encoding_changed_callback);

VALUE source_string = rb_str_new((const char *) pm_string_source(input), pm_string_length(input));
VALUE offsets = rb_ary_new_capa(parser.newline_list.size);
VALUE offsets = rb_ary_new_capa(parser.line_offsets.size);
VALUE source = rb_funcall(rb_cPrismSource, rb_id_source_for, 3, source_string, LONG2NUM(parser.start_line), offsets);

parse_lex_data_t parse_lex_data = {
Expand All @@ -767,8 +767,8 @@ parse_lex_input(pm_string_t *input, const pm_options_t *options, bool return_nod
rb_encoding *encoding = rb_enc_find(parser.encoding->name);
rb_enc_associate(source_string, encoding);

for (size_t index = 0; index < parser.newline_list.size; index++) {
rb_ary_push(offsets, ULONG2NUM(parser.newline_list.offsets[index]));
for (size_t index = 0; index < parser.line_offsets.size; index++) {
rb_ary_push(offsets, ULONG2NUM(parser.line_offsets.offsets[index]));
}

if (options->freeze) {
Expand Down
6 changes: 3 additions & 3 deletions prism/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "prism/static_literals.h"
#include "prism/util/pm_constant_pool.h"
#include "prism/util/pm_list.h"
#include "prism/util/pm_newline_list.h"
#include "prism/util/pm_line_offset_list.h"
#include "prism/util/pm_string.h"

#include <stdbool.h>
Expand Down Expand Up @@ -782,8 +782,8 @@ struct pm_parser {
*/
pm_constant_pool_t constant_pool;

/** This is the list of newline offsets in the source file. */
pm_newline_list_t newline_list;
/** This is the list of line offsets in the source file. */
pm_line_offset_list_t line_offsets;

/**
* We want to add a flag to integer nodes that indicates their base. We only
Expand Down
Loading