Skip to content

Commit

Permalink
Bug when 9!:5 on; prep for !LOCALRA; better explanation of QCxx seman…
Browse files Browse the repository at this point in the history
…tics changes
  • Loading branch information
HenryHRich committed Dec 17, 2024
1 parent c3ef08d commit 05c8af2
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 64 deletions.
2 changes: 1 addition & 1 deletion jsrc/cf.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ FORK2(jtfolk2,0x1000) // this version used by reversions, where localuse may

// see if f is defined as [:, as a single name
static B jtcap(J jt,A x){V*v;
if(v=VAV(x),CTILDE==v->id&&NAME&AT(v->fgh[0])&&(x=QCWORD(syrd(v->fgh[0],jt->locsyms)))){v=VAV(x); fa(x);} // don't go through chain of names, since it might loop (on u) and it's ugly to chase the chain syrd ra()s the value
if(v=VAV(x),CTILDE==v->id&&NAME&AT(v->fgh[0])&&(x=syrd(v->fgh[0],jt->locsyms))){v=VAV(QCWORD(x)); if(LOCALRA||ISGLOBAL(x))fa(QCWORD(x));} // don't go through chain of names, since it might loop (on u) and it's ugly to chase the chain syrd ra()s the value if global
R CCAP==v->id; //
}

