Index: generic/nsf.c =================================================================== diff -u -r0d57967b71cec0802c109bdef6aef37d85a817a2 -re89a635d134e85db66c3e7059ec81817b6b36ea5 --- generic/nsf.c (.../nsf.c) (revision 0d57967b71cec0802c109bdef6aef37d85a817a2) +++ generic/nsf.c (.../nsf.c) (revision e89a635d134e85db66c3e7059ec81817b6b36ea5) @@ -2959,7 +2959,11 @@ * perform the merge operation. For n elements in superClasses, the merge * operation is performed n-1 times. */ - for (sl = superClasses->nextPtr; sl != NULL; sl = sl->nextPtr) { + + sl = superClasses->nextPtr; + assert(superClasses->nextPtr != NULL); + + do { NsfClasses *mergeList = sl->cl->order, *baseListCurrent; #if defined(NSF_LINEARIZER_TRACE) @@ -3078,7 +3082,11 @@ pl = NULL; plNext = NsfClassListAdd(&pl, class, NULL); } - } + /* + * Get next element from the list. + */ + sl = sl->nextPtr; + } while (sl != NULL); for (sl = deletionList; sl != NULL; sl = sl->nextPtr) { /* fprintf(stderr, "delete from deletion list %p client data %p\n", sl, sl->clientData); */ @@ -6507,7 +6515,7 @@ entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&search)) { Tcl_Obj *nameObj; - Var *varPtr; + Var *varPtr; GetVarAndNameFromHash(entryPtr, &varPtr, &nameObj); if ((varPtr->flags & VAR_TRACED_UNSET) != 0u /* TclIsVarTraced(varPtr) */) { @@ -29731,17 +29739,16 @@ */ static int NsfNSCopyVarsCmd(Tcl_Interp *interp, Tcl_Obj *fromNsObj, Tcl_Obj *toNsObj) { - Tcl_Namespace *fromNsPtr = NULL, *toNsPtr; - Var *varPtr = NULL; - Tcl_HashSearch hSrch; + Tcl_Namespace *fromNsPtr = NULL, *toNsPtr; + Var *varPtr = NULL; + Tcl_HashSearch hSrch; const Tcl_HashEntry *hPtr; - TclVarHashTable *varTablePtr; - NsfObject *object, *destObject; - const char *destFullName; - Tcl_Obj *destFullNameObj; - Tcl_CallFrame frame, *framePtr = &frame; - Tcl_Obj *varNameObj = NULL; - int result; + TclVarHashTable *varTablePtr; + NsfObject *destObject; + const char *destFullName; + Tcl_Obj *destFullNameObj; + Tcl_CallFrame frame, *framePtr = &frame; + int result; nonnull_assert(interp != NULL); nonnull_assert(fromNsObj != NULL); @@ -29755,14 +29762,13 @@ ObjStr(toNsObj)); } - object = GetObjectFromString(interp, ObjStr(fromNsObj)); destFullName = toNsPtr->fullName; destFullNameObj = Tcl_NewStringObj(destFullName, -1); INCR_REF_COUNT(destFullNameObj); varTablePtr = Tcl_Namespace_varTablePtr(fromNsPtr); Tcl_PushCallFrame(interp, (Tcl_CallFrame *)framePtr, toNsPtr, 0); } else { - NsfObject *newObject; + NsfObject *newObject, *object; if (GetObjectFromObj(interp, fromNsObj, &object) != TCL_OK) { return NsfPrintError(interp, "CopyVars: Origin object/namespace %s does not exist", @@ -29786,7 +29792,7 @@ */ hPtr = (varTablePtr != NULL) ? Tcl_FirstHashEntry(TclVarHashTablePtr(varTablePtr), &hSrch) : NULL; while (hPtr != NULL) { - Tcl_Obj *resultObj; + Tcl_Obj *varNameObj, *resultObj; GetVarAndNameFromHash(hPtr, &varPtr, &varNameObj); INCR_REF_COUNT(varNameObj); @@ -29795,11 +29801,11 @@ if (TclIsVarScalar(varPtr)) { /* * Copy scalar variables from the namespace, which might be - * either object or namespace variables. + * either instance or namespace variables. */ if (destObject != NULL) { - /* fprintf(stderr, "copy in obj %s var %s val '%s'\n", ObjectName(object), ObjStr(varNameObj), + /* fprintf(stderr, "copy in obj %s var %s val '%s'\n", ObjectName(destObject), ObjStr(varNameObj), ObjStr(TclVarValue(Tcl_Obj, varPtr, objPtr)));*/ resultObj = Nsf_ObjSetVar2((Nsf_Object *)destObject, interp, varNameObj, NULL, @@ -29829,7 +29835,7 @@ INCR_REF_COUNT(eltNameObj); if (TclIsVarScalar(eltVar)) { - if (object != NULL) { + if (destObject != NULL) { resultObj = Nsf_ObjSetVar2((Nsf_Object *)destObject, interp, varNameObj, eltNameObj, TclVarValue(Tcl_Obj, eltVar, objPtr), TCL_LEAVE_ERR_MSG); } else { @@ -34608,6 +34614,7 @@ entryPtr = Tcl_NextHashEntry(&search)) { Tcl_Obj *nameObj; Var *varPtr; + GetVarAndNameFromHash(entryPtr, &varPtr, &nameObj); if (!TclIsVarUndefined(varPtr) || TclIsVarNamespaceVar(varPtr)) { /* fprintf(stderr, "unsetting var %s\n", ObjStr(nameObj));*/ Index: generic/nsfStack.c =================================================================== diff -u -r7aad1f9b1cd757ef50182bdef2bbbf401a866862 -re89a635d134e85db66c3e7059ec81817b6b36ea5 --- generic/nsfStack.c (.../nsfStack.c) (revision 7aad1f9b1cd757ef50182bdef2bbbf401a866862) +++ generic/nsfStack.c (.../nsfStack.c) (revision e89a635d134e85db66c3e7059ec81817b6b36ea5) @@ -638,53 +638,59 @@ Tcl_CallFrame **callingProcFramePtrPtr, Tcl_CallFrame **callingFramePtrPtr) { register Tcl_CallFrame *varFramePtr; - int lvl; nonnull_assert(interp != NULL); varFramePtr = (Tcl_CallFrame *)Tcl_Interp_varFramePtr(interp); - lvl = Tcl_CallFrame_level(varFramePtr); + if (likely(varFramePtr != NULL)) { + int lvl = Tcl_CallFrame_level(varFramePtr); - for (; likely(varFramePtr != NULL); varFramePtr = Tcl_CallFrame_callerVarPtr(varFramePtr)) { - register unsigned int flags = (unsigned int)Tcl_CallFrame_isProcCallFrame(varFramePtr); + do { + register unsigned int flags = (unsigned int)Tcl_CallFrame_isProcCallFrame(varFramePtr); - if (flags != 0u) { - /* - * A proc frame - */ - NsfCallStackContent *cscPtr = - (flags & (FRAME_IS_NSF_METHOD|FRAME_IS_NSF_CMETHOD)) ? - ((NsfCallStackContent *)Tcl_CallFrame_clientData(varFramePtr)) : NULL; - - if (cscPtr != NULL) { + if (flags != 0u) { /* - * An NSF method frame. + * A proc frame */ - if ((cscPtr->flags & (NSF_CSC_CALL_IS_NEXT|NSF_CSC_CALL_IS_ENSEMBLE)) - || (cscPtr->frameType & NSF_CSC_TYPE_INACTIVE)) { - continue; - } - } + NsfCallStackContent *cscPtr = + (flags & (FRAME_IS_NSF_METHOD|FRAME_IS_NSF_CMETHOD)) ? + ((NsfCallStackContent *)Tcl_CallFrame_clientData(varFramePtr)) : NULL; - if (offset != 0) { - offset--; - } else if (Tcl_CallFrame_level(varFramePtr) < lvl) { - if (callingProcFramePtrPtr != NULL) { - *callingProcFramePtrPtr = varFramePtr; + if ((cscPtr != NULL) + && ((cscPtr->flags & (NSF_CSC_CALL_IS_NEXT|NSF_CSC_CALL_IS_ENSEMBLE)) + || (cscPtr->frameType & NSF_CSC_TYPE_INACTIVE)) + ) { + /* + * Skip NSF method frames, which are next calls, ensembles or inactive + */ + } else { + + if (offset != 0) { + offset--; + } else if (Tcl_CallFrame_level(varFramePtr) < lvl) { + if (callingProcFramePtrPtr != NULL) { + *callingProcFramePtrPtr = varFramePtr; + } + return cscPtr; + } } - return cscPtr; + } else if (callingFramePtrPtr != NULL + && *callingFramePtrPtr == NULL + && Tcl_CallFrame_level(varFramePtr) < lvl + ) { + *callingFramePtrPtr = varFramePtr; } + /* + * Continue in loop. + */ + varFramePtr = Tcl_CallFrame_callerVarPtr(varFramePtr); + + } while (likely(varFramePtr != NULL)); - } else if (callingFramePtrPtr != NULL && - *callingFramePtrPtr == NULL && - Tcl_CallFrame_level(varFramePtr) < lvl) { - *callingFramePtrPtr = varFramePtr; + if (callingProcFramePtrPtr != NULL) { + *callingProcFramePtrPtr = NULL; } } - - if (callingProcFramePtrPtr != NULL) { - *callingProcFramePtrPtr = NULL; - } return NULL; }