aboutsummaryrefslogtreecommitdiff
path: root/jim.h
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2014-01-03 09:46:40 +1000
committerSteve Bennett <steveb@workware.net.au>2014-01-03 11:02:57 +1000
commit381cd0bed1a0ed9421eb1f5a0d368ec95024fd23 (patch)
treec4a79855f960c2d6dcd96d23f82f5cb2bb339bdd /jim.h
parentc07febeefdee3e620d61152574267107d59a1d6b (diff)
downloadjimtcl-381cd0bed1a0ed9421eb1f5a0d368ec95024fd23.zip
jimtcl-381cd0bed1a0ed9421eb1f5a0d368ec95024fd23.tar.gz
jimtcl-381cd0bed1a0ed9421eb1f5a0d368ec95024fd23.tar.bz2
tailcall: properly merge tailcall frames
Resolve the tailcall command immediately in [tailcall] and stash it. If a tailcall is currently being evaluated, new tailcalls in the same frame are merged/deferred to evaluate in the same C stack frame. Can't merge tailcall evaluations across uplevel. Add some tests for these cases Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim.h')
-rw-r--r--jim.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/jim.h b/jim.h
index 60a24a2..27c1e53 100644
--- a/jim.h
+++ b/jim.h
@@ -443,6 +443,9 @@ typedef struct Jim_CallFrame {
Jim_Obj *fileNameObj; /* file and line of caller of this proc (if available) */
int line;
Jim_Stack *localCommands; /* commands to be destroyed when the call frame is destroyed */
+ int tailcall; /* non-zero if a tailcall is being evaluated at this level */
+ struct Jim_Obj *tailcallObj; /* Pending tailcall invocation */
+ struct Jim_Cmd *tailcallCmd; /* Resolved command for pending tailcall invocation */
} Jim_CallFrame;
/* The var structure. It just holds the pointer of the referenced
@@ -524,7 +527,6 @@ typedef struct Jim_Interp {
int (*signal_set_result)(struct Jim_Interp *interp, jim_wide sigmask); /* Set a result for the sigmask */
Jim_CallFrame *framePtr; /* Pointer to the current call frame */
Jim_CallFrame *topFramePtr; /* toplevel/global frame pointer. */
- Jim_Obj *resolveNsObj; /* If not NULL, resolve the next command in this namespace - for tailcall */
struct Jim_HashTable commands; /* Commands hash table */
unsigned long procEpoch; /* Incremented every time the result
of procedures names lookup caching