You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// match found. this is a local name. Replace it with the shared copy, flag as shared, set negative bucket#
812
+
// suppress this step if the type is ornamented, i. e. if it is name:: - then we need a flagged copy
812
813
Aoldtv=tv;
813
-
*t=tv=sympv[k].name; // use shared copy
814
-
if(recur){ras(tv); fa(oldtv);} // if we are installing into a recursive box, increment/decr usecount new/old
815
-
NAV(tv)->flag|=NMSHARED; // tag the shared copy as shared
814
+
if(likely(!(AT(tv)&NAMEABANDON))){ // not name::
815
+
*t=tv=sympv[k].name; // use shared copy
816
+
if(recur){ras(tv); fa(oldtv);} // if we are installing into a recursive box, increment/decr usecount new/old
817
+
NAV(tv)->flag|=NMSHARED; // tag the shared copy as shared
818
+
}
816
819
// Remember the exact location of the symbol. It will not move as long as this symbol table is alive. We can
817
820
// use it only when we are in this primary symbol table
818
821
NAV(tv)->symx=k; // keep index of the allocated symbol
@@ -869,7 +872,7 @@ A jtcrelocalsyms(J jt, A l, A c,I type, I dyad, I flags){A actst,*lv,pfst,t,wds;
869
872
ln=AN(l); lv=AAV(l); // Get # words, address of first box
870
873
for(j=1;j<ln;++j) { // start at 1 because we look at previous word
871
874
t=lv[j-1]; // t is the previous word
872
-
// look for 'names' =./=: . If found (and the names do not begin with `, replace the string with a special form: a list of boxes where each box contains a name.
875
+
// look for 'names' =./=: . If found (and the names do not begin with `), replace the string with a special form: a list of boxes where each box contains a name.
873
876
// This form can appear only in compiled definitions
@@ -882,7 +885,13 @@ A jtcrelocalsyms(J jt, A l, A c,I type, I dyad, I flags){A actst,*lv,pfst,t,wds;
882
885
if((AT(lv[j])&ASGN+ASGNLOCAL)==(ASGN+ASGNLOCAL)) { // local assignment
883
886
if(AT(lv[j])&ASGNTONAME){ // preceded by name?
884
887
// Lookup the name, which will create the symbol-table entry for it
885
-
RZ(probeis(t,pfst));
888
+
// name:: causes a little trouble. The name carries with it the :: flag, but we will eventually replace all refs with the srade ref from
889
+
// this table. That means we have to remove the :: flag from the stored value, lest every reference appear flagged just because the last one was.
890
+
// Note that we are here looking only before =., so we are specifically checking for name:: =. ... . This should be an error, and we might catch
891
+
// it when executed; but we are just making sure that it doesn't make the refs invalid. name:: also sets NAMEXY, and we have to leave that because
892
+
// any valid ref to mnuvxy will need that set; so there is a chance that name:: =. will result in an ordinary reference to the name's having the NAMEXY
893
+
// flag. That won't hurt anything significant.
894
+
L*nml; RZ(nml=probeis(t,pfst)); AT(nml->name)&=~NAMEABANDON; // put name in symbol table, with ABANDON flag cleared
886
895
} elseif(AT(t)&LIT) {
887
896
// LIT followed by =. Probe each word. Now that we support lists of NAMEs, this is used only for AR assignments
888
897
// First, convert string to words
@@ -892,13 +901,13 @@ A jtcrelocalsyms(J jt, A l, A c,I type, I dyad, I flags){A actst,*lv,pfst,t,wds;
892
901
for(kk=0;kk<wdsn;++kk) {
893
902
// Convert word to NAME; if local name, add to symbol table
Copy file name to clipboardExpand all lines: jsrc/jtype.h
+9-4Lines changed: 9 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -323,6 +323,7 @@ typedef I SI;
323
323
#defineNAMEX 23
324
324
#defineNAME ((I)1L<<NAMEX) /* NM name */
325
325
#defineNAMESIZE sizeof(C) // when we allocate a NAME type, the length is the length of the name string
326
+
// NOTE: VERB, SYMB, and LPAR are used as flags in names
326
327
#defineSYMBX 24
327
328
#defineSYMB ((I)1L<<SYMBX) /* I locale (symbol table) */
328
329
#defineSYMBSIZE sizeof(LX)
@@ -341,15 +342,13 @@ typedef I SI;
341
342
#defineLPAR ((I)1L<<LPARX) /* I left parenthesis */
342
343
// note: LPAR used as flag to cvt() see below; also as modifier to ADV type
343
344
#defineLPARSIZE sizeof(I)
344
-
// CONJ must be 1 bit below RPAR, with no parsable type (including any flags that might be set, see below) higher than RPAR
345
+
// CONJ must be 1 bit below RPAR, with no parsable type (including any flags that might be set, see below) in CONJ or RPAR
345
346
#defineCONJX 29
346
347
#defineCONJ ((I)1L<<CONJX) /* V conjunction */
347
348
#defineCONJSIZE sizeof(V)
348
349
#defineRPARX 30
349
350
#defineRPAR ((I)1L<<RPARX) /* I right parenthesis */
350
351
#defineRPARSIZE sizeof(I)
351
-
#defineSPARSEX 31 // NOTE this extends to the sign bit
352
-
#defineSPARSE (-((I)1L<<SPARSEX)) /* P sparse boxed */
353
352
354
353
#defineASGNX 21
355
354
#defineASGN ((I)1L<<ASGNX) /* I assignment */
@@ -361,8 +360,13 @@ typedef I SI;
361
360
// NOTE: The parser assumes that CONW always means ASGNTONAME, so don't use it in any parseable type (such as NAME, NOUN)
362
361
// ** NOUN types can have the following informational bits set
363
362
#defineNOUNCVTVALIDCT ((I)1L<<SYMBX) // Flag for jtcvt arg only: if set, convert only the #atoms given in the parameter Aliases with SYMB
363
+
#defineSPARSEX 31 // NOTE this extends to the sign bit
364
+
#defineSPARSE (-((I)1L<<SPARSEX)) /* P sparse boxed */
364
365
// ** NAME type can have the following information flags set
365
366
#defineNAMEBYVALUE ((I)1L<<SYMBX) // set if the name is one of x x. m m. etc that is always passed by value, never by name Aliases with SYMB
367
+
#defineNAMEABANDONX LPARX
368
+
#defineNAMEABANDON ((I)1L<<NAMEABANDONX) // name is name::, which will be deassigned after the value is stacked. NAMEBYVALUE must also be set
369
+
// in the parser VERB is set in a NAME type to indicate use of global symbol table
366
370
// ** BOX type can have the following informational flags set
367
371
#defineBOXMULTIASSIGN ((I)1L<<MARKX) // set for the target of a direct multiple assignment (i. e. 'x y' =.), which is stored as a boxed list whose contents are NAMEs aliases with MARK
368
372
// Restriction: CONW must be reserved for use as ASGNTONAME because of how parser tests for it
@@ -477,7 +481,7 @@ typedef I SI;
477
481
#defineACINCR(a) ACINCRLOCAL(a)
478
482
#defineACDECR(a) ACDECRLOCAL(a)
479
483
#defineACINIT(a,v) AC(a)=(v); // used when it is known that a has just been allocated & is not shared
480
-
#defineACRESET(a,v) AC(a)=(v); // used when it is known that a has is not shared (perhaps it's UNINCORPABLE)
484
+
#defineACRESET(a,v) AC(a)=(v); // used when it is known that a is not shared (perhaps it's UNINCORPABLE)
481
485
#defineACSET(a,v) AC(a)=(v); // used when a might be shared, but atomic not needed
482
486
#defineACFAUX(a,v) AC(a)=(v); // used when a is known to be a faux block
483
487
#defineACINITZAP(a) {*AZAPLOC(a)=0; ACINIT(a,ACUC1)} // effect ra() immediately after allocation, by zapping
@@ -562,6 +566,7 @@ typedef I SI;
562
566
#defineAMNVRDECR(a,am) (am=AM(a),AM(a)-=AMNVRCT,am) // save count, decrement, return old value
563
567
#defineAMNVRSET(a,x) (AM(a)=(x))
564
568
#defineAMNVRAND(a,x) (AM(a)&=(x)); // AND, no return
569
+
#defineAMNVROR(a,x) (AM(a)|=(x)); // OR, no return
0 commit comments