prism 2.0.0.rc2-x86_64-linux-gnu → 2.0.0-x86_64-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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -2
  3. data/docs/serialization.md +19 -6
  4. data/ext/prism/api_node.c +80 -80
  5. data/ext/prism/extension.c +34 -67
  6. data/ext/prism/extension.h +1 -1
  7. data/include/prism/arena.h +8 -0
  8. data/include/prism/arena.hpp +42 -0
  9. data/include/prism/ast.h +11 -1
  10. data/include/prism/ast.hpp +641 -0
  11. data/include/prism/buffer.h +8 -0
  12. data/include/prism/buffer.hpp +55 -0
  13. data/include/prism/comments.h +17 -0
  14. data/include/prism/compiler/branch.h +26 -0
  15. data/include/prism/compiler/cplusplus.hpp +16 -0
  16. data/include/prism/compiler/exceptions.hpp +17 -0
  17. data/include/prism/compiler/format.h +2 -0
  18. data/include/prism/compiler/lifetimebound.hpp +25 -0
  19. data/include/prism/constant_pool.h +25 -0
  20. data/include/prism/diagnostic.h +18 -0
  21. data/include/prism/errors_format.h +8 -0
  22. data/include/prism/internal/node.h +8 -4
  23. data/include/prism/internal/stringy.h +1 -6
  24. data/include/prism/json.h +8 -0
  25. data/include/prism/line_offset_list.h +8 -0
  26. data/include/prism/magic_comments.h +18 -0
  27. data/include/prism/node.h +55 -10
  28. data/include/prism/node.hpp +272 -0
  29. data/include/prism/node_type.hpp +38 -0
  30. data/include/prism/options.h +10 -1
  31. data/include/prism/options.hpp +43 -0
  32. data/include/prism/parser.h +72 -64
  33. data/include/prism/parser.hpp +274 -0
  34. data/include/prism/prettyprint.h +8 -0
  35. data/include/prism/serialize.h +8 -0
  36. data/include/prism/source.h +8 -0
  37. data/include/prism/stream.h +8 -0
  38. data/include/prism/string_query.h +8 -0
  39. data/include/prism/stringy.h +16 -27
  40. data/include/prism/stringy.hpp +31 -0
  41. data/include/prism/version.h +9 -1
  42. data/include/prism.h +0 -8
  43. data/include/prism.hpp +24 -0
  44. data/lib/prism/3.3/prism.so +0 -0
  45. data/lib/prism/3.4/prism.so +0 -0
  46. data/lib/prism/4.0/prism.so +0 -0
  47. data/lib/prism/serialize.rb +2549 -3281
  48. data/prism.gemspec +14 -1
  49. data/rbi/generated/prism/node.rbi +736 -0
  50. data/rbi/generated/prism/serialize.rbi +6 -5
  51. data/sig/generated/prism/node.rbs +736 -0
  52. data/sig/generated/prism/serialize.rbs +7 -5
  53. data/src/comments.c +2 -2
  54. data/src/diagnostic.c +8 -0
  55. data/src/node.c +216 -368
  56. data/src/options.c +7 -13
  57. data/src/parser.c +52 -48
  58. data/src/prism.c +175 -194
  59. data/src/regexp.c +0 -1
  60. data/src/serialize.c +2300 -1950
  61. data/src/source.c +8 -2
  62. data/src/stringy.c +3 -33
  63. metadata +14 -1
