summaryrefslogtreecommitdiffstats
path: root/generic/tclExecute.c
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2012-10-26 13:13:27 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2012-10-26 13:13:27 (GMT)
commit4f20c3d555d869755b8fbe5cf295f4898929c8a3 (patch)
tree6c8fe78d397d6aa4bde624d40f39d906e66484e6 /generic/tclExecute.c
parentecb8fcec67eaa9ecc3902b669ad242dd76038562 (diff)
downloadtcl-4f20c3d555d869755b8fbe5cf295f4898929c8a3.zip
tcl-4f20c3d555d869755b8fbe5cf295f4898929c8a3.tar.gz
tcl-4f20c3d555d869755b8fbe5cf295f4898929c8a3.tar.bz2
Working towards a BCCed [yield]; this doesn't work right now.
Diffstat (limited to 'generic/tclExecute.c')
-rw-r--r--generic/tclExecute.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index a24c806..30f8d77 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -2332,6 +2332,32 @@ 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;
+ }
+
+ Tcl_SetObjResult(interp, OBJ_AT_TOS);
+ TclNRAddCallback(interp, TclNRCoroutineActivateCallback, corPtr,
+ INT2PTR(0), NULL, NULL);
+
+#ifdef TCL_COMPILE_DEBUG
+ TRACE_WITH_OBJ(("yield, result="), iPtr->objResultPtr);
+ if (traceInstructions) {
+ fprintf(stdout, "\n");
+ }
+#endif
+ goto checkForCatch;
+ }
+
case INST_DONE:
if (tosPtr > initTosPtr) {
/*