зеркало из https://github.com/github/ruby.git
[ruby/prism] Remove attr_writer's for ParseResult#start_line and #offsets
* As the user should not set these. * Use #instance_variable_set/rb_iv_set() instead internally. https://github.com/ruby/prism/commit/cace09fb8c
This commit is contained in:
Родитель
f0f6ffef42
Коммит
1b2708b123
|
@ -9,10 +9,10 @@ module Prism
|
|||
attr_reader :source
|
||||
|
||||
# The line number where this source starts.
|
||||
attr_accessor :start_line
|
||||
attr_reader :start_line
|
||||
|
||||
# The list of newline byte offsets in the source code.
|
||||
attr_accessor :offsets
|
||||
attr_reader :offsets
|
||||
|
||||
# Create a new source object with the given source code.
|
||||
def initialize(source)
|
||||
|
|
|
@ -49,13 +49,13 @@ pm_source_new(pm_parser_t *parser, rb_encoding *encoding) {
|
|||
|
||||
void
|
||||
pm_source_init(VALUE source, pm_parser_t *parser) {
|
||||
rb_funcall(source, rb_intern("start_line="), 1, LONG2NUM(parser->start_line));
|
||||
rb_iv_set(source, "@start_line", LONG2NUM(parser->start_line));
|
||||
|
||||
VALUE offsets = rb_ary_new_capa(parser->newline_list.size);
|
||||
for (size_t index = 0; index < parser->newline_list.size; index++) {
|
||||
rb_ary_push(offsets, ULONG2NUM(parser->newline_list.offsets[index]));
|
||||
}
|
||||
rb_funcall(source, rb_intern("offsets="), 1, offsets);
|
||||
rb_iv_set(source, "@offsets", offsets);
|
||||
}
|
||||
|
||||
typedef struct pm_node_stack_node {
|
||||
|
|
|
@ -79,11 +79,11 @@ module Prism
|
|||
end
|
||||
|
||||
def load_start_line
|
||||
source.start_line = load_varsint
|
||||
source.instance_variable_set :@start_line, load_varsint
|
||||
end
|
||||
|
||||
def load_line_offsets
|
||||
source.offsets = load_varuint.times.map { load_varuint }
|
||||
source.instance_variable_set :@offsets, load_varuint.times.map { load_varuint }
|
||||
end
|
||||
|
||||
def load_comments
|
||||
|
|
Загрузка…
Ссылка в новой задаче