prism 0.26.0 → 0.27.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/Makefile +3 -2
- data/config.yml +278 -5
- data/ext/prism/api_node.c +70 -72
- data/ext/prism/extconf.rb +23 -4
- data/ext/prism/extension.c +11 -6
- data/ext/prism/extension.h +1 -1
- data/include/prism/ast.h +271 -4
- data/include/prism/diagnostic.h +3 -0
- data/include/prism/version.h +2 -2
- data/lib/prism/ffi.rb +1 -1
- data/lib/prism/lex_compat.rb +18 -1
- data/lib/prism/node.rb +1772 -265
- data/lib/prism/parse_result/newlines.rb +0 -2
- data/lib/prism/parse_result.rb +59 -13
- data/lib/prism/reflection.rb +18 -28
- data/lib/prism/serialize.rb +7 -4
- data/lib/prism/translation/parser/compiler.rb +32 -13
- data/lib/prism/translation/ripper.rb +59 -59
- data/lib/prism/translation/ruby_parser.rb +66 -28
- data/lib/prism.rb +1 -1
- data/prism.gemspec +1 -1
- data/rbi/prism/node.rbi +5 -2
- data/rbi/prism/parse_result.rbi +62 -34
- data/rbi/prism/reflection.rbi +7 -13
- data/rbi/prism.rbi +9 -9
- data/sig/prism/node.rbs +4 -1
- data/sig/prism/parse_result.rbs +30 -10
- data/sig/prism/reflection.rbs +2 -8
- data/sig/prism/serialize.rbs +2 -3
- data/sig/prism.rbs +9 -9
- data/src/diagnostic.c +7 -1
- data/src/prism.c +16 -3
- data/src/util/pm_integer.c +9 -2
- metadata +2 -2
data/ext/prism/api_node.c
CHANGED
@@ -263,21 +263,21 @@ pm_node_stack_pop(pm_node_stack_node_t **stack) {
|
|
263
263
|
|
264
264
|
VALUE
|
265
265
|
pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encoding, VALUE source) {
|
266
|
-
|
266
|
+
VALUE constants = rb_ary_new_capa(parser->constant_pool.size);
|
267
267
|
|
268
268
|
for (uint32_t index = 0; index < parser->constant_pool.size; index++) {
|
269
269
|
pm_constant_t *constant = &parser->constant_pool.constants[index];
|
270
270
|
int state = 0;
|
271
271
|
|
272
272
|
VALUE string = rb_enc_str_new((const char *) constant->start, constant->length, encoding);
|
273
|
-
|
273
|
+
VALUE value = rb_protect(rb_str_intern, string, &state);
|
274
274
|
|
275
275
|
if (state != 0) {
|
276
|
-
value = rb_intern_const("?");
|
276
|
+
value = ID2SYM(rb_intern_const("?"));
|
277
277
|
rb_set_errinfo(Qnil);
|
278
278
|
}
|
279
279
|
|
280
|
-
constants
|
280
|
+
rb_ary_push(constants, value);
|
281
281
|
}
|
282
282
|
|
283
283
|
pm_node_stack_node_t *node_stack = NULL;
|
@@ -1365,7 +1365,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
1365
1365
|
// name
|
1366
1366
|
#line 199 "api_node.c.erb"
|
1367
1367
|
assert(cast->name != 0);
|
1368
|
-
argv[1] =
|
1368
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
1369
1369
|
|
1370
1370
|
// location
|
1371
1371
|
argv[2] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -1448,7 +1448,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
1448
1448
|
// name
|
1449
1449
|
#line 199 "api_node.c.erb"
|
1450
1450
|
assert(cast->name != 0);
|
1451
|
-
argv[2] =
|
1451
|
+
argv[2] = RARRAY_AREF(constants, cast->name - 1);
|
1452
1452
|
|
1453
1453
|
// location
|
1454
1454
|
argv[3] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -1469,7 +1469,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
1469
1469
|
argv[1] = rb_ary_new_capa(cast->locals.size);
|
1470
1470
|
for (size_t index = 0; index < cast->locals.size; index++) {
|
1471
1471
|
assert(cast->locals.ids[index] != 0);
|
1472
|
-
rb_ary_push(argv[1],
|
1472
|
+
rb_ary_push(argv[1], RARRAY_AREF(constants, cast->locals.ids[index] - 1));
|
1473
1473
|
}
|
1474
1474
|
|
1475
1475
|
// parameters
|
@@ -1507,7 +1507,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
1507
1507
|
argv[1] = ULONG2NUM(node->flags & ~PM_NODE_FLAG_COMMON_MASK);
|
1508
1508
|
|
1509
1509
|
// name
|
1510
|
-
argv[2] = cast->name == 0 ? Qnil :
|
1510
|
+
argv[2] = cast->name == 0 ? Qnil : RARRAY_AREF(constants, cast->name - 1);
|
1511
1511
|
|
1512
1512
|
// name_loc
|
1513
1513
|
#line 215 "api_node.c.erb"
|
@@ -1605,12 +1605,12 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
1605
1605
|
// read_name
|
1606
1606
|
#line 199 "api_node.c.erb"
|
1607
1607
|
assert(cast->read_name != 0);
|
1608
|
-
argv[5] =
|
1608
|
+
argv[5] = RARRAY_AREF(constants, cast->read_name - 1);
|
1609
1609
|
|
1610
1610
|
// write_name
|
1611
1611
|
#line 199 "api_node.c.erb"
|
1612
1612
|
assert(cast->write_name != 0);
|
1613
|
-
argv[6] =
|
1613
|
+
argv[6] = RARRAY_AREF(constants, cast->write_name - 1);
|
1614
1614
|
|
1615
1615
|
// operator_loc
|
1616
1616
|
#line 212 "api_node.c.erb"
|
@@ -1649,7 +1649,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
1649
1649
|
// name
|
1650
1650
|
#line 199 "api_node.c.erb"
|
1651
1651
|
assert(cast->name != 0);
|
1652
|
-
argv[4] =
|
1652
|
+
argv[4] = RARRAY_AREF(constants, cast->name - 1);
|
1653
1653
|
|
1654
1654
|
// message_loc
|
1655
1655
|
#line 215 "api_node.c.erb"
|
@@ -1704,17 +1704,17 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
1704
1704
|
// read_name
|
1705
1705
|
#line 199 "api_node.c.erb"
|
1706
1706
|
assert(cast->read_name != 0);
|
1707
|
-
argv[5] =
|
1707
|
+
argv[5] = RARRAY_AREF(constants, cast->read_name - 1);
|
1708
1708
|
|
1709
1709
|
// write_name
|
1710
1710
|
#line 199 "api_node.c.erb"
|
1711
1711
|
assert(cast->write_name != 0);
|
1712
|
-
argv[6] =
|
1712
|
+
argv[6] = RARRAY_AREF(constants, cast->write_name - 1);
|
1713
1713
|
|
1714
1714
|
// operator
|
1715
1715
|
#line 199 "api_node.c.erb"
|
1716
1716
|
assert(cast->operator != 0);
|
1717
|
-
argv[7] =
|
1717
|
+
argv[7] = RARRAY_AREF(constants, cast->operator - 1);
|
1718
1718
|
|
1719
1719
|
// operator_loc
|
1720
1720
|
#line 212 "api_node.c.erb"
|
@@ -1757,12 +1757,12 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
1757
1757
|
// read_name
|
1758
1758
|
#line 199 "api_node.c.erb"
|
1759
1759
|
assert(cast->read_name != 0);
|
1760
|
-
argv[5] =
|
1760
|
+
argv[5] = RARRAY_AREF(constants, cast->read_name - 1);
|
1761
1761
|
|
1762
1762
|
// write_name
|
1763
1763
|
#line 199 "api_node.c.erb"
|
1764
1764
|
assert(cast->write_name != 0);
|
1765
|
-
argv[6] =
|
1765
|
+
argv[6] = RARRAY_AREF(constants, cast->write_name - 1);
|
1766
1766
|
|
1767
1767
|
// operator_loc
|
1768
1768
|
#line 212 "api_node.c.erb"
|
@@ -1801,7 +1801,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
1801
1801
|
// name
|
1802
1802
|
#line 199 "api_node.c.erb"
|
1803
1803
|
assert(cast->name != 0);
|
1804
|
-
argv[4] =
|
1804
|
+
argv[4] = RARRAY_AREF(constants, cast->name - 1);
|
1805
1805
|
|
1806
1806
|
// message_loc
|
1807
1807
|
#line 212 "api_node.c.erb"
|
@@ -1926,7 +1926,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
1926
1926
|
argv[1] = rb_ary_new_capa(cast->locals.size);
|
1927
1927
|
for (size_t index = 0; index < cast->locals.size; index++) {
|
1928
1928
|
assert(cast->locals.ids[index] != 0);
|
1929
|
-
rb_ary_push(argv[1],
|
1929
|
+
rb_ary_push(argv[1], RARRAY_AREF(constants, cast->locals.ids[index] - 1));
|
1930
1930
|
}
|
1931
1931
|
|
1932
1932
|
// class_keyword_loc
|
@@ -1956,7 +1956,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
1956
1956
|
// name
|
1957
1957
|
#line 199 "api_node.c.erb"
|
1958
1958
|
assert(cast->name != 0);
|
1959
|
-
argv[8] =
|
1959
|
+
argv[8] = RARRAY_AREF(constants, cast->name - 1);
|
1960
1960
|
|
1961
1961
|
// location
|
1962
1962
|
argv[9] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -1975,7 +1975,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
1975
1975
|
// name
|
1976
1976
|
#line 199 "api_node.c.erb"
|
1977
1977
|
assert(cast->name != 0);
|
1978
|
-
argv[1] =
|
1978
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
1979
1979
|
|
1980
1980
|
// name_loc
|
1981
1981
|
#line 212 "api_node.c.erb"
|
@@ -2006,7 +2006,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2006
2006
|
// name
|
2007
2007
|
#line 199 "api_node.c.erb"
|
2008
2008
|
assert(cast->name != 0);
|
2009
|
-
argv[1] =
|
2009
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2010
2010
|
|
2011
2011
|
// name_loc
|
2012
2012
|
#line 212 "api_node.c.erb"
|
@@ -2023,7 +2023,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2023
2023
|
// operator
|
2024
2024
|
#line 199 "api_node.c.erb"
|
2025
2025
|
assert(cast->operator != 0);
|
2026
|
-
argv[5] =
|
2026
|
+
argv[5] = RARRAY_AREF(constants, cast->operator - 1);
|
2027
2027
|
|
2028
2028
|
// location
|
2029
2029
|
argv[6] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -2042,7 +2042,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2042
2042
|
// name
|
2043
2043
|
#line 199 "api_node.c.erb"
|
2044
2044
|
assert(cast->name != 0);
|
2045
|
-
argv[1] =
|
2045
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2046
2046
|
|
2047
2047
|
// name_loc
|
2048
2048
|
#line 212 "api_node.c.erb"
|
@@ -2073,7 +2073,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2073
2073
|
// name
|
2074
2074
|
#line 199 "api_node.c.erb"
|
2075
2075
|
assert(cast->name != 0);
|
2076
|
-
argv[1] =
|
2076
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2077
2077
|
|
2078
2078
|
// location
|
2079
2079
|
argv[2] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -2092,7 +2092,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2092
2092
|
// name
|
2093
2093
|
#line 199 "api_node.c.erb"
|
2094
2094
|
assert(cast->name != 0);
|
2095
|
-
argv[1] =
|
2095
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2096
2096
|
|
2097
2097
|
// location
|
2098
2098
|
argv[2] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -2111,7 +2111,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2111
2111
|
// name
|
2112
2112
|
#line 199 "api_node.c.erb"
|
2113
2113
|
assert(cast->name != 0);
|
2114
|
-
argv[1] =
|
2114
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2115
2115
|
|
2116
2116
|
// name_loc
|
2117
2117
|
#line 212 "api_node.c.erb"
|
@@ -2142,7 +2142,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2142
2142
|
// name
|
2143
2143
|
#line 199 "api_node.c.erb"
|
2144
2144
|
assert(cast->name != 0);
|
2145
|
-
argv[1] =
|
2145
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2146
2146
|
|
2147
2147
|
// name_loc
|
2148
2148
|
#line 212 "api_node.c.erb"
|
@@ -2173,7 +2173,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2173
2173
|
// name
|
2174
2174
|
#line 199 "api_node.c.erb"
|
2175
2175
|
assert(cast->name != 0);
|
2176
|
-
argv[1] =
|
2176
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2177
2177
|
|
2178
2178
|
// name_loc
|
2179
2179
|
#line 212 "api_node.c.erb"
|
@@ -2190,7 +2190,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2190
2190
|
// operator
|
2191
2191
|
#line 199 "api_node.c.erb"
|
2192
2192
|
assert(cast->operator != 0);
|
2193
|
-
argv[5] =
|
2193
|
+
argv[5] = RARRAY_AREF(constants, cast->operator - 1);
|
2194
2194
|
|
2195
2195
|
// location
|
2196
2196
|
argv[6] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -2209,7 +2209,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2209
2209
|
// name
|
2210
2210
|
#line 199 "api_node.c.erb"
|
2211
2211
|
assert(cast->name != 0);
|
2212
|
-
argv[1] =
|
2212
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2213
2213
|
|
2214
2214
|
// name_loc
|
2215
2215
|
#line 212 "api_node.c.erb"
|
@@ -2304,7 +2304,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2304
2304
|
// operator
|
2305
2305
|
#line 199 "api_node.c.erb"
|
2306
2306
|
assert(cast->operator != 0);
|
2307
|
-
argv[4] =
|
2307
|
+
argv[4] = RARRAY_AREF(constants, cast->operator - 1);
|
2308
2308
|
|
2309
2309
|
// location
|
2310
2310
|
argv[5] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -2401,7 +2401,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2401
2401
|
// name
|
2402
2402
|
#line 199 "api_node.c.erb"
|
2403
2403
|
assert(cast->name != 0);
|
2404
|
-
argv[1] =
|
2404
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2405
2405
|
|
2406
2406
|
// location
|
2407
2407
|
argv[2] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -2420,7 +2420,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2420
2420
|
// name
|
2421
2421
|
#line 199 "api_node.c.erb"
|
2422
2422
|
assert(cast->name != 0);
|
2423
|
-
argv[1] =
|
2423
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2424
2424
|
|
2425
2425
|
// location
|
2426
2426
|
argv[2] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -2439,7 +2439,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2439
2439
|
// name
|
2440
2440
|
#line 199 "api_node.c.erb"
|
2441
2441
|
assert(cast->name != 0);
|
2442
|
-
argv[1] =
|
2442
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2443
2443
|
|
2444
2444
|
// name_loc
|
2445
2445
|
#line 212 "api_node.c.erb"
|
@@ -2470,7 +2470,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2470
2470
|
// name
|
2471
2471
|
#line 199 "api_node.c.erb"
|
2472
2472
|
assert(cast->name != 0);
|
2473
|
-
argv[1] =
|
2473
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2474
2474
|
|
2475
2475
|
// name_loc
|
2476
2476
|
#line 212 "api_node.c.erb"
|
@@ -2493,7 +2493,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2493
2493
|
argv[6] = rb_ary_new_capa(cast->locals.size);
|
2494
2494
|
for (size_t index = 0; index < cast->locals.size; index++) {
|
2495
2495
|
assert(cast->locals.ids[index] != 0);
|
2496
|
-
rb_ary_push(argv[6],
|
2496
|
+
rb_ary_push(argv[6], RARRAY_AREF(constants, cast->locals.ids[index] - 1));
|
2497
2497
|
}
|
2498
2498
|
|
2499
2499
|
// def_keyword_loc
|
@@ -2854,7 +2854,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2854
2854
|
// name
|
2855
2855
|
#line 199 "api_node.c.erb"
|
2856
2856
|
assert(cast->name != 0);
|
2857
|
-
argv[1] =
|
2857
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2858
2858
|
|
2859
2859
|
// name_loc
|
2860
2860
|
#line 212 "api_node.c.erb"
|
@@ -2885,7 +2885,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2885
2885
|
// name
|
2886
2886
|
#line 199 "api_node.c.erb"
|
2887
2887
|
assert(cast->name != 0);
|
2888
|
-
argv[1] =
|
2888
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2889
2889
|
|
2890
2890
|
// name_loc
|
2891
2891
|
#line 212 "api_node.c.erb"
|
@@ -2902,7 +2902,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2902
2902
|
// operator
|
2903
2903
|
#line 199 "api_node.c.erb"
|
2904
2904
|
assert(cast->operator != 0);
|
2905
|
-
argv[5] =
|
2905
|
+
argv[5] = RARRAY_AREF(constants, cast->operator - 1);
|
2906
2906
|
|
2907
2907
|
// location
|
2908
2908
|
argv[6] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -2921,7 +2921,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2921
2921
|
// name
|
2922
2922
|
#line 199 "api_node.c.erb"
|
2923
2923
|
assert(cast->name != 0);
|
2924
|
-
argv[1] =
|
2924
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2925
2925
|
|
2926
2926
|
// name_loc
|
2927
2927
|
#line 212 "api_node.c.erb"
|
@@ -2952,7 +2952,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2952
2952
|
// name
|
2953
2953
|
#line 199 "api_node.c.erb"
|
2954
2954
|
assert(cast->name != 0);
|
2955
|
-
argv[1] =
|
2955
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2956
2956
|
|
2957
2957
|
// location
|
2958
2958
|
argv[2] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -2971,7 +2971,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2971
2971
|
// name
|
2972
2972
|
#line 199 "api_node.c.erb"
|
2973
2973
|
assert(cast->name != 0);
|
2974
|
-
argv[1] =
|
2974
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2975
2975
|
|
2976
2976
|
// location
|
2977
2977
|
argv[2] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -2990,7 +2990,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
2990
2990
|
// name
|
2991
2991
|
#line 199 "api_node.c.erb"
|
2992
2992
|
assert(cast->name != 0);
|
2993
|
-
argv[1] =
|
2993
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
2994
2994
|
|
2995
2995
|
// name_loc
|
2996
2996
|
#line 212 "api_node.c.erb"
|
@@ -3280,7 +3280,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3280
3280
|
// operator
|
3281
3281
|
#line 199 "api_node.c.erb"
|
3282
3282
|
assert(cast->operator != 0);
|
3283
|
-
argv[8] =
|
3283
|
+
argv[8] = RARRAY_AREF(constants, cast->operator - 1);
|
3284
3284
|
|
3285
3285
|
// operator_loc
|
3286
3286
|
#line 212 "api_node.c.erb"
|
@@ -3395,7 +3395,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3395
3395
|
// name
|
3396
3396
|
#line 199 "api_node.c.erb"
|
3397
3397
|
assert(cast->name != 0);
|
3398
|
-
argv[1] =
|
3398
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
3399
3399
|
|
3400
3400
|
// name_loc
|
3401
3401
|
#line 212 "api_node.c.erb"
|
@@ -3426,7 +3426,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3426
3426
|
// name
|
3427
3427
|
#line 199 "api_node.c.erb"
|
3428
3428
|
assert(cast->name != 0);
|
3429
|
-
argv[1] =
|
3429
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
3430
3430
|
|
3431
3431
|
// name_loc
|
3432
3432
|
#line 212 "api_node.c.erb"
|
@@ -3443,7 +3443,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3443
3443
|
// operator
|
3444
3444
|
#line 199 "api_node.c.erb"
|
3445
3445
|
assert(cast->operator != 0);
|
3446
|
-
argv[5] =
|
3446
|
+
argv[5] = RARRAY_AREF(constants, cast->operator - 1);
|
3447
3447
|
|
3448
3448
|
// location
|
3449
3449
|
argv[6] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -3462,7 +3462,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3462
3462
|
// name
|
3463
3463
|
#line 199 "api_node.c.erb"
|
3464
3464
|
assert(cast->name != 0);
|
3465
|
-
argv[1] =
|
3465
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
3466
3466
|
|
3467
3467
|
// name_loc
|
3468
3468
|
#line 212 "api_node.c.erb"
|
@@ -3493,7 +3493,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3493
3493
|
// name
|
3494
3494
|
#line 199 "api_node.c.erb"
|
3495
3495
|
assert(cast->name != 0);
|
3496
|
-
argv[1] =
|
3496
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
3497
3497
|
|
3498
3498
|
// location
|
3499
3499
|
argv[2] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -3512,7 +3512,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3512
3512
|
// name
|
3513
3513
|
#line 199 "api_node.c.erb"
|
3514
3514
|
assert(cast->name != 0);
|
3515
|
-
argv[1] =
|
3515
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
3516
3516
|
|
3517
3517
|
// location
|
3518
3518
|
argv[2] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -3531,7 +3531,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3531
3531
|
// name
|
3532
3532
|
#line 199 "api_node.c.erb"
|
3533
3533
|
assert(cast->name != 0);
|
3534
|
-
argv[1] =
|
3534
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
3535
3535
|
|
3536
3536
|
// name_loc
|
3537
3537
|
#line 212 "api_node.c.erb"
|
@@ -3781,7 +3781,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3781
3781
|
argv[1] = ULONG2NUM(node->flags & ~PM_NODE_FLAG_COMMON_MASK);
|
3782
3782
|
|
3783
3783
|
// name
|
3784
|
-
argv[2] = cast->name == 0 ? Qnil :
|
3784
|
+
argv[2] = cast->name == 0 ? Qnil : RARRAY_AREF(constants, cast->name - 1);
|
3785
3785
|
|
3786
3786
|
// name_loc
|
3787
3787
|
#line 215 "api_node.c.erb"
|
@@ -3810,7 +3810,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3810
3810
|
argv[1] = rb_ary_new_capa(cast->locals.size);
|
3811
3811
|
for (size_t index = 0; index < cast->locals.size; index++) {
|
3812
3812
|
assert(cast->locals.ids[index] != 0);
|
3813
|
-
rb_ary_push(argv[1],
|
3813
|
+
rb_ary_push(argv[1], RARRAY_AREF(constants, cast->locals.ids[index] - 1));
|
3814
3814
|
}
|
3815
3815
|
|
3816
3816
|
// operator_loc
|
@@ -3862,7 +3862,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3862
3862
|
// name
|
3863
3863
|
#line 199 "api_node.c.erb"
|
3864
3864
|
assert(cast->name != 0);
|
3865
|
-
argv[4] =
|
3865
|
+
argv[4] = RARRAY_AREF(constants, cast->name - 1);
|
3866
3866
|
|
3867
3867
|
// depth
|
3868
3868
|
#line 221 "api_node.c.erb"
|
@@ -3897,12 +3897,12 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3897
3897
|
// name
|
3898
3898
|
#line 199 "api_node.c.erb"
|
3899
3899
|
assert(cast->name != 0);
|
3900
|
-
argv[4] =
|
3900
|
+
argv[4] = RARRAY_AREF(constants, cast->name - 1);
|
3901
3901
|
|
3902
3902
|
// operator
|
3903
3903
|
#line 199 "api_node.c.erb"
|
3904
3904
|
assert(cast->operator != 0);
|
3905
|
-
argv[5] =
|
3905
|
+
argv[5] = RARRAY_AREF(constants, cast->operator - 1);
|
3906
3906
|
|
3907
3907
|
// depth
|
3908
3908
|
#line 221 "api_node.c.erb"
|
@@ -3937,7 +3937,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3937
3937
|
// name
|
3938
3938
|
#line 199 "api_node.c.erb"
|
3939
3939
|
assert(cast->name != 0);
|
3940
|
-
argv[4] =
|
3940
|
+
argv[4] = RARRAY_AREF(constants, cast->name - 1);
|
3941
3941
|
|
3942
3942
|
// depth
|
3943
3943
|
#line 221 "api_node.c.erb"
|
@@ -3960,7 +3960,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3960
3960
|
// name
|
3961
3961
|
#line 199 "api_node.c.erb"
|
3962
3962
|
assert(cast->name != 0);
|
3963
|
-
argv[1] =
|
3963
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
3964
3964
|
|
3965
3965
|
// depth
|
3966
3966
|
#line 221 "api_node.c.erb"
|
@@ -3983,7 +3983,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
3983
3983
|
// name
|
3984
3984
|
#line 199 "api_node.c.erb"
|
3985
3985
|
assert(cast->name != 0);
|
3986
|
-
argv[1] =
|
3986
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
3987
3987
|
|
3988
3988
|
// depth
|
3989
3989
|
#line 221 "api_node.c.erb"
|
@@ -4006,7 +4006,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
4006
4006
|
// name
|
4007
4007
|
#line 199 "api_node.c.erb"
|
4008
4008
|
assert(cast->name != 0);
|
4009
|
-
argv[1] =
|
4009
|
+
argv[1] = RARRAY_AREF(constants, cast->name - 1);
|
4010
4010
|
|
4011
4011
|
// depth
|
4012
4012
|
#line 221 "api_node.c.erb"
|
@@ -4167,7 +4167,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
4167
4167
|
argv[1] = rb_ary_new_capa(cast->locals.size);
|
4168
4168
|
for (size_t index = 0; index < cast->locals.size; index++) {
|
4169
4169
|
assert(cast->locals.ids[index] != 0);
|
4170
|
-
rb_ary_push(argv[1],
|
4170
|
+
rb_ary_push(argv[1], RARRAY_AREF(constants, cast->locals.ids[index] - 1));
|
4171
4171
|
}
|
4172
4172
|
|
4173
4173
|
// module_keyword_loc
|
@@ -4189,7 +4189,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
4189
4189
|
// name
|
4190
4190
|
#line 199 "api_node.c.erb"
|
4191
4191
|
assert(cast->name != 0);
|
4192
|
-
argv[6] =
|
4192
|
+
argv[6] = RARRAY_AREF(constants, cast->name - 1);
|
4193
4193
|
|
4194
4194
|
// location
|
4195
4195
|
argv[7] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -4393,7 +4393,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
4393
4393
|
// name
|
4394
4394
|
#line 199 "api_node.c.erb"
|
4395
4395
|
assert(cast->name != 0);
|
4396
|
-
argv[2] =
|
4396
|
+
argv[2] = RARRAY_AREF(constants, cast->name - 1);
|
4397
4397
|
|
4398
4398
|
// name_loc
|
4399
4399
|
#line 212 "api_node.c.erb"
|
@@ -4424,7 +4424,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
4424
4424
|
// name
|
4425
4425
|
#line 199 "api_node.c.erb"
|
4426
4426
|
assert(cast->name != 0);
|
4427
|
-
argv[2] =
|
4427
|
+
argv[2] = RARRAY_AREF(constants, cast->name - 1);
|
4428
4428
|
|
4429
4429
|
// name_loc
|
4430
4430
|
#line 212 "api_node.c.erb"
|
@@ -4675,7 +4675,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
4675
4675
|
argv[1] = rb_ary_new_capa(cast->locals.size);
|
4676
4676
|
for (size_t index = 0; index < cast->locals.size; index++) {
|
4677
4677
|
assert(cast->locals.ids[index] != 0);
|
4678
|
-
rb_ary_push(argv[1],
|
4678
|
+
rb_ary_push(argv[1], RARRAY_AREF(constants, cast->locals.ids[index] - 1));
|
4679
4679
|
}
|
4680
4680
|
|
4681
4681
|
// statements
|
@@ -4797,7 +4797,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
4797
4797
|
// name
|
4798
4798
|
#line 199 "api_node.c.erb"
|
4799
4799
|
assert(cast->name != 0);
|
4800
|
-
argv[2] =
|
4800
|
+
argv[2] = RARRAY_AREF(constants, cast->name - 1);
|
4801
4801
|
|
4802
4802
|
// name_loc
|
4803
4803
|
#line 212 "api_node.c.erb"
|
@@ -4824,7 +4824,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
4824
4824
|
// name
|
4825
4825
|
#line 199 "api_node.c.erb"
|
4826
4826
|
assert(cast->name != 0);
|
4827
|
-
argv[2] =
|
4827
|
+
argv[2] = RARRAY_AREF(constants, cast->name - 1);
|
4828
4828
|
|
4829
4829
|
// location
|
4830
4830
|
argv[3] = pm_location_new(parser, node->location.start, node->location.end);
|
@@ -4912,7 +4912,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
4912
4912
|
argv[1] = ULONG2NUM(node->flags & ~PM_NODE_FLAG_COMMON_MASK);
|
4913
4913
|
|
4914
4914
|
// name
|
4915
|
-
argv[2] = cast->name == 0 ? Qnil :
|
4915
|
+
argv[2] = cast->name == 0 ? Qnil : RARRAY_AREF(constants, cast->name - 1);
|
4916
4916
|
|
4917
4917
|
// name_loc
|
4918
4918
|
#line 215 "api_node.c.erb"
|
@@ -5010,7 +5010,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
5010
5010
|
argv[1] = rb_ary_new_capa(cast->locals.size);
|
5011
5011
|
for (size_t index = 0; index < cast->locals.size; index++) {
|
5012
5012
|
assert(cast->locals.ids[index] != 0);
|
5013
|
-
rb_ary_push(argv[1],
|
5013
|
+
rb_ary_push(argv[1], RARRAY_AREF(constants, cast->locals.ids[index] - 1));
|
5014
5014
|
}
|
5015
5015
|
|
5016
5016
|
// class_keyword_loc
|
@@ -5479,9 +5479,7 @@ pm_ast_new(const pm_parser_t *parser, const pm_node_t *node, rb_encoding *encodi
|
|
5479
5479
|
}
|
5480
5480
|
}
|
5481
5481
|
|
5482
|
-
|
5483
|
-
xfree(constants);
|
5484
|
-
return result;
|
5482
|
+
return rb_ary_pop(value_stack);
|
5485
5483
|
}
|
5486
5484
|
|
5487
5485
|
void
|
data/ext/prism/extconf.rb
CHANGED
@@ -40,15 +40,34 @@ def generate_templates
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
# We're going to need to run `make` using prism's `Makefile`. We want to match
|
44
|
+
# up as much of the configuration to the configuration that built the current
|
45
|
+
# version of Ruby as possible.
|
43
46
|
require "rbconfig"
|
47
|
+
env = RbConfig::CONFIG.slice("SOEXT", "CPPFLAGS", "CFLAGS", "CC", "AR", "ARFLAGS", "MAKEDIRS", "RMALL")
|
48
|
+
|
49
|
+
# It's possible that the Ruby that is being run wasn't actually compiled on this
|
50
|
+
# machine, in which case the configuration might be incorrect. In this case
|
51
|
+
# we'll need to do some additional checks and potentially fall back to defaults.
|
52
|
+
if env.key?("CC") && !File.exist?(env["CC"])
|
53
|
+
env.delete("CC")
|
54
|
+
env.delete("CFLAGS")
|
55
|
+
env.delete("CPPFLAGS")
|
56
|
+
end
|
57
|
+
|
58
|
+
if env.key?("AR") && !File.exist?(env["AR"])
|
59
|
+
env.delete("AR")
|
60
|
+
env.delete("ARFLAGS")
|
61
|
+
end
|
44
62
|
|
45
63
|
# Runs `make` in the root directory of the project. Note that this is the
|
46
64
|
# `Makefile` for the overall project, not the `Makefile` that is being generated
|
47
65
|
# by this script.`
|
48
|
-
def make(target)
|
66
|
+
def make(env, target)
|
67
|
+
puts "Running make #{target} with #{env.inspect}"
|
49
68
|
Dir.chdir(File.expand_path("../..", __dir__)) do
|
50
69
|
system(
|
51
|
-
|
70
|
+
env,
|
52
71
|
RUBY_PLATFORM.include?("openbsd") ? "gmake" : "make",
|
53
72
|
target,
|
54
73
|
exception: true
|
@@ -62,7 +81,7 @@ end
|
|
62
81
|
# but we want to use the native toolchain here since libprism is run natively.
|
63
82
|
if RUBY_ENGINE != "ruby"
|
64
83
|
generate_templates
|
65
|
-
make("build/libprism.#{RbConfig::CONFIG["SOEXT"]}")
|
84
|
+
make(env, "build/libprism.#{RbConfig::CONFIG["SOEXT"]}")
|
66
85
|
File.write("Makefile", "all install clean:\n\t@#{RbConfig::CONFIG["NULLCMD"]}\n")
|
67
86
|
return
|
68
87
|
end
|
@@ -110,7 +129,7 @@ append_cflags("-fvisibility=hidden")
|
|
110
129
|
archive_target = "build/libprism.a"
|
111
130
|
archive_path = File.expand_path("../../#{archive_target}", __dir__)
|
112
131
|
|
113
|
-
make(archive_target) unless File.exist?(archive_path)
|
132
|
+
make(env, archive_target) unless File.exist?(archive_path)
|
114
133
|
$LOCAL_LIBS << " #{archive_path}"
|
115
134
|
|
116
135
|
# Finally, we'll create the `Makefile` that is going to be used to configure and
|