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