diff options
| author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-10-29 12:03:03 (GMT) |
|---|---|---|
| committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-10-29 12:03:03 (GMT) |
| commit | 886fc6d1e98ed9bf51f884ae2e68d391c5033b3e (patch) | |
| tree | 8d660cdd778f0e2a9335fd376fb69ace61262c20 /generic/tclExecute.c | |
| parent | 78ed75a33905e55e8eabc5e41651556fbbc60fbc (diff) | |
| parent | 3cc94c1d69092f90d3aca7121cc57b3b6d4bbd2c (diff) | |
| download | tcl-886fc6d1e98ed9bf51f884ae2e68d391c5033b3e.zip tcl-886fc6d1e98ed9bf51f884ae2e68d391c5033b3e.tar.gz tcl-886fc6d1e98ed9bf51f884ae2e68d391c5033b3e.tar.bz2 | |
Merge corrected [yield] compilation. Many thanks to Miguel Sofer for help.
Diffstat (limited to 'generic/tclExecute.c')
| -rw-r--r-- | generic/tclExecute.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c index a24c806..b42e4ab 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -2332,6 +2332,48 @@ TEBCresume( cleanup = 1; goto processExceptionReturn; + case INST_YIELD: { + CoroutineData *corPtr = iPtr->execEnvPtr->corPtr; + + TRACE(("%.30s => ", O2S(OBJ_AT_TOS))); + if (!corPtr) { + TRACE_APPEND(("ERROR: yield outside coroutine\n")); + Tcl_SetObjResult(interp, Tcl_NewStringObj( + "yield can only be called in a coroutine", -1)); + Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ILLEGAL_YIELD", + NULL); + goto gotError; + } + +#ifdef TCL_COMPILE_DEBUG + TRACE_WITH_OBJ(("yield, result="), iPtr->objResultPtr); + if (traceInstructions) { + fprintf(stdout, "\n"); + } +#endif + /* TIP #280: Record the last piece of info needed by + * 'TclGetSrcInfoForPc', and push the frame. + */ + + bcFramePtr->data.tebc.pc = (char *) pc; + iPtr->cmdFramePtr = bcFramePtr; + + if (iPtr->flags & INTERP_DEBUG_FRAME) { + TclArgumentBCEnter((Tcl_Interp *) iPtr, objv, objc, + codePtr, bcFramePtr, pc - codePtr->codeStart); + } + + pc++; + cleanup = 1; + TEBC_YIELD(); + + Tcl_SetObjResult(interp, OBJ_AT_TOS); + TclNRAddCallback(interp, TclNRCoroutineActivateCallback, corPtr, + INT2PTR(0), NULL, NULL); + + return TCL_OK; + } + case INST_DONE: if (tosPtr > initTosPtr) { /* |
