prism 2.0.0.rc1-aarch64-linux-gnu → 2.0.0.rc2-aarch64-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/LICENSE.md +1 -1
- data/docs/serialization.md +1 -0
- data/ext/prism/api_node.c +1 -1
- data/ext/prism/extension.c +20 -2
- data/ext/prism/extension.h +1 -1
- data/include/prism/compiler/accel.h +3 -1
- data/include/prism/compiler/bswap.h +46 -0
- data/include/prism/compiler/endianness.h +34 -0
- data/include/prism/internal/buffer.h +3 -0
- data/include/prism/internal/parser.h +20 -0
- data/include/prism/internal/xxh3.h +16 -0
- data/include/prism/parser.h +21 -0
- data/include/prism/string_query.h +11 -0
- data/include/prism/version.h +1 -1
- data/lib/prism/3.3/prism.so +0 -0
- data/lib/prism/3.4/prism.so +0 -0
- data/lib/prism/4.0/prism.so +0 -0
- data/lib/prism/ffi.rb +6 -0
- data/lib/prism/node.rb +736 -0
- data/lib/prism/parse_result.rb +23 -8
- data/lib/prism/serialize.rb +19 -6
- data/lib/prism/string_query.rb +8 -0
- data/prism.gemspec +8 -4
- data/rbi/generated/prism/node.rbi +1706 -980
- data/rbi/generated/prism/parse_result.rbi +16 -4
- data/rbi/generated/prism/serialize.rbi +3 -0
- data/rbi/generated/prism/string_query.rbi +7 -0
- data/sig/generated/prism/node.rbs +1713 -977
- data/sig/generated/prism/parse_result.rbs +16 -4
- data/sig/generated/prism/serialize.rbs +3 -0
- data/sig/generated/prism/string_query.rbs +7 -0
- data/src/buffer.c +9 -0
- data/src/parser.c +18 -0
- data/src/prism.c +406 -225
- data/src/serialize.c +2 -1
- data/src/string_query.c +14 -0
- data/src/xxh3.c +292 -0
- metadata +7 -3
|
@@ -30,8 +30,11 @@ module Prism
|
|
|
30
30
|
# empty when the source is created by the parser and filled in afterward,
|
|
31
31
|
# because the comments themselves refer to the source.
|
|
32
32
|
#
|
|
33
|
-
#
|
|
34
|
-
|
|
33
|
+
# The checksum parameter is the value described by the attribute of the same
|
|
34
|
+
# name. It is nil when the source is not created by the parser.
|
|
35
|
+
#
|
|
36
|
+
# : (String source, Integer start_line, Array[Integer] offsets, ?Array[Comment] comments, ?Array[Comment] comment_attachments, ?Array[Integer?] comment_ranges, ?Integer? checksum) -> Source
|
|
37
|
+
def self.for: (String source, Integer start_line, Array[Integer] offsets, ?Array[Comment] comments, ?Array[Comment] comment_attachments, ?Array[Integer?] comment_ranges, ?Integer? checksum) -> Source
|
|
35
38
|
|
|
36
39
|
# The source code that this source object represents.
|
|
37
40
|
attr_reader source: String
|
|
@@ -39,6 +42,10 @@ module Prism
|
|
|
39
42
|
# The line number where this source starts.
|
|
40
43
|
attr_reader start_line: Integer
|
|
41
44
|
|
|
45
|
+
# The checksum of the source code which can be used to quickly determine if
|
|
46
|
+
# the source has changed.
|
|
47
|
+
attr_reader checksum: Integer?
|
|
48
|
+
|
|
42
49
|
# The list of comments that were encountered during parsing. When the source
|
|
43
50
|
# is parsed with the attach_comments option, these are sorted by start
|
|
44
51
|
# offset.
|
|
@@ -66,14 +73,19 @@ module Prism
|
|
|
66
73
|
# parameter can be either an Array of Integer byte offsets or a packed
|
|
67
74
|
# binary string of uint32_t values (from the C extension).
|
|
68
75
|
#
|
|
69
|
-
# : (String source, Integer start_line, Array[Integer] | String offsets, ?Array[Comment] comments, ?Array[Comment] comment_attachments, ?Array[Integer?] comment_ranges) -> void
|
|
70
|
-
def initialize: (String source, Integer start_line, Array[Integer] | String offsets, ?Array[Comment] comments, ?Array[Comment] comment_attachments, ?Array[Integer?] comment_ranges) -> void
|
|
76
|
+
# : (String source, Integer start_line, Array[Integer] | String offsets, ?Array[Comment] comments, ?Array[Comment] comment_attachments, ?Array[Integer?] comment_ranges, ?Integer? checksum) -> void
|
|
77
|
+
def initialize: (String source, Integer start_line, Array[Integer] | String offsets, ?Array[Comment] comments, ?Array[Comment] comment_attachments, ?Array[Integer?] comment_ranges, ?Integer? checksum) -> void
|
|
71
78
|
|
|
72
79
|
# Replace the value of start_line with the given value.
|
|
73
80
|
#
|
|
74
81
|
# : (Integer start_line) -> void
|
|
75
82
|
def replace_start_line: (Integer start_line) -> void
|
|
76
83
|
|
|
84
|
+
# Replace the value of checksum with the given value.
|
|
85
|
+
#
|
|
86
|
+
# : (Integer checksum) -> void
|
|
87
|
+
def replace_checksum: (Integer checksum) -> void
|
|
88
|
+
|
|
77
89
|
# Replace the value of offsets with the given value.
|
|
78
90
|
#
|
|
79
91
|
# : (Array[Integer] offsets) -> void
|
|
@@ -149,6 +149,9 @@ module Prism
|
|
|
149
149
|
# : () -> Integer
|
|
150
150
|
def load_uint32: () -> Integer
|
|
151
151
|
|
|
152
|
+
# : () -> Integer
|
|
153
|
+
def load_uint64: () -> Integer
|
|
154
|
+
|
|
152
155
|
# : (ConstantPool constant_pool, Encoding encoding, bool freeze) -> node?
|
|
153
156
|
def load_optional_node: (ConstantPool constant_pool, Encoding encoding, bool freeze) -> node?
|
|
154
157
|
|
|
@@ -10,6 +10,8 @@ module Prism
|
|
|
10
10
|
|
|
11
11
|
def self.method_name?: (String string) -> bool
|
|
12
12
|
|
|
13
|
+
def self.keyword?: (String string) -> bool
|
|
14
|
+
|
|
13
15
|
# The string that this query is wrapping.
|
|
14
16
|
attr_reader string: String
|
|
15
17
|
|
|
@@ -32,5 +34,10 @@ module Prism
|
|
|
32
34
|
#
|
|
33
35
|
# : () -> bool
|
|
34
36
|
def method_name?: () -> bool
|
|
37
|
+
|
|
38
|
+
# Whether or not this string is a valid keyword.
|
|
39
|
+
#
|
|
40
|
+
# : () -> bool
|
|
41
|
+
def keyword?: () -> bool
|
|
35
42
|
end
|
|
36
43
|
end
|
data/src/buffer.c
CHANGED
|
@@ -186,6 +186,15 @@ pm_buffer_append_double(pm_buffer_t *buffer, double value) {
|
|
|
186
186
|
pm_buffer_append(buffer, source, sizeof(double));
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
+
/**
|
|
190
|
+
* Append a 64-bit unsigned integer to the buffer in native endian order.
|
|
191
|
+
*/
|
|
192
|
+
void
|
|
193
|
+
pm_buffer_append_uint64(pm_buffer_t *buffer, uint64_t value) {
|
|
194
|
+
const void *source = &value;
|
|
195
|
+
pm_buffer_append(buffer, source, sizeof(uint64_t));
|
|
196
|
+
}
|
|
197
|
+
|
|
189
198
|
/**
|
|
190
199
|
* Append a unicode codepoint to the buffer.
|
|
191
200
|
*/
|
data/src/parser.c
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
#include "prism/internal/diagnostic.h"
|
|
6
6
|
#include "prism/internal/encoding.h"
|
|
7
7
|
#include "prism/internal/magic_comments.h"
|
|
8
|
+
#include "prism/internal/xxh3.h"
|
|
8
9
|
|
|
9
10
|
#include <stdlib.h>
|
|
11
|
+
#include <string.h>
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Register a callback that will be called whenever prism changes the encoding
|
|
@@ -131,6 +133,22 @@ pm_parser_data_loc(const pm_parser_t *parser) {
|
|
|
131
133
|
return &parser->data_loc;
|
|
132
134
|
}
|
|
133
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Returns the checksum of the source code that was parsed.
|
|
138
|
+
*/
|
|
139
|
+
uint64_t
|
|
140
|
+
pm_parser_checksum(const pm_parser_t *parser) {
|
|
141
|
+
const uint8_t *end = parser->end;
|
|
142
|
+
|
|
143
|
+
if (parser->data_loc.length != 0) {
|
|
144
|
+
const uint8_t *cursor = parser->start + parser->data_loc.start;
|
|
145
|
+
const uint8_t *newline = memchr(cursor, '\n', (size_t) (end - cursor));
|
|
146
|
+
if (newline != NULL) end = newline + 1;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return pm_xxh3(parser->start, (size_t) (end - parser->start));
|
|
150
|
+
}
|
|
151
|
+
|
|
134
152
|
/**
|
|
135
153
|
* Returns whether the given parser is continuable, meaning that it could become
|
|
136
154
|
* valid if more input were appended, as opposed to being definitively invalid.
|