@@ -1653,12 +1653,13 @@ pm_break_node_create(pm_parser_t *parser, const pm_token_t *keyword, pm_argument
1653
1653
* in the various specializations of this function.
1654
1654
*/
1655
1655
static pm_call_node_t *
1656
- pm_call_node_create(pm_parser_t *parser) {
1656
+ pm_call_node_create(pm_parser_t *parser, pm_node_flags_t flags ) {
1657
1657
pm_call_node_t *node = PM_ALLOC_NODE(parser, pm_call_node_t);
1658
1658
1659
1659
*node = (pm_call_node_t) {
1660
1660
{
1661
1661
.type = PM_CALL_NODE,
1662
+ .flags = flags,
1662
1663
.location = PM_LOCATION_NULL_VALUE(parser),
1663
1664
},
1664
1665
.receiver = NULL,
@@ -1674,6 +1675,15 @@ pm_call_node_create(pm_parser_t *parser) {
1674
1675
return node;
1675
1676
}
1676
1677
1678
+ /**
1679
+ * Returns the value that the ignore visibility flag should be set to for the
1680
+ * given receiver.
1681
+ */
1682
+ static inline pm_node_flags_t
1683
+ pm_call_node_ignore_visibility_flag(const pm_node_t *receiver) {
1684
+ return PM_NODE_TYPE_P(receiver, PM_SELF_NODE) ? PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY : 0;
1685
+ }
1686
+
1677
1687
/**
1678
1688
* Allocate and initialize a new CallNode node from an aref or an aset
1679
1689
* expression.
@@ -1682,7 +1692,7 @@ static pm_call_node_t *
1682
1692
pm_call_node_aref_create(pm_parser_t *parser, pm_node_t *receiver, pm_arguments_t *arguments) {
1683
1693
pm_assert_value_expression(parser, receiver);
1684
1694
1685
- pm_call_node_t *node = pm_call_node_create(parser);
1695
+ pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver) );
1686
1696
1687
1697
node->base.location.start = receiver->location.start;
1688
1698
node->base.location.end = pm_arguments_end(arguments);
@@ -1708,7 +1718,7 @@ pm_call_node_binary_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t
1708
1718
pm_assert_value_expression(parser, receiver);
1709
1719
pm_assert_value_expression(parser, argument);
1710
1720
1711
- pm_call_node_t *node = pm_call_node_create(parser);
1721
+ pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver) );
1712
1722
1713
1723
node->base.location.start = MIN(receiver->location.start, argument->location.start);
1714
1724
node->base.location.end = MAX(receiver->location.end, argument->location.end);
@@ -1731,7 +1741,7 @@ static pm_call_node_t *
1731
1741
pm_call_node_call_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t *operator, pm_token_t *message, pm_arguments_t *arguments) {
1732
1742
pm_assert_value_expression(parser, receiver);
1733
1743
1734
- pm_call_node_t *node = pm_call_node_create(parser);
1744
+ pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver) );
1735
1745
1736
1746
node->base.location.start = receiver->location.start;
1737
1747
const uint8_t *end = pm_arguments_end(arguments);
@@ -1762,7 +1772,7 @@ pm_call_node_call_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t *o
1762
1772
*/
1763
1773
static pm_call_node_t *
1764
1774
pm_call_node_fcall_create(pm_parser_t *parser, pm_token_t *message, pm_arguments_t *arguments) {
1765
- pm_call_node_t *node = pm_call_node_create(parser);
1775
+ pm_call_node_t *node = pm_call_node_create(parser, PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY );
1766
1776
1767
1777
node->base.location.start = message->start;
1768
1778
node->base.location.end = pm_arguments_end(arguments);
@@ -1784,7 +1794,7 @@ static pm_call_node_t *
1784
1794
pm_call_node_not_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t *message, pm_arguments_t *arguments) {
1785
1795
pm_assert_value_expression(parser, receiver);
1786
1796
1787
- pm_call_node_t *node = pm_call_node_create(parser);
1797
+ pm_call_node_t *node = pm_call_node_create(parser, receiver == NULL ? 0 : pm_call_node_ignore_visibility_flag(receiver) );
1788
1798
1789
1799
node->base.location.start = message->start;
1790
1800
if (arguments->closing_loc.start != NULL) {
@@ -1810,7 +1820,7 @@ static pm_call_node_t *
1810
1820
pm_call_node_shorthand_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t *operator, pm_arguments_t *arguments) {
1811
1821
pm_assert_value_expression(parser, receiver);
1812
1822
1813
- pm_call_node_t *node = pm_call_node_create(parser);
1823
+ pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver) );
1814
1824
1815
1825
node->base.location.start = receiver->location.start;
1816
1826
node->base.location.end = pm_arguments_end(arguments);
@@ -1837,7 +1847,7 @@ static pm_call_node_t *
1837
1847
pm_call_node_unary_create(pm_parser_t *parser, pm_token_t *operator, pm_node_t *receiver, const char *name) {
1838
1848
pm_assert_value_expression(parser, receiver);
1839
1849
1840
- pm_call_node_t *node = pm_call_node_create(parser);
1850
+ pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver) );
1841
1851
1842
1852
node->base.location.start = operator->start;
1843
1853
node->base.location.end = receiver->location.end;
@@ -1855,7 +1865,7 @@ pm_call_node_unary_create(pm_parser_t *parser, pm_token_t *operator, pm_node_t *
1855
1865
*/
1856
1866
static pm_call_node_t *
1857
1867
pm_call_node_variable_call_create(pm_parser_t *parser, pm_token_t *message) {
1858
- pm_call_node_t *node = pm_call_node_create(parser);
1868
+ pm_call_node_t *node = pm_call_node_create(parser, PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY );
1859
1869
1860
1870
node->base.location = PM_LOCATION_TOKEN_VALUE(message);
1861
1871
node->message_loc = PM_OPTIONAL_LOCATION_TOKEN_VALUE(message);
0 commit comments