Skip to content

Commit

Permalink
display primitive function and instance
Browse files Browse the repository at this point in the history
  • Loading branch information
tavmem committed Nov 29, 2014
1 parent e7875d2 commit 09cb1f1
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/k.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ C PPON=1;
I maX(I a,I b){R a>b?a:b;}
I miN(I a,I b){R a<b?a:b;}

K X(S s){kerr("undescribed"); R XN(s,strlen(s));}
K X(S s){kerr("undescribed"); fnci=0; R XN(s,strlen(s));}
Z K XN(S s,I n){R ex(wd(s,n));} //asserts ex(x) has first-line U(x)
K KX(K x){R XN(CSK(x),xn);} //assumes 3==ABS(xt)

Expand Down
1 change: 1 addition & 0 deletions src/k.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ void finally();
extern I PG;
extern I fError;
extern __thread I fer;
extern I fnci;

#if defined(DEBUG)
extern V krec[1000000];
Expand Down
52 changes: 26 additions & 26 deletions src/kc.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,17 @@ I line(FILE*f, S*a, I*n, PDA*p) // just starting or just executed: *a=*n=*p=0,
if(strlen(lineA)) {
if(fnc) { I cnt=0,i;
for(i=0;i<strlen(lineA);i++) { if(lineA[i]==*fnc) cnt++; }
if(cnt==1) { ctl=1; O("%s\n",lineA); S ptr=strchr(lineA,*fnc); DO(ptr-lineA,O(" ")) O("^\n"); }}}
if(cnt==1) { ctl=1; O("%s\n",lineA); S ptr=strchr(lineA,*fnc); DO(ptr-lineA,O(" ")) O("^\n"); }
if(cnt>1 && fnci) { I num=0;
for(i=0;i<fnci;i++) { if(fncp[i]==fncp[fnci-1])num++; }
O("at execution instance %lld of %s\n",num,fnc); }}}
if(strlen(lineB) && !ctl && strcmp(lineA,lineB)) {
if(fnc) { I cnt=0,i; O("%s\n",lineB);
for(i=0;i<strlen(lineB);i++) { if(lineB[i]==*fnc) cnt++; }
if(cnt==1) { S ptr=strchr(lineB,*fnc); DO(ptr-lineB,O(" ")) O("^\n"); }}}
if(cnt==1) { S ptr=strchr(lineB,*fnc); DO(ptr-lineB,O(" ")) O("^\n"); }
if(cnt>1 && fnci) { I num=0;
for(i=0;i<fnci;i++) { if(fncp[i]==fncp[fnci-1])num++; }
O("at execution instance %lld of %s\n",num,fnc); }}}
if(lineA || lineB) check(); //enter suspended execution mode for checking
if(!lineA && !lineB) O("%s\n",*a); }}
if(*p)pdafree(*p);*p=0;
Expand All @@ -198,7 +204,7 @@ I line(FILE*f, S*a, I*n, PDA*p) // just starting or just executed: *a=*n=*p=0,
done:
if(fWksp) { O("used now : %lld\n",(I)mUsed); O("max used : %lld\n",(I)mMax); O("symbols : %lld\n",nodeCount(SYMBOLS)); fWksp=0; }
if(o && !fLoad)prompt(b+fCheck);
kerr("undescribed"); fer=0; fnc=lineA=lineB=0;
kerr("undescribed"); fer=fnci=0; fnc=lineA=lineB=0;
R c;
}

