diff options
author | dkf <dkf@noemail.net> | 2014-01-09 21:20:23 (GMT) |
---|---|---|
committer | dkf <dkf@noemail.net> | 2014-01-09 21:20:23 (GMT) |
commit | 7d8a02893fb32ee5cdc7200c3ddeff1f5dc5a9d8 (patch) | |
tree | fe3896fd636563de7504eb24bce205cf9f547457 /generic/tclProc.c | |
parent | 7da7e2abb0592ad3f9c013e2f7647a7da34ba6b0 (diff) | |
parent | a751b89ba37d63984afa068eb6d9be52ed0e2ea9 (diff) | |
download | tcl-7d8a02893fb32ee5cdc7200c3ddeff1f5dc5a9d8.zip tcl-7d8a02893fb32ee5cdc7200c3ddeff1f5dc5a9d8.tar.gz tcl-7d8a02893fb32ee5cdc7200c3ddeff1f5dc5a9d8.tar.bz2 |
merge trunk
FossilOrigin-Name: cd045e6a26d65bfd6af289d2ffb5f5696e255af0
Diffstat (limited to 'generic/tclProc.c')
-rw-r--r-- | generic/tclProc.c | 72 |
1 files changed, 32 insertions, 40 deletions
diff --git a/generic/tclProc.c b/generic/tclProc.c index a154afa..42c9a72 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -1851,9 +1851,39 @@ InterpProcNR2( } /* - * Process the result code. + * Free the stack-allocated compiled locals and CallFrame. It is important + * to pop the call frame without freeing it first: the compiledLocals + * cannot be freed before the frame is popped, as the local variables must + * be deleted. But the compiledLocals must be freed first, as they were + * allocated later on the stack. + */ + + if (result != TCL_OK) { + goto process; + } + + done: + if (TCL_DTRACE_PROC_RESULT_ENABLED()) { + int l = iPtr->varFramePtr->isProcCallFrame & FRAME_IS_LAMBDA ? 1 : 0; + Tcl_Obj *r = Tcl_GetObjResult(interp); + + TCL_DTRACE_PROC_RESULT(l < iPtr->varFramePtr->objc ? + TclGetString(iPtr->varFramePtr->objv[l]) : NULL, result, + TclGetString(r), r); + } + + freePtr = iPtr->framePtr; + Tcl_PopCallFrame(interp); /* Pop but do not free. */ + TclStackFree(interp, freePtr->compiledLocals); + /* Free compiledLocals. */ + TclStackFree(interp, freePtr); /* Free CallFrame. */ + return result; + + /* + * Process any non-TCL_OK result code. */ + process: switch (result) { case TCL_RETURN: /* @@ -1888,46 +1918,8 @@ InterpProcNR2( */ errorProc(interp, procNameObj); - - default: - /* - * Process other results (OK and non-standard) by doing nothing - * special, skipping directly to the code afterwards that cleans up - * associated memory. - * - * Non-standard results are processed by passing them through quickly. - * This means they all work as exceptions, unwinding the stack quickly - * and neatly. Who knows how well they are handled by third-party code - * though... - */ - - (void) 0; /* do nothing */ - } - - if (TCL_DTRACE_PROC_RESULT_ENABLED()) { - int l = iPtr->varFramePtr->isProcCallFrame & FRAME_IS_LAMBDA ? 1 : 0; - Tcl_Obj *r = Tcl_GetObjResult(interp); - - TCL_DTRACE_PROC_RESULT(l < iPtr->varFramePtr->objc ? - TclGetString(iPtr->varFramePtr->objv[l]) : NULL, result, - TclGetString(r), r); } - - /* - * Free the stack-allocated compiled locals and CallFrame. It is important - * to pop the call frame without freeing it first: the compiledLocals - * cannot be freed before the frame is popped, as the local variables must - * be deleted. But the compiledLocals must be freed first, as they were - * allocated later on the stack. - */ - - freePtr = iPtr->framePtr; - Tcl_PopCallFrame(interp); /* Pop but do not free. */ - TclStackFree(interp, freePtr->compiledLocals); - /* Free compiledLocals. */ - TclStackFree(interp, freePtr); /* Free CallFrame. */ - - return result; + goto done; } /* |