data/src/source.c CHANGED
@@ -377,7 +377,13 @@ pm_source_stream_read(pm_source_t *source) {
377
377
  */
378
378
  #define LINE_FILL 0xff
379
379
 
380
- while (memset(line, LINE_FILL, LINE_SIZE), source->stream.fgets(line, LINE_SIZE, source->stream.stream) != NULL) {
380
+ /*
381
+ * The fgets and feof members share their names with standard library
382
+ * functions, which <stdio.h> may define as function-like macros (newlib on
383
+ * Cygwin does this for feof). Parenthesizing the member access keeps those
384
+ * macros from expanding at the call sites.
385
+ */
386
+ while (memset(line, LINE_FILL, LINE_SIZE), (source->stream.fgets)(line, LINE_SIZE, source->stream.stream) != NULL) {
381
387
  /*
382
388
  * Locate the NUL terminator written by fgets (the last NUL in the
383
389
  * buffer) to recover the length of the chunk, then drop the terminator.
@@ -408,7 +414,7 @@ pm_source_stream_read(pm_source_t *source) {
408
414
  * EOF. A newline-terminated line needs no such check: if it happens to
409
415
  * be the last line, the next fgets returns NULL and ends the loop.
410
416
  */
411
- if (!newline && !source->stream.feof(source->stream.stream)) {
417
+ if (!newline && !(source->stream.feof)(source->stream.stream)) {
412
418
  continue;
413
419
  }
414
420
 
data/src/stringy.c CHANGED
@@ -1,9 +1,6 @@
1
1
  #include "prism/internal/stringy.h"
2
2
 
3
- #include "prism/internal/allocator.h"
4
-
5
3
  #include <assert.h>
6
- #include <stdlib.h>
7
4
  #include <string.h>
8
5
 
9
6
  /**
@@ -14,34 +11,17 @@ pm_string_shared_init(pm_string_t *string, const uint8_t *start, const uint8_t *
14
11
  assert(start <= end);
15
12
 
16
13
  *string = (pm_string_t) {
17
- .type = PM_STRING_SHARED,
18
14
  .source = start,
19
15
  .length = (size_t) (end - start)
20
16
  };
21
17
  }
22
18
 
23
19
  /**
24
- * Initialize an owned string that is responsible for freeing allocated memory.
25
- */
26
- void
27
- pm_string_owned_init(pm_string_t *string, uint8_t *source, size_t length) {
28
- *string = (pm_string_t) {
29
- .type = PM_STRING_OWNED,
30
- .source = source,
31
- .length = length
32
- };
33
- }
34
-
35
- /**
36
- * Initialize a constant string that doesn't own its memory source.
20
+ * Initialize a string that views the given bytes.
37
21
  */
38
22
  void
39
- pm_string_constant_init(pm_string_t *string, const char *source, size_t length) {
40
- *string = (pm_string_t) {
41
- .type = PM_STRING_CONSTANT,
42
- .source = (const uint8_t *) source,
43
- .length = length
44
- };
23
+ pm_string_init(pm_string_t *string, const uint8_t *source, size_t length) {
24
+ *string = (pm_string_t) { .source = source, .length = length };
45
25
  }
46
26
 
47
27
  /**
@@ -79,13 +59,3 @@ const uint8_t *
79
59
  pm_string_source(const pm_string_t *string) {
80
60
  return string->source;
81
61
  }
82
-
83
- /**
84
- * Free the associated memory of the given string.
85
- */
86
- void
87
- pm_string_cleanup(pm_string_t *string) {
88
- if (string->type == PM_STRING_OWNED) {
89
- xfree_sized((void *) string->source, string->length);
90
- }
91
- }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prism
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.rc2
4
+ version: 2.0.0
5
5
  platform: x86_64-linux-gnu
6
6
  authors:
7
7
  - Ruby developers
@@ -47,15 +47,22 @@ files:
47
47
  - ext/prism/extension.c
48
48
  - ext/prism/extension.h
49
49
  - include/prism.h
50
+ - include/prism.hpp
50
51
  - include/prism/arena.h
52
+ - include/prism/arena.hpp
51
53
  - include/prism/ast.h
54
+ - include/prism/ast.hpp
52
55
  - include/prism/buffer.h
56
+ - include/prism/buffer.hpp
53
57
  - include/prism/comments.h
54
58
  - include/prism/compiler/accel.h
55
59
  - include/prism/compiler/align.h
56
60
  - include/prism/compiler/assume.h
61
+ - include/prism/compiler/branch.h
57
62
  - include/prism/compiler/bswap.h
63
+ - include/prism/compiler/cplusplus.hpp
58
64
  - include/prism/compiler/endianness.h
65
+ - include/prism/compiler/exceptions.hpp
59
66
  - include/prism/compiler/exported.h
60
67
  - include/prism/compiler/fallthrough.h
61
68
  - include/prism/compiler/filesystem.h
@@ -63,6 +70,7 @@ files:
63
70
  - include/prism/compiler/force_inline.h
64
71
  - include/prism/compiler/format.h
65
72
  - include/prism/compiler/inline.h
73
+ - include/prism/compiler/lifetimebound.hpp
66
74
  - include/prism/compiler/nodiscard.h
67
75
  - include/prism/compiler/nonnull.h
68
76
  - include/prism/compiler/unused.h
@@ -103,14 +111,19 @@ files:
103
111
  - include/prism/line_offset_list.h
104
112
  - include/prism/magic_comments.h
105
113
  - include/prism/node.h
114
+ - include/prism/node.hpp
115
+ - include/prism/node_type.hpp
106
116
  - include/prism/options.h
117
+ - include/prism/options.hpp
107
118
  - include/prism/parser.h
119
+ - include/prism/parser.hpp
108
120
  - include/prism/prettyprint.h
109
121
  - include/prism/serialize.h
110
122
  - include/prism/source.h
111
123
  - include/prism/stream.h
112
124
  - include/prism/string_query.h
113
125
  - include/prism/stringy.h
126
+ - include/prism/stringy.hpp
114
127
  - include/prism/version.h
115
128
  - lib/prism.rb
116
129
  - lib/prism/3.3/prism.so