|
299 | 299 |
|
300 | 300 | /***********************************************************************
|
301 | 301 | **
|
302 |
| -*/ REBFLG MT_Map(REBVAL *out, REBVAL *data, REBCNT type) |
| 302 | +*/ REBFLG MT_Map(REBVAL *out, REBVAL *data, REBCNT type, REBU64 types) |
303 | 303 | /*
|
304 | 304 | ***********************************************************************/
|
305 | 305 | {
|
| 306 | + /* |
| 307 | + Oldes asking: |
| 308 | + 1. What means the MT in the function name? |
| 309 | + 2. What is purpose of the unused `type` argument? |
| 310 | + */ |
306 | 311 | REBCNT n;
|
307 | 312 | REBSER *series;
|
308 | 313 |
|
|
316 | 321 | //COPY_BLK_PART(series, VAL_BLK_DATA(data), n);
|
317 | 322 | Append_Map(series, data, UNKNOWN);
|
318 | 323 |
|
| 324 | + if (types != 0) Copy_Deep_Values(series, 0, SERIES_TAIL(series), types); |
| 325 | + |
319 | 326 | Rehash_Hash(series);
|
320 | 327 |
|
321 | 328 | Set_Series(REB_MAP, out, series);
|
|
466 | 473 | case A_TO:
|
467 | 474 | // make map! [word val word val]
|
468 | 475 | if (IS_BLOCK(arg) || IS_PAREN(arg) || IS_MAP(arg)) {
|
469 |
| - if (MT_Map(D_RET, arg, 0)) return R_RET; |
| 476 | + if (MT_Map(D_RET, arg, 0, 0)) return R_RET; |
470 | 477 | Trap_Arg(arg);
|
471 | 478 | // } else if (IS_NONE(arg)) {
|
472 | 479 | // n = 3; // just a start
|
|
481 | 488 | Set_Series(REB_MAP, D_RET, series);
|
482 | 489 | break;
|
483 | 490 |
|
484 |
| - case A_COPY: |
485 |
| - if (MT_Map(D_RET, val, 0)) return R_RET; |
| 491 | + case A_COPY: { |
| 492 | + REBU64 types = 0; |
| 493 | + if (D_REF(ARG_COPY_DEEP)) { |
| 494 | + //puts("deep copy wanted"); |
| 495 | + types |= CP_DEEP | (D_REF(ARG_COPY_TYPES) ? 0 : TS_STD_SERIES); |
| 496 | + } |
| 497 | + if D_REF(ARG_COPY_TYPES) { |
| 498 | + arg = D_ARG(ARG_COPY_KINDS); |
| 499 | + if (IS_DATATYPE(arg)) types |= TYPESET(VAL_DATATYPE(arg)); |
| 500 | + else types |= VAL_TYPESET(arg); |
| 501 | + } |
| 502 | + if (MT_Map(D_RET, val, 0, types)) return R_RET; |
486 | 503 | Trap_Arg(val);
|
487 |
| - |
| 504 | + } |
488 | 505 | case A_CLEAR:
|
489 | 506 | Clear_Series(series);
|
490 | 507 | if (series->series) Clear_Series(series->series);
|
|
0 commit comments