Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Changes In Branch dah-proc-arg-upvar Excluding Merge-Ins
This is equivalent to a diff from 088e1f413e to af8005b8b2
2016-12-18
| ||
15:39 | More comments, fix bug where numArgs should be argCt Leaf check-in: af8005b8b2 user: dah tags: dah-proc-arg-upvar | |
15:04 | More tests, frame lookup tweak and attempt to take advantage of a branch prediction. check-in: e3c53025a8 user: dah tags: dah-proc-arg-upvar | |
2016-12-02
| ||
14:52 | Implement %ll (WideInt) handling for Tcl_ObjPrintf(). Use it in some places. (now without edit-error... check-in: eac13870dc user: jan.nijtmans tags: trunk | |
13:50 |
Implement %ll (WideInt) handling for Tcl_ObjPrintf(). Use it in some places.
Moved to feature bra... check-in: e3ba334a42 user: jan.nijtmans tags: jn-wide-printf | |
2016-12-01
| ||
22:07 | [507d9b9651a3c903] Possible implementation of auto-upvar for procedures. check-in: 6e39d87cbc user: dkf tags: dah-proc-arg-upvar | |
20:13 | Reports from NSF that command epoch bumping isn't properly timed. http://paste.tclers.tk/4030 Since ... check-in: d3f2f88f49 user: dgp tags: dgp-cmd-epoch | |
17:25 | So long as we register only one, we can have multiple Tcl_ObjTypes with the same name. This smooths... check-in: 088e1f413e user: dgp tags: trunk | |
13:20 | Created a new "proper bytearray" Tcl_ObjType so we can use bytearrays as bytearrays without all this... check-in: 3ef69dfebe user: dgp tags: trunk | |
Changes to generic/tclInt.h.
︙ | |||
958 959 960 961 962 963 964 965 966 967 968 969 970 971 | 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 | + + + | struct Command *cmdPtr; /* Points to the Command structure for this * procedure. This is used to get the * namespace in which to execute the * procedure. */ Tcl_Obj *bodyPtr; /* Points to the ByteCode object for * procedure's body command. */ int numArgs; /* Number of formal parameters. */ int numArgsCompiledLocals; /* TIP #460: Count of locals recognized by * the compiler used in the arguments list. */ int numCompiledLocals; /* Count of local variables recognized by the * compiler including arguments and * temporaries. */ CompiledLocal *firstLocalPtr; /* Pointer to first of the procedure's * compiler-allocated local variables, or NULL * if none. The first numArgs entries in this |
︙ | |||
1692 1693 1694 1695 1696 1697 1698 | 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 | - | #define CMD_IS_DELETED 0x01 #define CMD_TRACE_ACTIVE 0x02 #define CMD_HAS_EXEC_TRACES 0x04 #define CMD_COMPILES_EXPANDED 0x08 #define CMD_REDEF_IN_PROGRESS 0x10 #define CMD_VIA_RESOLVER 0x20 |
︙ |
Changes to generic/tclProc.c.
︙ | |||
459 460 461 462 463 464 465 466 467 468 469 470 471 472 | 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | + | Tcl_IncrRefCount(bodyPtr); procPtr = ckalloc(sizeof(Proc)); procPtr->iPtr = iPtr; procPtr->refCount = 1; procPtr->bodyPtr = bodyPtr; procPtr->numArgs = 0; /* Actual argument count is set below. */ procPtr->numArgsCompiledLocals = 0; procPtr->numCompiledLocals = 0; procPtr->firstLocalPtr = NULL; procPtr->lastLocalPtr = NULL; } /* * Break up the argument list into argument specifiers, then process each |
︙ | |||
492 493 494 495 496 497 498 499 500 501 502 | 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 | + - - + + + - + - + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + | Tcl_SetErrorCode(interp, "TCL", "OPERATION", "PROC", "BYTECODELIES", NULL); goto procError; } localPtr = procPtr->firstLocalPtr; } else { procPtr->numArgs = numArgs; procPtr->numArgsCompiledLocals = numArgs; procPtr->numCompiledLocals = numArgs; } for (i = 0; i < numArgs; i++) { |
︙ | |||
607 608 609 610 611 612 613 | 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 | - + - + - - - - - + + + + + + + - - - - - + + + + - - - - - - - - - - + + + + + + + + + + + - - - - - - - - + + + + + + + + - - - - - - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | &tmpLength); if ((valueLength != tmpLength) || strncmp(fieldValues[1], tmpPtr, (size_t) tmpLength)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "procedure \"%s\": formal parameter \"%s\" has " "default value inconsistent with precompiled body", |
︙ | |||
1320 1321 1322 1323 1324 1325 1326 | 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 | - + - + + + - + - - + + + + + + + + + + + | static void InitLocalCache( Proc *procPtr) { Interp *iPtr = procPtr->iPtr; ByteCode *codePtr = procPtr->bodyPtr->internalRep.twoPtrValue.ptr1; int localCt = procPtr->numCompiledLocals; |
︙ | |||
1380 1381 1382 1383 1384 1385 1386 | 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 | - + + - + | * Results: * A standard Tcl result. * * Side effects: * Allocates memory on the stack for the compiled local variables, the * caller is responsible for freeing them. Initialises all variables. May * invoke various name resolvers in order to determine which variables |
︙ | |||
1444 1445 1446 1447 1448 1449 1450 1451 | 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 | + - - - + + + - + + | if (numArgs == 0) { if (argCt) { goto incorrectArgs; } else { goto correctArgs; } } imax = ((argCt < numArgs-1) ? argCt : numArgs-1); |
︙ | |||
1505 1506 1507 1508 1509 1510 1511 | 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - + - + | /* * Initialise and resolve the remaining compiledLocals. In the absence of * resolvers, they are undefined local vars: (flags=0, value=NULL). */ correctArgs: { /* * TIP #460: Check for and construct links for any formals defined to be * linked to their corresponding argument. The link locals will be * immediately after the args list. The local's index they link to is * stored in the link's default value. */ int numArgVars = procPtr->numArgsCompiledLocals; if (numArgVars > numArgs) { CallFrame *upFramePtr; Var *otherPtr, *arrayPtr; /* * If we got here, assume we'll be resolving links. */ if (TclObjGetFrame(interp, NULL, &upFramePtr) == -1) { i = -1; /* Tell incorrectArgs we set the error */ goto incorrectArgs; } defPtr++; /* Here, defPtr cannot be NULL */ for(i = numArgs; i < numArgVars; i++, varPtr++, defPtr++) { if (TclIsVarLink(defPtr)) { int argIndex; if (TCL_OK != (TclGetIntFromObj(interp, defPtr->value.objPtr, &argIndex)) || (argIndex < 0 || argIndex > argCt - 1)) { /* * Something went horribly wrong if this comes to a Panic. * Should not happen unless there's an internal bug. */ Tcl_Panic("Link variable points to an invalid local index."); } else { /* * Defaults are illegal for linked arguments, so argIndex * should be safe. */ Tcl_Obj *objPtr = argObjs[argIndex]; /* * Locate the other variable. */ ((Interp *)interp)->varFramePtr = upFramePtr; otherPtr = TclObjLookupVarEx(interp, objPtr, NULL, TCL_LEAVE_ERR_MSG, "access", /*createPart1*/ 1, /*createPart2*/ 1, &arrayPtr); ((Interp *)interp)->varFramePtr = framePtr; if (otherPtr == NULL) { i = -1; /* Tell incorrectArgs we set the error */ goto incorrectArgs; } varPtr->flags = VAR_LINK; varPtr->value.linkPtr = otherPtr; if (TclIsVarInHash(otherPtr)) { VarHashRefCount(otherPtr)++; } } } } } |
︙ | |||
1990 1991 1992 1993 1994 1995 1996 | 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 | + + + + + - + - + - + | * TRICKY NOTE: Be careful to push a call frame with the proper * namespace context, so that the byte codes are compiled in the * appropriate class context. */ iPtr->compiledProcPtr = procPtr; /* * TIP #460: We may need to hang on to more locals than just the * Proc's formals (i.e. locals to be linked to an arg's value). */ |
︙ | |||
2019 2020 2021 2022 2023 2024 2025 | 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 | - + | toFree->resolveInfo->deleteProc(toFree->resolveInfo); } else { ckfree(toFree->resolveInfo); } } ckfree(toFree); } |
︙ |
Changes to tests/oo.test.
︙ | |||
3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 | 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 | + + + + + + + + + + + + + + + + + + + + + | } {} test oo-35.4 {Bug 593baa032c: mixins list teardown} { # Bug makes this crash, especially with mem-debugging on oo::class create B {} oo::class create D {mixin B} namespace eval [info object namespace D] [list [namespace which B] destroy] } {} test oo-36.1 {OO: Auto linking} -setup { oo::class create C } -body { oo::define C { constructor {*a} { incr a lappend ::result $a } method m {*a} { incr a lappend ::result $a } } set a 0 set c [C new a] $c m a return $result } -cleanup { C destroy } -result {1 2} cleanupTests return # Local Variables: # mode: tcl |
︙ |
Changes to tests/proc.test.
︙ | |||
379 380 381 382 383 384 385 386 387 388 389 390 391 392 | 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 | + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + | set lambda x lappend lambda {set a 1} interp create slave slave eval [list apply $lambda foo] interp delete slave unset lambda } {} test proc-8.1 {Auto argument linking} -body { proc P {*a} { set a 1 return } apply {{} { set a {} P a set a }} } -cleanup { rename P {} } -result 1 test proc-8.2 {Auto argument linking, multiple} -body { proc P {*a *b} { set a 1 set b 2 return } apply {{} { set a {} set b {} P a b set b }} } -cleanup { rename P {} } -result 2 test proc-8.3 {Auto argument linking, multiple of same} -body { proc P {*a *a} { set a 1 return } apply {{} { set a {} P a a set a }} } -cleanup { rename P {} } -result 1 test proc-8.4 {Auto argument linking, and defaults} -body { proc P {*a {foo bar} args} { return $foo } apply {{} { set a {} P a }} } -cleanup { rename P {} } -result {bar} test proc-8.5 {Auto argument linking, and args} -body { proc P {*a args} { return [lindex $args 0] } apply {{} { set a {} P a foo }} } -cleanup { rename P {} } -result {foo} test proc-8.6 {Auto argument linking, chain linking} -body { proc P {*a} { P2 a } proc P2 {*a} { incr a } apply {{} { P a set a }} } -cleanup { rename P {} rename P2 {} } -result {1} test proc-8.7 {Auto argument linking, create var in caller} -body { proc P {*a} { incr a } apply {{} { P a set a }} } -cleanup { rename P {} } -result {1} test proc-8.8 {Auto argument linking, default for auto-link formal} -body { proc P {{*a b}} { incr a } apply {{} { set a 0 P a }} } -constraints procbodytest -returnCodes error -cleanup { catch {rename P {}} } -result {procedure "P": formal parameter "*a" is to be linked and must not have a default value} test proc-8.9 {Auto argument linking, bad variable} -body { proc P {*a} { incr a } P mumbo::jumbo } -constraints procbodytest -returnCodes error -cleanup { catch {rename P {}} } -result {can't access "mumbo::jumbo": parent namespace doesn't exist} test proc-8.10 {Auto argument linking, empty link name} -body { proc P {*} { incr {} } apply {{} { P a set a }} } -cleanup { rename P {} } -result {1} test proc-8.11 {Auto argument linking, link name consistency} -body { proc P {**a} { incr *a } apply {{} { P a set a }} } -cleanup { rename P {} } -result {1} test proc-8.12 {Auto argument linking, info args} -body { proc P {*a b *c} {} info args P } -cleanup { rename P {} } -result {*a b *c} test proc-8.13 {Auto argument linking, info locals} -body { proc P {*a b *c} {info locals} P a b c } -cleanup { rename P {} } -result {*a b *c} test proc-8.14 {Auto argument linking, linked arg retains value} -body { proc P {*a} {set *a} P a } -cleanup { rename P {} } -result {a} # cleanup catch {rename p ""} catch {rename t ""} ::tcltest::cleanupTests return |
︙ |