From 979c306881ba8cf494991a37b63935f551999f25 Mon Sep 17 00:00:00 2001 From: ketmar Date: Wed, 17 Nov 2010 11:58:39 +0200 Subject: [PATCH] resuming should work now --- src/lstcore/k8lst.h | 1 + src/lstcore/lst_interp.c | 34 ++++++++++++++-------------------- 2 files changed, 15 insertions(+), 20 deletions(-) diff --git a/src/lstcore/k8lst.h b/src/lstcore/k8lst.h index 502cfa8..7aed726 100644 --- a/src/lstcore/k8lst.h +++ b/src/lstcore/k8lst.h @@ -542,6 +542,7 @@ extern void *lstGetUData (lstObject *o); extern int lstExecute (lstObject *aProcess, int ticks, int locked); extern int lstResume (void); extern int lstCanResume (void); +extern void lstResetResume (void); /* arg==NULL: no argument * result==NULL: don't need result diff --git a/src/lstcore/lst_interp.c b/src/lstcore/lst_interp.c index 00b4daf..34bc68e 100644 --- a/src/lstcore/lst_interp.c +++ b/src/lstcore/lst_interp.c @@ -544,26 +544,12 @@ static int lstExecuteInternal (lstObject *aProcess, int ticks, int locked) { lstExecUserBreak = 0; - lstSuspended = 0; assert(runGroups->group == NULL); -#if 0 - { /* enter dummy record; add new process */ - LstRunGroup *og = curGroup; /* save old */ - curGroup = runGroups; /* switch to 'main' */ - runGroups->ticks = ticks; - LstRunContext *dummy = allocRunContext(); - dummy->process = NULL; /* 'stop it' flag */ - if (loadNewProcess(aProcess) != 0) { - releaseRunContext(); /* drop dummy context */ - curGroup = og; /* restore old group */ - runGroups->ticks = oTicks; - return lstReturnError; /* barf */ - } - curGroup = og ? og : runGroups; /* restore old group */ - } -#else - { + if (lstSuspended) { + lstSuspended = 0; + reloadFromGroup(); + } else { curGroup = runGroups; /* switch to 'main' */ runGroups->ticks = ticks; if (loadNewProcess(aProcess) != 0) { @@ -572,7 +558,6 @@ static int lstExecuteInternal (lstObject *aProcess, int ticks, int locked) { return lstReturnError; /* barf */ } } -#endif LST_ENTER_BLOCK(); LST_TEMP(aProcess); @@ -2145,7 +2130,7 @@ doReturn3: aProcess->data[lstIVcontextInProcess] = context; int lstExecute (lstObject *aProcess, int ticks, int locked) { - if (lstSuspended) return -1; /* very fatal error */ + lstResetResume(); return lstExecuteInternal(aProcess, ticks, locked); } @@ -2161,6 +2146,15 @@ int lstCanResume (void) { } +void lstResetResume (void) { + if (lstSuspended) { + lstSuspended = 0; + curGroup = runGroups; + while (curGroup->group) releaseRunContext(); + } +} + + #define RARG (lstRootStack[otop+0]) #define RMETHOD (lstRootStack[otop+1]) #define RPROCESS (lstRootStack[otop+2]) -- 2.11.4.GIT