Copyright 2014, BEST, LLC. All rights reserved.

This patch and the code contained within is licensed 
under the GNU General Public License version 3 
as published by the Free Software Foundation.

 jsrc/a.c  | 34 ++++++++++++++++++++++++++++++++++
 jsrc/au.c | 10 ++++++++--
 jsrc/jc.h |  1 +
 jsrc/je.h |  1 +
 jsrc/jt.h |  1 +
 jsrc/t.c  |  1 +
 jsrc/ws.c |  8 ++++----
 7 files changed, 50 insertions(+), 6 deletions(-)

diff --git a/jsrc/a.c b/jsrc/a.c
index 61b42c9..363725a 100644
--- a/jsrc/a.c
+++ b/jsrc/a.c
@@ -161,3 +161,37 @@ F1(jtmemo){A h,*hv,q;I m;V*v;
  GA(q,BOX,m,1,0);                  hv[2]=q;
  R fdef(CMCAP,VERB,jtmemo1,jtmemo2,w,0L,h,0L,v->mr,v->lr,v->rr);
 }
+
+DF1(jttramp1){I old;B oldtramp=jt->tramp;A z;DECLF;
+ RZ(w);
+ jt->tramp=1;
+ old=jt->tbase+jt->ttop;
+ z=CALL1(f1,w,fs);
+ while(VERB&AT(z)){
+  z=CALL1(f1,VAV(z)->f,fs);
+  ra(z); tpop(old); tpush(z);
+ }
+ jt->tramp=0;
+ ASSERT(NOUN&AT(z),EVDOMAIN);
+ R z;
+}
+
+DF2(jttramp2){I old;B oldtramp=jt->tramp;A z;DECLF;
+ RZ(a&&w);
+ jt->tramp=1;
+ z=CALL2(f2,a,w,fs);
+ old=jt->tbase+jt->ttop;
+ while(VERB&AT(z)){
+  z=CALL2(f2,VAV(z)->f,VAV(z)->g,fs);
+  ra(z); tpop(old); tpush(z);
+ }
+ jt->tramp=0;
+ ASSERT(NOUN&AT(z),EVDOMAIN);
+ R z;
+}
+
+F1(jttramp){
+ RZ(w);
+ ASSERT(VERB&AT(w),EVDOMAIN);
+ R ADERIV(CTRAMP,jttramp1,jttramp2,mr(w),rr(w),lr(w));
+}
diff --git a/jsrc/au.c b/jsrc/au.c
index 575fbcc..2e5df08 100644
--- a/jsrc/au.c
+++ b/jsrc/au.c
@@ -32,8 +32,14 @@ DF1(jtdfs1){A s=jt->sf,z; RZ(self); z=CALL1(VAV(self)->f1,  w,jt->sf=self); jt->
 DF2(jtdfs2){A s=jt->sf,z; RZ(self); z=CALL2(VAV(self)->f2,a,w,jt->sf=self); jt->sf=s; R z;}    
      /* for monads and dyads that can possibly involve $: */
 
-F1(jtself1){A z;I d=fdep(jt->sf); FDEPINC(d); z=df1(  w,jt->sf); FDEPDEC(d); R z;}
-F2(jtself2){A z;I d=fdep(jt->sf); FDEPINC(d); z=df2(a,w,jt->sf); FDEPDEC(d); R z;}
+F1(jtself1){A z;I d;
+ if(jt->tramp) R fdef(CTRAMP,VERB, 0L,0L, w,0L,0L, 0L, 0L,0L,0L);
+ d=fdep(jt->sf); FDEPINC(d); z=df1(  w,jt->sf); FDEPDEC(d); R z;
+}
+F2(jtself2){A z;I d;
+ if(jt->tramp) R fdef(CTRAMP,VERB, 0L,0L, a,w,0L, 0L, 0L,0L,0L);
+ d=fdep(jt->sf); FDEPINC(d); z=df2(a,w,jt->sf); FDEPDEC(d); R z;
+}
 
 A jtac1(J jt,AF f){R fdef(0,VERB, f,0L, 0L,0L,0L, 0L, RMAX,RMAX,RMAX);}
 A jtac2(J jt,AF f){R fdef(0,VERB, 0L,f, 0L,0L,0L, 0L, RMAX,RMAX,RMAX);}
diff --git a/jsrc/jc.h b/jsrc/jc.h
index 18d024b..756207a 100644
--- a/jsrc/jc.h
+++ b/jsrc/jc.h
@@ -199,4 +199,5 @@
 #define CPDERIV    '\357'       /* 239 357 ef p..                          */
 #define CAPIP      '\360'       /* 240 360 f0 ,   append in place          */
 
+#define CTRAMP       '\361'       /* 241 361 f1 J.  trampoline               */
 #define CFF        '\377'       /* 255 377 ff                              */
diff --git a/jsrc/je.h b/jsrc/je.h
index e10a89d..516bceb 100644
--- a/jsrc/je.h
+++ b/jsrc/je.h
@@ -325,6 +325,7 @@ extern F1(jttss);
 extern F1(jttoutf8);
 extern F1(jttoutf16);
 extern F1(jttoutf16x);
+extern F1(jttramp);
 extern F1(jtuco1);
 extern F1(jtunbin);
 extern F1(jtunlock1);
diff --git a/jsrc/jt.h b/jsrc/jt.h
index 3224f15..7d5f4e7 100644
--- a/jsrc/jt.h
+++ b/jsrc/jt.h
@@ -231,6 +231,7 @@ typedef struct {
  UI   timelimit;        /* execution time limit milliseconds               */
  B    tmonad;           /* tacit translator: 1 iff monad                   */
  B    tostdout;         /* 1 if output to stdout                           */
+ B    tramp;            /* 1 if in a trampoline                            */
  I    transposeflag;    /* com flag for transposed arrays                  */
  D    tssbase;          /* initial time of date                            */
  A*   tstack;           /* data portion of current frame                   */
diff --git a/jsrc/t.c b/jsrc/t.c
index 6cb9652..e1a7c50 100644
--- a/jsrc/t.c
+++ b/jsrc/t.c
@@ -150,6 +150,7 @@ B jtpinit(J jt){A t;C*s;
  /*  M. */  pdef(CMCAP,   ADV,  jtmemo,    0L,       0,   0,   0   );
  /*  n. */       /* see above */
  /*  o. */  pdef(CCIRCLE, VERB, jtpix,     jtcircle, 0,   0,   0   );
+ /*  O. */  pdef(CTRAMP,  ADV,  jttramp,   0L,       0,   0,   0   );
  /*  p. */  pdef(CPOLY,   VERB, jtpoly1,   jtpoly2,  1,   1,   0   );
  /*  p..*/  pdef(CPDERIV, VERB, jtpderiv1, jtpderiv2,1,   0,   1   );
  /*  p: */  pdef(CPCO,    VERB, jtprime,   jtpco2,   0,   RMAX,RMAX);
diff --git a/jsrc/ws.c b/jsrc/ws.c
index c46973d..24f1198 100644
--- a/jsrc/ws.c
+++ b/jsrc/ws.c
@@ -7,13 +7,13 @@
 #include "w.h"
 
 
-static C spell[3][70]={
+static C spell[3][71]={
  '=',     '<',     '>',     '_',     '+',     '*',     '-',     '%',
  '^',     '$',     '~',     '|',     '.',     ':',     ',',     ';',
  '#',     '@',     '/',     CBSLASH, '[',     ']',     '{',     '}',
  '`',     CQQ,     '&',     '!',     '?',     'a',     'A',     'b',
  'c',     'C',     'd',     'D',     'e',     'E',     'f',     'H',
- 'i',     'I',     'j',     'L',     'm',     'M',     'n',     'o',
+ 'i',     'I',     'j',     'L',     'm',     'M',     'n',     'o',     'O',
  'p',     'q',     'r',     's',     'S',     't',     'T',     'u',
  'v',     'x',     'y',     '0',     '1',     '2',     '3',     '4',
  '5',     '6',     '7',     '8',     '9',     0,
@@ -23,7 +23,7 @@ static C spell[3][70]={
  CBASE,   CATDOT,  CSLDOT,  CBSDOT,  CLEV,    CDEX,    CTAKE,   CDROP,
  CGRDOT,  CEXEC,   CUNDER,  CFIT,    CQRYDOT, CALP,    CATOMIC, CBDOT,
  CCDOT,   CCYCLE,  CDDOT,   CDCAP,   CEPS,    CEBAR,   CFIX,    CHGEOM,
- CIOTA,   CICAP,   CJDOT,   CLDOT,   CMDOT,   CMCAP,   CNDOT,   CCIRCLE,
+ CIOTA,   CICAP,   CJDOT,   CLDOT,   CMDOT,   CMCAP,   CNDOT,   CCIRCLE,  CTRAMP,
  CPOLY,   1,       CRDOT,   1,       1,       CTDOT,   CTCAP,   CUDOT,
  CVDOT,   CXDOT,   CYDOT,   1,       1,       1,       1,       1,
  1,       1,       1,       1,       1,       0,
@@ -33,7 +33,7 @@ static C spell[3][70]={
  CABASE,  CATCO,   CGRADE,  CDGRADE, CCAP,    CIDA,    CTAIL,   CCTAIL,
  CGRCO,   CTHORN,  CAMPCO,  CIBEAM,  CQRYCO,  CACE,    1,       1,
  1,       1,       1,       CDCAPCO, 1,       1,       1,       1,       
- CICO,    1,       1,       CLCAPCO, 1,       1,       1,       1,
+ CICO,    1,       1,       CLCAPCO, 1,       1,       1,       1,       1,
  CPCO,    CQCO,    1,       CSCO,    CSCAPCO, CTCO,    1,       CUCO,    
  1,       CXCO,    1,       CFCONS,  CFCONS,  CFCONS,  CFCONS,  CFCONS,  
  CFCONS,  CFCONS,  CFCONS,  CFCONS,  CFCONS,  0,
