Skip to content

Commit cace09f

Browse files
committed
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.
1 parent 6e57db7 commit cace09f

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

lib/prism/parse_result.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ class Source
99
attr_reader :source
1010

1111
# The line number where this source starts.
12-
attr_accessor :start_line
12+
attr_reader :start_line
1313

1414
# The list of newline byte offsets in the source code.
15-
attr_accessor :offsets
15+
attr_reader :offsets
1616

1717
# Create a new source object with the given source code.
1818
def initialize(source)

templates/ext/prism/api_node.c.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ pm_source_new(pm_parser_t *parser, rb_encoding *encoding) {
4949

5050
void
5151
pm_source_init(VALUE source, pm_parser_t *parser) {
52-
rb_funcall(source, rb_intern("start_line="), 1, LONG2NUM(parser->start_line));
52+
rb_iv_set(source, "@start_line", LONG2NUM(parser->start_line));
5353

5454
VALUE offsets = rb_ary_new_capa(parser->newline_list.size);
5555
for (size_t index = 0; index < parser->newline_list.size; index++) {
5656
rb_ary_push(offsets, ULONG2NUM(parser->newline_list.offsets[index]));
5757
}
58-
rb_funcall(source, rb_intern("offsets="), 1, offsets);
58+
rb_iv_set(source, "@offsets", offsets);
5959
}
6060

6161
typedef struct pm_node_stack_node {

templates/java/org/prism/Nodes.java.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ public abstract class Nodes {
4949
this.bytes = bytes;
5050
}
5151

52-
public void setStartLine(int startLine) {
52+
void setStartLine(int startLine) {
5353
this.startLine = startLine;
5454
}
5555

56-
public void setLineOffsets(int[] lineOffsets) {
56+
void setLineOffsets(int[] lineOffsets) {
5757
this.lineOffsets = lineOffsets;
5858
}
5959

templates/lib/prism/serialize.rb.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ module Prism
7979
end
8080

8181
def load_start_line
82-
source.start_line = load_varsint
82+
source.instance_variable_set :@start_line, load_varsint
8383
end
8484

8585
def load_line_offsets
86-
source.offsets = load_varuint.times.map { load_varuint }
86+
source.instance_variable_set :@offsets, load_varuint.times.map { load_varuint }
8787
end
8888

8989
def load_comments

0 commit comments

Comments
 (0)