@@ -1692,12 +1692,24 @@ pm_eval_make_iseq(VALUE src, VALUE fname, int line,
16921692 iseq = parent ;
16931693 rb_encoding * encoding = rb_enc_get (src );
16941694
1695+ #define FORWARDING_POSITIONALS_CHR '*'
1696+ #define FORWARDING_POSITIONALS_STR "*"
1697+ #define FORWARDING_KEYWORDS_CHR ':'
1698+ #define FORWARDING_KEYWORDS_STR ":"
1699+ #define FORWARDING_BLOCK_CHR '&'
1700+ #define FORWARDING_BLOCK_STR "&"
1701+ #define FORWARDING_ALL_CHR '.'
1702+ #define FORWARDING_ALL_STR "."
1703+
16951704 for (int scopes_index = 0 ; scopes_index < scopes_count ; scopes_index ++ ) {
16961705 VALUE iseq_value = (VALUE )iseq ;
16971706 int locals_count = ISEQ_BODY (iseq )-> local_table_size ;
1707+
16981708 pm_options_scope_t * options_scope = & result .options .scopes [scopes_count - scopes_index - 1 ];
16991709 pm_options_scope_init (options_scope , locals_count );
17001710
1711+ uint8_t forwarding = PM_OPTIONS_SCOPE_FORWARDING_NONE ;
1712+
17011713 for (int local_index = 0 ; local_index < locals_count ; local_index ++ ) {
17021714 pm_string_t * scope_local = & options_scope -> locals [local_index ];
17031715 ID local = ISEQ_BODY (iseq )-> local_table [local_index ];
@@ -1729,10 +1741,23 @@ pm_eval_make_iseq(VALUE src, VALUE fname, int line,
17291741
17301742 RB_GC_GUARD (name_obj );
17311743
1732- pm_string_owned_init (scope_local , (uint8_t * )name_dup , length );
1744+ pm_string_owned_init (scope_local , (uint8_t * ) name_dup , length );
1745+ } else if (local == idMULT ) {
1746+ forwarding |= PM_OPTIONS_SCOPE_FORWARDING_POSITIONALS ;
1747+ pm_string_constant_init (scope_local , FORWARDING_POSITIONALS_STR , 1 );
1748+ } else if (local == idPow ) {
1749+ forwarding |= PM_OPTIONS_SCOPE_FORWARDING_KEYWORDS ;
1750+ pm_string_constant_init (scope_local , FORWARDING_KEYWORDS_STR , 1 );
1751+ } else if (local == idAnd ) {
1752+ forwarding |= PM_OPTIONS_SCOPE_FORWARDING_BLOCK ;
1753+ pm_string_constant_init (scope_local , FORWARDING_BLOCK_STR , 1 );
1754+ } else if (local == idDot3 ) {
1755+ forwarding |= PM_OPTIONS_SCOPE_FORWARDING_ALL ;
1756+ pm_string_constant_init (scope_local , FORWARDING_ALL_STR , 1 );
17331757 }
17341758 }
17351759
1760+ pm_options_scope_forwarding_set (options_scope , forwarding );
17361761 iseq = ISEQ_BODY (iseq )-> parent_iseq ;
17371762
17381763 /* We need to GC guard the iseq because the code above malloc memory
@@ -1775,14 +1800,38 @@ pm_eval_make_iseq(VALUE src, VALUE fname, int line,
17751800
17761801 for (int local_index = 0 ; local_index < locals_count ; local_index ++ ) {
17771802 const pm_string_t * scope_local = & options_scope -> locals [local_index ];
1778-
17791803 pm_constant_id_t constant_id = 0 ;
1780- if (pm_string_length (scope_local ) > 0 ) {
1781- constant_id = pm_constant_pool_insert_constant (
1782- & result .parser .constant_pool , pm_string_source (scope_local ),
1783- pm_string_length (scope_local ));
1784- st_insert (parent_scope -> index_lookup_table , (st_data_t )constant_id , (st_data_t )local_index );
1804+
1805+ const uint8_t * source = pm_string_source (scope_local );
1806+ size_t length = pm_string_length (scope_local );
1807+
1808+ if (length > 0 ) {
1809+ if (length == 1 ) {
1810+ switch (* source ) {
1811+ case FORWARDING_POSITIONALS_CHR :
1812+ constant_id = PM_CONSTANT_MULT ;
1813+ break ;
1814+ case FORWARDING_KEYWORDS_CHR :
1815+ constant_id = PM_CONSTANT_POW ;
1816+ break ;
1817+ case FORWARDING_BLOCK_CHR :
1818+ constant_id = PM_CONSTANT_AND ;
1819+ break ;
1820+ case FORWARDING_ALL_CHR :
1821+ constant_id = PM_CONSTANT_DOT3 ;
1822+ break ;
1823+ default :
1824+ constant_id = pm_constant_pool_insert_constant (& result .parser .constant_pool , source , length );
1825+ break ;
1826+ }
1827+ }
1828+ else {
1829+ constant_id = pm_constant_pool_insert_constant (& result .parser .constant_pool , source , length );
1830+ }
1831+
1832+ st_insert (parent_scope -> index_lookup_table , (st_data_t ) constant_id , (st_data_t ) local_index );
17851833 }
1834+
17861835 pm_constant_id_list_append (& parent_scope -> locals , constant_id );
17871836 }
17881837
@@ -1791,6 +1840,15 @@ pm_eval_make_iseq(VALUE src, VALUE fname, int line,
17911840 iseq = ISEQ_BODY (iseq )-> parent_iseq ;
17921841 }
17931842
1843+ #undef FORWARDING_POSITIONALS_CHR
1844+ #undef FORWARDING_POSITIONALS_STR
1845+ #undef FORWARDING_KEYWORDS_CHR
1846+ #undef FORWARDING_KEYWORDS_STR
1847+ #undef FORWARDING_BLOCK_CHR
1848+ #undef FORWARDING_BLOCK_STR
1849+ #undef FORWARDING_ALL_CHR
1850+ #undef FORWARDING_ALL_STR
1851+
17941852 int error_state ;
17951853 iseq = pm_iseq_new_eval (& result .node , name , fname , Qnil , line , parent , 0 , & error_state );
17961854
0 commit comments