Expand Down
10 changes: 6 additions & 4 deletions jsrc/d.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ A jteformat(J jt,A self,A a,A w,A m){
F1PREFIP;
if(likely(self!=DUMMYSELF)){ // if we are called without a real self, we must be executing something internal. Format it later when we have a real self
C e=jt->jerr;
if(e!=0 && !(jt->emsgstate&EMSGSTATEFORMATTED)){ // if no error, or we have already run eformat on this error, don't do it again
if(e!=0 && e!=EVABORTEMPTY && !(jt->emsgstate&EMSGSTATEFORMATTED)){ // if no error, or we have already run eformat on this error, don't do it again. Don't waste time on aborts
if(!jt->glock && !(jt->emsgstate&EMSGSTATENOEFORMAT)){ // if we are locked, show nothing; if eformat suppressed, leave the error line as is
A saverr; // savearea for the initial message
A *old=jt->tnextpushp; // we must free all memory that we allocate here
Expand All @@ -238,10 +238,12 @@ A jteformat(J jt,A self,A a,A w,A m){
// we have to reset the state of the error system after saving what we will need
I pareninfo = (jt->emsgstate&EMSGSTATEPAREN)>>EMSGSTATEPARENX; // unbalanced-paren info from infererrtok
RESETERR; jt->emsgstate|=EMSGSTATEFORMATTED; // clear error system; indicate that we are starting to format, so that the error line will not be modified during eformat
A nam=nfs(10,"eformat_j_"); A val; if((val=syrd(nam,jt->locsyms))==0)goto noeformat; if((val=QCWORD(namerefacv(nam,val)))==0)goto noeformat;
if(!(val&&LOWESTBIT(AT(val))&VERB))goto noeformat; // there is always a ref, but it may be to [:. Undo ra() in syrd
// obsolete A nam=nfs(10,"eformat_j_"); A val; if((val=syrd(nam,jt->locsyms))==0)goto noeformat; if((val=QCWORD(namerefacv(nam,val)))==0)goto noeformat;
// obsolete if(!(val&&LOWESTBIT(AT(val))&VERB))goto noeformat; // there is always a ref, but it may be to [:. Undo ra() in syrd
A nam=nfs(10,"eformat_j_"); A val; if((val=syrd(nam,jt->locsyms))==0)goto noeformat;
if((val=QCWORD(namerefacv(nam,QCWORD(val))))==0)goto noeformat; if(!(val&&LOWESTBIT(AT(val))&VERB))goto noeformat; // there is always a ref, but it may be to [:. namerefscv will undo ra() in syrd
// we also have to reset processing state: ranks. It seems too hard to force eformat to infer the ranks from the args
// other internal state (i. e. from !.n) will have been restored before we get here
// other internal state (i. e. from !.n) will have been restored before we get here
// establish internal-state args: jt->ranks.
A rnk; if((rnk=v2((I)(B)jt->ranks,(I)(B)(jt->ranks>>RANKTX)))==0)goto noeformat; // cell ranks
RESETRANK; // We have to reset the rank before we call internal functions
Expand Down
2 changes: 2 additions & 0 deletions jsrc/j.h
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,8 @@ struct jtimespec jmtfclk(void); //'fast clock'; maybe less inaccurate; intended
#define SWMAX 32767 // max # words in a sentence
#define EXPWMAX 16777215 // max # words in an explicit defn

#define LOCALRA 1 // ra() local names during lookup - must be set, but perhaps we can make it an option in explicit def

// flags for jteformat
#define EMSGE 0xff // the error-code part
#define EMSGNOEVM 0x200 // set to suppress moving the terse message
Expand Down
1 change: 1 addition & 0 deletions jsrc/jerr.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
#define EWOVFLOOR1 69 // major oflo in <./>., must be converted to FL
#define EVCUTSTACK 76 // set when Cut Stack executed; passed into caller to force its termination; intercepted when terminated line finishes, to revert to suspension
#define EVDEBUGEND 79 // EVEXIT+64 set when debug wants to fail all avoiding all try blocks
#define EVABORTEMPTY 80 // when a verb produces this, abort the sentence without error and return empty
#define EVNOCONV 128 // must be higher than other errors. Set when a FL has lost precision and must not be converted to INT
#define EVSUPPRESS 255 // turn off error reporting: don't change anything. Not used
#define EVOK 256 // error code used to mean 'no error' in cases where we have to take the minimum of returned errors
Expand Down
6 changes: 4 additions & 2 deletions jsrc/jtype.h
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ struct AD {
#define ACSETLOCAL(a,v) AC(a)=(v); // used when a might be shared, but atomic not needed
#define ACSET(a,v) __atomic_store_n(&AC(a),(v),__ATOMIC_RELEASE); // used when a might be shared, but atomic not needed
#define ACFAUX(a,v) AC(a)=(v); // used when a is known to be a faux block
#define ACINITZAP(a) {*AZAPLOC(a)=0; ACINIT(a,ACUC1)} // effect ra() immediately after allocation, by zapping
#define ACINITZAP(a) {*AZAPLOC(a)=0; ACINIT(a,ACUC1)} // effect ra() after allocation, by zapping: used when we are not sure the most-recent value on the stack is a
#define ACINITUNPUSH(a) {A *pushp=jt->tnextpushp; --pushp; \
if(unlikely(((I)pushp&(NTSTACKBLOCK-1))==0)){A *nextp=(A*)*pushp; if(unlikely(nextp!=pushp-1))freetstackallo(jt); pushp=nextp;} /* check start of block and start of allo */ \
jt->tnextpushp=pushp; ACINIT(a,ACUC1)} // effect ra() immediately after allocation, by backing the tpush pointer
Expand Down Expand Up @@ -882,11 +882,12 @@ typedef DST* DC;
// In the LSBs returned by syrd() (stored by symbis()), bit 4 and the higher code points have QCGLOBAL semantics:
#define QCGLOBALX 4
#define QCGLOBAL 0x10 // set if the name was found in a global table
#define ISGLOBAL(w) ((I)w&QCGLOBAL) // true if global, if w has QCGLOBAL semantics
#define SETGLOBAL(w) (A)((I)(w)|QCGLOBAL)
#define CLRGLOBAL(w) (A)((I)(w)&~QCGLOBAL)
#define VALTYPENAMELESS ((SYMBX-LASTNOUNX)+1) // 6 set in nameless non-locative ACV, to suppress reference creation.
#define VALTYPESPARSE ((CONWX-LASTNOUNX)+1) // 7 set in sparse noun, which is the only type of a stored value that requires traverse. Has bit 0 set, as befits a noun
#define NAMELESSQCTOTYPEDQC(q) q=QCWORD(q), q=(A)((I)q+ATYPETOVALTYPEACV(AT(q))); // q is name of NAMELESS QC; result has QC type for t
#define NAMELESSQCTOTYPEDQC(q) q=(A)(((I)q&~0xf)+ATYPETOVALTYPEACV(AT(QCWORD(q)))); // q is name of NAMELESS QC; result has QC type for t with unchanged QCGLOBAL semantics
// In the LSBs returned by syrd1() bit 4 have QCNAMED semantics:
#define QCNAMEDX 4 // set if the value was found in a named locale, clear if numbered
#define QCNAMED ((I)1<<QCNAMEDX) // set if the value was found in a named locale, clear if numbered
Expand All @@ -896,6 +897,7 @@ typedef DST* DC;
#define SETFAOWED(w) (A)((I)(w)|QCFAOWED)
#define CLRFAOWED(w) (A)((I)(w)&~QCFAOWED)
#define ISFAOWED(w) ((I)(w)&QCFAOWED) // is fa() required?
#define SYRDGLOBALTOFAOWED(w) (w) // convert QCGLOBAL semantics of syrd() result to QCFAOWED: FAOWED if GLOBAL
#define QCPTYPE(x) ((I)(x)&0xf) // the type-code part, 0-15 for the syntax units including assignment
// When the value is pushed onto the parser stack, the FAOWED bit moves to bit 0 where it can be distinguished from a tstack pointer
#define STKFAOWEDX 0
Expand Down
Loading

0 comments on commit 05c8af2

Please sign in to comment.