Expand Down Expand Up @@ -353,37 +359,31 @@ I line(S s, S*a, I*n, PDA*p) { // just starting or just executed: *a=*n=*p=0,
#endif
if(o)show(k); cd(k);
cleanup:
if(strcmp(errmsg,"undescribed")) {
oerr(); I ctl=0;
if(strcmp(errmsg,"undescribed")) { oerr(); I ctl=0;
if(fError) {
if(strlen(lineA)) {
if(fnc) {
I cnt=0,i; for(i=0;i<strlen(lineA);i++) { if(lineA[i]==*fnc) cnt++; }
if(fnc) { I cnt=0,i;
for(i=0;i<strlen(lineA);i++) { if(lineA[i]==*fnc) cnt++; }
if(cnt==1) { ctl=1; O("%s\n",lineA); S ptr=strchr(lineA,*fnc); DO(ptr-lineA,O(" ")) O("^\n"); }
}
}
if(strlen(lineB) && !ctl) {
if(fnc) {
I cnt=0,i; for(i=0;i<strlen(lineB);i++) { if(lineB[i]==*fnc) cnt++; }
if(cnt==1) { O("%s\n",lineB); S ptr=strchr(lineB,*fnc); DO(ptr-lineB,O(" ")) O("^\n"); }
}
}
if(cnt>1 && fnci) { I num=0;
for(i=0;i<fnci;i++) { if(fncp[i]==fncp[fnci-1])num++; }
O("at execution instance %lld of %s\n",num,fnc); }}}
if(strlen(lineB) && !ctl && strcmp(lineA,lineB)) {
if(fnc) { I cnt=0,i; O("%s\n",lineB);
for(i=0;i<strlen(lineB);i++) { if(lineB[i]==*fnc) cnt++; }
if(cnt==1) { S ptr=strchr(lineB,*fnc); DO(ptr-lineB,O(" ")) O("^\n"); }
if(cnt>1 && fnci) { I num=0;
for(i=0;i<fnci;i++) { if(fncp[i]==fncp[fnci-1])num++; }
O("at execution instance %lld of %s\n",num,fnc); }}}
if(lineA || lineB) check(); //enter suspended execution mode for checking
if(!lineA && !lineB) O("%s\n",*a);
}
}
if(!lineA && !lineB) O("%s\n",*a); }}
if(*p)pdafree(*p);*p=0;
if(*a)free(*a);*a=0;*n=0;
if(s)free(s);s=0;
done:
if(fWksp) {
O("used now : %lld\n",(I)mUsed);
O("max used : %lld\n",(I)mMax);
O("symbols : %lld\n",nodeCount(SYMBOLS));
fWksp=0;
}
if(o && !fLoad)prompt(b+fCheck);
kerr("undescribed"); fer=0; fnc=0;
if(fWksp) { O("used now : %lld\n",(I)mUsed); O("max used : %lld\n",(I)mMax); O("symbols : %lld\n",nodeCount(SYMBOLS)); fWksp=0; }
if(o && !fLoad)prompt(b+fCheck);
kerr("undescribed"); fer=fnci=0; fnc=lineA=lineB=0;
R c;
}

Expand Down
2 changes: 2 additions & 0 deletions src/kc.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ extern S IFS[3];
extern S IFP[3];
extern S LS;
extern S fnc;
extern V fncp[128];
extern I fnci;
S sp(S k);
extern S __d;
K Kn();
Expand Down
32 changes: 18 additions & 14 deletions src/kx.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ Z V ex_(V a,I r);
I cirRef(K p,K y);
I cirRef_(K p,K y,I f);

__thread I fer=0; // Flag Early Return
__thread I fwh=0; // Flag While
__thread I stk=0; // Stack counter
__thread I prj=0; // Projection flag
__thread I prj2=0; // 2nd Projection flag
__thread K prnt=0; // Parent of Subfunction
__thread I f1s=1; // Flag 1 for Subfunctions
__thread I f2s=0; // Flag 2 for Subfunctions
__thread K grnt=0; // GrandParent of Subfunction
__thread K encf=0; // Enclosing Function
__thread I encp=0; // Enclosing Function Param
__thread I frg=0; // Flag reset globals
S fnc=0; // Most recent function from Dispatch Table
__thread I fer=0; // Flag Early Return
__thread I fwh=0; // Flag While
__thread I stk=0; // Stack counter
__thread I prj=0; // Projection flag
__thread I prj2=0; // 2nd Projection flag
__thread K prnt=0; // Parent of Subfunction
__thread I f1s=1; // Flag 1 for Subfunctions
__thread I f2s=0; // Flag 2 for Subfunctions
__thread K grnt=0; // GrandParent of Subfunction
__thread K encf=0; // Enclosing Function
__thread I encp=0; // Enclosing Function Param
__thread I frg=0; // Flag reset globals
S fnc=0; // Most recent function from Dispatch Table
V fncp[128];// DT pointers of executed functions
I fnci=0; // indicator of next function pointer position

//TODO: for derived verbs like +/ you can add the sub-pieces in parallel
Z K overDyad(K a, V *p, K b)
Expand Down Expand Up @@ -381,7 +383,9 @@ K vf_ex(V q, K g)
if(gn > 2 && (q==offsetAt || q==offsetDot )){ z= (q==offsetAt?at_tetradic:dot_tetradic)(a,b,c,d); GC;}
//common verbs

if(2==k && a && b){ fnc=DT[(L)q].text; z=((K(*)(K,K))DT[(L)q].func)(a,b); GC;}
if(2==k && a && b){ fnc=DT[(L)q].text;
if(fnci<127){fncp[fnci]=q; fnci++;}
z=((K(*)(K,K))DT[(L)q].func)(a,b); GC;}
//? (+).1 -> err ; {[a;b]a+b} 1 -> err
if(2==k && !a){VE; GC;} //Reachable? Projection?

Expand Down

0 comments on commit 09cb1f1

Please sign in to comment.