Tcl Source Code

Artifact [b4898cfde6]
Login

Artifact b4898cfde60da21be942383ed29ace6f8427e450:

Attachment "231259.txt" to ticket [231259ffff] added by msofer 2001-05-11 05:54:42.
? 231259.txt
Index: generic/tclInt.h
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclInt.h,v
retrieving revision 1.52
diff -r1.52 tclInt.h
187,191c187,193
<     int resolverEpoch;		 /* Incremented whenever the name resolution
< 				  * rules change for this namespace; this
< 				  * invalidates all byte codes compiled in
< 				  * the namespace, causing the code to be
< 				  * recompiled under the new rules. */
---
>     int resolverEpoch;		 /* Incremented whenever (a) the name resolution
> 				  * rules change for this namespace or (b) a 
> 				  * newly added command shadows a command that
> 				  * is compiled to bytecodes.
> 				  * This invalidates all byte codes compiled
> 				  * in the namespace, causing the code to be
> 				  * recompiled under the new rules.*/
Index: generic/tclNamesp.c
===================================================================
RCS file: /cvsroot/tcl/tcl/generic/tclNamesp.c,v
retrieving revision 1.22
diff -r1.22 tclNamesp.c
2285a2286,2296
> 
> 		/* 
> 		 * If the shadowed command was compiled to bytecodes, we
> 		 * invalidate all the bytecodes in nsPtr, to force a new
> 		 * compilation. We use the resolverEpoch to signal the need
> 		 * for a fresh compilation of every bytecode.
> 		 */
> 
> 		if ((((Command *) hPtr)->compileProc) != NULL) {
> 		    nsPtr->resolverEpoch++;
> 		}
Index: tests/namespace.test
===================================================================
RCS file: /cvsroot/tcl/tcl/tests/namespace.test,v
retrieving revision 1.15
diff -r1.15 namespace.test
1138a1139,1152
> test namespace-41.1 {Shadowing byte-compiled commands} {
>     namespace eval ns {
> 	proc test {} {
> 	    set ::g 0
> 	}  
> 	lappend ::res [test]
> 	proc set {a b} {
> 	    ::set a [incr b]
> 	}
> 	lappend ::res [test]
>     }
>     set res
> } {0 1}
>