"Fossies" - the Fresh Open Source Software Archive

Member "rakudo-star-2020.10/src/rakudo-2020.10/rakudo-2020.10/src/core.c/SLICE.pm6" (25 Oct 2020, 33300 Bytes) of package /linux/misc/rakudo-star-2020.10.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #===============================================================================
    2 #
    3 # This file has been generated by tools/build/makeSLICE.raku
    4 # on 2020-03-19T14:52:51.258447Z.
    5 #
    6 # Please do *NOT* make changes to this file, as they will be lost
    7 # whenever this file is generated again.
    8 #
    9 #===============================================================================
   10 
   11 # internal 1 element list access with adverbs
   12 sub SLICE_ONE_LIST(\SELF,$one,$key,$value,%adv) { # is implementation-detail
   13     my Mu $d := nqp::clone(nqp::getattr(%adv,Map,'$!storage'));
   14     nqp::bindkey($d,nqp::unbox_s($key),nqp::decont($value));
   15 
   16     sub HANDLED($key) {
   17         nqp::if(
   18           nqp::existskey($d,nqp::unbox_s($key)),
   19           nqp::stmts(
   20             (my $value := nqp::atkey($d,$key)),
   21             nqp::deletekey($d,$key),
   22             $value
   23           ),
   24           Nil
   25         )
   26     }
   27 
   28     my @nogo;
   29     my \result = do {
   30 
   31         if HANDLED('delete') {            # :delete:*
   32             if nqp::elems($d) == 0 {          # :delete
   33                 SELF.DELETE-POS($one);
   34             }
   35             elsif nqp::existskey($d,'exists') { # :delete:exists(0|1):*
   36                 my $exists   := HANDLED('exists');
   37                 my $wasthere := SELF.EXISTS-POS($one);
   38                 SELF.DELETE-POS($one);
   39                 if nqp::elems($d) == 0 {          # :delete:exists(0|1)
   40                     !( $wasthere ?^ $exists )
   41                 }
   42                 elsif nqp::existskey($d,'kv') {   # :delete:exists(0|1):kv(0|1)
   43                     my $kv := HANDLED('kv');
   44                     if nqp::elems($d) == 0 {
   45                         !$kv || $wasthere
   46                           ?? ( $one, !( $wasthere ?^ $exists ) )
   47                           !! ();
   48                     }
   49                     else {
   50                         @nogo = <delete exists kv>;
   51                     }
   52                 }
   53                 elsif nqp::existskey($d,'p') {    # :delete:exists(0|1):p(0|1)
   54                     my $p := HANDLED('p');
   55                     if nqp::elems($d) == 0 {
   56                         !$p || $wasthere
   57                           ?? Pair.new($one, !($wasthere ?^ $exists) )
   58                           !! ();
   59                     }
   60                     else {
   61                         @nogo = <delete exists p>;
   62                     }
   63                 }
   64                 else {
   65                     @nogo = <delete exists>;
   66                 }
   67             }
   68             elsif nqp::existskey($d,'kv') {    # :delete:kv(0|1)
   69                 my $kv := HANDLED('kv');
   70                 if nqp::elems($d) == 0 {
   71                     !$kv || SELF.EXISTS-POS($one)
   72                       ?? ( $one, SELF.DELETE-POS($one) )
   73                       !! ();
   74                 }
   75                 else {
   76                     @nogo = <delete kv>;
   77                 }
   78             }
   79             elsif nqp::existskey($d,'p') {     # :delete:p(0|1)
   80                 my $p := HANDLED('p');
   81                 if nqp::elems($d) == 0 {
   82                     !$p || SELF.EXISTS-POS($one)
   83                       ?? Pair.new($one, SELF.DELETE-POS($one))
   84                       !! ();
   85                 }
   86                 else {
   87                     @nogo = <delete p>;
   88                 }
   89             }
   90             elsif nqp::existskey($d,'k') {     # :delete:k(0|1)
   91                 my $k := HANDLED('k');
   92                 if nqp::elems($d) == 0 {
   93                     !$k || SELF.EXISTS-POS($one)
   94                       ?? do { SELF.DELETE-POS($one); $one }
   95                       !! ();
   96                 }
   97                 else {
   98                     @nogo = <delete k>;
   99                 }
  100             }
  101             elsif nqp::existskey($d,'v') {     # :delete:v(0|1)
  102                 my $v := HANDLED('v');
  103                 if nqp::elems($d) == 0 {
  104                     !$v || SELF.EXISTS-POS($one)
  105                       ?? SELF.DELETE-POS($one)
  106                       !! ();
  107                 }
  108                 else {
  109                     @nogo = <delete v>;
  110                 }
  111             }
  112             else {
  113                 @nogo = <delete>;
  114             }
  115         }
  116         elsif nqp::existskey($d,'exists') {  # :!delete?:exists(0|1):*
  117             my $exists  := HANDLED('exists');
  118             my $wasthere = SELF.EXISTS-POS($one);
  119             if nqp::elems($d) == 0 {           # :!delete?:exists(0|1)
  120                 !( $wasthere ?^ $exists )
  121             }
  122             elsif nqp::existskey($d,'kv') {    # :!delete?:exists(0|1):kv(0|1)
  123                 my $kv := HANDLED('kv');
  124                 if nqp::elems($d) == 0 {
  125                     !$kv || $wasthere
  126                       ?? ( $one, !( $wasthere ?^ $exists ) )
  127                       !! ();
  128                 }
  129                 else {
  130                     @nogo = <exists kv>;
  131                 }
  132             }
  133             elsif nqp::existskey($d,'p') {     # :!delete?:exists(0|1):p(0|1)
  134                 my $p := HANDLED('p');
  135                 if nqp::elems($d) == 0 {
  136                     !$p || $wasthere
  137                       ?? Pair.new($one, !( $wasthere ?^ $exists ))
  138                       !! ();
  139                 }
  140                 else {
  141                     @nogo = <exists p>;
  142                 }
  143             }
  144             else {
  145                 @nogo = <exists>;
  146             }
  147         }
  148         elsif nqp::existskey($d,'kv') {      # :!delete?:kv(0|1):*
  149             my $kv := HANDLED('kv');
  150             if nqp::elems($d) == 0 {           # :!delete?:kv(0|1)
  151                 !$kv || SELF.EXISTS-POS($one)
  152                   ?? ($one, SELF.AT-POS($one))
  153                   !! ();
  154             }
  155             else {
  156                 @nogo = <kv>;
  157             }
  158         }
  159         elsif nqp::existskey($d,'p') {       # :!delete?:p(0|1):*
  160             my $p := HANDLED('p');
  161             if nqp::elems($d) == 0 {           # :!delete?:p(0|1)
  162                 !$p || SELF.EXISTS-POS($one)
  163                   ?? Pair.new($one, SELF.AT-POS($one))
  164                   !! ();
  165             }
  166             else {
  167                 @nogo = <p>;
  168             }
  169         }
  170         elsif nqp::existskey($d,'k') {       # :!delete?:k(0|1):*
  171             my $k := HANDLED('k');
  172             if nqp::elems($d) == 0 {           # :!delete?:k(0|1)
  173                 !$k || SELF.EXISTS-POS($one)
  174                   ?? $one
  175                   !! ();
  176             }
  177             else {
  178                 @nogo = <k>;
  179             }
  180         }
  181         elsif nqp::existskey($d,'v') {       # :!delete?:v(0|1):*
  182             my $v := HANDLED('v');             # :!delete?:v(0|1)
  183             if nqp::elems($d) == 0 {
  184                 !$v || SELF.EXISTS-POS($one)
  185                   ?? SELF.AT-POS($one)
  186                   !! ();
  187             }
  188             else {
  189                 @nogo = <v>;
  190             }
  191         }
  192         elsif nqp::elems($d) == 0 {           # :!delete
  193             SELF.AT-POS($one);
  194         }
  195     }
  196 
  197     @nogo || nqp::elems($d)
  198       ?? Rakudo::Internals.SLICE_HUH( SELF, @nogo, $d, %adv )
  199       !! result;
  200 } #SLICE_ONE_LIST
  201 
  202 # internal >1 element list access with adverbs
  203 sub SLICE_MORE_LIST(\SELF,$more,$key,$value,%adv) { # is implementation-detail
  204     my Mu $d := nqp::clone(nqp::getattr(%adv,Map,'$!storage'));
  205     nqp::bindkey($d,nqp::unbox_s($key),nqp::decont($value));
  206 
  207     sub HANDLED($key) {
  208         nqp::if(
  209           nqp::existskey($d,nqp::unbox_s($key)),
  210           nqp::stmts(
  211             (my $value := nqp::atkey($d,$key)),
  212             nqp::deletekey($d,$key),
  213             $value
  214           ),
  215           Nil
  216         )
  217     }
  218 
  219     my @nogo;
  220     my \result = do {
  221 
  222         if HANDLED('delete') {            # :delete:*
  223             if nqp::elems($d) == 0 {          # :delete
  224                 $more.cache.flatmap( { SELF.DELETE-POS($_) } ).eager.list;
  225             }
  226             elsif nqp::existskey($d,'exists') { # :delete:exists(0|1):*
  227                 my $exists := HANDLED('exists');
  228                 my $wasthere; # no need to initialize every iteration of map
  229                 if nqp::elems($d) == 0 {          # :delete:exists(0|1)
  230                     $more.cache.flatmap( {
  231                         SELF.DELETE-POS($_) if $wasthere = SELF.EXISTS-POS($_);
  232                         !( $wasthere ?^ $exists );
  233                     } ).eager.list;
  234                 }
  235                 elsif nqp::existskey($d,'kv') { # :delete:exists(0|1):kv(0|1):*
  236                     my $kv := HANDLED('kv');
  237                     if nqp::elems($d) == 0 {      # :delete:exists(0|1):kv(0|1)
  238                         $more.cache.flatmap( {
  239                             SELF.DELETE-POS($_) if $wasthere = SELF.EXISTS-POS($_);
  240                             next unless !$kv || $wasthere;
  241                             ($_, !( $wasthere ?^ $exists ));
  242                         } ).flat.eager.list;
  243                     }
  244                     else {
  245                         @nogo = <delete exists kv>;
  246                     }
  247                 }
  248                 elsif nqp::existskey($d,'p') {  # :delete:exists(0|1):p(0|1):*
  249                     my $p := HANDLED('p');
  250                     if nqp::elems($d) == 0 {      # :delete:exists(0|1):p(0|1)
  251                         $more.cache.flatmap( {
  252                             SELF.DELETE-POS($_) if $wasthere = SELF.EXISTS-POS($_);
  253                             next unless !$p || $wasthere;
  254                             Pair.new($_,!($wasthere ?^ $exists));
  255                         } ).eager.list;
  256                     }
  257                     else {
  258                         @nogo = <delete exists p>;
  259                     }
  260                 }
  261                 else {
  262                     @nogo = <delete exists>;
  263                 }
  264             }
  265             elsif nqp::existskey($d,'kv') {     # :delete:kv(0|1):*
  266                 my $kv := HANDLED('kv');
  267                 if nqp::elems($d) == 0 {          # :delete:kv(0|1)
  268                     $kv
  269                       ?? $more.cache.flatmap( {
  270                              next unless SELF.EXISTS-POS($_);
  271                              ( $_, SELF.DELETE-POS($_) );
  272                          } ).flat.eager.list
  273                       !! $more.cache.flatmap( {
  274                              ( $_, SELF.DELETE-POS($_) )
  275                          } ).flat.eager.list;
  276                 }
  277                 else {
  278                     @nogo = <delete kv>;
  279                 }
  280             }
  281             elsif nqp::existskey($d,'p') {      # :delete:p(0|1):*
  282                 my $p := HANDLED('p');
  283                 if nqp::elems($d) == 0 {          # :delete:p(0|1)
  284                     $p
  285                       ?? $more.cache.flatmap( {
  286                              next unless SELF.EXISTS-POS($_);
  287                              Pair.new($_, SELF.DELETE-POS($_));
  288                          } ).eager.list
  289                       !! $more.cache.flatmap( {
  290                              Pair.new($_, SELF.DELETE-POS($_))
  291                          } ).eager.list;
  292                 }
  293                 else {
  294                     @nogo = <delete p>;
  295                 }
  296             }
  297             elsif nqp::existskey($d,'k') {     # :delete:k(0|1):*
  298                 my $k := HANDLED('k');
  299                 if nqp::elems($d) == 0 {          # :delete:k(0|1)
  300                     $k
  301                       ?? $more.cache.flatmap( {
  302                              nqp::if(
  303                                SELF.EXISTS-POS($_),
  304                                nqp::stmts(
  305                                  SELF.DELETE-POS($_),
  306                                  $_
  307                                ),
  308                                next
  309                              )
  310                          } ).eager.list
  311                       !! $more.cache.flatmap( {
  312                              SELF.DELETE-POS($_); $_
  313                          } ).eager.list;
  314                 }
  315                 else {
  316                     @nogo = <delete k>;
  317                 }
  318             }
  319             elsif nqp::existskey($d,'v') {      # :delete:v(0|1):*
  320                 my $v := HANDLED('v');
  321                 if nqp::elems($d) == 0 {          # :delete:v(0|1)
  322                     $v
  323                       ?? $more.cache.flatmap( {
  324                              next unless SELF.EXISTS-POS($_);
  325                              SELF.DELETE-POS($_);
  326                      } ).eager.list
  327                       !! $more.cache.flatmap( {
  328                              SELF.DELETE-POS($_)
  329                      } ).eager.list;
  330                 }
  331                 else {
  332                     @nogo = <delete v>;
  333                 }
  334             }
  335             else {
  336                 @nogo = <delete>;
  337             }
  338         }
  339         elsif nqp::existskey($d,'exists') { # :!delete?:exists(0|1):*
  340             my $exists := HANDLED('exists');
  341             if nqp::elems($d) == 0 {          # :!delete?:exists(0|1)
  342                 $more.cache.flatmap({ !( SELF.EXISTS-POS($_) ?^ $exists ) }).eager.list;
  343             }
  344             elsif nqp::existskey($d,'kv') {   # :!delete?:exists(0|1):kv(0|1):*
  345                 my $kv := HANDLED('kv');
  346                 if nqp::elems($d) == 0 {        # :!delete?:exists(0|1):kv(0|1)
  347                     $kv
  348                       ?? $more.cache.flatmap( {
  349                              next unless SELF.EXISTS-POS($_);
  350                              ( $_, $exists );
  351                          } ).flat.eager.list
  352                       !! $more.cache.flatmap( {
  353                              ( $_, !( SELF.EXISTS-POS($_) ?^ $exists ) )
  354                          } ).flat.eager.list;
  355                 }
  356                 else {
  357                     @nogo = <exists kv>;
  358                 }
  359             }
  360             elsif nqp::existskey($d,'p') {  # :!delete?:exists(0|1):p(0|1):*
  361                 my $p := HANDLED('p');
  362                 if nqp::elems($d) == 0 {      # :!delete?:exists(0|1):p(0|1)
  363                     $p
  364                       ?? $more.cache.flatmap( {
  365                              next unless SELF.EXISTS-POS($_);
  366                              Pair.new( $_, $exists );
  367                          } ).eager.list
  368                       !! $more.cache.flatmap( {
  369                              Pair.new( $_, !( SELF.EXISTS-POS($_) ?^ $exists ) )
  370                          } ).eager.list;
  371                 }
  372                 else {
  373                     @nogo = <exists p>;
  374                 }
  375             }
  376             else {
  377                 @nogo = <exists>;
  378             }
  379         }
  380         elsif nqp::existskey($d,'kv') {     # :!delete?:kv(0|1):*
  381             my $kv := HANDLED('kv');
  382             if nqp::elems($d) == 0 {          # :!delete?:kv(0|1)
  383                 $kv
  384                   ?? $more.cache.flatmap( {
  385                          next unless SELF.EXISTS-POS($_);
  386                          $_, SELF.AT-POS($_);
  387                      } ).flat.eager.list
  388                   !! $more.cache.flatmap( {
  389                          $_, SELF.AT-POS($_)
  390                      } ).flat.eager.list;
  391             }
  392             else {
  393                 @nogo = <kv>;
  394             }
  395         }
  396         elsif nqp::existskey($d,'p') {      # :!delete?:p(0|1):*
  397             my $p := HANDLED('p');
  398             if nqp::elems($d) == 0 {          # :!delete?:p(0|1)
  399                 $p
  400                   ?? $more.cache.flatmap( {
  401                          next unless SELF.EXISTS-POS($_);
  402                          Pair.new($_, SELF.AT-POS($_));
  403                      } ).eager.list
  404                   !! $more.cache.flatmap( {
  405                          Pair.new( $_, SELF.AT-POS($_) )
  406                      } ).eager.list;
  407             }
  408             else {
  409                 @nogo = <p>
  410             }
  411         }
  412         elsif nqp::existskey($d,'k') {      # :!delete?:k(0|1):*
  413             my $k := HANDLED('k');
  414             if nqp::elems($d) == 0 {          # :!delete?:k(0|1)
  415                 $k
  416                   ?? $more.cache.flatmap( {
  417                          next unless SELF.EXISTS-POS($_);
  418                          $_;
  419                      } ).eager.list
  420                   !! $more.cache.flat.eager.list;
  421             }
  422             else {
  423                 @nogo = <k>;
  424             }
  425         }
  426         elsif nqp::existskey($d,'v') {      # :!delete?:v(0|1):*
  427             my $v := HANDLED('v');
  428             if nqp::elems($d) == 0 {          # :!delete?:v(0|1)
  429                 $v
  430                   ??  $more.cache.flatmap( {
  431                           next unless SELF.EXISTS-POS($_);
  432                           SELF.AT-POS($_);
  433                       } ).eager.list
  434                   !!  $more.cache.flatmap( {
  435                           SELF.AT-POS($_)
  436                       } ).eager.list;
  437             }
  438             else {
  439                 @nogo = <v>;
  440             }
  441         }
  442         elsif nqp::elems($d) == 0 {         # :!delete
  443             $more.cache.flatmap( { SELF.AT-POS($_) } ).eager.list;
  444         }
  445     }
  446 
  447     @nogo || nqp::elems($d)
  448       ?? Rakudo::Internals.SLICE_HUH( SELF, @nogo, $d, %adv )
  449       !! result;
  450 } #SLICE_MORE_LIST
  451 
  452 
  453 # internal 1 element hash access with adverbs
  454 sub SLICE_ONE_HASH(\SELF,$one,$key,$value,%adv) { # is implementation-detail
  455     my Mu $d := nqp::clone(nqp::getattr(%adv,Map,'$!storage'));
  456     nqp::bindkey($d,nqp::unbox_s($key),nqp::decont($value));
  457 
  458     sub HANDLED($key) {
  459         nqp::if(
  460           nqp::existskey($d,nqp::unbox_s($key)),
  461           nqp::stmts(
  462             (my $value := nqp::atkey($d,$key)),
  463             nqp::deletekey($d,$key),
  464             $value
  465           ),
  466           Nil
  467         )
  468     }
  469 
  470     my @nogo;
  471     my \result = do {
  472 
  473         if HANDLED('delete') {            # :delete:*
  474             if nqp::elems($d) == 0 {          # :delete
  475                 SELF.DELETE-KEY($one);
  476             }
  477             elsif nqp::existskey($d,'exists') { # :delete:exists(0|1):*
  478                 my $exists   := HANDLED('exists');
  479                 my $wasthere := SELF.EXISTS-KEY($one);
  480                 SELF.DELETE-KEY($one);
  481                 if nqp::elems($d) == 0 {          # :delete:exists(0|1)
  482                     !( $wasthere ?^ $exists )
  483                 }
  484                 elsif nqp::existskey($d,'kv') {   # :delete:exists(0|1):kv(0|1)
  485                     my $kv := HANDLED('kv');
  486                     if nqp::elems($d) == 0 {
  487                         !$kv || $wasthere
  488                           ?? ( $one, !( $wasthere ?^ $exists ) )
  489                           !! ();
  490                     }
  491                     else {
  492                         @nogo = <delete exists kv>;
  493                     }
  494                 }
  495                 elsif nqp::existskey($d,'p') {    # :delete:exists(0|1):p(0|1)
  496                     my $p := HANDLED('p');
  497                     if nqp::elems($d) == 0 {
  498                         !$p || $wasthere
  499                           ?? Pair.new($one, !($wasthere ?^ $exists) )
  500                           !! ();
  501                     }
  502                     else {
  503                         @nogo = <delete exists p>;
  504                     }
  505                 }
  506                 else {
  507                     @nogo = <delete exists>;
  508                 }
  509             }
  510             elsif nqp::existskey($d,'kv') {    # :delete:kv(0|1)
  511                 my $kv := HANDLED('kv');
  512                 if nqp::elems($d) == 0 {
  513                     !$kv || SELF.EXISTS-KEY($one)
  514                       ?? ( $one, SELF.DELETE-KEY($one) )
  515                       !! ();
  516                 }
  517                 else {
  518                     @nogo = <delete kv>;
  519                 }
  520             }
  521             elsif nqp::existskey($d,'p') {     # :delete:p(0|1)
  522                 my $p := HANDLED('p');
  523                 if nqp::elems($d) == 0 {
  524                     !$p || SELF.EXISTS-KEY($one)
  525                       ?? Pair.new($one, SELF.DELETE-KEY($one))
  526                       !! ();
  527                 }
  528                 else {
  529                     @nogo = <delete p>;
  530                 }
  531             }
  532             elsif nqp::existskey($d,'k') {     # :delete:k(0|1)
  533                 my $k := HANDLED('k');
  534                 if nqp::elems($d) == 0 {
  535                     !$k || SELF.EXISTS-KEY($one)
  536                       ?? do { SELF.DELETE-KEY($one); $one }
  537                       !! ();
  538                 }
  539                 else {
  540                     @nogo = <delete k>;
  541                 }
  542             }
  543             elsif nqp::existskey($d,'v') {     # :delete:v(0|1)
  544                 my $v := HANDLED('v');
  545                 if nqp::elems($d) == 0 {
  546                     !$v || SELF.EXISTS-KEY($one)
  547                       ?? SELF.DELETE-KEY($one)
  548                       !! ();
  549                 }
  550                 else {
  551                     @nogo = <delete v>;
  552                 }
  553             }
  554             else {
  555                 @nogo = <delete>;
  556             }
  557         }
  558         elsif nqp::existskey($d,'exists') {  # :!delete?:exists(0|1):*
  559             my $exists  := HANDLED('exists');
  560             my $wasthere = SELF.EXISTS-KEY($one);
  561             if nqp::elems($d) == 0 {           # :!delete?:exists(0|1)
  562                 !( $wasthere ?^ $exists )
  563             }
  564             elsif nqp::existskey($d,'kv') {    # :!delete?:exists(0|1):kv(0|1)
  565                 my $kv := HANDLED('kv');
  566                 if nqp::elems($d) == 0 {
  567                     !$kv || $wasthere
  568                       ?? ( $one, !( $wasthere ?^ $exists ) )
  569                       !! ();
  570                 }
  571                 else {
  572                     @nogo = <exists kv>;
  573                 }
  574             }
  575             elsif nqp::existskey($d,'p') {     # :!delete?:exists(0|1):p(0|1)
  576                 my $p := HANDLED('p');
  577                 if nqp::elems($d) == 0 {
  578                     !$p || $wasthere
  579                       ?? Pair.new($one, !( $wasthere ?^ $exists ))
  580                       !! ();
  581                 }
  582                 else {
  583                     @nogo = <exists p>;
  584                 }
  585             }
  586             else {
  587                 @nogo = <exists>;
  588             }
  589         }
  590         elsif nqp::existskey($d,'kv') {      # :!delete?:kv(0|1):*
  591             my $kv := HANDLED('kv');
  592             if nqp::elems($d) == 0 {           # :!delete?:kv(0|1)
  593                 !$kv || SELF.EXISTS-KEY($one)
  594                   ?? ($one, SELF.AT-KEY($one))
  595                   !! ();
  596             }
  597             else {
  598                 @nogo = <kv>;
  599             }
  600         }
  601         elsif nqp::existskey($d,'p') {       # :!delete?:p(0|1):*
  602             my $p := HANDLED('p');
  603             if nqp::elems($d) == 0 {           # :!delete?:p(0|1)
  604                 !$p || SELF.EXISTS-KEY($one)
  605                   ?? Pair.new($one, SELF.AT-KEY($one))
  606                   !! ();
  607             }
  608             else {
  609                 @nogo = <p>;
  610             }
  611         }
  612         elsif nqp::existskey($d,'k') {       # :!delete?:k(0|1):*
  613             my $k := HANDLED('k');
  614             if nqp::elems($d) == 0 {           # :!delete?:k(0|1)
  615                 !$k || SELF.EXISTS-KEY($one)
  616                   ?? $one
  617                   !! ();
  618             }
  619             else {
  620                 @nogo = <k>;
  621             }
  622         }
  623         elsif nqp::existskey($d,'v') {       # :!delete?:v(0|1):*
  624             my $v := HANDLED('v');             # :!delete?:v(0|1)
  625             if nqp::elems($d) == 0 {
  626                 !$v || SELF.EXISTS-KEY($one)
  627                   ?? SELF.AT-KEY($one)
  628                   !! ();
  629             }
  630             else {
  631                 @nogo = <v>;
  632             }
  633         }
  634         elsif nqp::elems($d) == 0 {           # :!delete
  635             SELF.AT-KEY($one);
  636         }
  637     }
  638 
  639     @nogo || nqp::elems($d)
  640       ?? Rakudo::Internals.SLICE_HUH( SELF, @nogo, $d, %adv )
  641       !! result;
  642 } #SLICE_ONE_HASH
  643 
  644 # internal >1 element hash access with adverbs
  645 sub SLICE_MORE_HASH(\SELF,$more,$key,$value,%adv) { # is implementation-detail
  646     my Mu $d := nqp::clone(nqp::getattr(%adv,Map,'$!storage'));
  647     nqp::bindkey($d,nqp::unbox_s($key),nqp::decont($value));
  648 
  649     sub HANDLED($key) {
  650         nqp::if(
  651           nqp::existskey($d,nqp::unbox_s($key)),
  652           nqp::stmts(
  653             (my $value := nqp::atkey($d,$key)),
  654             nqp::deletekey($d,$key),
  655             $value
  656           ),
  657           Nil
  658         )
  659     }
  660 
  661     my @nogo;
  662     my \result = do {
  663 
  664         if HANDLED('delete') {            # :delete:*
  665             if nqp::elems($d) == 0 {          # :delete
  666                 $more.cache.flatmap( { SELF.DELETE-KEY($_) } ).eager.list;
  667             }
  668             elsif nqp::existskey($d,'exists') { # :delete:exists(0|1):*
  669                 my $exists := HANDLED('exists');
  670                 my $wasthere; # no need to initialize every iteration of map
  671                 if nqp::elems($d) == 0 {          # :delete:exists(0|1)
  672                     $more.cache.flatmap( {
  673                         SELF.DELETE-KEY($_) if $wasthere = SELF.EXISTS-KEY($_);
  674                         !( $wasthere ?^ $exists );
  675                     } ).eager.list;
  676                 }
  677                 elsif nqp::existskey($d,'kv') { # :delete:exists(0|1):kv(0|1):*
  678                     my $kv := HANDLED('kv');
  679                     if nqp::elems($d) == 0 {      # :delete:exists(0|1):kv(0|1)
  680                         $more.cache.flatmap( {
  681                             SELF.DELETE-KEY($_) if $wasthere = SELF.EXISTS-KEY($_);
  682                             next unless !$kv || $wasthere;
  683                             ($_, !( $wasthere ?^ $exists ));
  684                         } ).flat.eager.list;
  685                     }
  686                     else {
  687                         @nogo = <delete exists kv>;
  688                     }
  689                 }
  690                 elsif nqp::existskey($d,'p') {  # :delete:exists(0|1):p(0|1):*
  691                     my $p := HANDLED('p');
  692                     if nqp::elems($d) == 0 {      # :delete:exists(0|1):p(0|1)
  693                         $more.cache.flatmap( {
  694                             SELF.DELETE-KEY($_) if $wasthere = SELF.EXISTS-KEY($_);
  695                             next unless !$p || $wasthere;
  696                             Pair.new($_,!($wasthere ?^ $exists));
  697                         } ).eager.list;
  698                     }
  699                     else {
  700                         @nogo = <delete exists p>;
  701                     }
  702                 }
  703                 else {
  704                     @nogo = <delete exists>;
  705                 }
  706             }
  707             elsif nqp::existskey($d,'kv') {     # :delete:kv(0|1):*
  708                 my $kv := HANDLED('kv');
  709                 if nqp::elems($d) == 0 {          # :delete:kv(0|1)
  710                     $kv
  711                       ?? $more.cache.flatmap( {
  712                              next unless SELF.EXISTS-KEY($_);
  713                              ( $_, SELF.DELETE-KEY($_) );
  714                          } ).flat.eager.list
  715                       !! $more.cache.flatmap( {
  716                              ( $_, SELF.DELETE-KEY($_) )
  717                          } ).flat.eager.list;
  718                 }
  719                 else {
  720                     @nogo = <delete kv>;
  721                 }
  722             }
  723             elsif nqp::existskey($d,'p') {      # :delete:p(0|1):*
  724                 my $p := HANDLED('p');
  725                 if nqp::elems($d) == 0 {          # :delete:p(0|1)
  726                     $p
  727                       ?? $more.cache.flatmap( {
  728                              next unless SELF.EXISTS-KEY($_);
  729                              Pair.new($_, SELF.DELETE-KEY($_));
  730                          } ).eager.list
  731                       !! $more.cache.flatmap( {
  732                              Pair.new($_, SELF.DELETE-KEY($_))
  733                          } ).eager.list;
  734                 }
  735                 else {
  736                     @nogo = <delete p>;
  737                 }
  738             }
  739             elsif nqp::existskey($d,'k') {     # :delete:k(0|1):*
  740                 my $k := HANDLED('k');
  741                 if nqp::elems($d) == 0 {          # :delete:k(0|1)
  742                     $k
  743                       ?? $more.cache.flatmap( {
  744                              nqp::if(
  745                                SELF.EXISTS-KEY($_),
  746                                nqp::stmts(
  747                                  SELF.DELETE-KEY($_),
  748                                  $_
  749                                ),
  750                                next
  751                              )
  752                          } ).eager.list
  753                       !! $more.cache.flatmap( {
  754                              SELF.DELETE-KEY($_); $_
  755                          } ).eager.list;
  756                 }
  757                 else {
  758                     @nogo = <delete k>;
  759                 }
  760             }
  761             elsif nqp::existskey($d,'v') {      # :delete:v(0|1):*
  762                 my $v := HANDLED('v');
  763                 if nqp::elems($d) == 0 {          # :delete:v(0|1)
  764                     $v
  765                       ?? $more.cache.flatmap( {
  766                              next unless SELF.EXISTS-KEY($_);
  767                              SELF.DELETE-KEY($_);
  768                      } ).eager.list
  769                       !! $more.cache.flatmap( {
  770                              SELF.DELETE-KEY($_)
  771                      } ).eager.list;
  772                 }
  773                 else {
  774                     @nogo = <delete v>;
  775                 }
  776             }
  777             else {
  778                 @nogo = <delete>;
  779             }
  780         }
  781         elsif nqp::existskey($d,'exists') { # :!delete?:exists(0|1):*
  782             my $exists := HANDLED('exists');
  783             if nqp::elems($d) == 0 {          # :!delete?:exists(0|1)
  784                 $more.cache.flatmap({ !( SELF.EXISTS-KEY($_) ?^ $exists ) }).eager.list;
  785             }
  786             elsif nqp::existskey($d,'kv') {   # :!delete?:exists(0|1):kv(0|1):*
  787                 my $kv := HANDLED('kv');
  788                 if nqp::elems($d) == 0 {        # :!delete?:exists(0|1):kv(0|1)
  789                     $kv
  790                       ?? $more.cache.flatmap( {
  791                              next unless SELF.EXISTS-KEY($_);
  792                              ( $_, $exists );
  793                          } ).flat.eager.list
  794                       !! $more.cache.flatmap( {
  795                              ( $_, !( SELF.EXISTS-KEY($_) ?^ $exists ) )
  796                          } ).flat.eager.list;
  797                 }
  798                 else {
  799                     @nogo = <exists kv>;
  800                 }
  801             }
  802             elsif nqp::existskey($d,'p') {  # :!delete?:exists(0|1):p(0|1):*
  803                 my $p := HANDLED('p');
  804                 if nqp::elems($d) == 0 {      # :!delete?:exists(0|1):p(0|1)
  805                     $p
  806                       ?? $more.cache.flatmap( {
  807                              next unless SELF.EXISTS-KEY($_);
  808                              Pair.new( $_, $exists );
  809                          } ).eager.list
  810                       !! $more.cache.flatmap( {
  811                              Pair.new( $_, !( SELF.EXISTS-KEY($_) ?^ $exists ) )
  812                          } ).eager.list;
  813                 }
  814                 else {
  815                     @nogo = <exists p>;
  816                 }
  817             }
  818             else {
  819                 @nogo = <exists>;
  820             }
  821         }
  822         elsif nqp::existskey($d,'kv') {     # :!delete?:kv(0|1):*
  823             my $kv := HANDLED('kv');
  824             if nqp::elems($d) == 0 {          # :!delete?:kv(0|1)
  825                 $kv
  826                   ?? $more.cache.flatmap( {
  827                          next unless SELF.EXISTS-KEY($_);
  828                          $_, SELF.AT-KEY($_);
  829                      } ).flat.eager.list
  830                   !! $more.cache.flatmap( {
  831                          $_, SELF.AT-KEY($_)
  832                      } ).flat.eager.list;
  833             }
  834             else {
  835                 @nogo = <kv>;
  836             }
  837         }
  838         elsif nqp::existskey($d,'p') {      # :!delete?:p(0|1):*
  839             my $p := HANDLED('p');
  840             if nqp::elems($d) == 0 {          # :!delete?:p(0|1)
  841                 $p
  842                   ?? $more.cache.flatmap( {
  843                          next unless SELF.EXISTS-KEY($_);
  844                          Pair.new($_, SELF.AT-KEY($_));
  845                      } ).eager.list
  846                   !! $more.cache.flatmap( {
  847                          Pair.new( $_, SELF.AT-KEY($_) )
  848                      } ).eager.list;
  849             }
  850             else {
  851                 @nogo = <p>
  852             }
  853         }
  854         elsif nqp::existskey($d,'k') {      # :!delete?:k(0|1):*
  855             my $k := HANDLED('k');
  856             if nqp::elems($d) == 0 {          # :!delete?:k(0|1)
  857                 $k
  858                   ?? $more.cache.flatmap( {
  859                          next unless SELF.EXISTS-KEY($_);
  860                          $_;
  861                      } ).eager.list
  862                   !! $more.cache.flat.eager.list;
  863             }
  864             else {
  865                 @nogo = <k>;
  866             }
  867         }
  868         elsif nqp::existskey($d,'v') {      # :!delete?:v(0|1):*
  869             my $v := HANDLED('v');
  870             if nqp::elems($d) == 0 {          # :!delete?:v(0|1)
  871                 $v
  872                   ??  $more.cache.flatmap( {
  873                           next unless SELF.EXISTS-KEY($_);
  874                           SELF.AT-KEY($_);
  875                       } ).eager.list
  876                   !!  $more.cache.flatmap( {
  877                           SELF.AT-KEY($_)
  878                       } ).eager.list;
  879             }
  880             else {
  881                 @nogo = <v>;
  882             }
  883         }
  884         elsif nqp::elems($d) == 0 {         # :!delete
  885             $more.cache.flatmap( { SELF.AT-KEY($_) } ).eager.list;
  886         }
  887     }
  888 
  889     @nogo || nqp::elems($d)
  890       ?? Rakudo::Internals.SLICE_HUH( SELF, @nogo, $d, %adv )
  891       !! result;
  892 } #SLICE_MORE_HASH
  893 
  894 # vim: expandtab shiftwidth=4