Attachment "cmdResVsCmdLiterals.patch" to
ticket [3418547fff]
added by
foxcruiser
2011-10-04 23:15:23.
0000: 49 6e 64 65 78 3a 20 67 65 6e 65 72 69 63 2f 74 Index: generic/t
0010: 63 6c 42 61 73 69 63 2e 63 0a 3d 3d 3d 3d 3d 3d clBasic.c.======
0020: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0030: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0040: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0050: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 2d 2d =============.--
0060: 2d 20 67 65 6e 65 72 69 63 2f 74 63 6c 42 61 73 - generic/tclBas
0070: 69 63 2e 63 0a 2b 2b 2b 20 67 65 6e 65 72 69 63 ic.c.+++ generic
0080: 2f 74 63 6c 42 61 73 69 63 2e 63 0a 40 40 20 2d /tclBasic.c.@@ -
0090: 31 39 32 30 2c 31 30 20 2b 31 39 32 30 2c 32 30 1920,10 +1920,20
00a0: 20 40 40 0a 20 20 20 20 20 20 20 20 20 54 63 6c @@. Tcl
00b0: 5f 53 65 74 45 72 72 6f 72 43 6f 64 65 28 69 6e _SetErrorCode(in
00c0: 74 65 72 70 2c 20 22 54 43 4c 22 2c 20 22 45 58 terp, "TCL", "EX
00d0: 50 4f 53 45 22 2c 20 22 43 4f 4d 4d 41 4e 44 5f POSE", "COMMAND_
00e0: 45 58 49 53 54 53 22 2c 20 4e 55 4c 4c 29 3b 0a EXISTS", NULL);.
00f0: 20 09 72 65 74 75 72 6e 20 54 43 4c 5f 45 52 52 .return TCL_ERR
0100: 4f 52 3b 0a 20 20 20 20 20 7d 0a 20 0a 20 20 20 OR;. }. .
0110: 20 20 2f 2a 0a 2b 20 20 20 20 20 2a 20 43 6f 6d /*.+ * Com
0120: 6d 61 6e 64 20 72 65 73 6f 6c 76 65 72 73 20 28 mand resolvers (
0130: 70 65 72 2d 69 6e 74 65 72 70 2c 20 70 65 72 2d per-interp, per-
0140: 6e 61 6d 65 73 70 61 63 65 29 20 6d 69 67 68 74 namespace) might
0150: 20 68 61 76 65 20 72 65 73 6f 6c 76 65 64 20 74 have resolved t
0160: 6f 20 61 0a 2b 20 20 20 20 20 2a 20 63 6f 6d 6d o a.+ * comm
0170: 61 6e 64 20 66 6f 72 20 74 68 65 20 67 69 76 65 and for the give
0180: 6e 20 6e 61 6d 65 73 70 61 63 65 20 73 63 6f 70 n namespace scop
0190: 65 20 77 69 74 68 20 74 68 69 73 20 63 6f 6d 6d e with this comm
01a0: 61 6e 64 20 6e 6f 74 20 62 65 69 6e 67 0a 2b 20 and not being.+
01b0: 20 20 20 20 2a 20 72 65 67 69 73 74 65 72 65 64 * registered
01c0: 20 77 69 74 68 20 74 68 65 20 6e 61 6d 65 73 70 with the namesp
01d0: 61 63 65 27 73 20 63 6f 6d 6d 61 6e 64 20 74 61 ace's command ta
01e0: 62 6c 65 2e 20 44 75 72 69 6e 67 20 42 43 20 63 ble. During BC c
01f0: 6f 6d 70 69 6c 61 74 69 6f 6e 2c 0a 2b 20 20 20 ompilation,.+
0200: 20 20 2a 20 74 68 65 20 73 6f 2d 72 65 73 6f 6c * the so-resol
0210: 76 65 64 20 63 6f 6d 6d 61 6e 64 20 74 75 72 6e ved command turn
0220: 73 20 69 6e 74 6f 20 61 20 43 6d 64 4e 61 6d 65 s into a CmdName
0230: 20 6c 69 74 65 72 61 6c 2e 20 57 69 74 68 6f 75 literal. Withou
0240: 74 0a 2b 20 20 20 20 20 2a 20 69 6e 76 61 6c 69 t.+ * invali
0250: 64 61 74 69 6e 67 20 61 20 70 6f 73 73 69 62 6c dating a possibl
0260: 65 20 43 6d 64 4e 61 6d 65 20 6c 69 74 65 72 61 e CmdName litera
0270: 6c 20 68 65 72 65 20 65 78 70 6c 69 63 69 74 6c l here explicitl
0280: 79 2c 20 73 75 63 68 20 6c 69 74 65 72 61 6c 73 y, such literals
0290: 0a 2b 20 20 20 20 20 2a 20 6b 65 65 70 20 62 65 .+ * keep be
02a0: 69 6e 67 20 72 65 75 73 65 64 20 77 68 69 6c 65 ing reused while
02b0: 20 70 6f 69 6e 74 69 6e 67 20 74 6f 20 6f 76 65 pointing to ove
02c0: 72 68 61 75 6c 65 64 20 63 6f 6d 6d 61 6e 64 73 rhauled commands
02d0: 2e 0a 2b 20 20 20 20 20 2a 2f 0a 2b 20 20 20 20 ..+ */.+
02e0: 54 63 6c 49 6e 76 61 6c 69 64 61 74 65 43 6d 64 TclInvalidateCmd
02f0: 4c 69 74 65 72 61 6c 28 69 6e 74 65 72 70 2c 20 Literal(interp,
0300: 63 6d 64 4e 61 6d 65 2c 20 6e 73 50 74 72 29 3b cmdName, nsPtr);
0310: 0a 2b 0a 2b 20 20 20 20 2f 2a 0a 20 20 20 20 20 .+.+ /*.
0320: 20 2a 20 54 68 65 20 6c 69 73 74 20 6f 66 20 63 * The list of c
0330: 6f 6d 6d 61 6e 64 20 65 78 70 6f 72 74 65 64 20 ommand exported
0340: 66 72 6f 6d 20 74 68 65 20 6e 61 6d 65 73 70 61 from the namespa
0350: 63 65 20 6d 69 67 68 74 20 68 61 76 65 20 63 68 ce might have ch
0360: 61 6e 67 65 64 2e 0a 20 20 20 20 20 20 2a 20 48 anged.. * H
0370: 6f 77 65 76 65 72 2c 20 77 65 20 64 6f 20 6e 6f owever, we do no
0380: 74 20 6e 65 65 64 20 74 6f 20 72 65 63 6f 6d 70 t need to recomp
0390: 75 74 65 20 74 68 69 73 20 6a 75 73 74 20 79 65 ute this just ye
03a0: 74 3b 20 6e 65 78 74 20 74 69 6d 65 20 77 65 20 t; next time we
03b0: 6e 65 65 64 0a 20 20 20 20 20 20 2a 20 74 68 65 need. * the
03c0: 20 69 6e 66 6f 20 77 69 6c 6c 20 62 65 20 73 6f info will be so
03d0: 6f 6e 20 65 6e 6f 75 67 68 2e 0a 20 20 20 20 20 on enough..
03e0: 20 2a 2f 0a 20 0a 40 40 20 2d 32 30 36 36 2c 31 */. .@@ -2066,1
03f0: 30 20 2b 32 30 37 36 2c 32 31 20 40 40 0a 20 09 0 +2076,21 @@. .
0400: 20 20 20 20 20 2a 2f 0a 20 0a 20 09 20 20 20 20 */. . .
0410: 63 6b 66 72 65 65 28 54 63 6c 5f 47 65 74 48 61 ckfree(Tcl_GetHa
0420: 73 68 56 61 6c 75 65 28 68 50 74 72 29 29 3b 0a shValue(hPtr));.
0430: 20 09 7d 0a 20 20 20 20 20 7d 20 65 6c 73 65 20 .}. } else
0440: 7b 0a 2b 20 20 20 20 20 20 20 20 0a 2b 20 20 20 {.+ .+
0450: 20 20 20 20 20 2f 2a 0a 2b 20 20 20 20 20 20 20 /*.+
0460: 20 20 2a 20 43 6f 6d 6d 61 6e 64 20 72 65 73 6f * Command reso
0470: 6c 76 65 72 73 20 28 70 65 72 2d 69 6e 74 65 72 lvers (per-inter
0480: 70 2c 20 70 65 72 2d 6e 61 6d 65 73 70 61 63 65 p, per-namespace
0490: 29 20 6d 69 67 68 74 20 68 61 76 65 20 72 65 73 ) might have res
04a0: 6f 6c 76 65 64 20 74 6f 20 61 0a 2b 20 20 20 20 olved to a.+
04b0: 20 20 20 20 20 2a 20 63 6f 6d 6d 61 6e 64 20 66 * command f
04c0: 6f 72 20 74 68 65 20 67 69 76 65 6e 20 6e 61 6d or the given nam
04d0: 65 73 70 61 63 65 20 73 63 6f 70 65 20 77 69 74 espace scope wit
04e0: 68 20 74 68 69 73 20 63 6f 6d 6d 61 6e 64 20 6e h this command n
04f0: 6f 74 20 62 65 69 6e 67 0a 2b 20 20 20 20 20 20 ot being.+
0500: 20 20 20 2a 20 72 65 67 69 73 74 65 72 65 64 20 * registered
0510: 77 69 74 68 20 74 68 65 20 6e 61 6d 65 73 70 61 with the namespa
0520: 63 65 27 73 20 63 6f 6d 6d 61 6e 64 20 74 61 62 ce's command tab
0530: 6c 65 2e 20 44 75 72 69 6e 67 20 42 43 20 63 6f le. During BC co
0540: 6d 70 69 6c 61 74 69 6f 6e 2c 0a 2b 20 20 20 20 mpilation,.+
0550: 20 20 20 20 20 2a 20 74 68 65 20 73 6f 2d 72 65 * the so-re
0560: 73 6f 6c 76 65 64 20 63 6f 6d 6d 61 6e 64 20 74 solved command t
0570: 75 72 6e 73 20 69 6e 74 6f 20 61 20 43 6d 64 4e urns into a CmdN
0580: 61 6d 65 20 6c 69 74 65 72 61 6c 2e 20 57 69 74 ame literal. Wit
0590: 68 6f 75 74 0a 2b 20 20 20 20 20 20 20 20 20 2a hout.+ *
05a0: 20 69 6e 76 61 6c 69 64 61 74 69 6e 67 20 61 20 invalidating a
05b0: 70 6f 73 73 69 62 6c 65 20 43 6d 64 4e 61 6d 65 possible CmdName
05c0: 20 6c 69 74 65 72 61 6c 20 68 65 72 65 20 65 78 literal here ex
05d0: 70 6c 69 63 69 74 6c 79 2c 20 73 75 63 68 20 6c plicitly, such l
05e0: 69 74 65 72 61 6c 73 0a 2b 20 20 20 20 20 20 20 iterals.+
05f0: 20 20 2a 20 6b 65 65 70 20 62 65 69 6e 67 20 72 * keep being r
0600: 65 75 73 65 64 20 77 68 69 6c 65 20 70 6f 69 6e eused while poin
0610: 74 69 6e 67 20 74 6f 20 6f 76 65 72 68 61 75 6c ting to overhaul
0620: 65 64 20 63 6f 6d 6d 61 6e 64 73 2e 0a 2b 20 20 ed commands..+
0630: 20 20 20 20 20 20 20 2a 2f 0a 2b 20 20 20 20 20 */.+
0640: 20 20 20 54 63 6c 49 6e 76 61 6c 69 64 61 74 65 TclInvalidate
0650: 43 6d 64 4c 69 74 65 72 61 6c 28 69 6e 74 65 72 CmdLiteral(inter
0660: 70 2c 20 74 61 69 6c 2c 20 6e 73 50 74 72 29 3b p, tail, nsPtr);
0670: 0a 2b 0a 20 09 2f 2a 0a 20 09 20 2a 20 54 68 65 .+. ./*. . * The
0680: 20 6c 69 73 74 20 6f 66 20 63 6f 6d 6d 61 6e 64 list of command
0690: 20 65 78 70 6f 72 74 65 64 20 66 72 6f 6d 20 74 exported from t
06a0: 68 65 20 6e 61 6d 65 73 70 61 63 65 20 6d 69 67 he namespace mig
06b0: 68 74 20 68 61 76 65 20 63 68 61 6e 67 65 64 2e ht have changed.
06c0: 0a 20 09 20 2a 20 48 6f 77 65 76 65 72 2c 20 77 . . * However, w
06d0: 65 20 64 6f 20 6e 6f 74 20 6e 65 65 64 20 74 6f e do not need to
06e0: 20 72 65 63 6f 6d 70 75 74 65 20 74 68 69 73 20 recompute this
06f0: 6a 75 73 74 20 79 65 74 3b 20 6e 65 78 74 20 74 just yet; next t
0700: 69 6d 65 20 77 65 0a 20 09 20 2a 20 6e 65 65 64 ime we. . * need
0710: 20 74 68 65 20 69 6e 66 6f 20 77 69 6c 6c 20 62 the info will b
0720: 65 20 73 6f 6f 6e 20 65 6e 6f 75 67 68 2e 0a 20 e soon enough..
0730: 09 20 2a 2f 0a 40 40 20 2d 32 32 33 39 2c 31 30 . */.@@ -2239,10
0740: 20 2b 32 32 36 30 2c 32 30 20 40 40 0a 20 09 20 +2260,20 @@. .
0750: 20 20 20 20 2a 2f 0a 20 0a 20 09 20 20 20 20 63 */. . . c
0760: 6b 66 72 65 65 28 54 63 6c 5f 47 65 74 48 61 73 kfree(Tcl_GetHas
0770: 68 56 61 6c 75 65 28 68 50 74 72 29 29 3b 0a 20 hValue(hPtr));.
0780: 09 7d 0a 20 20 20 20 20 7d 20 65 6c 73 65 20 7b .}. } else {
0790: 0a 2b 20 20 20 20 20 20 20 20 2f 2a 0a 2b 20 20 .+ /*.+
07a0: 20 20 20 20 20 20 20 2a 20 43 6f 6d 6d 61 6e 64 * Command
07b0: 20 72 65 73 6f 6c 76 65 72 73 20 28 70 65 72 2d resolvers (per-
07c0: 69 6e 74 65 72 70 2c 20 70 65 72 2d 6e 61 6d 65 interp, per-name
07d0: 73 70 61 63 65 29 20 6d 69 67 68 74 20 68 61 76 space) might hav
07e0: 65 20 72 65 73 6f 6c 76 65 64 20 74 6f 20 61 0a e resolved to a.
07f0: 2b 20 20 20 20 20 20 20 20 20 2a 20 63 6f 6d 6d + * comm
0800: 61 6e 64 20 66 6f 72 20 74 68 65 20 67 69 76 65 and for the give
0810: 6e 20 6e 61 6d 65 73 70 61 63 65 20 73 63 6f 70 n namespace scop
0820: 65 20 77 69 74 68 20 74 68 69 73 20 63 6f 6d 6d e with this comm
0830: 61 6e 64 20 6e 6f 74 20 62 65 69 6e 67 0a 2b 20 and not being.+
0840: 20 20 20 20 20 20 20 20 2a 20 72 65 67 69 73 74 * regist
0850: 65 72 65 64 20 77 69 74 68 20 74 68 65 20 6e 61 ered with the na
0860: 6d 65 73 70 61 63 65 27 73 20 63 6f 6d 6d 61 6e mespace's comman
0870: 64 20 74 61 62 6c 65 2e 20 44 75 72 69 6e 67 20 d table. During
0880: 42 43 20 63 6f 6d 70 69 6c 61 74 69 6f 6e 2c 0a BC compilation,.
0890: 2b 20 20 20 20 20 20 20 20 20 2a 20 74 68 65 20 + * the
08a0: 73 6f 2d 72 65 73 6f 6c 76 65 64 20 63 6f 6d 6d so-resolved comm
08b0: 61 6e 64 20 74 75 72 6e 73 20 69 6e 74 6f 20 61 and turns into a
08c0: 20 43 6d 64 4e 61 6d 65 20 6c 69 74 65 72 61 6c CmdName literal
08d0: 2e 20 57 69 74 68 6f 75 74 0a 2b 20 20 20 20 20 . Without.+
08e0: 20 20 20 20 2a 20 69 6e 76 61 6c 69 64 61 74 69 * invalidati
08f0: 6e 67 20 61 20 70 6f 73 73 69 62 6c 65 20 43 6d ng a possible Cm
0900: 64 4e 61 6d 65 20 6c 69 74 65 72 61 6c 20 68 65 dName literal he
0910: 72 65 20 65 78 70 6c 69 63 69 74 6c 79 2c 20 73 re explicitly, s
0920: 75 63 68 20 6c 69 74 65 72 61 6c 73 0a 2b 20 20 uch literals.+
0930: 20 20 20 20 20 20 20 2a 20 6b 65 65 70 20 62 65 * keep be
0940: 69 6e 67 20 72 65 75 73 65 64 20 77 68 69 6c 65 ing reused while
0950: 20 70 6f 69 6e 74 69 6e 67 20 74 6f 20 6f 76 65 pointing to ove
0960: 72 68 61 75 6c 65 64 20 63 6f 6d 6d 61 6e 64 73 rhauled commands
0970: 2e 0a 2b 20 20 20 20 20 20 20 20 20 2a 2f 0a 2b ..+ */.+
0980: 20 20 20 20 20 20 20 20 54 63 6c 49 6e 76 61 6c TclInval
0990: 69 64 61 74 65 43 6d 64 4c 69 74 65 72 61 6c 28 idateCmdLiteral(
09a0: 69 6e 74 65 72 70 2c 20 74 61 69 6c 2c 20 6e 73 interp, tail, ns
09b0: 50 74 72 29 3b 0a 2b 0a 20 09 2f 2a 0a 20 09 20 Ptr);.+. ./*. .
09c0: 2a 20 54 68 65 20 6c 69 73 74 20 6f 66 20 63 6f * The list of co
09d0: 6d 6d 61 6e 64 20 65 78 70 6f 72 74 65 64 20 66 mmand exported f
09e0: 72 6f 6d 20 74 68 65 20 6e 61 6d 65 73 70 61 63 rom the namespac
09f0: 65 20 6d 69 67 68 74 20 68 61 76 65 20 63 68 61 e might have cha
0a00: 6e 67 65 64 2e 0a 20 09 20 2a 20 48 6f 77 65 76 nged.. . * Howev
0a10: 65 72 2c 20 77 65 20 64 6f 20 6e 6f 74 20 6e 65 er, we do not ne
0a20: 65 64 20 74 6f 20 72 65 63 6f 6d 70 75 74 65 20 ed to recompute
0a30: 74 68 69 73 20 6a 75 73 74 20 79 65 74 3b 20 6e this just yet; n
0a40: 65 78 74 20 74 69 6d 65 20 77 65 0a 20 09 20 2a ext time we. . *
0a50: 20 6e 65 65 64 20 74 68 65 20 69 6e 66 6f 20 77 need the info w
0a60: 69 6c 6c 20 62 65 20 73 6f 6f 6e 20 65 6e 6f 75 ill be soon enou
0a70: 67 68 2e 0a 20 09 20 2a 2f 0a 40 40 20 2d 32 35 gh.. . */.@@ -25
0a80: 34 37 2c 31 30 20 2b 32 35 37 38 2c 32 31 20 40 47,10 +2578,21 @
0a90: 40 0a 20 20 20 20 20 20 2a 20 62 75 74 20 74 68 @. * but th
0aa0: 61 74 27 73 20 6e 6f 20 62 69 67 20 64 65 61 6c at's no big deal
0ab0: 2e 0a 20 20 20 20 20 20 2a 2f 0a 20 0a 20 20 20 .. */. .
0ac0: 20 20 54 63 6c 49 6e 76 61 6c 69 64 61 74 65 4e TclInvalidateN
0ad0: 73 43 6d 64 4c 6f 6f 6b 75 70 28 63 6d 64 4e 73 sCmdLookup(cmdNs
0ae0: 50 74 72 29 3b 0a 20 20 20 20 20 54 63 6c 49 6e Ptr);. TclIn
0af0: 76 61 6c 69 64 61 74 65 4e 73 43 6d 64 4c 6f 6f validateNsCmdLoo
0b00: 6b 75 70 28 63 6d 64 50 74 72 2d 3e 6e 73 50 74 kup(cmdPtr->nsPt
0b10: 72 29 3b 0a 2b 0a 2b 20 20 20 20 0a 2b 20 20 20 r);.+.+ .+
0b20: 20 2f 2a 0a 2b 20 20 20 20 20 2a 20 43 6f 6d 6d /*.+ * Comm
0b30: 61 6e 64 20 72 65 73 6f 6c 76 65 72 73 20 28 70 and resolvers (p
0b40: 65 72 2d 69 6e 74 65 72 70 2c 20 70 65 72 2d 6e er-interp, per-n
0b50: 61 6d 65 73 70 61 63 65 29 20 6d 69 67 68 74 20 amespace) might
0b60: 68 61 76 65 20 72 65 73 6f 6c 76 65 64 20 74 6f have resolved to
0b70: 20 61 0a 2b 20 20 20 20 20 2a 20 63 6f 6d 6d 61 a.+ * comma
0b80: 6e 64 20 66 6f 72 20 74 68 65 20 67 69 76 65 6e nd for the given
0b90: 20 6e 61 6d 65 73 70 61 63 65 20 73 63 6f 70 65 namespace scope
0ba0: 20 77 69 74 68 20 74 68 69 73 20 63 6f 6d 6d 61 with this comma
0bb0: 6e 64 20 6e 6f 74 20 62 65 69 6e 67 0a 2b 20 20 nd not being.+
0bc0: 20 20 20 2a 20 72 65 67 69 73 74 65 72 65 64 20 * registered
0bd0: 77 69 74 68 20 74 68 65 20 6e 61 6d 65 73 70 61 with the namespa
0be0: 63 65 27 73 20 63 6f 6d 6d 61 6e 64 20 74 61 62 ce's command tab
0bf0: 6c 65 2e 20 44 75 72 69 6e 67 20 42 43 20 63 6f le. During BC co
0c00: 6d 70 69 6c 61 74 69 6f 6e 2c 0a 2b 20 20 20 20 mpilation,.+
0c10: 20 2a 20 74 68 65 20 73 6f 2d 72 65 73 6f 6c 76 * the so-resolv
0c20: 65 64 20 63 6f 6d 6d 61 6e 64 20 74 75 72 6e 73 ed command turns
0c30: 20 69 6e 74 6f 20 61 20 43 6d 64 4e 61 6d 65 20 into a CmdName
0c40: 6c 69 74 65 72 61 6c 2e 20 57 69 74 68 6f 75 74 literal. Without
0c50: 0a 2b 20 20 20 20 20 2a 20 69 6e 76 61 6c 69 64 .+ * invalid
0c60: 61 74 69 6e 67 20 61 20 70 6f 73 73 69 62 6c 65 ating a possible
0c70: 20 43 6d 64 4e 61 6d 65 20 6c 69 74 65 72 61 6c CmdName literal
0c80: 20 68 65 72 65 20 65 78 70 6c 69 63 69 74 6c 79 here explicitly
0c90: 2c 20 73 75 63 68 20 6c 69 74 65 72 61 6c 73 0a , such literals.
0ca0: 2b 20 20 20 20 20 2a 20 6b 65 65 70 20 62 65 69 + * keep bei
0cb0: 6e 67 20 72 65 75 73 65 64 20 77 68 69 6c 65 20 ng reused while
0cc0: 70 6f 69 6e 74 69 6e 67 20 74 6f 20 6f 76 65 72 pointing to over
0cd0: 68 61 75 6c 65 64 20 63 6f 6d 6d 61 6e 64 73 2e hauled commands.
0ce0: 0a 2b 20 20 20 20 20 2a 2f 0a 2b 20 20 20 20 54 .+ */.+ T
0cf0: 63 6c 49 6e 76 61 6c 69 64 61 74 65 43 6d 64 4c clInvalidateCmdL
0d00: 69 74 65 72 61 6c 28 69 6e 74 65 72 70 2c 20 6e iteral(interp, n
0d10: 65 77 54 61 69 6c 2c 20 63 6d 64 50 74 72 2d 3e ewTail, cmdPtr->
0d20: 6e 73 50 74 72 29 3b 0a 20 0a 20 20 20 20 20 2f nsPtr);. . /
0d30: 2a 0a 20 20 20 20 20 20 2a 20 53 63 72 69 70 74 *. * Script
0d40: 20 66 6f 72 20 72 65 6e 61 6d 65 20 74 72 61 63 for rename trac
0d50: 65 73 20 63 61 6e 20 64 65 6c 65 74 65 20 74 68 es can delete th
0d60: 65 20 63 6f 6d 6d 61 6e 64 20 22 6f 6c 64 4e 61 e command "oldNa
0d70: 6d 65 22 2e 20 54 68 65 72 65 66 6f 72 65 0a 20 me". Therefore.
0d80: 20 20 20 20 20 2a 20 69 6e 63 72 65 6d 65 6e 74 * increment
0d90: 20 74 68 65 20 72 65 66 65 72 65 6e 63 65 20 63 the reference c
0da0: 6f 75 6e 74 20 66 6f 72 20 63 6d 64 50 74 72 20 ount for cmdPtr
0db0: 73 6f 20 74 68 61 74 20 69 74 27 73 20 43 6f 6d so that it's Com
0dc0: 6d 61 6e 64 20 73 74 72 75 63 74 75 72 65 0a 20 mand structure.
0dd0: 20 20 20 20 20 2a 20 69 73 20 66 72 65 65 64 20 * is freed
0de0: 6f 6e 6c 79 20 74 6f 77 61 72 64 73 20 74 68 65 only towards the
0df0: 20 65 6e 64 20 6f 66 20 74 68 69 73 20 66 75 6e end of this fun
0e00: 63 74 69 6f 6e 20 62 79 20 63 61 6c 6c 69 6e 67 ction by calling
0e10: 0a 0a 49 6e 64 65 78 3a 20 67 65 6e 65 72 69 63 ..Index: generic
0e20: 2f 74 63 6c 43 6f 6d 70 69 6c 65 2e 68 0a 3d 3d /tclCompile.h.==
0e30: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0e40: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0e50: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0e60: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
0e70: 3d 0a 2d 2d 2d 20 67 65 6e 65 72 69 63 2f 74 63 =.--- generic/tc
0e80: 6c 43 6f 6d 70 69 6c 65 2e 68 0a 2b 2b 2b 20 67 lCompile.h.+++ g
0e90: 65 6e 65 72 69 63 2f 74 63 6c 43 6f 6d 70 69 6c eneric/tclCompil
0ea0: 65 2e 68 0a 40 40 20 2d 39 35 33 2c 31 30 20 2b e.h.@@ -953,10 +
0eb0: 39 35 33 2c 31 32 20 40 40 0a 20 09 09 09 20 20 953,12 @@. ...
0ec0: 20 20 63 6f 6e 73 74 20 63 68 61 72 20 2a 73 74 const char *st
0ed0: 72 69 6e 67 2c 20 69 6e 74 20 6d 61 78 43 68 61 ring, int maxCha
0ee0: 72 73 29 3b 0a 20 4d 4f 44 55 4c 45 5f 53 43 4f rs);. MODULE_SCO
0ef0: 50 45 20 76 6f 69 64 09 54 63 6c 52 65 67 69 73 PE void.TclRegis
0f00: 74 65 72 41 75 78 44 61 74 61 54 79 70 65 28 63 terAuxDataType(c
0f10: 6f 6e 73 74 20 41 75 78 44 61 74 61 54 79 70 65 onst AuxDataType
0f20: 20 2a 74 79 70 65 50 74 72 29 3b 0a 20 4d 4f 44 *typePtr);. MOD
0f30: 55 4c 45 5f 53 43 4f 50 45 20 69 6e 74 09 54 63 ULE_SCOPE int.Tc
0f40: 6c 52 65 67 69 73 74 65 72 4c 69 74 65 72 61 6c lRegisterLiteral
0f50: 28 43 6f 6d 70 69 6c 65 45 6e 76 20 2a 65 6e 76 (CompileEnv *env
0f60: 50 74 72 2c 0a 20 09 09 09 20 20 20 20 63 68 61 Ptr,. ... cha
0f70: 72 20 2a 62 79 74 65 73 2c 20 69 6e 74 20 6c 65 r *bytes, int le
0f80: 6e 67 74 68 2c 20 69 6e 74 20 66 6c 61 67 73 29 ngth, int flags)
0f90: 3b 0a 20 4d 4f 44 55 4c 45 5f 53 43 4f 50 45 20 ;. MODULE_SCOPE
0fa0: 76 6f 69 64 09 54 63 6c 52 65 6c 65 61 73 65 4c void.TclReleaseL
0fb0: 69 74 65 72 61 6c 28 54 63 6c 5f 49 6e 74 65 72 iteral(Tcl_Inter
0fc0: 70 20 2a 69 6e 74 65 72 70 2c 20 54 63 6c 5f 4f p *interp, Tcl_O
0fd0: 62 6a 20 2a 6f 62 6a 50 74 72 29 3b 0a 2b 4d 4f bj *objPtr);.+MO
0fe0: 44 55 4c 45 5f 53 43 4f 50 45 20 76 6f 69 64 09 DULE_SCOPE void.
0ff0: 54 63 6c 49 6e 76 61 6c 69 64 61 74 65 43 6d 64 TclInvalidateCmd
1000: 4c 69 74 65 72 61 6c 28 54 63 6c 5f 49 6e 74 65 Literal(Tcl_Inte
1010: 72 70 20 2a 69 6e 74 65 72 70 2c 20 0a 2b 09 09 rp *interp, .+..
1020: 09 09 09 09 43 4f 4e 53 54 20 63 68 61 72 20 2a ....CONST char *
1030: 6e 61 6d 65 2c 20 4e 61 6d 65 73 70 61 63 65 20 name, Namespace
1040: 2a 6e 73 50 74 72 29 3b 0a 20 4d 4f 44 55 4c 45 *nsPtr);. MODULE
1050: 5f 53 43 4f 50 45 20 69 6e 74 09 54 63 6c 53 69 _SCOPE int.TclSi
1060: 6e 67 6c 65 4f 70 43 6d 64 28 43 6c 69 65 6e 74 ngleOpCmd(Client
1070: 44 61 74 61 20 63 6c 69 65 6e 74 44 61 74 61 2c Data clientData,
1080: 0a 20 09 09 09 20 20 20 20 54 63 6c 5f 49 6e 74 . ... Tcl_Int
1090: 65 72 70 20 2a 69 6e 74 65 72 70 2c 20 69 6e 74 erp *interp, int
10a0: 20 6f 62 6a 63 2c 0a 20 09 09 09 20 20 20 20 54 objc,. ... T
10b0: 63 6c 5f 4f 62 6a 20 2a 63 6f 6e 73 74 20 6f 62 cl_Obj *const ob
10c0: 6a 76 5b 5d 29 3b 0a 20 4d 4f 44 55 4c 45 5f 53 jv[]);. MODULE_S
10d0: 43 4f 50 45 20 69 6e 74 09 54 63 6c 53 6f 72 74 COPE int.TclSort
10e0: 69 6e 67 4f 70 43 6d 64 28 43 6c 69 65 6e 74 44 ingOpCmd(ClientD
10f0: 61 74 61 20 63 6c 69 65 6e 74 44 61 74 61 2c 0a ata clientData,.
1100: 20 09 09 09 20 20 20 20 54 63 6c 5f 49 6e 74 65 ... Tcl_Inte
1110: 72 70 20 2a 69 6e 74 65 72 70 2c 20 69 6e 74 20 rp *interp, int
1120: 6f 62 6a 63 2c 0a 0a 49 6e 64 65 78 3a 20 67 65 objc,..Index: ge
1130: 6e 65 72 69 63 2f 74 63 6c 4c 69 74 65 72 61 6c neric/tclLiteral
1140: 2e 63 0a 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d .c.=============
1150: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
1160: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
1170: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
1180: 3d 3d 3d 3d 3d 3d 0a 2d 2d 2d 20 67 65 6e 65 72 ======.--- gener
1190: 69 63 2f 74 63 6c 4c 69 74 65 72 61 6c 2e 63 0a ic/tclLiteral.c.
11a0: 2b 2b 2b 20 67 65 6e 65 72 69 63 2f 74 63 6c 4c +++ generic/tclL
11b0: 69 74 65 72 61 6c 2e 63 0a 40 40 20 2d 39 33 34 iteral.c.@@ -934
11c0: 2c 31 30 20 2b 39 33 34 2c 35 32 20 40 40 0a 20 ,10 +934,52 @@.
11d0: 20 20 20 20 69 66 20 28 6f 6c 64 42 75 63 6b 65 if (oldBucke
11e0: 74 73 20 21 3d 20 74 61 62 6c 65 50 74 72 2d 3e ts != tablePtr->
11f0: 73 74 61 74 69 63 42 75 63 6b 65 74 73 29 20 7b staticBuckets) {
1200: 0a 20 09 63 6b 66 72 65 65 28 6f 6c 64 42 75 63 . .ckfree(oldBuc
1210: 6b 65 74 73 29 3b 0a 20 20 20 20 20 7d 0a 20 7d kets);. }. }
1220: 0a 20 0c 0a 2b 0a 2b 2f 2a 0a 2b 20 2a 2d 2d 2d . ..+.+/*.+ *---
1230: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1240: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1250: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1260: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
1270: 2d 2d 2d 0a 2b 20 2a 0a 2b 20 2a 20 54 63 6c 49 ---.+ *.+ * TclI
1280: 6e 76 61 6c 69 64 61 74 65 43 6d 64 4c 69 74 65 nvalidateCmdLite
1290: 72 61 6c 20 2d 2d 0a 2b 20 2a 0a 2b 20 2a 09 49 ral --.+ *.+ *.I
12a0: 6e 76 61 6c 69 64 61 74 65 20 61 20 63 6f 6d 6d nvalidate a comm
12b0: 61 6e 64 20 6c 69 74 65 72 61 6c 20 65 6e 74 72 and literal entr
12c0: 79 2c 20 69 66 20 70 72 65 73 65 6e 74 20 69 6e y, if present in
12d0: 20 74 68 65 20 6c 69 74 65 72 61 6c 20 68 61 73 the literal has
12e0: 68 0a 2b 20 2a 09 74 61 62 6c 65 73 2c 20 62 79 h.+ *.tables, by
12f0: 20 72 65 73 65 74 74 69 6e 67 20 69 74 73 20 69 resetting its i
1300: 6e 74 65 72 6e 61 6c 20 72 65 70 72 65 73 65 6e nternal represen
1310: 74 61 74 69 6f 6e 2e 20 54 68 69 73 20 69 6e 76 tation. This inv
1320: 61 6c 69 64 61 74 69 6f 6e 0a 2b 20 2a 09 6c 65 alidation.+ *.le
1330: 61 76 65 73 20 69 74 20 69 6e 20 74 68 65 20 6c aves it in the l
1340: 69 74 65 72 61 6c 20 74 61 62 6c 65 73 20 61 6e iteral tables an
1350: 64 20 69 6e 20 65 78 69 73 74 69 6e 67 20 6c 69 d in existing li
1360: 74 65 72 61 6c 20 61 72 72 61 79 73 2e 20 41 73 teral arrays. As
1370: 20 61 0a 2b 20 2a 09 72 65 73 75 6c 74 2c 20 65 a.+ *.result, e
1380: 78 69 73 74 69 6e 67 20 72 65 66 65 72 65 6e 63 xisting referenc
1390: 65 73 20 63 6f 6e 74 69 6e 75 65 20 74 6f 20 77 es continue to w
13a0: 6f 72 6b 20 62 75 74 20 77 65 20 66 6f 72 63 65 ork but we force
13b0: 20 61 20 66 72 65 73 68 0a 2b 20 2a 09 63 6f 6d a fresh.+ *.com
13c0: 6d 61 6e 64 20 6c 6f 6f 6b 2d 75 70 20 75 70 6f mand look-up upo
13d0: 6e 20 74 68 65 20 6e 65 78 74 20 75 73 65 20 28 n the next use (
13e0: 73 65 65 2c 20 69 6e 20 70 61 72 74 69 63 75 6c see, in particul
13f0: 61 72 2c 0a 2b 20 2a 09 54 63 6c 53 65 74 43 6d ar,.+ *.TclSetCm
1400: 64 4e 61 6d 65 4f 62 6a 28 29 29 2e 0a 2b 20 2a dNameObj())..+ *
1410: 0a 2b 20 2a 20 52 65 73 75 6c 74 73 3a 0a 2b 20 .+ * Results:.+
1420: 2a 09 4e 6f 6e 65 2e 0a 2b 20 2a 0a 2b 20 2a 20 *.None..+ *.+ *
1430: 53 69 64 65 20 65 66 66 65 63 74 73 3a 20 0a 2b Side effects: .+
1440: 20 2a 09 52 65 73 65 74 73 20 74 68 65 20 69 6e *.Resets the in
1450: 74 65 72 6e 61 6c 20 72 65 70 72 65 73 65 6e 74 ternal represent
1460: 61 74 69 6f 6e 20 6f 66 20 74 68 65 20 43 6d 64 ation of the Cmd
1470: 4e 61 6d 65 20 54 63 6c 5f 4f 62 6a 0a 2b 20 2a Name Tcl_Obj.+ *
1480: 09 75 73 69 6e 67 20 54 63 6c 46 72 65 65 49 6e .using TclFreeIn
1490: 74 52 65 70 28 29 2e 0a 2b 20 2a 0a 2b 20 2a 2d tRep()..+ *.+ *-
14a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
14b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
14c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
14d0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
14e0: 2d 2d 2d 2d 2d 0a 2b 20 2a 2f 0a 2b 0a 2b 76 6f -----.+ */.+.+vo
14f0: 69 64 0a 2b 54 63 6c 49 6e 76 61 6c 69 64 61 74 id.+TclInvalidat
1500: 65 43 6d 64 4c 69 74 65 72 61 6c 28 0a 2b 20 20 eCmdLiteral(.+
1510: 20 20 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e Tcl_Interp *in
1520: 74 65 72 70 2c 09 09 2f 2a 20 49 6e 74 65 72 70 terp,../* Interp
1530: 72 65 74 65 72 20 66 6f 72 20 77 68 69 63 68 20 reter for which
1540: 74 6f 20 69 6e 76 61 6c 69 64 61 74 65 20 61 0a to invalidate a.
1550: 2b 09 09 09 09 20 20 20 63 6f 6d 6d 61 6e 64 20 +.... command
1560: 6c 69 74 65 72 61 6c 20 2a 2f 0a 2b 20 20 20 20 literal */.+
1570: 43 4f 4e 53 54 20 63 68 61 72 20 2a 6e 61 6d 65 CONST char *name
1580: 2c 09 09 2f 2a 20 50 6f 69 6e 74 73 20 74 6f 20 ,../* Points to
1590: 74 68 65 20 73 74 61 72 74 20 6f 66 20 74 68 65 the start of the
15a0: 20 63 6d 64 20 6c 69 74 65 72 61 6c 20 6e 61 6d cmd literal nam
15b0: 65 20 2a 2f 0a 2b 20 20 20 20 4e 61 6d 65 73 70 e */.+ Namesp
15c0: 61 63 65 20 2a 6e 73 50 74 72 29 09 09 2f 2a 20 ace *nsPtr)../*
15d0: 54 68 65 20 6e 61 6d 65 73 70 61 63 65 20 66 6f The namespace fo
15e0: 72 20 77 68 69 63 68 20 74 6f 20 6c 6f 6f 6b 75 r which to looku
15f0: 70 20 61 6e 64 0a 2b 09 09 09 09 20 20 20 69 6e p and.+.... in
1600: 76 61 6c 69 64 61 74 65 20 61 20 63 6d 64 20 6c validate a cmd l
1610: 69 74 65 72 61 6c 20 2a 2f 0a 2b 7b 0a 2b 20 20 iteral */.+{.+
1620: 20 20 49 6e 74 65 72 70 20 2a 69 50 74 72 20 3d Interp *iPtr =
1630: 20 28 49 6e 74 65 72 70 20 2a 29 69 6e 74 65 72 (Interp *)inter
1640: 70 3b 0a 2b 20 20 20 20 54 63 6c 5f 4f 62 6a 20 p;.+ Tcl_Obj
1650: 2a 6c 69 74 65 72 61 6c 4f 62 6a 50 74 72 3b 0a *literalObjPtr;.
1660: 2b 20 20 20 20 0a 2b 20 20 20 20 6c 69 74 65 72 + .+ liter
1670: 61 6c 4f 62 6a 50 74 72 20 3d 20 54 63 6c 43 72 alObjPtr = TclCr
1680: 65 61 74 65 4c 69 74 65 72 61 6c 28 69 50 74 72 eateLiteral(iPtr
1690: 2c 20 28 63 68 61 72 20 2a 29 6e 61 6d 65 2c 20 , (char *)name,
16a0: 73 74 72 6c 65 6e 28 6e 61 6d 65 29 2c 20 2d 31 strlen(name), -1
16b0: 2c 20 4e 55 4c 4c 2c 20 0a 2b 20 20 20 20 20 20 , NULL, .+
16c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
16d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 6e n
16e0: 73 50 74 72 2c 20 30 2c 20 4e 55 4c 4c 29 3b 0a sPtr, 0, NULL);.
16f0: 2b 20 20 20 20 69 66 20 28 6c 69 74 65 72 61 6c + if (literal
1700: 4f 62 6a 50 74 72 20 26 26 20 6c 69 74 65 72 61 ObjPtr && litera
1710: 6c 4f 62 6a 50 74 72 2d 3e 74 79 70 65 50 74 72 lObjPtr->typePtr
1720: 20 3d 3d 20 26 74 63 6c 43 6d 64 4e 61 6d 65 54 == &tclCmdNameT
1730: 79 70 65 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 ype) {.+
1740: 54 63 6c 46 72 65 65 49 6e 74 52 65 70 28 6c 69 TclFreeIntRep(li
1750: 74 65 72 61 6c 4f 62 6a 50 74 72 29 3b 0a 2b 20 teralObjPtr);.+
1760: 20 20 20 7d 0a 2b 7d 0a 2b 0a 2b 0a 20 23 69 66 }.+}.+.+. #if
1770: 64 65 66 20 54 43 4c 5f 43 4f 4d 50 49 4c 45 5f def TCL_COMPILE_
1780: 53 54 41 54 53 0a 20 2f 2a 0a 20 20 2a 2d 2d 2d STATS. /*. *---
1790: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
17a0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
17b0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
17c0: 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d 2d ----------------
17d0: 2d 2d 2d 0a 20 20 2a 0a 20 20 2a 20 54 63 6c 4c ---. *. * TclL
17e0: 69 74 65 72 61 6c 53 74 61 74 73 20 2d 2d 0a 0a iteralStats --..
17f0: 49 6e 64 65 78 3a 20 67 65 6e 65 72 69 63 2f 74 Index: generic/t
1800: 63 6c 54 65 73 74 2e 63 0a 3d 3d 3d 3d 3d 3d 3d clTest.c.=======
1810: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
1820: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
1830: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
1840: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 2d 2d 2d ============.---
1850: 20 67 65 6e 65 72 69 63 2f 74 63 6c 54 65 73 74 generic/tclTest
1860: 2e 63 0a 2b 2b 2b 20 67 65 6e 65 72 69 63 2f 74 .c.+++ generic/t
1870: 63 6c 54 65 73 74 2e 63 0a 40 40 20 2d 34 30 39 clTest.c.@@ -409
1880: 2c 31 30 20 2b 34 30 39 2c 31 34 20 40 40 0a 20 ,10 +409,14 @@.
1890: 09 09 09 20 20 20 20 54 63 6c 5f 49 6e 74 65 72 ... Tcl_Inter
18a0: 70 20 2a 69 6e 74 65 72 70 2c 20 69 6e 74 20 6f p *interp, int o
18b0: 62 6a 63 2c 0a 20 09 09 09 20 20 20 20 54 63 6c bjc,. ... Tcl
18c0: 5f 4f 62 6a 20 2a 63 6f 6e 73 74 20 6f 62 6a 76 _Obj *const objv
18d0: 5b 5d 29 3b 0a 20 73 74 61 74 69 63 20 69 6e 74 []);. static int
18e0: 09 09 54 65 73 74 4e 52 45 4c 65 76 65 6c 73 28 ..TestNRELevels(
18f0: 43 6c 69 65 6e 74 44 61 74 61 20 63 6c 69 65 6e ClientData clien
1900: 74 44 61 74 61 2c 0a 20 09 09 09 20 20 20 20 54 tData,. ... T
1910: 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 cl_Interp *inter
1920: 70 2c 20 69 6e 74 20 6f 62 6a 63 2c 0a 20 09 09 p, int objc,. ..
1930: 09 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 63 6f . Tcl_Obj *co
1940: 6e 73 74 20 6f 62 6a 76 5b 5d 29 3b 0a 2b 73 74 nst objv[]);.+st
1950: 61 74 69 63 20 69 6e 74 09 09 54 65 73 74 49 6e atic int..TestIn
1960: 74 65 72 70 52 65 73 6f 6c 76 65 72 73 43 6d 64 terpResolversCmd
1970: 28 43 6c 69 65 6e 74 44 61 74 61 20 63 6c 69 65 (ClientData clie
1980: 6e 74 44 61 74 61 2c 0a 2b 09 09 09 20 20 20 20 ntData,.+...
1990: 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 Tcl_Interp *inte
19a0: 72 70 2c 20 69 6e 74 20 6f 62 6a 63 2c 0a 2b 09 rp, int objc,.+.
19b0: 09 09 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 63 .. Tcl_Obj *c
19c0: 6f 6e 73 74 20 6f 62 6a 76 5b 5d 29 3b 0a 2b 0a onst objv[]);.+.
19d0: 20 0a 20 73 74 61 74 69 63 20 63 6f 6e 73 74 20 . static const
19e0: 54 63 6c 5f 46 69 6c 65 73 79 73 74 65 6d 20 74 Tcl_Filesystem t
19f0: 65 73 74 52 65 70 6f 72 74 69 6e 67 46 69 6c 65 estReportingFile
1a00: 73 79 73 74 65 6d 20 3d 20 7b 0a 20 20 20 20 20 system = {.
1a10: 22 72 65 70 6f 72 74 69 6e 67 22 2c 0a 20 20 20 "reporting",.
1a20: 20 20 73 69 7a 65 6f 66 28 54 63 6c 5f 46 69 6c sizeof(Tcl_Fil
1a30: 65 73 79 73 74 65 6d 29 2c 0a 20 20 20 20 20 54 esystem),. T
1a40: 43 4c 5f 46 49 4c 45 53 59 53 54 45 4d 5f 56 45 CL_FILESYSTEM_VE
1a50: 52 53 49 4f 4e 5f 31 2c 0a 40 40 20 2d 36 37 33 RSION_1,.@@ -673
1a60: 2c 31 30 20 2b 36 37 37 2c 31 34 20 40 40 0a 20 ,10 +677,14 @@.
1a70: 20 20 20 20 54 63 6c 5f 43 72 65 61 74 65 4d 61 Tcl_CreateMa
1a80: 74 68 46 75 6e 63 28 69 6e 74 65 72 70 2c 20 22 thFunc(interp, "
1a90: 54 33 22 2c 20 32 2c 20 74 33 41 72 67 54 79 70 T3", 2, t3ArgTyp
1aa0: 65 73 2c 20 54 65 73 74 4d 61 74 68 46 75 6e 63 es, TestMathFunc
1ab0: 32 2c 0a 20 09 20 20 20 20 4e 55 4c 4c 29 3b 0a 2,. . NULL);.
1ac0: 20 0a 20 20 20 20 20 54 63 6c 5f 43 72 65 61 74 . Tcl_Creat
1ad0: 65 4f 62 6a 43 6f 6d 6d 61 6e 64 28 69 6e 74 65 eObjCommand(inte
1ae0: 72 70 2c 20 22 74 65 73 74 6e 72 65 6c 65 76 65 rp, "testnreleve
1af0: 6c 73 22 2c 20 54 65 73 74 4e 52 45 4c 65 76 65 ls", TestNRELeve
1b00: 6c 73 2c 0a 20 09 20 20 20 20 4e 55 4c 4c 2c 20 ls,. . NULL,
1b10: 4e 55 4c 4c 29 3b 0a 2b 0a 2b 20 20 20 20 54 63 NULL);.+.+ Tc
1b20: 6c 5f 43 72 65 61 74 65 4f 62 6a 43 6f 6d 6d 61 l_CreateObjComma
1b30: 6e 64 28 69 6e 74 65 72 70 2c 20 22 74 65 73 74 nd(interp, "test
1b40: 69 6e 74 65 72 70 72 65 73 6f 6c 76 65 72 22 2c interpresolver",
1b50: 20 54 65 73 74 49 6e 74 65 72 70 52 65 73 6f 6c TestInterpResol
1b60: 76 65 72 73 43 6d 64 2c 0a 2b 09 20 20 20 20 4e versCmd,.+. N
1b70: 55 4c 4c 2c 20 4e 55 4c 4c 29 3b 0a 2b 0a 20 0a ULL, NULL);.+. .
1b80: 20 20 20 20 20 69 66 20 28 54 63 6c 4f 62 6a 54 if (TclObjT
1b90: 65 73 74 5f 49 6e 69 74 28 69 6e 74 65 72 70 29 est_Init(interp)
1ba0: 20 21 3d 20 54 43 4c 5f 4f 4b 29 20 7b 0a 20 09 != TCL_OK) {. .
1bb0: 72 65 74 75 72 6e 20 54 43 4c 5f 45 52 52 4f 52 return TCL_ERROR
1bc0: 3b 0a 20 20 20 20 20 7d 0a 20 20 20 20 20 69 66 ;. }. if
1bd0: 20 28 50 72 6f 63 62 6f 64 79 74 65 73 74 5f 49 (Procbodytest_I
1be0: 6e 69 74 28 69 6e 74 65 72 70 29 20 21 3d 20 54 nit(interp) != T
1bf0: 43 4c 5f 4f 4b 29 20 7b 0a 40 40 20 2d 37 31 32 CL_OK) {.@@ -712
1c00: 34 2c 31 30 20 2b 37 31 33 32 2c 31 39 36 20 40 4,10 +7132,196 @
1c10: 40 0a 20 20 20 20 20 72 65 73 75 6c 74 5b 32 5d @. result[2]
1c20: 20 3d 20 54 63 6c 5f 4e 65 77 4c 69 73 74 4f 62 = Tcl_NewListOb
1c30: 6a 28 63 6f 75 6e 74 2c 20 72 65 6d 4f 62 6a 76 j(count, remObjv
1c40: 29 3b 0a 20 20 20 20 20 54 63 6c 5f 53 65 74 4f );. Tcl_SetO
1c50: 62 6a 52 65 73 75 6c 74 28 69 6e 74 65 72 70 2c bjResult(interp,
1c60: 20 54 63 6c 5f 4e 65 77 4c 69 73 74 4f 62 6a 28 Tcl_NewListObj(
1c70: 33 2c 20 72 65 73 75 6c 74 29 29 3b 0a 20 20 20 3, result));.
1c80: 20 20 63 6b 66 72 65 65 28 72 65 6d 4f 62 6a 76 ckfree(remObjv
1c90: 29 3b 0a 20 20 20 20 20 72 65 74 75 72 6e 20 54 );. return T
1ca0: 43 4c 5f 4f 4b 3b 0a 20 7d 0a 2b 20 0a 2b 20 0a CL_OK;. }.+ .+ .
1cb0: 2b 73 74 61 74 69 63 20 69 6e 74 0a 2b 49 6e 74 +static int.+Int
1cc0: 65 72 70 43 6d 64 52 65 73 6f 6c 76 65 72 28 54 erpCmdResolver(T
1cd0: 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 cl_Interp *inter
1ce0: 70 2c 20 0a 2b 20 20 20 20 20 20 20 20 20 20 20 p, .+
1cf0: 20 20 20 20 20 20 20 43 4f 4e 53 54 38 34 20 63 CONST84 c
1d00: 68 61 72 20 2a 6e 61 6d 65 2c 0a 2b 20 20 20 20 har *name,.+
1d10: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 54 63 Tc
1d20: 6c 5f 4e 61 6d 65 73 70 61 63 65 20 2a 63 6f 6e l_Namespace *con
1d30: 74 65 78 74 2c 20 0a 2b 20 20 20 20 20 20 20 20 text, .+
1d40: 20 20 20 20 20 20 20 20 20 20 69 6e 74 20 66 6c int fl
1d50: 61 67 73 2c 20 0a 2b 20 20 20 20 20 20 20 20 20 ags, .+
1d60: 20 20 20 20 20 20 20 20 20 54 63 6c 5f 43 6f 6d Tcl_Com
1d70: 6d 61 6e 64 20 2a 72 50 74 72 29 20 0a 2b 7b 0a mand *rPtr) .+{.
1d80: 2b 20 20 20 20 54 63 6c 5f 43 6f 6d 6d 61 6e 64 + Tcl_Command
1d90: 20 73 6f 75 72 63 65 43 6d 64 50 74 72 3b 0a 2b sourceCmdPtr;.+
1da0: 20 20 20 20 49 6e 74 65 72 70 20 2a 69 50 74 72 Interp *iPtr
1db0: 20 3d 20 28 49 6e 74 65 72 70 20 2a 29 69 6e 74 = (Interp *)int
1dc0: 65 72 70 3b 0a 2b 20 20 20 20 43 61 6c 6c 46 72 erp;.+ CallFr
1dd0: 61 6d 65 20 2a 76 61 72 46 72 61 6d 65 50 74 72 ame *varFramePtr
1de0: 20 3d 20 69 50 74 72 2d 3e 76 61 72 46 72 61 6d = iPtr->varFram
1df0: 65 50 74 72 3b 0a 2b 20 20 20 20 50 72 6f 63 20 ePtr;.+ Proc
1e00: 2a 70 72 6f 63 50 74 72 20 3d 20 28 76 61 72 46 *procPtr = (varF
1e10: 72 61 6d 65 50 74 72 2d 3e 69 73 50 72 6f 63 43 ramePtr->isProcC
1e20: 61 6c 6c 46 72 61 6d 65 20 26 20 46 52 41 4d 45 allFrame & FRAME
1e30: 5f 49 53 5f 50 52 4f 43 29 20 3f 20 0a 2b 20 20 _IS_PROC) ? .+
1e40: 20 20 20 20 20 20 76 61 72 46 72 61 6d 65 50 74 varFramePt
1e50: 72 2d 3e 70 72 6f 63 50 74 72 20 3a 20 4e 55 4c r->procPtr : NUL
1e60: 4c 3b 0a 2b 20 20 20 20 4e 61 6d 65 73 70 61 63 L;.+ Namespac
1e70: 65 20 2a 6e 73 32 4e 73 50 74 72 3b 0a 2b 20 20 e *ns2NsPtr;.+
1e80: 20 20 0a 2b 20 20 20 20 6e 73 32 4e 73 50 74 72 .+ ns2NsPtr
1e90: 20 3d 20 54 63 6c 5f 46 69 6e 64 4e 61 6d 65 73 = Tcl_FindNames
1ea0: 70 61 63 65 28 69 6e 74 65 72 70 2c 20 22 3a 3a pace(interp, "::
1eb0: 6e 73 32 22 2c 20 4e 55 4c 4c 2c 20 30 29 3b 0a ns2", NULL, 0);.
1ec0: 2b 20 0a 2b 20 20 20 20 69 66 20 28 70 72 6f 63 + .+ if (proc
1ed0: 50 74 72 20 26 26 20 28 70 72 6f 63 50 74 72 2d Ptr && (procPtr-
1ee0: 3e 63 6d 64 50 74 72 2d 3e 6e 73 50 74 72 20 3d >cmdPtr->nsPtr =
1ef0: 3d 20 69 50 74 72 2d 3e 67 6c 6f 62 61 6c 4e 73 = iPtr->globalNs
1f00: 50 74 72 20 7c 7c 20 28 6e 73 32 4e 73 50 74 72 Ptr || (ns2NsPtr
1f10: 20 26 26 20 70 72 6f 63 50 74 72 2d 3e 63 6d 64 && procPtr->cmd
1f20: 50 74 72 2d 3e 6e 73 50 74 72 20 3d 3d 20 6e 73 Ptr->nsPtr == ns
1f30: 32 4e 73 50 74 72 29 29 29 20 7b 0a 2b 20 20 20 2NsPtr))) {.+
1f40: 20 20 20 20 20 43 4f 4e 53 54 20 63 68 61 72 20 CONST char
1f50: 2a 63 61 6c 6c 69 6e 67 43 6d 64 4e 61 6d 65 20 *callingCmdName
1f60: 3d 20 54 63 6c 5f 47 65 74 43 6f 6d 6d 61 6e 64 = Tcl_GetCommand
1f70: 4e 61 6d 65 28 69 6e 74 65 72 70 2c 20 28 54 63 Name(interp, (Tc
1f80: 6c 5f 43 6f 6d 6d 61 6e 64 29 70 72 6f 63 50 74 l_Command)procPt
1f90: 72 2d 3e 63 6d 64 50 74 72 29 3b 0a 2b 20 09 0a r->cmdPtr);.+ ..
1fa0: 2b 20 20 20 20 20 20 20 20 69 66 20 28 2a 63 61 + if (*ca
1fb0: 6c 6c 69 6e 67 43 6d 64 4e 61 6d 65 20 3d 3d 20 llingCmdName ==
1fc0: 27 78 27 20 26 26 20 2a 28 63 61 6c 6c 69 6e 67 'x' && *(calling
1fd0: 43 6d 64 4e 61 6d 65 20 2b 20 31 29 20 3d 3d 20 CmdName + 1) ==
1fe0: 27 5c 30 27 20 26 26 20 0a 2b 20 20 20 20 20 20 '\0' && .+
1ff0: 20 20 20 20 20 20 2a 6e 61 6d 65 20 3d 3d 20 27 *name == '
2000: 7a 27 20 26 26 20 2a 28 6e 61 6d 65 20 2b 20 31 z' && *(name + 1
2010: 29 20 3d 3d 20 27 5c 30 27 29 20 7b 0a 2b 20 20 ) == '\0') {.+
2020: 20 20 20 20 20 20 20 20 20 20 73 6f 75 72 63 65 source
2030: 43 6d 64 50 74 72 20 3d 20 54 63 6c 5f 46 69 6e CmdPtr = Tcl_Fin
2040: 64 43 6f 6d 6d 61 6e 64 28 69 6e 74 65 72 70 2c dCommand(interp,
2050: 20 22 79 22 2c 20 4e 55 4c 4c 2c 20 54 43 4c 5f "y", NULL, TCL_
2060: 47 4c 4f 42 41 4c 5f 4f 4e 4c 59 29 3b 0a 2b 20 GLOBAL_ONLY);.+
2070: 20 20 20 20 20 20 20 20 20 20 20 69 66 20 28 73 if (s
2080: 6f 75 72 63 65 43 6d 64 50 74 72 20 21 3d 20 4e ourceCmdPtr != N
2090: 55 4c 4c 29 20 7b 0a 2b 20 0a 2b 20 09 09 2f 2a ULL) {.+ .+ ../*
20a0: 66 70 72 69 6e 74 66 28 73 74 64 6f 75 74 2c 20 fprintf(stdout,
20b0: 22 49 6e 74 65 72 70 43 6d 64 52 65 73 6f 6c 76 "InterpCmdResolv
20c0: 65 72 20 72 65 73 6f 6c 76 65 73 20 63 6d 64 20 er resolves cmd
20d0: 25 73 20 61 73 20 27 3a 3a 79 27 20 69 6e 20 70 %s as '::y' in p
20e0: 72 6f 63 20 27 78 27 5c 6e 22 2c 20 6e 61 6d 65 roc 'x'\n", name
20f0: 29 3b 2a 2f 0a 2b 20 0a 2b 20 20 20 20 20 20 20 );*/.+ .+
2100: 20 20 20 20 20 20 20 20 20 2a 72 50 74 72 20 3d *rPtr =
2110: 20 73 6f 75 72 63 65 43 6d 64 50 74 72 3b 0a 2b sourceCmdPtr;.+
2120: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2130: 72 65 74 75 72 6e 20 54 43 4c 5f 4f 4b 3b 0a 2b return TCL_OK;.+
2140: 20 20 20 20 20 20 20 20 20 20 20 20 7d 0a 2b 20 }.+
2150: 20 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 7d 0a }.+ }.
2160: 2b 20 20 20 20 72 65 74 75 72 6e 20 54 43 4c 5f + return TCL_
2170: 43 4f 4e 54 49 4e 55 45 3b 0a 2b 7d 0a 2b 20 0a CONTINUE;.+}.+ .
2180: 2b 73 74 61 74 69 63 20 69 6e 74 0a 2b 49 6e 74 +static int.+Int
2190: 65 72 70 56 61 72 52 65 73 6f 6c 76 65 72 28 54 erpVarResolver(T
21a0: 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 cl_Interp *inter
21b0: 70 2c 20 0a 2b 20 20 20 20 20 20 20 20 20 20 20 p, .+
21c0: 20 20 20 20 20 20 20 43 4f 4e 53 54 38 34 20 63 CONST84 c
21d0: 68 61 72 20 2a 6e 61 6d 65 2c 0a 2b 20 20 20 20 har *name,.+
21e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 54 63 Tc
21f0: 6c 5f 4e 61 6d 65 73 70 61 63 65 20 2a 63 6f 6e l_Namespace *con
2200: 74 65 78 74 2c 20 0a 2b 20 20 20 20 20 20 20 20 text, .+
2210: 20 20 20 20 20 20 20 20 20 20 69 6e 74 20 66 6c int fl
2220: 61 67 73 2c 20 0a 2b 20 20 20 20 20 20 20 20 20 ags, .+
2230: 20 20 20 20 20 20 20 20 20 54 63 6c 5f 56 61 72 Tcl_Var
2240: 20 2a 72 50 74 72 29 20 0a 2b 7b 0a 2b 20 20 20 *rPtr) .+{.+
2250: 20 72 65 74 75 72 6e 20 54 43 4c 5f 43 4f 4e 54 return TCL_CONT
2260: 49 4e 55 45 3b 0a 2b 7d 0a 2b 20 0a 2b 74 79 70 INUE;.+}.+ .+typ
2270: 65 64 65 66 20 73 74 72 75 63 74 20 4d 79 52 65 edef struct MyRe
2280: 73 6f 6c 76 65 64 56 61 72 49 6e 66 6f 20 7b 0a solvedVarInfo {.
2290: 2b 20 20 20 20 54 63 6c 5f 52 65 73 6f 6c 76 65 + Tcl_Resolve
22a0: 64 56 61 72 49 6e 66 6f 20 76 49 6e 66 6f 3b 20 dVarInfo vInfo;
22b0: 20 20 20 20 20 20 20 2f 2a 20 54 68 69 73 20 6d /* This m
22c0: 75 73 74 20 62 65 20 74 68 65 20 66 69 72 73 74 ust be the first
22d0: 20 65 6c 65 6d 65 6e 74 2e 20 2a 2f 0a 2b 20 20 element. */.+
22e0: 20 20 54 63 6c 5f 56 61 72 20 76 61 72 3b 0a 2b Tcl_Var var;.+
22f0: 20 20 20 20 54 63 6c 5f 4f 62 6a 20 2a 6e 61 6d Tcl_Obj *nam
2300: 65 4f 62 6a 3b 0a 2b 7d 20 4d 79 52 65 73 6f 6c eObj;.+} MyResol
2310: 76 65 64 56 61 72 49 6e 66 6f 3b 0a 2b 20 0a 2b vedVarInfo;.+ .+
2320: 20 0a 2b 73 74 61 74 69 63 20 76 6f 69 64 0a 2b .+static void.+
2330: 48 61 73 68 56 61 72 46 72 65 65 28 54 63 6c 5f HashVarFree(Tcl_
2340: 56 61 72 20 76 61 72 29 20 7b 0a 2b 20 20 20 20 Var var) {.+
2350: 69 66 20 28 56 61 72 48 61 73 68 52 65 66 43 6f if (VarHashRefCo
2360: 75 6e 74 28 76 61 72 29 20 3c 20 32 29 20 7b 0a unt(var) < 2) {.
2370: 2b 20 20 20 20 20 20 20 20 63 6b 66 72 65 65 28 + ckfree(
2380: 28 63 68 61 72 20 2a 29 20 76 61 72 29 3b 0a 2b (char *) var);.+
2390: 20 20 20 20 7d 20 65 6c 73 65 20 7b 0a 2b 20 20 } else {.+
23a0: 20 20 20 20 20 20 56 61 72 48 61 73 68 52 65 66 VarHashRef
23b0: 43 6f 75 6e 74 28 76 61 72 29 2d 2d 3b 0a 2b 20 Count(var)--;.+
23c0: 20 20 20 7d 0a 2b 7d 0a 2b 20 0a 2b 20 0a 2b 73 }.+}.+ .+ .+s
23d0: 74 61 74 69 63 20 76 6f 69 64 0a 2b 4d 79 43 6f tatic void.+MyCo
23e0: 6d 70 69 6c 65 64 56 61 72 46 72 65 65 28 54 63 mpiledVarFree(Tc
23f0: 6c 5f 52 65 73 6f 6c 76 65 64 56 61 72 49 6e 66 l_ResolvedVarInf
2400: 6f 20 2a 76 49 6e 66 6f 50 74 72 29 20 7b 0a 2b o *vInfoPtr) {.+
2410: 20 20 20 20 4d 79 52 65 73 6f 6c 76 65 64 56 61 MyResolvedVa
2420: 72 49 6e 66 6f 20 2a 72 65 73 56 61 72 49 6e 66 rInfo *resVarInf
2430: 6f 20 3d 20 28 4d 79 52 65 73 6f 6c 76 65 64 56 o = (MyResolvedV
2440: 61 72 49 6e 66 6f 20 2a 29 76 49 6e 66 6f 50 74 arInfo *)vInfoPt
2450: 72 3b 0a 2b 20 0a 2b 20 20 20 20 2f 2a 66 70 72 r;.+ .+ /*fpr
2460: 69 6e 74 66 28 73 74 64 65 72 72 2c 20 22 4d 79 intf(stderr, "My
2470: 43 6f 6d 70 69 6c 65 64 56 61 72 46 72 65 65 20 CompiledVarFree
2480: 25 70 20 66 6f 72 20 76 61 72 69 61 62 6c 65 20 %p for variable
2490: 27 25 73 27 5c 6e 22 2c 20 0a 2b 20 20 20 20 20 '%s'\n", .+
24a0: 20 72 65 73 56 61 72 49 6e 66 6f 2c 20 54 63 6c resVarInfo, Tcl
24b0: 5f 47 65 74 53 74 72 69 6e 67 28 72 65 73 56 61 _GetString(resVa
24c0: 72 49 6e 66 6f 2d 3e 6e 61 6d 65 4f 62 6a 29 29 rInfo->nameObj))
24d0: 3b 2a 2f 0a 2b 20 0a 2b 20 20 20 20 54 63 6c 5f ;*/.+ .+ Tcl_
24e0: 44 65 63 72 52 65 66 43 6f 75 6e 74 28 72 65 73 DecrRefCount(res
24f0: 56 61 72 49 6e 66 6f 2d 3e 6e 61 6d 65 4f 62 6a VarInfo->nameObj
2500: 29 3b 0a 2b 20 20 20 20 69 66 20 28 72 65 73 56 );.+ if (resV
2510: 61 72 49 6e 66 6f 2d 3e 76 61 72 29 20 7b 0a 2b arInfo->var) {.+
2520: 20 20 20 20 20 20 20 20 48 61 73 68 56 61 72 46 HashVarF
2530: 72 65 65 28 72 65 73 56 61 72 49 6e 66 6f 2d 3e ree(resVarInfo->
2540: 76 61 72 29 3b 0a 2b 20 20 20 20 7d 0a 2b 20 20 var);.+ }.+
2550: 20 20 63 6b 66 72 65 65 28 28 63 68 61 72 20 2a ckfree((char *
2560: 29 76 49 6e 66 6f 50 74 72 29 3b 0a 2b 7d 0a 2b )vInfoPtr);.+}.+
2570: 20 0a 2b 23 64 65 66 69 6e 65 20 54 63 6c 56 61 .+#define TclVa
2580: 72 48 61 73 68 47 65 74 56 61 6c 75 65 28 68 50 rHashGetValue(hP
2590: 74 72 29 09 28 28 56 61 72 20 2a 29 20 28 28 63 tr).((Var *) ((c
25a0: 68 61 72 20 2a 29 68 50 74 72 20 2d 20 54 63 6c har *)hPtr - Tcl
25b0: 4f 66 66 73 65 74 28 56 61 72 49 6e 48 61 73 68 Offset(VarInHash
25c0: 2c 20 65 6e 74 72 79 29 29 29 0a 2b 20 0a 2b 73 , entry))).+ .+s
25d0: 74 61 74 69 63 20 54 63 6c 5f 56 61 72 0a 2b 4d tatic Tcl_Var.+M
25e0: 79 43 6f 6d 70 69 6c 65 64 56 61 72 46 65 74 63 yCompiledVarFetc
25f0: 68 28 54 63 6c 5f 49 6e 74 65 72 70 20 2a 69 6e h(Tcl_Interp *in
2600: 74 65 72 70 2c 20 54 63 6c 5f 52 65 73 6f 6c 76 terp, Tcl_Resolv
2610: 65 64 56 61 72 49 6e 66 6f 20 2a 76 69 6e 66 6f edVarInfo *vinfo
2620: 50 74 72 29 20 7b 0a 2b 20 20 20 20 4d 79 52 65 Ptr) {.+ MyRe
2630: 73 6f 6c 76 65 64 56 61 72 49 6e 66 6f 20 2a 72 solvedVarInfo *r
2640: 65 73 56 61 72 49 6e 66 6f 20 3d 20 28 4d 79 52 esVarInfo = (MyR
2650: 65 73 6f 6c 76 65 64 56 61 72 49 6e 66 6f 20 2a esolvedVarInfo *
2660: 29 76 69 6e 66 6f 50 74 72 3b 0a 2b 20 20 20 20 )vinfoPtr;.+
2670: 54 63 6c 5f 56 61 72 20 76 61 72 20 3d 20 72 65 Tcl_Var var = re
2680: 73 56 61 72 49 6e 66 6f 2d 3e 76 61 72 3b 0a 2b sVarInfo->var;.+
2690: 20 20 20 20 4e 61 6d 65 73 70 61 63 65 20 2a 6e Namespace *n
26a0: 73 50 74 72 3b 0a 2b 20 20 20 20 69 6e 74 20 69 sPtr;.+ int i
26b0: 73 4e 65 77 56 61 72 3b 0a 2b 20 20 20 20 49 6e sNewVar;.+ In
26c0: 74 65 72 70 20 2a 69 50 74 72 20 3d 20 28 49 6e terp *iPtr = (In
26d0: 74 65 72 70 20 2a 29 20 69 6e 74 65 72 70 3b 0a terp *) interp;.
26e0: 2b 20 20 20 20 54 63 6c 5f 48 61 73 68 45 6e 74 + Tcl_HashEnt
26f0: 72 79 20 2a 68 50 74 72 3b 0a 2b 20 0a 2b 20 20 ry *hPtr;.+ .+
2700: 20 20 2f 2a 0a 2b 20 20 20 20 20 20 69 6e 74 20 /*.+ int
2710: 66 6c 61 67 73 20 3d 20 76 61 72 20 3f 20 28 28 flags = var ? ((
2720: 56 61 72 20 2a 29 76 61 72 29 2d 3e 66 6c 61 67 Var *)var)->flag
2730: 73 20 3a 20 30 3b 0a 2b 20 20 20 20 20 20 66 70 s : 0;.+ fp
2740: 72 69 6e 74 66 28 73 74 64 65 72 72 2c 22 4d 79 rintf(stderr,"My
2750: 43 6f 6d 70 69 6c 65 64 56 61 72 46 65 74 63 68 CompiledVarFetch
2760: 20 76 61 72 20 27 25 73 27 20 76 61 72 20 25 70 var '%s' var %p
2770: 20 66 6c 61 67 73 20 3d 20 25 2e 34 78 20 64 65 flags = %.4x de
2780: 61 64 3f 20 25 2e 34 78 5c 6e 22 2c 0a 2b 20 20 ad? %.4x\n",.+
2790: 20 20 20 20 54 63 6c 5f 47 65 74 53 74 72 69 6e Tcl_GetStrin
27a0: 67 28 72 65 73 56 61 72 49 6e 66 6f 2d 3e 6e 61 g(resVarInfo->na
27b0: 6d 65 4f 62 6a 29 2c 20 76 61 72 2c 20 66 6c 61 meObj), var, fla
27c0: 67 73 2c 20 66 6c 61 67 73 20 26 20 56 41 52 5f gs, flags & VAR_
27d0: 44 45 41 44 5f 48 41 53 48 29 3b 2a 2f 0a 2b 20 DEAD_HASH);*/.+
27e0: 0a 2b 20 20 20 20 69 66 20 28 76 61 72 20 26 26 .+ if (var &&
27f0: 20 28 28 28 28 28 56 61 72 20 2a 29 76 61 72 29 (((((Var *)var)
2800: 2d 3e 66 6c 61 67 73 29 20 26 20 56 41 52 5f 44 ->flags) & VAR_D
2810: 45 41 44 5f 48 41 53 48 29 20 3d 3d 20 30 29 29 EAD_HASH) == 0))
2820: 20 7b 0a 2b 20 20 20 20 20 20 20 20 2f 2a 0a 2b {.+ /*.+
2830: 20 20 20 20 20 20 20 20 20 2a 20 54 68 65 20 63 * The c
2840: 61 63 68 65 64 20 76 61 72 69 61 62 6c 65 20 69 ached variable i
2850: 73 20 76 61 6c 69 64 2c 20 72 65 74 75 72 6e 20 s valid, return
2860: 69 74 2e 0a 2b 20 20 20 20 20 20 20 20 20 2a 2f it..+ */
2870: 0a 2b 20 20 20 20 20 20 20 20 2f 2a 66 70 72 69 .+ /*fpri
2880: 6e 74 66 28 73 74 64 65 72 72 2c 20 22 2e 2e 2e ntf(stderr, "...
2890: 2e 20 75 73 65 20 63 61 63 68 65 64 20 76 61 72 . use cached var
28a0: 20 27 25 73 27 20 76 61 72 20 25 70 20 66 6c 61 '%s' var %p fla
28b0: 67 73 20 3d 20 25 2e 34 78 5c 6e 22 2c 0a 2b 20 gs = %.4x\n",.+
28c0: 20 20 20 20 20 20 20 20 20 54 63 6c 5f 47 65 74 Tcl_Get
28d0: 53 74 72 69 6e 67 28 72 65 73 56 61 72 49 6e 66 String(resVarInf
28e0: 6f 2d 3e 6e 61 6d 65 4f 62 6a 29 2c 20 76 61 72 o->nameObj), var
28f0: 2c 20 28 28 56 61 72 20 2a 29 76 61 72 29 2d 3e , ((Var *)var)->
2900: 66 6c 61 67 73 29 3b 2a 2f 0a 2b 20 20 20 20 20 flags);*/.+
2910: 20 20 20 72 65 74 75 72 6e 20 76 61 72 3b 0a 2b return var;.+
2920: 20 20 20 20 7d 0a 2b 20 0a 2b 20 20 20 20 69 66 }.+ .+ if
2930: 20 28 76 61 72 29 20 7b 0a 2b 20 20 20 20 20 20 (var) {.+
2940: 20 20 2f 2a 0a 2b 20 20 20 20 20 20 20 20 20 2a /*.+ *
2950: 20 54 68 65 20 76 61 72 69 61 62 6c 65 20 69 73 The variable is
2960: 20 6e 6f 74 20 76 61 6c 69 64 20 61 6e 79 6d 6f not valid anymo
2970: 72 65 2e 20 43 6c 65 61 6e 20 69 74 20 75 70 2e re. Clean it up.
2980: 0a 2b 20 20 20 20 20 20 20 20 20 2a 2f 0a 2b 20 .+ */.+
2990: 20 20 20 20 20 20 20 48 61 73 68 56 61 72 46 72 HashVarFr
29a0: 65 65 28 76 61 72 29 3b 0a 2b 20 20 20 20 7d 0a ee(var);.+ }.
29b0: 2b 20 0a 2b 20 20 20 20 6e 73 50 74 72 20 3d 20 + .+ nsPtr =
29c0: 69 50 74 72 2d 3e 67 6c 6f 62 61 6c 4e 73 50 74 iPtr->globalNsPt
29d0: 72 3b 0a 2b 20 0a 2b 20 20 20 20 68 50 74 72 20 r;.+ .+ hPtr
29e0: 3d 20 54 63 6c 5f 43 72 65 61 74 65 48 61 73 68 = Tcl_CreateHash
29f0: 45 6e 74 72 79 28 28 54 63 6c 5f 48 61 73 68 54 Entry((Tcl_HashT
2a00: 61 62 6c 65 20 2a 29 26 28 6e 73 50 74 72 2d 3e able *)&(nsPtr->
2a10: 76 61 72 54 61 62 6c 65 29 2c 0a 2b 20 20 20 20 varTable),.+
2a20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2a30: 20 20 20 20 20 20 20 20 20 20 20 28 63 68 61 72 (char
2a40: 20 2a 29 20 72 65 73 56 61 72 49 6e 66 6f 2d 3e *) resVarInfo->
2a50: 6e 61 6d 65 4f 62 6a 2c 20 26 69 73 4e 65 77 56 nameObj, &isNewV
2a60: 61 72 29 3b 0a 2b 20 20 20 20 69 66 20 28 68 50 ar);.+ if (hP
2a70: 74 72 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 76 tr) {.+ v
2a80: 61 72 20 3d 20 28 54 63 6c 5f 56 61 72 29 54 63 ar = (Tcl_Var)Tc
2a90: 6c 56 61 72 48 61 73 68 47 65 74 56 61 6c 75 65 lVarHashGetValue
2aa0: 28 68 50 74 72 29 3b 0a 2b 20 20 20 20 7d 20 65 (hPtr);.+ } e
2ab0: 6c 73 65 20 7b 0a 2b 20 20 20 20 20 20 20 20 76 lse {.+ v
2ac0: 61 72 20 3d 20 4e 55 4c 4c 3b 0a 2b 20 20 20 20 ar = NULL;.+
2ad0: 7d 0a 2b 20 20 20 0a 2b 20 20 20 20 72 65 73 56 }.+ .+ resV
2ae0: 61 72 49 6e 66 6f 2d 3e 76 61 72 20 3d 20 76 61 arInfo->var = va
2af0: 72 3b 0a 2b 20 20 20 20 2f 2a 0a 2b 20 20 20 20 r;.+ /*.+
2b00: 20 2a 20 49 6e 63 72 65 6d 65 6e 74 20 74 68 65 * Increment the
2b10: 20 72 65 66 65 72 65 6e 63 65 20 63 6f 75 6e 74 reference count
2b20: 65 72 20 74 6f 20 61 76 6f 69 64 20 63 6b 66 72 er to avoid ckfr
2b30: 65 65 28 29 20 6f 66 20 74 68 65 20 76 61 72 69 ee() of the vari
2b40: 61 62 6c 65 0a 2b 20 20 20 20 20 2a 20 69 6e 20 able.+ * in
2b50: 54 63 6c 27 73 20 46 72 65 65 56 61 72 45 6e 74 Tcl's FreeVarEnt
2b60: 72 79 28 29 3b 20 66 6f 72 20 63 6c 65 61 6e 75 ry(); for cleanu
2b70: 70 2c 20 77 65 20 70 72 6f 76 69 64 65 20 6f 75 p, we provide ou
2b80: 72 20 6f 77 6e 0a 2b 20 20 20 20 20 2a 20 48 61 r own.+ * Ha
2b90: 73 68 56 61 72 46 72 65 65 28 29 3b 0a 2b 20 20 shVarFree();.+
2ba0: 20 20 20 2a 2f 0a 2b 20 20 20 20 56 61 72 48 61 */.+ VarHa
2bb0: 73 68 52 65 66 43 6f 75 6e 74 28 76 61 72 29 3b shRefCount(var);
2bc0: 0a 2b 20 0a 2b 20 20 20 20 72 65 74 75 72 6e 20 .+ .+ return
2bd0: 76 61 72 3b 0a 2b 7d 0a 2b 20 0a 2b 20 0a 2b 73 var;.+}.+ .+ .+s
2be0: 74 61 74 69 63 20 69 6e 74 0a 2b 49 6e 74 65 72 tatic int.+Inter
2bf0: 70 43 6f 6d 70 69 6c 65 64 56 61 72 52 65 73 6f pCompiledVarReso
2c00: 6c 76 65 72 28 54 63 6c 5f 49 6e 74 65 72 70 20 lver(Tcl_Interp
2c10: 2a 69 6e 74 65 72 70 2c 0a 2b 20 20 20 20 20 20 *interp,.+
2c20: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2c30: 20 20 20 20 43 4f 4e 53 54 38 34 20 63 68 61 72 CONST84 char
2c40: 20 2a 6e 61 6d 65 2c 20 0a 2b 20 20 20 20 20 20 *name, .+
2c50: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
2c60: 20 20 20 20 69 6e 74 20 6c 65 6e 67 74 68 2c 20 int length,
2c70: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .+
2c80: 20 20 20 20 20 20 20 20 20 20 20 20 54 63 6c 5f Tcl_
2c90: 4e 61 6d 65 73 70 61 63 65 20 2a 63 6f 6e 74 65 Namespace *conte
2ca0: 78 74 2c 0a 2b 20 20 20 20 20 20 20 20 20 20 20 xt,.+
2cb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 54 T
2cc0: 63 6c 5f 52 65 73 6f 6c 76 65 64 56 61 72 49 6e cl_ResolvedVarIn
2cd0: 66 6f 20 2a 2a 72 50 74 72 29 0a 2b 7b 0a 2b 20 fo **rPtr).+{.+
2ce0: 20 20 20 2f 2a 66 70 72 69 6e 74 66 28 73 74 64 /*fprintf(std
2cf0: 65 72 72 2c 20 22 49 6e 74 65 72 70 43 6f 6d 70 err, "InterpComp
2d00: 69 6c 65 64 56 61 72 52 65 73 6f 6c 76 65 72 20 iledVarResolver
2d10: 66 6f 72 20 27 25 73 27 5c 6e 22 2c 20 6e 61 6d for '%s'\n", nam
2d20: 65 29 3b 2a 2f 0a 2b 20 20 20 20 2f 2a 20 73 70 e);*/.+ /* sp
2d30: 65 63 69 61 6c 20 68 61 6e 64 6c 69 6e 67 20 6f ecial handling o
2d40: 66 20 76 61 72 69 61 62 6c 65 73 20 73 74 61 72 f variables star
2d50: 74 69 6e 67 20 77 69 74 68 20 61 20 63 61 70 69 ting with a capi
2d60: 74 61 6c 20 54 20 2a 2f 0a 2b 20 20 20 20 69 66 tal T */.+ if
2d70: 20 28 2a 6e 61 6d 65 20 3d 3d 20 27 54 27 29 20 (*name == 'T')
2d80: 7b 0a 2b 20 09 4d 79 52 65 73 6f 6c 76 65 64 56 {.+ .MyResolvedV
2d90: 61 72 49 6e 66 6f 20 2a 72 65 73 56 61 72 49 6e arInfo *resVarIn
2da0: 66 6f 20 3d 20 63 6b 61 6c 6c 6f 63 28 73 69 7a fo = ckalloc(siz
2db0: 65 6f 66 28 4d 79 52 65 73 6f 6c 76 65 64 56 61 eof(MyResolvedVa
2dc0: 72 49 6e 66 6f 29 29 3b 0a 2b 20 09 2f 2a 66 70 rInfo));.+ ./*fp
2dd0: 72 69 6e 74 66 28 73 74 64 65 72 72 2c 20 22 61 rintf(stderr, "a
2de0: 6c 6c 6f 63 20 4d 79 52 65 73 6f 6c 76 65 64 56 lloc MyResolvedV
2df0: 61 72 49 6e 66 6f 20 25 70 5c 6e 22 2c 20 72 65 arInfo %p\n", re
2e00: 73 56 61 72 49 6e 66 6f 29 3b 2a 2f 0a 2b 20 09 sVarInfo);*/.+ .
2e10: 72 65 73 56 61 72 49 6e 66 6f 2d 3e 76 49 6e 66 resVarInfo->vInf
2e20: 6f 2e 66 65 74 63 68 50 72 6f 63 20 3d 20 4d 79 o.fetchProc = My
2e30: 43 6f 6d 70 69 6c 65 64 56 61 72 46 65 74 63 68 CompiledVarFetch
2e40: 3b 0a 2b 20 09 72 65 73 56 61 72 49 6e 66 6f 2d ;.+ .resVarInfo-
2e50: 3e 76 49 6e 66 6f 2e 64 65 6c 65 74 65 50 72 6f >vInfo.deletePro
2e60: 63 20 3d 20 4d 79 43 6f 6d 70 69 6c 65 64 56 61 c = MyCompiledVa
2e70: 72 46 72 65 65 3b 20 2f 2a 20 69 66 20 4e 55 4c rFree; /* if NUL
2e80: 4c 2c 20 54 63 6c 20 64 6f 65 73 20 61 20 63 6b L, Tcl does a ck
2e90: 66 72 65 65 20 6f 6e 20 70 72 6f 63 20 63 6c 65 free on proc cle
2ea0: 61 6e 20 75 70 20 2a 2f 0a 2b 20 09 72 65 73 56 an up */.+ .resV
2eb0: 61 72 49 6e 66 6f 2d 3e 76 61 72 20 3d 20 4e 55 arInfo->var = NU
2ec0: 4c 4c 3b 0a 2b 20 09 72 65 73 56 61 72 49 6e 66 LL;.+ .resVarInf
2ed0: 6f 2d 3e 6e 61 6d 65 4f 62 6a 20 3d 20 54 63 6c o->nameObj = Tcl
2ee0: 5f 4e 65 77 53 74 72 69 6e 67 4f 62 6a 28 6e 61 _NewStringObj(na
2ef0: 6d 65 2c 20 2d 31 29 3b 0a 2b 20 09 54 63 6c 5f me, -1);.+ .Tcl_
2f00: 49 6e 63 72 52 65 66 43 6f 75 6e 74 28 72 65 73 IncrRefCount(res
2f10: 56 61 72 49 6e 66 6f 2d 3e 6e 61 6d 65 4f 62 6a VarInfo->nameObj
2f20: 29 3b 0a 2b 20 09 2a 72 50 74 72 20 3d 20 28 54 );.+ .*rPtr = (T
2f30: 63 6c 5f 52 65 73 6f 6c 76 65 64 56 61 72 49 6e cl_ResolvedVarIn
2f40: 66 6f 20 2a 29 72 65 73 56 61 72 49 6e 66 6f 3b fo *)resVarInfo;
2f50: 0a 2b 20 09 72 65 74 75 72 6e 20 54 43 4c 5f 4f .+ .return TCL_O
2f60: 4b 3b 0a 2b 20 20 20 20 7d 0a 2b 20 20 20 20 72 K;.+ }.+ r
2f70: 65 74 75 72 6e 20 54 43 4c 5f 43 4f 4e 54 49 4e eturn TCL_CONTIN
2f80: 55 45 3b 0a 2b 7d 0a 2b 20 0a 2b 73 74 61 74 69 UE;.+}.+ .+stati
2f90: 63 20 69 6e 74 20 0a 2b 54 65 73 74 49 6e 74 65 c int .+TestInte
2fa0: 72 70 52 65 73 6f 6c 76 65 72 73 43 6d 64 28 43 rpResolversCmd(C
2fb0: 6c 69 65 6e 74 44 61 74 61 20 63 6c 69 65 6e 74 lientData client
2fc0: 44 61 74 61 2c 0a 2b 20 20 20 20 20 20 20 20 20 Data,.+
2fd0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 54 63 Tc
2fe0: 6c 5f 49 6e 74 65 72 70 20 2a 69 6e 74 65 72 70 l_Interp *interp
2ff0: 2c 20 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 , .+
3000: 20 20 20 20 20 20 20 20 20 20 20 69 6e 74 20 6f int o
3010: 62 6a 63 2c 0a 2b 20 20 20 20 20 20 20 20 20 20 bjc,.+
3020: 20 20 20 20 20 20 20 20 20 20 20 20 20 54 63 6c Tcl
3030: 5f 4f 62 6a 20 2a 63 6f 6e 73 74 20 6f 62 6a 76 _Obj *const objv
3040: 5b 5d 29 20 0a 2b 7b 0a 2b 20 20 20 20 43 4f 4e []) .+{.+ CON
3050: 53 54 20 63 68 61 72 20 2a 6f 70 74 69 6f 6e 3b ST char *option;
3060: 0a 2b 20 20 20 20 69 66 20 28 6f 62 6a 63 20 21 .+ if (objc !
3070: 3d 20 32 29 20 7b 0a 2b 20 09 54 63 6c 5f 41 70 = 2) {.+ .Tcl_Ap
3080: 70 65 6e 64 52 65 73 75 6c 74 28 69 6e 74 65 72 pendResult(inter
3090: 70 2c 20 22 77 72 6f 6e 67 20 23 20 61 72 67 75 p, "wrong # argu
30a0: 6d 65 6e 74 73 3a 20 73 68 6f 75 6c 64 20 62 65 ments: should be
30b0: 20 5c 22 22 2c 20 54 63 6c 47 65 74 53 74 72 69 \"", TclGetStri
30c0: 6e 67 28 6f 62 6a 76 5b 30 5d 29 2c 0a 2b 20 20 ng(objv[0]),.+
30d0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
30e0: 20 20 20 20 20 20 20 22 20 75 70 7c 64 6f 77 6e " up|down
30f0: 5c 22 22 2c 20 4e 55 4c 4c 29 3b 0a 2b 20 09 72 \"", NULL);.+ .r
3100: 65 74 75 72 6e 20 54 43 4c 5f 45 52 52 4f 52 3b eturn TCL_ERROR;
3110: 0a 2b 20 20 20 20 7d 0a 2b 20 20 20 20 6f 70 74 .+ }.+ opt
3120: 69 6f 6e 20 3d 20 54 63 6c 47 65 74 53 74 72 69 ion = TclGetStri
3130: 6e 67 28 6f 62 6a 76 5b 31 5d 29 3b 0a 2b 20 20 ng(objv[1]);.+
3140: 20 20 69 66 20 28 2a 6f 70 74 69 6f 6e 20 3d 3d if (*option ==
3150: 20 27 75 27 20 26 26 20 73 74 72 63 6d 70 28 6f 'u' && strcmp(o
3160: 70 74 69 6f 6e 2c 20 22 75 70 22 29 20 3d 3d 20 ption, "up") ==
3170: 30 29 20 7b 0a 2b 20 20 20 20 20 20 20 20 54 63 0) {.+ Tc
3180: 6c 5f 41 64 64 49 6e 74 65 72 70 52 65 73 6f 6c l_AddInterpResol
3190: 76 65 72 73 28 69 6e 74 65 72 70 2c 22 69 6e 74 vers(interp,"int
31a0: 65 72 70 52 65 73 6f 6c 76 65 72 22 2c 0a 2b 20 erpResolver",.+
31b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
31c0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 49 6e In
31d0: 74 65 72 70 43 6d 64 52 65 73 6f 6c 76 65 72 2c terpCmdResolver,
31e0: 0a 2b 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .+
31f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3200: 20 49 6e 74 65 72 70 56 61 72 52 65 73 6f 6c 76 InterpVarResolv
3210: 65 72 2c 0a 2b 20 20 20 20 20 20 20 20 20 20 20 er,.+
3220: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
3230: 20 20 20 20 49 6e 74 65 72 70 43 6f 6d 70 69 6c InterpCompil
3240: 65 64 56 61 72 52 65 73 6f 6c 76 65 72 29 3b 0a edVarResolver);.
3250: 2b 20 20 20 20 7d 20 65 6c 73 65 20 69 66 20 28 + } else if (
3260: 2a 6f 70 74 69 6f 6e 20 3d 3d 20 27 64 27 20 26 *option == 'd' &
3270: 26 20 73 74 72 63 6d 70 28 6f 70 74 69 6f 6e 2c & strcmp(option,
3280: 20 22 64 6f 77 6e 22 29 20 3d 3d 20 30 29 20 7b "down") == 0) {
3290: 0a 2b 20 20 20 20 20 20 20 20 69 66 28 54 63 6c .+ if(Tcl
32a0: 5f 52 65 6d 6f 76 65 49 6e 74 65 72 70 52 65 73 _RemoveInterpRes
32b0: 6f 6c 76 65 72 73 28 69 6e 74 65 72 70 2c 20 22 olvers(interp, "
32c0: 69 6e 74 65 72 70 52 65 73 6f 6c 76 65 72 22 29 interpResolver")
32d0: 20 3d 3d 20 30 29 20 7b 0a 2b 20 20 20 20 20 20 == 0) {.+
32e0: 20 20 20 20 20 20 54 63 6c 5f 41 70 70 65 6e 64 Tcl_Append
32f0: 52 65 73 75 6c 74 28 69 6e 74 65 72 70 2c 20 22 Result(interp, "
3300: 63 6f 75 6c 64 20 6e 6f 74 20 72 65 6d 6f 76 65 could not remove
3310: 20 74 68 65 20 72 65 73 6f 6c 76 65 72 20 73 63 the resolver sc
3320: 68 65 6d 65 22 2c 20 4e 55 4c 4c 29 3b 0a 2b 20 heme", NULL);.+
3330: 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 retur
3340: 6e 20 54 43 4c 5f 45 52 52 4f 52 3b 0a 2b 20 20 n TCL_ERROR;.+
3350: 20 20 20 20 20 20 7d 0a 2b 20 20 20 20 7d 20 65 }.+ } e
3360: 6c 73 65 20 7b 0a 2b 20 09 54 63 6c 5f 41 70 70 lse {.+ .Tcl_App
3370: 65 6e 64 52 65 73 75 6c 74 28 69 6e 74 65 72 70 endResult(interp
3380: 2c 20 22 62 61 64 20 6f 70 74 69 6f 6e 20 5c 22 , "bad option \"
3390: 22 2c 20 6f 70 74 69 6f 6e 2c 0a 2b 20 20 20 20 ", option,.+
33a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
33b0: 20 20 20 20 20 22 5c 22 3a 20 6d 75 73 74 20 62 "\": must b
33c0: 65 20 27 75 70 27 20 6f 72 20 27 64 6f 77 6e 27 e 'up' or 'down'
33d0: 22 2c 20 4e 55 4c 4c 29 3b 0a 2b 20 09 72 65 74 ", NULL);.+ .ret
33e0: 75 72 6e 20 54 43 4c 5f 45 52 52 4f 52 3b 0a 2b urn TCL_ERROR;.+
33f0: 20 20 20 20 7d 0a 2b 20 20 20 20 72 65 74 75 72 }.+ retur
3400: 6e 20 54 43 4c 5f 4f 4b 3b 0a 2b 7d 0a 2b 0a 2b n TCL_OK;.+}.+.+
3410: 0a 20 0c 0a 20 2f 2a 0a 20 20 2a 20 4c 6f 63 61 . .. /*. * Loca
3420: 6c 20 56 61 72 69 61 62 6c 65 73 3a 0a 20 20 2a l Variables:. *
3430: 20 6d 6f 64 65 3a 20 63 0a 20 20 2a 20 63 2d 62 mode: c. * c-b
3440: 61 73 69 63 2d 6f 66 66 73 65 74 3a 20 34 0a 0a asic-offset: 4..
3450: 41 44 44 45 44 20 20 20 20 74 65 73 74 73 2f 72 ADDED tests/r
3460: 65 73 6f 6c 76 65 72 73 2e 74 65 73 74 0a 49 6e esolvers.test.In
3470: 64 65 78 3a 20 74 65 73 74 73 2f 72 65 73 6f 6c dex: tests/resol
3480: 76 65 72 73 2e 74 65 73 74 0a 3d 3d 3d 3d 3d 3d vers.test.======
3490: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
34a0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
34b0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================
34c0: 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 0a 2d 2d =============.--
34d0: 2d 20 74 65 73 74 73 2f 72 65 73 6f 6c 76 65 72 - tests/resolver
34e0: 73 2e 74 65 73 74 0a 2b 2b 2b 20 74 65 73 74 73 s.test.+++ tests
34f0: 2f 72 65 73 6f 6c 76 65 72 73 2e 74 65 73 74 0a /resolvers.test.
3500: 40 40 20 2d 30 2c 30 20 2b 31 2c 32 32 30 20 40 @@ -0,0 +1,220 @
3510: 40 0a 2b 23 0a 2b 23 20 54 68 69 73 20 74 65 73 @.+#.+# This tes
3520: 74 20 63 6f 6c 6c 65 63 74 69 6f 6e 20 63 6f 76 t collection cov
3530: 65 72 73 20 73 6f 6d 65 20 75 6e 77 61 6e 74 65 ers some unwante
3540: 64 20 69 6e 74 65 72 61 63 74 69 6f 6e 73 20 62 d interactions b
3550: 65 74 77 65 65 6e 0a 2b 23 20 63 6f 6d 6d 61 6e etween.+# comman
3560: 64 20 6c 69 74 65 72 61 6c 20 73 68 61 72 69 6e d literal sharin
3570: 67 20 61 6e 64 20 74 68 65 20 75 73 65 20 6f 66 g and the use of
3580: 20 63 6f 6d 6d 61 6e 64 20 72 65 73 6f 6c 76 65 command resolve
3590: 72 73 0a 2b 23 20 28 70 65 72 2d 69 6e 74 65 72 rs.+# (per-inter
35a0: 70 29 20 77 68 69 63 68 20 63 61 75 73 65 20 63 p) which cause c
35b0: 6f 6d 6d 61 6e 64 20 6c 69 74 65 72 61 6c 73 20 ommand literals
35c0: 74 6f 20 62 65 20 72 65 2d 75 73 65 64 20 77 69 to be re-used wi
35d0: 74 68 20 74 68 65 69 72 0a 2b 23 20 63 6f 6d 6d th their.+# comm
35e0: 61 6e 64 20 72 65 66 65 72 65 6e 63 65 73 20 62 and references b
35f0: 65 69 6e 67 20 69 6e 76 61 6c 69 64 20 69 6e 20 eing invalid in
3600: 74 68 65 20 72 65 75 73 69 6e 67 20 63 6f 6e 74 the reusing cont
3610: 65 78 74 2e 0a 2b 23 0a 2b 23 20 67 75 73 74 61 ext..+#.+# gusta
3620: 66 2e 6e 65 75 6d 61 6e 6e 40 77 75 2e 61 63 2e [email protected].
3630: 61 74 0a 2b 23 20 73 74 65 66 61 6e 2e 73 6f 62 at.+# stefan.sob
3640: 65 72 6e 69 67 40 77 75 2e 61 63 2e 61 74 0a 2b [email protected].+
3650: 23 0a 2b 0a 2b 69 66 20 7b 5b 6c 73 65 61 72 63 #.+.+if {[lsearc
3660: 68 20 5b 6e 61 6d 65 73 70 61 63 65 20 63 68 69 h [namespace chi
3670: 6c 64 72 65 6e 5d 20 3a 3a 74 63 6c 74 65 73 74 ldren] ::tcltest
3680: 5d 20 3d 3d 20 2d 31 7d 20 7b 0a 2b 20 20 20 20 ] == -1} {.+
3690: 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 package require
36a0: 74 63 6c 74 65 73 74 0a 2b 20 20 20 20 6e 61 6d tcltest.+ nam
36b0: 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 2d 66 espace import -f
36c0: 6f 72 63 65 20 3a 3a 74 63 6c 74 65 73 74 3a 3a orce ::tcltest::
36d0: 2a 0a 2b 7d 0a 2b 0a 2b 74 65 73 74 20 6c 69 74 *.+}.+.+test lit
36e0: 2d 31 2e 31 20 7b 63 6d 64 4e 61 6d 65 4f 62 6a -1.1 {cmdNameObj
36f0: 20 73 68 61 72 69 6e 67 20 76 73 2e 20 63 6d 64 sharing vs. cmd
3700: 20 72 65 73 6f 6c 76 65 72 3a 20 6e 61 6d 65 73 resolver: names
3710: 70 61 63 65 20 69 6d 70 6f 72 74 7d 20 2d 73 65 pace import} -se
3720: 74 75 70 20 7b 0a 2b 20 20 74 65 73 74 69 6e 74 tup {.+ testint
3730: 65 72 70 72 65 73 6f 6c 76 65 72 20 75 70 0a 2b erpresolver up.+
3740: 0a 2b 20 20 6e 61 6d 65 73 70 61 63 65 20 65 76 .+ namespace ev
3750: 61 6c 20 3a 3a 6e 73 31 20 7b 0a 2b 20 20 20 20 al ::ns1 {.+
3760: 70 72 6f 63 20 7a 20 7b 7d 20 7b 20 72 65 74 75 proc z {} { retu
3770: 72 6e 20 5a 20 7d 0a 2b 20 20 20 20 6e 61 6d 65 rn Z }.+ name
3780: 73 70 61 63 65 20 65 78 70 6f 72 74 20 7a 0a 2b space export z.+
3790: 20 20 7d 0a 2b 20 20 70 72 6f 63 20 3a 3a 79 20 }.+ proc ::y
37a0: 7b 7d 20 7b 20 72 65 74 75 72 6e 20 59 20 7d 0a {} { return Y }.
37b0: 2b 20 20 0a 2b 20 20 70 72 6f 63 20 3a 3a 78 20 + .+ proc ::x
37c0: 7b 7d 20 7b 0a 2b 20 20 20 20 7a 0a 2b 20 20 7d {} {.+ z.+ }
37d0: 0a 2b 0a 2b 7d 20 2d 62 6f 64 79 20 7b 0a 2b 20 .+.+} -body {.+
37e0: 20 23 20 31 29 20 48 61 76 65 20 74 68 65 20 70 # 1) Have the p
37f0: 72 6f 63 20 62 6f 64 79 20 63 6f 6d 70 69 6c 65 roc body compile
3800: 64 3a 20 44 75 72 69 6e 67 20 63 6f 6d 70 69 6c d: During compil
3810: 61 74 69 6f 6e 20 6f 72 2c 0a 2b 20 20 23 20 61 ation or,.+ # a
3820: 6c 74 65 72 6e 61 74 69 76 65 6c 79 2c 20 74 68 lternatively, th
3830: 65 20 66 69 72 73 74 20 65 76 61 6c 75 61 74 69 e first evaluati
3840: 6f 6e 20 6f 66 20 74 68 65 20 63 6f 6d 70 69 6c on of the compil
3850: 65 64 20 62 6f 64 79 2c 20 74 68 65 0a 2b 20 20 ed body, the.+
3860: 23 20 49 6e 74 65 72 70 43 6d 64 52 65 73 6f 6c # InterpCmdResol
3870: 76 65 72 20 28 73 65 65 20 74 63 6c 54 65 73 74 ver (see tclTest
3880: 2e 63 29 20 6d 61 70 73 20 74 68 65 20 63 6d 64 .c) maps the cmd
3890: 20 74 6f 6b 65 6e 20 22 7a 22 20 74 6f 20 22 3a token "z" to ":
38a0: 3a 79 22 3b 0a 2b 20 20 23 20 74 68 69 73 20 6d :y";.+ # this m
38b0: 61 70 70 69 6e 67 20 69 73 20 73 61 76 65 64 20 apping is saved
38c0: 69 6e 20 74 68 65 20 72 65 73 75 6c 74 69 6e 67 in the resulting
38d0: 20 43 6d 64 4e 61 6d 65 20 54 63 6c 5f 4f 62 6a CmdName Tcl_Obj
38e0: 20 77 69 74 68 20 74 68 65 0a 2b 20 20 23 20 70 with the.+ # p
38f0: 72 69 6e 74 20 73 74 72 69 6e 67 20 22 7a 22 2e rint string "z".
3900: 20 54 68 65 20 43 6d 64 4e 61 6d 65 20 54 63 6c The CmdName Tcl
3910: 5f 4f 62 6a 20 69 73 20 74 75 72 6e 65 64 20 69 _Obj is turned i
3920: 6e 74 6f 20 61 20 63 6f 6d 6d 61 6e 64 0a 2b 20 nto a command.+
3930: 20 23 20 6c 69 74 65 72 61 6c 20 73 68 61 72 65 # literal share
3940: 64 20 66 6f 72 20 61 20 67 69 76 65 6e 20 28 68 d for a given (h
3950: 65 72 65 3a 20 74 68 65 20 67 6c 6f 62 61 6c 29 ere: the global)
3960: 20 6e 61 6d 65 73 70 61 63 65 2e 0a 2b 20 20 73 namespace..+ s
3970: 65 74 20 72 30 20 5b 78 5d 3b 20 23 20 2d 2d 3e et r0 [x]; # -->
3980: 20 54 68 65 20 72 65 73 75 6c 74 20 6f 66 20 5b The result of [
3990: 78 5d 20 69 73 20 22 59 22 0a 2b 20 20 23 20 32 x] is "Y".+ # 2
39a0: 29 20 41 66 74 65 72 20 68 61 76 69 6e 67 20 72 ) After having r
39b0: 65 71 75 65 73 74 65 64 20 63 6d 64 20 72 65 73 equested cmd res
39c0: 6f 6c 75 74 69 6f 6e 20 61 62 6f 76 65 2c 20 77 olution above, w
39d0: 65 20 63 61 6e 20 6e 6f 77 20 75 73 65 0a 2b 20 e can now use.+
39e0: 20 23 20 74 68 65 20 67 6c 6f 62 61 6c 6c 79 20 # the globally
39f0: 73 68 61 72 65 64 20 43 6d 64 4e 61 6d 65 20 54 shared CmdName T
3a00: 63 6c 5f 4f 62 6a 20 22 7a 22 2c 20 6e 6f 77 20 cl_Obj "z", now
3a10: 62 6f 75 6e 64 20 74 6f 20 63 6d 64 0a 2b 20 20 bound to cmd.+
3a20: 23 20 3a 3a 79 2e 20 54 68 69 73 20 69 73 20 63 # ::y. This is c
3a30: 65 72 74 61 69 6e 6c 79 20 71 75 65 73 74 69 6f ertainly questio
3a40: 6e 61 62 6c 65 2c 20 62 75 74 20 64 65 66 65 6e nable, but defen
3a50: 73 69 62 6c 65 0a 2b 20 20 73 65 74 20 72 31 20 sible.+ set r1
3a60: 5b 7a 5d 3b 20 23 20 23 20 2d 2d 3e 20 54 68 65 [z]; # # --> The
3a70: 20 72 65 73 75 6c 74 20 6f 66 20 5b 7a 5d 20 69 result of [z] i
3a80: 73 20 22 59 22 0a 2b 20 20 23 20 33 29 20 57 65 s "Y".+ # 3) We
3a90: 20 69 6d 70 6f 72 74 20 66 72 6f 6d 20 74 68 65 import from the
3aa0: 20 6e 61 6d 65 73 70 61 63 65 20 6e 73 31 20 61 namespace ns1 a
3ab0: 6e 6f 74 68 65 72 20 7a 2e 20 5b 6e 61 6d 65 73 nother z. [names
3ac0: 70 61 63 65 20 69 6d 70 6f 72 74 5d 0a 2b 20 20 pace import].+
3ad0: 23 20 74 61 6b 65 73 20 63 61 72 65 20 22 73 68 # takes care "sh
3ae0: 61 64 6f 77 65 64 22 20 63 6d 64 20 72 65 66 65 adowed" cmd refe
3af0: 72 65 6e 63 65 73 2c 20 68 6f 77 65 76 65 72 2c rences, however,
3b00: 20 74 69 6c 6c 20 6e 6f 77 20 63 6d 64 0a 2b 20 till now cmd.+
3b10: 20 23 20 6c 69 74 65 72 61 6c 73 20 68 61 76 65 # literals have
3b20: 20 6e 6f 74 20 62 65 65 6e 20 74 6f 75 63 68 65 not been touche
3b30: 64 2e 20 54 68 69 73 20 69 73 2c 20 68 6f 77 65 d. This is, howe
3b40: 76 65 72 2c 20 6e 65 63 65 73 73 61 72 79 20 73 ver, necessary s
3b50: 69 6e 63 65 0a 2b 20 20 23 20 74 68 65 20 42 43 ince.+ # the BC
3b60: 20 63 6f 6d 70 69 6c 65 72 20 28 75 73 65 64 20 compiler (used
3b70: 69 6e 20 74 68 65 20 5b 6e 61 6d 65 73 70 61 63 in the [namespac
3b80: 65 20 65 76 61 6c 5d 29 20 73 65 65 6d 73 20 74 e eval]) seems t
3b90: 6f 20 62 65 20 65 61 67 65 72 0a 2b 20 20 23 20 o be eager.+ #
3ba0: 74 6f 20 72 65 75 73 65 20 43 6d 64 4e 61 6d 65 to reuse CmdName
3bb0: 20 54 63 6c 5f 4f 62 6a 73 20 61 73 20 63 6d 64 Tcl_Objs as cmd
3bc0: 20 6c 69 74 65 72 61 6c 73 20 66 6f 72 20 61 20 literals for a
3bd0: 67 69 76 65 6e 20 4e 53 20 73 63 6f 70 65 2e 20 given NS scope.
3be0: 57 65 0a 2b 20 20 23 20 65 78 70 65 63 74 2c 20 We.+ # expect,
3bf0: 74 68 61 74 20 72 32 20 69 73 20 22 5a 22 2c 20 that r2 is "Z",
3c00: 74 68 65 20 72 65 73 75 6c 74 20 6f 66 20 74 68 the result of th
3c10: 65 20 6e 61 6d 65 73 70 61 63 65 20 69 6d 70 6f e namespace impo
3c20: 72 74 65 64 20 63 6d 64 2e 0a 2b 20 20 6e 61 6d rted cmd..+ nam
3c30: 65 73 70 61 63 65 20 65 76 61 6c 20 3a 3a 20 7b espace eval :: {
3c40: 0a 2b 20 20 20 20 6e 61 6d 65 73 70 61 63 65 20 .+ namespace
3c50: 69 6d 70 6f 72 74 20 3a 3a 6e 73 31 3a 3a 7a 0a import ::ns1::z.
3c60: 2b 20 20 20 20 73 65 74 20 72 32 20 5b 7a 5d 0a + set r2 [z].
3c70: 2b 20 20 7d 0a 2b 20 20 6c 69 73 74 20 24 72 30 + }.+ list $r0
3c80: 20 24 72 31 20 24 72 32 0a 2b 7d 20 2d 63 6c 65 $r1 $r2.+} -cle
3c90: 61 6e 75 70 20 7b 0a 2b 20 20 74 65 73 74 69 6e anup {.+ testin
3ca0: 74 65 72 70 72 65 73 6f 6c 76 65 72 20 64 6f 77 terpresolver dow
3cb0: 6e 0a 2b 20 20 72 65 6e 61 6d 65 20 3a 3a 78 20 n.+ rename ::x
3cc0: 22 22 0a 2b 20 20 72 65 6e 61 6d 65 20 3a 3a 79 "".+ rename ::y
3cd0: 20 22 22 0a 2b 20 20 6e 61 6d 65 73 70 61 63 65 "".+ namespace
3ce0: 20 64 65 6c 65 74 65 20 3a 3a 6e 73 31 0a 2b 7d delete ::ns1.+}
3cf0: 20 2d 63 6f 6e 73 74 72 61 69 6e 74 73 20 7b 0a -constraints {.
3d00: 2b 7d 20 2d 72 65 73 75 6c 74 20 7b 59 20 59 20 +} -result {Y Y
3d10: 5a 7d 0a 2b 0a 2b 0a 2b 74 65 73 74 20 6c 69 74 Z}.+.+.+test lit
3d20: 2d 31 2e 32 20 7b 63 6d 64 4e 61 6d 65 4f 62 6a -1.2 {cmdNameObj
3d30: 20 73 68 61 72 69 6e 67 20 76 73 2e 20 63 6d 64 sharing vs. cmd
3d40: 20 72 65 73 6f 6c 76 65 72 3a 20 70 72 6f 63 20 resolver: proc
3d50: 63 72 65 61 74 69 6f 6e 7d 20 2d 73 65 74 75 70 creation} -setup
3d60: 20 7b 0a 2b 20 20 74 65 73 74 69 6e 74 65 72 70 {.+ testinterp
3d70: 72 65 73 6f 6c 76 65 72 20 75 70 0a 2b 0a 2b 20 resolver up.+.+
3d80: 20 70 72 6f 63 20 3a 3a 79 20 7b 7d 20 7b 20 72 proc ::y {} { r
3d90: 65 74 75 72 6e 20 59 20 7d 0a 2b 20 20 0a 2b 20 eturn Y }.+ .+
3da0: 20 70 72 6f 63 20 3a 3a 78 20 7b 7d 20 7b 0a 2b proc ::x {} {.+
3db0: 20 20 20 20 7a 0a 2b 20 20 7d 0a 2b 0a 2b 7d 20 z.+ }.+.+}
3dc0: 2d 62 6f 64 79 20 7b 0a 2b 20 20 73 65 74 20 72 -body {.+ set r
3dd0: 30 20 5b 78 5d 0a 2b 20 20 73 65 74 20 72 31 20 0 [x].+ set r1
3de0: 5b 7a 5d 0a 2b 20 20 70 72 6f 63 20 3a 3a 66 6f [z].+ proc ::fo
3df0: 6f 20 7b 7d 20 7b 0a 2b 20 20 20 20 70 72 6f 63 o {} {.+ proc
3e00: 20 3a 3a 7a 20 7b 7d 20 7b 20 72 65 74 75 72 6e ::z {} { return
3e10: 20 5a 20 7d 0a 2b 20 20 20 20 72 65 74 75 72 6e Z }.+ return
3e20: 20 5b 7a 5d 0a 2b 20 20 7d 0a 2b 20 20 6c 69 73 [z].+ }.+ lis
3e30: 74 20 24 72 30 20 24 72 31 20 5b 3a 3a 66 6f 6f t $r0 $r1 [::foo
3e40: 5d 0a 2b 7d 20 2d 63 6c 65 61 6e 75 70 20 7b 0a ].+} -cleanup {.
3e50: 2b 20 20 74 65 73 74 69 6e 74 65 72 70 72 65 73 + testinterpres
3e60: 6f 6c 76 65 72 20 64 6f 77 6e 0a 2b 20 20 72 65 olver down.+ re
3e70: 6e 61 6d 65 20 3a 3a 78 20 22 22 0a 2b 20 20 72 name ::x "".+ r
3e80: 65 6e 61 6d 65 20 3a 3a 79 20 22 22 0a 2b 20 20 ename ::y "".+
3e90: 72 65 6e 61 6d 65 20 3a 3a 66 6f 6f 20 22 22 0a rename ::foo "".
3ea0: 2b 20 20 72 65 6e 61 6d 65 20 3a 3a 7a 20 22 22 + rename ::z ""
3eb0: 0a 2b 7d 20 2d 72 65 73 75 6c 74 20 7b 59 20 59 .+} -result {Y Y
3ec0: 20 5a 7d 0a 2b 0a 2b 74 65 73 74 20 6c 69 74 2d Z}.+.+test lit-
3ed0: 31 2e 33 20 7b 63 6d 64 4e 61 6d 65 4f 62 6a 20 1.3 {cmdNameObj
3ee0: 73 68 61 72 69 6e 67 20 76 73 2e 20 63 6d 64 20 sharing vs. cmd
3ef0: 72 65 73 6f 6c 76 65 72 3a 20 72 65 6e 61 6d 65 resolver: rename
3f00: 7d 20 2d 73 65 74 75 70 20 7b 0a 2b 20 20 74 65 } -setup {.+ te
3f10: 73 74 69 6e 74 65 72 70 72 65 73 6f 6c 76 65 72 stinterpresolver
3f20: 20 75 70 0a 2b 20 20 70 72 6f 63 20 3a 3a 5a 20 up.+ proc ::Z
3f30: 7b 7d 20 7b 20 72 65 74 75 72 6e 20 5a 20 7d 0a {} { return Z }.
3f40: 2b 0a 2b 20 20 70 72 6f 63 20 3a 3a 79 20 7b 7d +.+ proc ::y {}
3f50: 20 7b 20 72 65 74 75 72 6e 20 59 20 7d 0a 2b 20 { return Y }.+
3f60: 20 0a 2b 20 20 70 72 6f 63 20 3a 3a 78 20 7b 7d .+ proc ::x {}
3f70: 20 7b 0a 2b 20 20 20 20 7a 0a 2b 20 20 7d 0a 2b {.+ z.+ }.+
3f80: 0a 2b 7d 20 2d 62 6f 64 79 20 7b 0a 2b 20 20 73 .+} -body {.+ s
3f90: 65 74 20 72 30 20 5b 78 5d 0a 2b 20 20 73 65 74 et r0 [x].+ set
3fa0: 20 72 31 20 5b 7a 5d 0a 2b 20 20 6e 61 6d 65 73 r1 [z].+ names
3fb0: 70 61 63 65 20 65 76 61 6c 20 3a 3a 20 7b 0a 2b pace eval :: {.+
3fc0: 20 20 20 20 72 65 6e 61 6d 65 20 3a 3a 5a 20 3a rename ::Z :
3fd0: 3a 7a 0a 2b 20 20 20 20 73 65 74 20 72 32 20 5b :z.+ set r2 [
3fe0: 7a 5d 0a 2b 20 20 7d 0a 2b 20 20 6c 69 73 74 20 z].+ }.+ list
3ff0: 24 72 30 20 24 72 31 20 24 72 32 0a 2b 7d 20 2d $r0 $r1 $r2.+} -
4000: 63 6c 65 61 6e 75 70 20 7b 0a 2b 20 20 74 65 73 cleanup {.+ tes
4010: 74 69 6e 74 65 72 70 72 65 73 6f 6c 76 65 72 20 tinterpresolver
4020: 64 6f 77 6e 0a 2b 20 20 72 65 6e 61 6d 65 20 3a down.+ rename :
4030: 3a 78 20 22 22 0a 2b 20 20 72 65 6e 61 6d 65 20 :x "".+ rename
4040: 3a 3a 79 20 22 22 0a 2b 20 20 72 65 6e 61 6d 65 ::y "".+ rename
4050: 20 3a 3a 7a 20 22 22 0a 2b 7d 20 2d 72 65 73 75 ::z "".+} -resu
4060: 6c 74 20 7b 59 20 59 20 5a 7d 0a 2b 0a 2b 74 65 lt {Y Y Z}.+.+te
4070: 73 74 20 6c 69 74 2d 31 2e 34 20 7b 63 6d 64 4e st lit-1.4 {cmdN
4080: 61 6d 65 4f 62 6a 20 73 68 61 72 69 6e 67 20 76 ameObj sharing v
4090: 73 2e 20 63 6d 64 20 72 65 73 6f 6c 76 65 72 3a s. cmd resolver:
40a0: 20 69 6e 74 65 72 70 20 65 78 70 6f 73 65 7d 20 interp expose}
40b0: 2d 73 65 74 75 70 20 7b 0a 2b 20 20 74 65 73 74 -setup {.+ test
40c0: 69 6e 74 65 72 70 72 65 73 6f 6c 76 65 72 20 75 interpresolver u
40d0: 70 0a 2b 20 20 70 72 6f 63 20 3a 3a 5a 20 7b 7d p.+ proc ::Z {}
40e0: 20 7b 20 72 65 74 75 72 6e 20 5a 20 7d 0a 2b 20 { return Z }.+
40f0: 20 69 6e 74 65 72 70 20 68 69 64 65 20 7b 7d 20 interp hide {}
4100: 5a 0a 2b 0a 2b 20 20 70 72 6f 63 20 3a 3a 79 20 Z.+.+ proc ::y
4110: 7b 7d 20 7b 20 72 65 74 75 72 6e 20 59 20 7d 0a {} { return Y }.
4120: 2b 20 20 0a 2b 20 20 70 72 6f 63 20 3a 3a 78 20 + .+ proc ::x
4130: 7b 7d 20 7b 0a 2b 20 20 20 20 7a 0a 2b 20 20 7d {} {.+ z.+ }
4140: 0a 2b 0a 2b 7d 20 2d 62 6f 64 79 20 7b 0a 2b 20 .+.+} -body {.+
4150: 20 73 65 74 20 72 30 20 5b 78 5d 0a 2b 20 20 73 set r0 [x].+ s
4160: 65 74 20 72 31 20 5b 7a 5d 0a 2b 20 20 69 6e 74 et r1 [z].+ int
4170: 65 72 70 20 65 78 70 6f 73 65 20 7b 7d 20 5a 20 erp expose {} Z
4180: 7a 0a 2b 20 20 6e 61 6d 65 73 70 61 63 65 20 65 z.+ namespace e
4190: 76 61 6c 20 3a 3a 20 7b 0a 2b 20 20 20 20 73 65 val :: {.+ se
41a0: 74 20 72 32 20 5b 7a 5d 0a 2b 20 20 7d 0a 2b 20 t r2 [z].+ }.+
41b0: 20 6c 69 73 74 20 24 72 30 20 24 72 31 20 24 72 list $r0 $r1 $r
41c0: 32 0a 2b 7d 20 2d 63 6c 65 61 6e 75 70 20 7b 0a 2.+} -cleanup {.
41d0: 2b 20 20 74 65 73 74 69 6e 74 65 72 70 72 65 73 + testinterpres
41e0: 6f 6c 76 65 72 20 64 6f 77 6e 0a 2b 20 20 72 65 olver down.+ re
41f0: 6e 61 6d 65 20 3a 3a 78 20 22 22 0a 2b 20 20 72 name ::x "".+ r
4200: 65 6e 61 6d 65 20 3a 3a 79 20 22 22 0a 2b 20 20 ename ::y "".+
4210: 72 65 6e 61 6d 65 20 3a 3a 7a 20 22 22 0a 2b 7d rename ::z "".+}
4220: 20 2d 72 65 73 75 6c 74 20 7b 59 20 59 20 5a 7d -result {Y Y Z}
4230: 0a 2b 0a 2b 74 65 73 74 20 6c 69 74 2d 31 2e 35 .+.+test lit-1.5
4240: 20 7b 63 6d 64 4e 61 6d 65 4f 62 6a 20 73 68 61 {cmdNameObj sha
4250: 72 69 6e 67 20 76 73 2e 20 63 6d 64 20 72 65 73 ring vs. cmd res
4260: 6f 6c 76 65 72 3a 20 6f 74 68 65 72 20 74 68 61 olver: other tha
4270: 6e 20 67 6c 6f 62 61 6c 20 4e 53 7d 20 2d 73 65 n global NS} -se
4280: 74 75 70 20 7b 0a 2b 20 20 74 65 73 74 69 6e 74 tup {.+ testint
4290: 65 72 70 72 65 73 6f 6c 76 65 72 20 75 70 0a 2b erpresolver up.+
42a0: 0a 2b 20 20 6e 61 6d 65 73 70 61 63 65 20 65 76 .+ namespace ev
42b0: 61 6c 20 3a 3a 6e 73 31 20 7b 0a 2b 20 20 20 20 al ::ns1 {.+
42c0: 70 72 6f 63 20 7a 20 7b 7d 20 7b 20 72 65 74 75 proc z {} { retu
42d0: 72 6e 20 5a 20 7d 0a 2b 20 20 20 20 6e 61 6d 65 rn Z }.+ name
42e0: 73 70 61 63 65 20 65 78 70 6f 72 74 20 7a 0a 2b space export z.+
42f0: 20 20 7d 0a 2b 0a 2b 20 20 70 72 6f 63 20 3a 3a }.+.+ proc ::
4300: 79 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 59 20 y {} { return Y
4310: 7d 0a 2b 0a 2b 20 20 6e 61 6d 65 73 70 61 63 65 }.+.+ namespace
4320: 20 65 76 61 6c 20 3a 3a 6e 73 32 20 7b 0a 2b 20 eval ::ns2 {.+
4330: 20 20 20 70 72 6f 63 20 78 20 7b 7d 20 7b 0a 2b proc x {} {.+
4340: 20 20 20 20 20 20 7a 0a 2b 20 20 20 20 7d 0a 2b z.+ }.+
4350: 20 20 7d 0a 2b 0a 2b 7d 20 2d 62 6f 64 79 20 7b }.+.+} -body {
4360: 0a 2b 20 20 0a 2b 20 20 73 65 74 20 72 30 20 5b .+ .+ set r0 [
4370: 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c 20 3a namespace eval :
4380: 3a 6e 73 32 20 7b 78 7d 5d 0a 2b 20 20 73 65 74 :ns2 {x}].+ set
4390: 20 72 31 20 5b 6e 61 6d 65 73 70 61 63 65 20 65 r1 [namespace e
43a0: 76 61 6c 20 3a 3a 6e 73 32 20 7b 7a 7d 5d 0a 2b val ::ns2 {z}].+
43b0: 20 20 6e 61 6d 65 73 70 61 63 65 20 65 76 61 6c namespace eval
43c0: 20 3a 3a 6e 73 32 20 7b 0a 2b 20 20 20 20 6e 61 ::ns2 {.+ na
43d0: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a mespace import :
43e0: 3a 6e 73 31 3a 3a 7a 0a 2b 20 20 20 20 73 65 74 :ns1::z.+ set
43f0: 20 72 32 20 5b 7a 5d 0a 2b 20 20 7d 0a 2b 20 20 r2 [z].+ }.+
4400: 6c 69 73 74 20 24 72 30 20 24 72 31 20 24 72 32 list $r0 $r1 $r2
4410: 0a 2b 7d 20 2d 63 6c 65 61 6e 75 70 20 7b 0a 2b .+} -cleanup {.+
4420: 20 20 74 65 73 74 69 6e 74 65 72 70 72 65 73 6f testinterpreso
4430: 6c 76 65 72 20 64 6f 77 6e 0a 2b 20 20 6e 61 6d lver down.+ nam
4440: 65 73 70 61 63 65 20 64 65 6c 65 74 65 20 3a 3a espace delete ::
4450: 6e 73 32 0a 2b 20 20 6e 61 6d 65 73 70 61 63 65 ns2.+ namespace
4460: 20 64 65 6c 65 74 65 20 3a 3a 6e 73 31 0a 2b 7d delete ::ns1.+}
4470: 20 2d 72 65 73 75 6c 74 20 7b 59 20 59 20 5a 7d -result {Y Y Z}
4480: 0a 2b 0a 2b 74 65 73 74 20 6c 69 74 2d 31 2e 36 .+.+test lit-1.6
4490: 20 7b 63 6d 64 4e 61 6d 65 4f 62 6a 20 73 68 61 {cmdNameObj sha
44a0: 72 69 6e 67 20 76 73 2e 20 63 6d 64 20 72 65 73 ring vs. cmd res
44b0: 6f 6c 76 65 72 3a 20 69 6e 74 65 72 70 20 61 6c olver: interp al
44c0: 69 61 73 7d 20 2d 73 65 74 75 70 20 7b 0a 2b 20 ias} -setup {.+
44d0: 20 74 65 73 74 69 6e 74 65 72 70 72 65 73 6f 6c testinterpresol
44e0: 76 65 72 20 75 70 0a 2b 20 20 70 72 6f 63 20 3a ver up.+ proc :
44f0: 3a 5a 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 5a :Z {} { return Z
4500: 20 7d 0a 2b 0a 2b 20 20 70 72 6f 63 20 3a 3a 79 }.+.+ proc ::y
4510: 20 7b 7d 20 7b 20 72 65 74 75 72 6e 20 59 20 7d {} { return Y }
4520: 0a 2b 20 20 0a 2b 20 20 70 72 6f 63 20 3a 3a 78 .+ .+ proc ::x
4530: 20 7b 7d 20 7b 0a 2b 20 20 20 20 7a 0a 2b 20 20 {} {.+ z.+
4540: 7d 0a 2b 0a 2b 7d 20 2d 62 6f 64 79 20 7b 0a 2b }.+.+} -body {.+
4550: 20 20 73 65 74 20 72 30 20 5b 78 5d 0a 2b 20 20 set r0 [x].+
4560: 73 65 74 20 72 31 20 5b 7a 5d 0a 2b 20 20 6e 61 set r1 [z].+ na
4570: 6d 65 73 70 61 63 65 20 65 76 61 6c 20 3a 3a 20 mespace eval ::
4580: 7b 0a 2b 20 20 20 20 69 6e 74 65 72 70 20 61 6c {.+ interp al
4590: 69 61 73 20 7b 7d 20 3a 3a 7a 20 7b 7d 20 3a 3a ias {} ::z {} ::
45a0: 5a 0a 2b 20 20 20 20 73 65 74 20 72 32 20 5b 7a Z.+ set r2 [z
45b0: 5d 0a 2b 20 20 7d 0a 2b 20 20 6c 69 73 74 20 24 ].+ }.+ list $
45c0: 72 30 20 24 72 31 20 24 72 32 0a 2b 7d 20 2d 63 r0 $r1 $r2.+} -c
45d0: 6c 65 61 6e 75 70 20 7b 0a 2b 20 20 74 65 73 74 leanup {.+ test
45e0: 69 6e 74 65 72 70 72 65 73 6f 6c 76 65 72 20 64 interpresolver d
45f0: 6f 77 6e 0a 2b 20 20 72 65 6e 61 6d 65 20 3a 3a own.+ rename ::
4600: 78 20 22 22 0a 2b 20 20 72 65 6e 61 6d 65 20 3a x "".+ rename :
4610: 3a 79 20 22 22 0a 2b 20 20 72 65 6e 61 6d 65 20 :y "".+ rename
4620: 3a 3a 5a 20 22 22 0a 2b 7d 20 2d 72 65 73 75 6c ::Z "".+} -resul
4630: 74 20 7b 59 20 59 20 5a 7d 0a 2b 0a 2b 0a 2b 0a t {Y Y Z}.+.+.+.
4640: 2b 74 65 73 74 20 69 6e 74 65 72 70 52 65 73 2d +test interpRes-
4650: 31 2e 31 20 7b 63 6f 6d 70 69 6c 65 64 20 76 61 1.1 {compiled va
4660: 72 20 72 65 73 6f 6c 76 65 72 3a 20 42 75 67 20 r resolver: Bug
4670: 23 33 33 38 33 36 31 36 7d 20 2d 73 65 74 75 70 #3383616} -setup
4680: 20 7b 0a 2b 20 20 74 65 73 74 69 6e 74 65 72 70 {.+ testinterp
4690: 72 65 73 6f 6c 76 65 72 20 75 70 0a 2b 0a 2b 20 resolver up.+.+
46a0: 20 23 20 54 68 65 20 63 6f 6d 70 69 6c 65 64 20 # The compiled
46b0: 76 61 72 20 72 65 73 6f 6c 76 65 72 20 66 65 74 var resolver fet
46c0: 63 68 65 73 20 6a 75 73 74 20 76 61 72 69 61 62 ches just variab
46d0: 6c 65 73 20 73 74 61 72 74 69 6e 67 20 77 69 74 les starting wit
46e0: 68 20 61 0a 2b 20 20 23 20 63 61 70 69 74 61 6c h a.+ # capital
46f0: 20 22 54 22 20 61 6e 64 20 73 74 6f 72 65 73 20 "T" and stores
4700: 73 6f 6d 65 20 74 65 73 74 20 69 6e 66 6f 72 6d some test inform
4710: 61 74 69 6f 6e 20 69 6e 20 74 68 65 0a 2b 20 20 ation in the.+
4720: 23 20 72 65 73 6f 6c 76 65 72 2d 73 70 65 63 69 # resolver-speci
4730: 66 69 63 20 72 65 73 6f 6c 76 65 72 20 76 61 72 fic resolver var
4740: 20 69 6e 66 6f 2e 0a 2b 0a 2b 20 20 70 72 6f 63 info..+.+ proc
4750: 20 3a 3a 78 20 7b 7d 20 7b 0a 2b 20 20 20 20 73 ::x {} {.+ s
4760: 65 74 20 54 31 20 31 30 30 0a 2b 20 20 20 20 72 et T1 100.+ r
4770: 65 74 75 72 6e 20 24 54 31 0a 2b 20 20 7d 20 0a eturn $T1.+ } .
4780: 2b 0a 2b 7d 20 2d 62 6f 64 79 20 7b 0a 2b 20 20 +.+} -body {.+
4790: 23 20 43 61 6c 6c 20 22 78 22 20 74 68 65 20 66 # Call "x" the f
47a0: 69 72 73 74 20 74 69 6d 65 2c 20 63 61 75 73 69 irst time, causi
47b0: 6e 67 20 61 20 62 79 74 65 20 63 6f 64 65 20 63 ng a byte code c
47c0: 6f 6d 70 69 6c 61 74 69 6f 6e 20 6f 66 20 74 68 ompilation of th
47d0: 65 0a 2b 20 20 23 20 62 6f 64 79 2e 20 44 75 72 e.+ # body. Dur
47e0: 69 6e 67 20 74 68 65 20 63 6f 6d 70 69 6c 61 74 ing the compilat
47f0: 69 6f 6e 20 74 68 65 20 63 6f 6d 70 69 6c 65 64 ion the compiled
4800: 20 76 61 72 20 72 65 73 6f 6c 76 65 72 2c 20 74 var resolver, t
4810: 68 65 0a 2b 20 20 23 20 72 65 73 6f 6c 76 65 2d he.+ # resolve-
4820: 73 70 65 63 69 66 69 63 20 76 61 72 20 69 6e 66 specific var inf
4830: 6f 20 69 73 20 61 6c 6c 6f 63 61 74 65 64 2c 20 o is allocated,
4840: 64 75 72 69 6e 67 20 74 68 65 20 65 78 65 63 75 during the execu
4850: 74 69 6f 6e 20 6f 66 0a 2b 20 20 23 20 74 68 65 tion of.+ # the
4860: 20 62 6f 64 79 2c 20 74 68 65 20 76 61 72 69 61 body, the varia
4870: 62 6c 65 20 69 73 20 66 65 74 63 68 65 64 20 61 ble is fetched a
4880: 6e 64 20 63 61 63 68 65 64 2e 0a 2b 20 20 78 3b nd cached..+ x;
4890: 20 0a 2b 20 20 23 20 44 75 72 69 6e 67 20 6c 61 .+ # During la
48a0: 74 65 72 20 63 61 6c 6c 73 2c 20 74 68 65 20 63 ter calls, the c
48b0: 61 63 68 65 64 20 76 61 72 69 61 62 6c 65 20 69 ached variable i
48c0: 73 20 72 65 75 73 65 64 2e 0a 2b 20 20 78 0a 2b s reused..+ x.+
48d0: 20 20 23 20 57 68 65 6e 20 74 68 65 20 70 72 6f # When the pro
48e0: 63 20 69 73 20 66 72 65 65 64 2c 20 74 68 65 20 c is freed, the
48f0: 72 65 73 6f 6c 76 65 72 2d 73 70 65 63 69 66 69 resolver-specifi
4900: 63 20 72 65 73 6f 6c 76 65 72 20 76 61 72 20 69 c resolver var i
4910: 6e 66 6f 20 69 73 0a 2b 20 20 23 20 66 72 65 65 nfo is.+ # free
4920: 64 2e 20 54 68 69 73 20 64 69 64 20 6e 6f 74 20 d. This did not
4930: 68 61 70 70 65 6e 20 62 65 66 6f 72 65 20 66 69 happen before fi
4940: 78 20 23 33 33 38 33 36 31 36 2e 0a 2b 20 20 72 x #3383616..+ r
4950: 65 6e 61 6d 65 20 3a 3a 78 20 22 22 0a 2b 7d 20 ename ::x "".+}
4960: 2d 63 6c 65 61 6e 75 70 20 7b 0a 2b 20 20 74 65 -cleanup {.+ te
4970: 73 74 69 6e 74 65 72 70 72 65 73 6f 6c 76 65 72 stinterpresolver
4980: 20 64 6f 77 6e 0a 2b 7d 20 2d 72 65 73 75 6c 74 down.+} -result
4990: 20 7b 7d 0a 0a {}..