prism 2.0.0.rc2 → 2.1.0

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 (69) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +57 -41
  3. data/Makefile +8 -8
  4. data/README.md +3 -1
  5. data/docs/fuzzing.md +5 -5
  6. data/docs/serialization.md +19 -6
  7. data/ext/prism/api_node.c +80 -80
  8. data/ext/prism/extension.c +34 -67
  9. data/ext/prism/extension.h +1 -1
  10. data/include/prism/arena.h +8 -0
  11. data/include/prism/arena.hpp +42 -0
  12. data/include/prism/ast.h +11 -1
  13. data/include/prism/ast.hpp +641 -0
  14. data/include/prism/buffer.h +8 -0
  15. data/include/prism/buffer.hpp +55 -0
  16. data/include/prism/comments.h +17 -0
  17. data/include/prism/compiler/branch.h +26 -0
  18. data/include/prism/compiler/cplusplus.hpp +16 -0
  19. data/include/prism/compiler/exceptions.hpp +17 -0
  20. data/include/prism/compiler/format.h +2 -0
  21. data/include/prism/compiler/lifetimebound.hpp +25 -0
  22. data/include/prism/constant_pool.h +25 -0
  23. data/include/prism/diagnostic.h +18 -0
  24. data/include/prism/errors_format.h +8 -0
  25. data/include/prism/internal/comments.h +2 -1
  26. data/include/prism/internal/node.h +8 -4
  27. data/include/prism/internal/parser.h +26 -15
  28. data/include/prism/internal/static_literals.h +24 -64
  29. data/include/prism/internal/stringy.h +1 -6
  30. data/include/prism/json.h +8 -0
  31. data/include/prism/line_offset_list.h +8 -0
  32. data/include/prism/magic_comments.h +18 -0
  33. data/include/prism/node.h +55 -10
  34. data/include/prism/node.hpp +272 -0
  35. data/include/prism/node_type.hpp +38 -0
  36. data/include/prism/options.h +10 -1
  37. data/include/prism/options.hpp +43 -0
  38. data/include/prism/parser.h +72 -64
  39. data/include/prism/parser.hpp +274 -0
  40. data/include/prism/prettyprint.h +8 -0
  41. data/include/prism/serialize.h +8 -0
  42. data/include/prism/source.h +8 -0
  43. data/include/prism/stream.h +8 -0
  44. data/include/prism/string_query.h +8 -0
  45. data/include/prism/stringy.h +16 -27
  46. data/include/prism/stringy.hpp +31 -0
  47. data/include/prism/version.h +10 -2
  48. data/include/prism.h +0 -8
  49. data/include/prism.hpp +24 -0
  50. data/lib/prism/serialize.rb +2550 -3282
  51. data/prism.gemspec +14 -1
  52. data/rbi/generated/prism/node.rbi +736 -0
  53. data/rbi/generated/prism/serialize.rbi +6 -5
  54. data/sig/generated/prism/node.rbs +736 -0
  55. data/sig/generated/prism/serialize.rbs +7 -5
  56. data/src/arena.c +6 -1
  57. data/src/comments.c +11 -10
  58. data/src/diagnostic.c +24 -4
  59. data/src/integer.c +6 -1
  60. data/src/node.c +216 -368
  61. data/src/options.c +7 -13
  62. data/src/parser.c +52 -48
  63. data/src/prism.c +222 -240
  64. data/src/regexp.c +0 -1
  65. data/src/serialize.c +2300 -1950
  66. data/src/source.c +8 -2
  67. data/src/static_literals.c +280 -405
  68. data/src/stringy.c +3 -33
  69. metadata +14 -1
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.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruby developers
@@ -48,15 +48,22 @@ files:
48
48
  - ext/prism/extension.c
49
49
  - ext/prism/extension.h
50
50
  - include/prism.h
51
+ - include/prism.hpp
51
52
  - include/prism/arena.h
53
+ - include/prism/arena.hpp
52
54
  - include/prism/ast.h
55
+ - include/prism/ast.hpp
53
56
  - include/prism/buffer.h
57
+ - include/prism/buffer.hpp
54
58
  - include/prism/comments.h
55
59
  - include/prism/compiler/accel.h
56
60
  - include/prism/compiler/align.h
57
61
  - include/prism/compiler/assume.h
62
+ - include/prism/compiler/branch.h
58
63
  - include/prism/compiler/bswap.h
64
+ - include/prism/compiler/cplusplus.hpp
59
65
  - include/prism/compiler/endianness.h
66
+ - include/prism/compiler/exceptions.hpp
60
67
  - include/prism/compiler/exported.h
61
68
  - include/prism/compiler/fallthrough.h
62
69
  - include/prism/compiler/filesystem.h
@@ -64,6 +71,7 @@ files:
64
71
  - include/prism/compiler/force_inline.h
65
72
  - include/prism/compiler/format.h
66
73
  - include/prism/compiler/inline.h
74
+ - include/prism/compiler/lifetimebound.hpp
67
75
  - include/prism/compiler/nodiscard.h
68
76
  - include/prism/compiler/nonnull.h
69
77
  - include/prism/compiler/unused.h
@@ -104,14 +112,19 @@ files:
104
112
  - include/prism/line_offset_list.h
105
113
  - include/prism/magic_comments.h
106
114
  - include/prism/node.h
115
+ - include/prism/node.hpp
116
+ - include/prism/node_type.hpp
107
117
  - include/prism/options.h
118
+ - include/prism/options.hpp
108
119
  - include/prism/parser.h
120
+ - include/prism/parser.hpp
109
121
  - include/prism/prettyprint.h
110
122
  - include/prism/serialize.h
111
123
  - include/prism/source.h
112
124
  - include/prism/stream.h
113
125
  - include/prism/string_query.h
114
126
  - include/prism/stringy.h
127
+ - include/prism/stringy.hpp
115
128
  - include/prism/version.h
116
129
  - lib/prism.rb
117
130
  - lib/prism/compiler.rb