53 if ( nametree->
namenode == 0 )
return(0);
60 else if ( i > 0 ) newnode = n->
right;
62 }
while ( newnode >= 0 );
71 int AddName(
NAMETREE *nametree, UBYTE *name, WORD type, WORD number,
int *nodenum)
75 LONG *c1,*c2, j, newsize;
76 int node, newnode, node3, r, rr = 0, i, retval = 0;
78 s = name; i = 1;
while ( *s ) { i++; s++; }
82 "new nametree in AddName");
84 "new namebuffer in AddName");
98 while ( *s ) *ss++ = *s++;
108 newnode = n->
left; r = -1;
111 newnode = n->
right; r = 1;
113 }
while ( newnode >= 0 );
119 if ( newsize > MAXINNAMETREE ) newsize = MAXINNAMETREE;
120 if ( nametree->
nodefill >= MAXINNAMETREE ) {
121 MesPrint(
"!!!More than %l names in one object",(LONG)MAXINNAMETREE);
125 "extra names in AddName");
126 c1 = (LONG *)nnn; c2 = (LONG *)nametree->
namenode;
128 while ( --i >= 0 ) *c1++ = *c2++;
129 M_free(nametree->
namenode,
"nametree->namenode");
134 *nodenum = newnode = nametree->
nodefill++;
137 if ( r < 0 ) n->
left = newnode;
else n->
right = newnode;
142 i = 1; s = name;
while ( *s ) { i++; s++; }
144 sss = (UBYTE *)Malloc1(2*nametree->
namesize,
145 "extra names in AddName");
147 while ( --j >= 0 ) *s++ = *ss++;
148 M_free(nametree->
namebuffer,
"nametree->namebuffer");
156 while ( *name ) *s++ = *name++;
161 while ( node >= 0 ) {
163 if ( newnode == n->
left ) rr = -1;
166 else if ( n->
balance == rr )
break;
171 if ( node < 0 )
return(retval);
208 if ( node == nn->
left ) nn->
left = node3;
209 else nn->
right = node3;
213 else if ( nn->
balance == rr ) {
225 if ( node == nnn->
left ) nnn->
left = newnode;
226 else nnn->
right = newnode;
233 MesPrint(
"We ran into an impossible case in AddName\n");
252 int GetName(
NAMETREE *nametree, UBYTE *name, WORD *number,
int par)
255 int node, newnode, i;
264 else if ( i > 0 ) newnode = n->
right;
269 }
while ( newnode >= 0 );
272 if ( s > name && s[-1] ==
'_' && nametree == AC.varnames ) {
276 if ( s == name+2 && ( *name ==
'd' || *name ==
'D' ) ) {
277 *number = DELTA-FUNCTION;
283 if ( s > name+2 && *name ==
'N' ) {
285 while ( FG.cTable[*t] == 1 ) i = 10*i + *t++ -
'0';
287 *number = i + AM.IndDum - AM.OffsetIndex;
300 else if ( i > 0 ) newnode = n->
right;
304 }
while ( newnode >= 0 );
311 t = name; u = AC.extrasym;
312 while ( *t == *u ) { t++; u++; }
313 if ( *u == 0 && *t != 0 ) {
315 while ( FG.cTable[*t] == 1 ) {
316 x = 10*x + (*t++ -
'0');
318 if ( *t ==
'_' && x > 0 && x <= cbuf[AM.sbufnum].numrhs ) {
319 *number = MAXVARIABLES-x;
325 if ( par != WITHAUTO || nametree == AC.autonames )
return(NAMENOTFOUND);
326 return(GetAutoName(name,number));
340 int GetLastExprName(UBYTE *name, WORD *number)
344 for ( i = NumExpressions; i > 0; i-- ) {
346 if ( StrCmp(AC.exprnames->namebuffer+e->name,name) == 0 ) {
362 int GetOName(
NAMETREE *nametree, UBYTE *name, WORD *number,
int par)
364 int retval = GetName(nametree,name,number,par);
366 case CVECTOR: *number += AM.OffsetVector;
break;
367 case CINDEX: *number += AM.OffsetIndex;
break;
368 case CFUNCTION: *number += FUNCTION;
break;
381 int GetAutoName(UBYTE *name, WORD *number)
385 if ( GetName(AC.exprnames,name,number,NOAUTO) != NAMENOTFOUND )
386 return(NAMENOTFOUND);
388 while ( *s ) { s++; }
389 if ( s[-1] ==
'_' ) {
390 return(NAMENOTFOUND);
394 type = GetName(AC.autonames,name,number,NOAUTO);
399 *number = AddSymbol(name,sym->minpower,sym->maxpower,sym->complex,sym->dimension);
403 *number = AddVector(name,vec->complex,vec->dimension);
407 *number = AddIndex(name,ind->dimension,ind->nmin4);
418 return(NAMENOTFOUND);
426 int GetVar(UBYTE *name, WORD *type, WORD *number,
int wantedtype,
int par)
430 if ( ( typ = GetName(AC.varnames,name,number,par) ) != wantedtype ) {
431 if ( typ != NAMENOTFOUND ) {
432 if ( wantedtype == -1 ) {
436 NameConflict(typ,name);
437 MakeDubious(AC.varnames,name,&funnum);
440 if ( ( typ = GetName(AC.exprnames,name,&funnum,par) ) != NAMENOTFOUND ) {
441 if ( typ == wantedtype || wantedtype == -1 ) {
442 *number = funnum; *type = typ;
return(1);
444 NameConflict(typ,name);
447 return(NAMENOTFOUND);
449 if ( typ == -1 ) {
return(0); }
459 WORD EntVar(WORD type, UBYTE *name, WORD x, WORD y, WORD z, WORD d)
463 return(AddSymbol(name,y,z,x,d));
466 return(AddIndex(name,x,z));
469 return(AddVector(name,x,d));
472 return(AddFunction(name,y,z,x,0,d,-1,-1));
475 AC.SetList.numtemp++;
476 return(AddSet(name,d));
479 return(AddExpression(name,x,y));
492 int GetDollar(UBYTE *name)
495 if ( GetName(AC.dollarnames,name,&number,NOAUTO) == NAMENOTFOUND )
return(-1);
508 DumpNode(nametree,nametree->
headnode,0);
517 VOID DumpNode(
NAMETREE *nametree, WORD node, WORD depth)
523 if ( n->
left >= 0 ) DumpNode(nametree,n->
left,depth+1);
524 for ( i = 0; i < depth; i++ ) printf(
" ");
526 printf(
"%s(%d): {%d}(%d)(%d)[%d]\n",
528 if ( n->
right >= 0 ) DumpNode(nametree,n->
right,depth+1);
536 int CompactifyTree(
NAMETREE *nametree,WORD par)
543 for ( i = 0, j = 0, k = 0, n = nametree->
namenode, ns = 0;
544 i < nametree->nodefill; i++, n++ ) {
545 if ( n->
type != CDELETE ) {
547 while ( *s ) { s++; ns++; }
552 if ( k == 0 )
return(0);
567 if ( j < 10 ) j = 10;
568 if ( ns < 100 ) ns = 100;
571 newtree.
namebuffer = (UBYTE *)Malloc1(2*ns,
"compactify namestree");
573 CopyTree(&newtree,nametree,nametree->
headnode,par);
575 LinkTree(&newtree,(WORD)0,newtree.
nodefill);
577 M_free(nametree->
namebuffer,
"nametree->namebuffer");
578 M_free(nametree->
namenode,
"nametree->namenode");
603 if ( n->
left >= 0 ) CopyTree(newtree,oldtree,n->
left,par);
604 if ( n->
type != CDELETE ) {
613 if ( par == AUTONAMES ) {
623 if ( par == AUTONAMES ) {
633 if ( par == AUTONAMES ) {
643 if ( par == AUTONAMES ) {
669 MesPrint(
"Illegal variable type in CopyTree: %d",n->
type);
675 while ( *t ) { *s++ = *t++; newtree->
namefill++; }
678 if ( n->
right >= 0 ) CopyTree(newtree,oldtree,n->
right,par);
686 VOID LinkTree(
NAMETREE *
tree, WORD offset, WORD numnodes)
691 int med,numleft,numright,medleft,medright;
694 numright = numnodes - med - 1;
695 medleft = numleft >> 1;
696 medright = ( numright >> 1 ) + med + 1;
701 if ( numright > 0 ) {
705 if ( numleft > 0 ) LinkTree(tree,offset,numleft);
706 if ( numright > 0 ) LinkTree(tree,offset+med+1,numright);
707 while ( numleft && numright ) { numleft >>= 1; numright >>= 1; }
741 M_free(n,
"nametree");
751 void ClearWildcardNames()
753 AC.NumWildcardNames = 0;
756 int AddWildcardName(UBYTE *name)
759 int size = 0, tocopy, i;
760 UBYTE *s = name, *t, *newbuffer;
761 while ( *s ) { s++; size++; }
762 for ( i = 0, t = AC.WildcardNames; i < AC.NumWildcardNames; i++ ) {
764 while ( ( *s == *t ) && *s ) { s++; t++; }
765 if ( *s == 0 && *t == 0 )
return(i+1);
769 tocopy = t - AC.WildcardNames;
770 if ( tocopy + size + 1 > AC.WildcardBufferSize ) {
771 if ( AC.WildcardBufferSize == 0 ) {
772 AC.WildcardBufferSize = size+1;
773 if ( AC.WildcardBufferSize < 100 ) AC.WildcardBufferSize = 100;
775 else if ( size+1 >= AC.WildcardBufferSize ) {
776 AC.WildcardBufferSize += size+1;
779 AC.WildcardBufferSize *= 2;
781 newbuffer = (UBYTE *)Malloc1((LONG)AC.WildcardBufferSize,
"argument list names");
783 if ( AC.WildcardNames ) {
784 s = AC.WildcardNames;
785 while ( tocopy > 0 ) { *t++ = *s++; tocopy--; }
786 M_free(AC.WildcardNames,
"AC.WildcardNames");
788 AC.WildcardNames = newbuffer;
789 M_free(AT.WildArgTaken,
"AT.WildArgTaken");
790 AT.WildArgTaken = (WORD *)Malloc1((LONG)AC.WildcardBufferSize*
sizeof(WORD)/2
791 ,
"argument list names");
794 while ( *s ) *t++ = *s++;
796 AC.NumWildcardNames++;
797 return(AC.NumWildcardNames);
800 int GetWildcardName(UBYTE *name)
804 for ( i = 0, t = AC.WildcardNames; i < AC.NumWildcardNames; i++ ) {
806 while ( ( *s == *t ) && *s ) { s++; t++; }
807 if ( *s == 0 && *t == 0 )
return(i+1);
822 int AddSymbol(UBYTE *name,
int minpow,
int maxpow,
int cplx,
int dim)
824 int nodenum, numsymbol = AC.Symbols->num;
827 bzero(sym,
sizeof(
struct SyMbOl));
828 sym->name = AddName(*AC.activenames,name,CSYMBOL,numsymbol,&nodenum);
829 sym->minpower = minpow;
830 sym->maxpower = maxpow;
835 sym->namesize = (s-name)+1;
847 int CoSymbol(UBYTE *s)
849 int type, error = 0, minpow, maxpow, cplx, sgn, dim;
851 UBYTE *name, *oldc, c, cc;
858 if ( ( s = SkipAName(s) ) == 0 ) {
859 IllForm: MesPrint(
"&Illegally formed name in symbol statement");
861 s = SkipField(name,0);
864 oldc = s; cc = c = *s; *s = 0;
865 if ( TestName(name) ) { *s = c;
goto IllForm; }
868 if ( tolower(*s) ==
'r' ) cplx = VARTYPENONE;
869 else if ( tolower(*s) ==
'c' ) cplx = VARTYPECOMPLEX;
870 else if ( tolower(*s) ==
'i' ) cplx = VARTYPEIMAGINARY;
871 else if ( ( ( *s ==
'-' || *s ==
'+' ) && ( s[1] >=
'0' && s[1] <=
'9' ) )
872 || ( *s >=
'0' && *s <=
'9' ) ) {
875 if ( *s ==
'-' ) { sgn = VARTYPEMINUS; s++; }
876 else if ( *s ==
'+' ) { sgn = 0; s++; }
878 while ( s[1] >=
'0' && s[1] <=
'9' ) {
879 x = 10*x + (s[1] -
'0'); s++;
881 if ( x >= MAXPOWER || x <= 1 ) {
882 MesPrint(
"&Illegal value for root of unity %s",name);
888 cplx = VARTYPEROOTOFUNITY | sgn;
891 MesPrint(
"&Illegal specification for complexity of symbol %s",name);
901 if ( ( *s ==
'd' || *s ==
'D' ) && s[1] ==
'=' ) {
903 if ( *s ==
'-' || *s ==
'+' || FG.cTable[*s] == 1 ) {
904 ParseSignedNumber(dim,s)
905 if ( dim < -HALFMAX || dim > HALFMAX ) {
906 MesPrint(
"&Warning: dimension of %s (%d) out of range" 910 if ( *s !=
'}' )
goto IllDim;
914 IllDim: MesPrint(
"&Error: Illegal dimension field for variable %s",name);
922 if ( ( cplx & VARTYPEROOTOFUNITY ) == VARTYPEROOTOFUNITY ) {
923 MesPrint(
"&Root of unity property for %s cannot be combined with power restrictions",name);
927 if ( *s ==
'-' || *s ==
'+' || FG.cTable[*s] == 1 ) {
928 ParseSignedNumber(minpow,s)
929 if ( minpow < -MAXPOWER ) {
932 MesPrint(
"&Warning: minimum power of %s corrected to %d" 942 if ( *s ==
'-' || *s ==
'+' || FG.cTable[*s] == 1 ) {
943 ParseSignedNumber(maxpow,s)
944 if ( maxpow > MAXPOWER ) {
947 MesPrint(
"&Warning: maximum power of %s corrected to %d" 951 if ( *s !=
')' )
goto skippar;
954 if ( ( AC.AutoDeclareFlag == 0 &&
955 ( ( type = GetName(AC.exprnames,name,&numsymbol,NOAUTO) )
957 || ( ( type = GetName(*(AC.activenames),name,&numsymbol,NOAUTO) ) != NAMENOTFOUND ) ) {
958 if ( type != CSYMBOL ) error = NameConflict(type,name);
962 sym->minpower = minpow;
963 sym->maxpower = maxpow;
968 AddSymbol(name,minpow,maxpow,cplx,dim);
971 eol:
while ( *s ==
',' ) s++;
983 int AddIndex(UBYTE *name,
int dim,
int dim4)
985 int nodenum, numindex = AC.Indices->num;
988 bzero(ind,
sizeof(
struct InDeX));
989 ind->name = AddName(*AC.activenames,name,CINDEX,numindex,&nodenum);
991 ind->dimension = dim;
995 ind->namesize = (s-name)+1;
1006 int CoIndex(UBYTE *s)
1008 int type, error = 0, dim, dim4;
1010 UBYTE *name, *oldc, c;
1015 if ( ( s = SkipAName(s) ) == 0 ) {
1016 IllForm: MesPrint(
"&Illegally formed name in index statement");
1018 s = SkipField(name,0);
1021 oldc = s; c = *s; *s = 0;
1022 if ( TestName(name) ) { *s = c;
goto IllForm; }
1025 if ( ( s = DoDimension(s,&dim,&dim4) ) == 0 ) {
1028 s = SkipField(name,0);
1032 if ( ( AC.AutoDeclareFlag == 0 &&
1033 ( ( type = GetName(AC.exprnames,name,&numindex,NOAUTO) )
1035 || ( ( type = GetName(*(AC.activenames),name,&numindex,NOAUTO) ) != NAMENOTFOUND ) ) {
1036 if ( type != CINDEX ) error = NameConflict(type,name);
1038 indices[numindex].dimension = dim;
1039 indices[numindex].nmin4 = dim4;
1042 else AddIndex(name,dim,dim4);
1044 eol:
while ( *s ==
',' ) s++;
1054 UBYTE *DoDimension(UBYTE *s,
int *dim,
int *dim4)
1057 int type, error = 0;
1059 NAMETREE **oldtree = AC.activenames;
1060 *dim4 = -NMIN4SHIFT;
1061 if ( FG.cTable[*s] == 1 ) {
1064 #if ( BITSINWORD/8 < 4 ) 1065 if ( *dim >= (1 << (BITSINWORD-1)) )
goto illeg;
1070 else if ( ( (FG.cTable[*s] == 0 ) || ( *s ==
'[' ) )
1071 && ( s = SkipAName(s) ) != 0 ) {
1072 AC.activenames = &(AC.varnames);
1074 if ( ( ( type = GetName(AC.exprnames,t,&numsymbol,NOAUTO) ) != NAMENOTFOUND )
1075 || ( ( type = GetName(AC.varnames,t,&numsymbol,WITHAUTO) ) != NAMENOTFOUND ) ) {
1076 if ( type != CSYMBOL ) error = NameConflict(type,t);
1079 numsymbol = AddSymbol(t,-MAXPOWER,MAXPOWER,0,0);
1080 if ( *oldtree != AC.autonames && AC.WarnFlag )
1081 MesPrint(
"&Warning: Implicit declaration of %s as a symbol",t);
1084 if ( ( *s = c ) ==
':' ) {
1087 if ( ( s = SkipAName(s) ) == 0 )
goto illeg;
1088 if ( ( ( type = GetName(AC.exprnames,t,&numsymbol,NOAUTO) ) != NAMENOTFOUND )
1089 || ( ( type = GetName(AC.varnames,t,&numsymbol,WITHAUTO) ) != NAMENOTFOUND ) ) {
1090 if ( type != CSYMBOL ) error = NameConflict(type,t);
1093 numsymbol = AddSymbol(t,-MAXPOWER,MAXPOWER,0,0);
1094 if ( *oldtree != AC.autonames && AC.WarnFlag )
1095 MesPrint(
"&Warning: Implicit declaration of %s as a symbol",t);
1097 *dim4 = -numsymbol-NMIN4SHIFT;
1100 else if ( *s ==
'+' && FG.cTable[s[1]] == 1 ) {
1104 illeg: MesPrint(
"&Illegal dimension specification. Should be number >= 0, symbol or symbol:symbol");
1107 AC.activenames = oldtree;
1108 if ( error )
return(0);
1117 int CoDimension(UBYTE *s)
1119 s = DoDimension(s,&AC.lDefDim,&AC.lDefDim4);
1120 if ( s == 0 )
return(1);
1122 MesPrint(
"&Argument of dimension statement should be number >= 0, symbol or symbol:symbol");
1135 int AddVector(UBYTE *name,
int cplx,
int dim)
1137 int nodenum, numvector = AC.Vectors->num;
1140 bzero(v,
sizeof(
struct VeCtOr));
1141 v->name = AddName(*AC.activenames,name,CVECTOR,numvector,&nodenum);
1146 v->namesize = (s-name)+1;
1157 int CoVector(UBYTE *s)
1159 int type, error = 0, dim;
1161 UBYTE *name, c, *endname;
1165 if ( ( s = SkipAName(s) ) == 0 ) {
1166 IllForm: MesPrint(
"&Illegally formed name in vector statement");
1171 c = *s; *s = 0, endname = s;
1172 if ( TestName(name) ) { *s = c;
goto IllForm; }
1175 if ( ( *s ==
'd' || *s ==
'D' ) && s[1] ==
'=' ) {
1177 if ( *s ==
'-' || *s ==
'+' || FG.cTable[*s] == 1 ) {
1178 ParseSignedNumber(dim,s)
1179 if ( dim < -HALFMAX || dim > HALFMAX ) {
1180 MesPrint(
"&Warning: dimension of %s (%d) out of range" 1184 if ( *s !=
'}' )
goto IllDim;
1188 IllDim: MesPrint(
"&Error: Illegal dimension field for variable %s",name);
1191 while ( *s ==
',' ) s++;
1195 if ( ( AC.AutoDeclareFlag == 0 &&
1196 ( ( type = GetName(AC.exprnames,name,&numvector,NOAUTO) )
1198 || ( ( type = GetName(*(AC.activenames),name,&numvector,NOAUTO) ) != NAMENOTFOUND ) ) {
1199 if ( type != CVECTOR ) error = NameConflict(type,name);
1201 else AddVector(name,0,dim);
1204 while ( *s ==
',' ) s++;
1216 int AddFunction(UBYTE *name,
int comm,
int istensor,
int cplx,
int symprop,
int dim,
int argmax,
int argmin)
1218 int nodenum, numfunction = AC.Functions->num;
1221 bzero(fun,
sizeof(
struct FuNcTiOn));
1222 fun->
name = AddName(*AC.activenames,name,CFUNCTION,numfunction,&nodenum);
1224 fun->
spec = istensor;
1227 fun->
node = nodenum;
1230 fun->dimension = dim;
1231 fun->maxnumargs = argmax;
1232 fun->minnumargs = argmin;
1235 return(numfunction);
1247 int CoFunction(UBYTE *s,
int comm,
int istensor)
1249 int type, error = 0, cplx, symtype, dim, argmax, argmin;
1250 WORD numfunction, reverseorder = 0, addone;
1251 UBYTE *name, *oldc, *par, c, cc;
1253 symtype = cplx = 0, argmin = argmax = -1;
1256 if ( ( s = SkipAName(s) ) == 0 ) {
1257 IllForm: MesPrint(
"&Illegally formed function/tensor name");
1259 s = SkipField(name,0);
1262 oldc = s; cc = c = *s; *s = 0;
1263 if ( TestName(name) ) { *s = c;
goto IllForm; }
1266 if ( tolower(*s) ==
'r' ) cplx = VARTYPENONE;
1267 else if ( tolower(*s) ==
'c' ) cplx = VARTYPECOMPLEX;
1268 else if ( tolower(*s) ==
'i' ) cplx = VARTYPEIMAGINARY;
1270 MesPrint(
"&Illegal specification for complexity of %s",name);
1280 if ( ( *s ==
'd' || *s ==
'D' ) && s[1] ==
'=' ) {
1282 if ( *s ==
'-' || *s ==
'+' || FG.cTable[*s] == 1 ) {
1283 ParseSignedNumber(dim,s)
1284 if ( dim < -HALFMAX || dim > HALFMAX ) {
1285 MesPrint(
"&Warning: dimension of %s (%d) out of range" 1289 if ( *s !=
'}' )
goto IllDim;
1293 IllDim: MesPrint(
"&Error: Illegal dimension field for variable %s",name);
1303 reverseorder = REVERSEORDER;
1310 while ( FG.cTable[*s] == 0 ) s++;
1314 MesPrint(
"&Illegal specification for symmetry of %s",name);
1320 if ( StrICont(par,(UBYTE *)
"symmetric") == 0 ) symtype = SYMMETRIC;
1321 else if ( StrICont(par,(UBYTE *)
"antisymmetric") == 0 ) symtype = ANTISYMMETRIC;
1322 else if ( ( StrICont(par,(UBYTE *)
"cyclesymmetric") == 0 )
1323 || ( StrICont(par,(UBYTE *)
"cyclic") == 0 ) ) symtype = CYCLESYMMETRIC;
1324 else if ( ( StrICont(par,(UBYTE *)
"rcyclesymmetric") == 0 )
1325 || ( StrICont(par,(UBYTE *)
"rcyclic") == 0 )
1326 || ( StrICont(par,(UBYTE *)
"reversecyclic") == 0 ) ) symtype = RCYCLESYMMETRIC;
1329 if ( *s !=
')' || ( s[1] && s[1] !=
',' && s[1] !=
'<' ) ) {
1330 Warning(
"&Excess information in symmetric properties currently ignored");
1334 symtype |= reverseorder;
1340 if ( *s ==
'=' ) { addone++; s++; }
1342 while ( FG.cTable[*s] == 1 ) { argmax = 10*argmax + *s++ -
'0'; }
1345 while ( FG.cTable[*s] == 0 ) s++;
1348 if ( ( StrICont(par,(UBYTE *)
"arguments") == 0 )
1349 || ( StrICont(par,(UBYTE *)
"args") == 0 ) ) {}
1351 Warning(
"&Illegal information in number of arguments properties currently ignored");
1356 if ( argmax <= 0 ) {
1357 MesPrint(
"&Error: Cannot have fewer than 0 arguments for variable %s",name);
1364 if ( *s ==
'=' ) { addone = 0; s++; }
1366 while ( FG.cTable[*s] == 1 ) { argmin = 10*argmin + *s++ -
'0'; }
1369 while ( FG.cTable[*s] == 0 ) s++;
1372 if ( ( StrICont(par,(UBYTE *)
"arguments") == 0 )
1373 || ( StrICont(par,(UBYTE *)
"args") == 0 ) ) {}
1375 Warning(
"&Illegal information in number of arguments properties currently ignored");
1382 if ( cc ==
'<' )
goto retry;
1383 if ( ( AC.AutoDeclareFlag == 0 &&
1384 ( ( type = GetName(AC.exprnames,name,&numfunction,NOAUTO) )
1386 || ( ( type = GetName(*(AC.activenames),name,&numfunction,NOAUTO) ) != NAMENOTFOUND ) ) {
1387 if ( type != CFUNCTION ) error = NameConflict(type,name);
1393 if ( istensor && fun->
spec == 0 ) {
1394 MesPrint(
"&Function %s changed to tensor",name);
1397 else if ( istensor == 0 && fun->
spec ) {
1398 MesPrint(
"&Tensor %s changed to function",name);
1401 fun->
spec = istensor;
1404 AC.SymChangeFlag = 1;
1406 fun->maxnumargs = argmax;
1407 fun->minnumargs = argmin;
1411 AddFunction(name,comm,istensor,cplx,symtype,dim,argmax,argmin);
1414 eol:
while ( *s ==
',' ) s++;
1419 int CoNFunction(UBYTE *s) {
return(CoFunction(s,1,0)); }
1420 int CoCFunction(UBYTE *s) {
return(CoFunction(s,0,0)); }
1421 int CoNTensor(UBYTE *s) {
return(CoFunction(s,1,2)); }
1422 int CoCTensor(UBYTE *s) {
return(CoFunction(s,0,2)); }
1454 static int nwarntab = 1;
1456 int DoTable(UBYTE *s,
int par)
1459 UBYTE *name, *p, *inp, c;
1460 int i, j, sparseflag = 0, rflag = 0, checkflag = 0, error = 0, ret, oldcbufnum;
1461 WORD funnum, type, *OldWork, *w, *newp, *flags1;
1466 while ( *s ==
',' ) s++;
1469 if ( ( s = SkipAName(s) ) == 0 ) {
1470 IllForm: MesPrint(
"&Illegal name or option in table declaration");
1474 if ( TestName(name) ) { *s = c;
goto IllForm; }
1476 if ( *s ==
'(' )
break;
1478 MesPrint(
"&Illegal definition of table");
1485 if ( StrICmp(name,(UBYTE *)(
"check" )) == 0 ) checkflag = 1;
1486 else if ( StrICmp(name,(UBYTE *)(
"zero" )) == 0 ) checkflag = 2;
1487 else if ( StrICmp(name,(UBYTE *)(
"strict")) == 0 ) rflag = 1;
1488 else if ( StrICmp(name,(UBYTE *)(
"relax" )) == 0 ) rflag = -1;
1489 else if ( StrICmp(name,(UBYTE *)(
"zerofill" )) == 0 ) rflag = -2;
1490 else if ( StrICmp(name,(UBYTE *)(
"sparse")) == 0 ) sparseflag |= 1;
1491 else if ( StrICmp(name,(UBYTE *)(
"base")) == 0 ) sparseflag |= 3;
1492 else if ( StrICmp(name,(UBYTE *)(
"tablebase")) == 0 ) sparseflag |= 3;
1494 MesPrint(
"&Illegal option in table definition: '%s'",name);
1498 while ( *s ==
',' ) s++;
1500 if ( name == s || *s == 0 ) {
1501 MesPrint(
"&Illegal name or option in table declaration");
1506 if ( checkflag == 1 ) rflag = 0;
1507 else if ( checkflag == 2 ) rflag = -2;
1510 if ( ( ret = GetVar(name,&type,&funnum,CFUNCTION,NOAUTO) ) ==
1513 funnum = EntVar(CFUNCTION,name,0,1,0,0);
1515 else if ( par == 1 || par == 2 ) {
1516 funnum = EntVar(CFUNCTION,name,0,0,0,0);
1519 else if ( ret <= 0 ) {
1520 funnum = EntVar(CFUNCTION,name,0,0,0,0);
1526 Warning(
"Table now declares its (commuting) function.");
1527 Warning(
"Earlier definition in Function statement obsolete. Please remove.");
1533 MesPrint(
"&(N)(C)Tables should not be declared previously");
1536 if ( functions[funnum].spec > 0 ) {
1537 MesPrint(
"&Tensors cannot become tables");
1540 if ( functions[funnum].tabl ) {
1541 MesPrint(
"&Redefinition of an existing table is not allowed.");
1544 functions[funnum].tabl = T = (
TABLES)Malloc1(
sizeof(
struct TaBlEs),
"table");
1564 if ( rflag > 0 ) AC.MustTestTable++;
1578 T->argtail = strDup1(p,"argtail");
1585 if ( FG.cTable[p[-1]] != 1 || ( *p != ',' && *p != ')' ) ) {
1587 MesPrint(
"&First argument in a sparse table must be a number of dimensions");
1593 T->
flags = (WORD *)Malloc1(x*
sizeof(WORD),
"table flags");
1605 if ( FG.cTable[*p] != 1 && *p !=
'+' && *p !=
'-' )
break;
1606 ParseSignedNumber(x,p)
1607 if ( FG.cTable[p[-1]] != 1 || *p != ':' ) break;
1609 ParseSignedNumber(y,p)
1610 if ( FG.cTable[p[-1]] != 1 || ( *p != ',' && *p != ')' ) ) {
1611 MesPrint(
"&Illegal dimension field in table declaration");
1615 flags1 = (WORD *)Malloc1((T->
numind+1)*
sizeof(WORD),
"table flags");
1616 for ( i = 0; i < T->
numind; i++ ) { mm1[i] = T->
mm[i]; flags1[i] = T->
flags[i]; }
1617 if ( T->
mm ) M_free(T->
mm,
"table dimensions");
1618 if ( T->
flags ) M_free(T->
flags,
"table flags");
1625 if ( *p ==
')' ) { inp = p;
break; }
1628 = (WORD *)Malloc1(TABLEEXTENSION*
sizeof(WORD)*(T->
totind),
"table pointers");
1630 for ( i = TABLEEXTENSION*T->
totind; i > 0; i-- ) *w++ = -1;
1631 for ( i = T->
numind-1, x = 1; i >= 0; i-- ) {
1640 OldWork = AT.WorkPointer;
1641 oldcbufnum = AC.cbufnum;
1643 while ( s >= name ) *--inp = *s--;
1644 AC.ProtoType = w = AT.WorkPointer;
1645 *w++ = SUBEXPRESSION;
1653 AT.WorkPointer = w + 4*AM.MaxWildcards;
1655 if ( ( ret = CompileAlgebra(inp,LHSIDE,AC.ProtoType) ) < 0 ) error = 1;
1657 if ( AC.NwildC &&
SortWild(w,AC.NwildC) ) error = 1;
1661 j = cbuf[AC.cbufnum].Pointer-cbuf[AC.cbufnum].lhs[ret] + T->
numind*2-3;
1663 T->
prototypeSize = ((i+j)*
sizeof(WORD)+2*
sizeof(WORD *)) * AM.totalnumberofthreads;
1668 t = (WORD *)(T->
pattern + AM.totalnumberofthreads);
1669 for ( n = 0; n < AM.totalnumberofthreads; n++ ) {
1671 for ( k = 0; k < i; k++ ) *t++ = OldWork[k];
1679 while ( --i >= 0 ) T->
prototype[i] = OldWork[i];
1692 twstop = tw + tw[1]; tw += SUBEXPSIZE;
1693 while ( tw < twstop ) {
1694 if ( *tw == LOADDOLLAR ) {
1695 Warning(
"The use of $-variable assignments in tables disables parallel\ 1696 execution for the whole program.");
1697 AM.hparallelflag |= NOPARALLEL_TBLDOLLAR;
1698 AC.mparallelflag |= NOPARALLEL_TBLDOLLAR;
1705 w = cbuf[AC.cbufnum].lhs[ret] + 1;
1711 *newp++ = *w++; *newp++ = *w++ + T->
numind*2;
1712 for ( i = 2; i < FUNHEAD; i++ ) *newp++ = *w++;
1713 for ( i = 0; i < T->
numind; i++ ) { *newp++ = -SNUMBER; *newp++ = 0; j -= 2; }
1714 if ( sparseflag ) { w += 2; j -= 4; }
1715 for ( i = FUNHEAD; i < j; i++ ) *newp++ = *w++;
1725 for ( n = 1; n < AM.totalnumberofthreads; n++ ) {
1727 for ( i = 0; i < k; i++ ) *newp++ = *t++;
1734 AT.WorkPointer = OldWork;
1735 AC.cbufnum = oldcbufnum;
1736 if ( T->
sparse ) ClearTableTree(T);
1737 if ( ( sparseflag & 2 ) != 0 ) {
1738 if ( T->
spare == 0 ) { SpareTable(T); }
1748 int CoTable(UBYTE *s)
1750 return(DoTable(s,2));
1758 int CoNTable(UBYTE *s)
1760 return(DoTable(s,0));
1768 int CoCTable(UBYTE *s)
1770 return(DoTable(s,1));
1778 int AddSet(UBYTE *name, WORD dim)
1780 int nodenum, numset = AC.SetList.num;
1781 SETS set = (
SETS)FromVarList(&AC.SetList);
1784 set->name = AddName(AC.varnames,name,CSET,numset,&nodenum);
1787 set->namesize = (s-name)+1;
1788 set->node = nodenum;
1796 set->last = AC.SetElementList.num;
1798 set->dimension = dim;
1810 int DoElements(UBYTE *s,
SETS set, UBYTE *name)
1812 int type, error = 0, x, sgn, i;
1816 if ( *s ==
',' ) { s++;
continue; }
1818 while ( *s ==
'-' || *s ==
'+' ) { sgn ^= 1; s++; }
1820 if ( FG.cTable[*s] == 0 || *s ==
'_' || *s ==
'[' ) {
1821 if ( ( s = SkipAName(s) ) == 0 ) {
1822 MesPrint(
"&Illegal name in set definition");
1826 if ( ( ( type = GetName(AC.exprnames,cname,&numset,NOAUTO) ) == NAMENOTFOUND )
1827 && ( ( type = GetOName(AC.varnames,cname,&numset,WITHAUTO) ) == NAMENOTFOUND ) ) {
1830 MesPrint(
"&%s has not been declared",cname);
1834 numset = AC.DubiousList.num;
1835 dv = (
DUBIOUSV)FromVarList(&AC.DubiousList);
1836 dv->name = AddName(AC.varnames,cname,CDUBIOUS,numset,&nodenum);
1838 set->type = type = CDUBIOUS;
1842 if ( set->type == -1 ) {
1843 if ( type == CSYMBOL ) {
1844 for ( i = set->first; i < set->last; i++ ) {
1845 SetElements[i] += 2*MAXPOWER;
1850 if ( set->type != type && set->type != CDUBIOUS
1851 && type != CDUBIOUS ) {
1852 if ( set->type != CNUMBER || ( type != CSYMBOL
1853 && type != CINDEX ) ) {
1855 "&%s has not the same type as the other members of the set" 1858 set->type = CDUBIOUS;
1861 if ( type == CSYMBOL ) {
1862 for ( i = set->first; i < set->last; i++ ) {
1863 SetElements[i] += 2*MAXPOWER;
1869 if ( set->dimension != MAXPOSITIVE ) {
1870 switch ( set->type ) {
1872 if ( symbols[numset].dimension != set->dimension ) {
1873 MesPrint(
"&Dimension check failed in set %s, symbol %s",
1874 VARNAME(Sets,(
set-Sets)),
1875 VARNAME(symbols,numset));
1877 set->dimension = MAXPOSITIVE;
1881 if ( vectors[numset-AM.OffsetVector].dimension != set->dimension ) {
1882 MesPrint(
"&Dimension check failed in set %s, vector %s",
1883 VARNAME(Sets,(
set-Sets)),
1884 VARNAME(vectors,(numset-AM.OffsetVector)));
1886 set->dimension = MAXPOSITIVE;
1890 if ( functions[numset-FUNCTION].dimension != set->dimension ) {
1891 MesPrint(
"&Dimension check failed in set %s, function %s",
1892 VARNAME(Sets,(
set-Sets)),
1893 VARNAME(functions,(numset-FUNCTION)));
1897 set->dimension = MAXPOSITIVE;
1901 if ( type != CVECTOR ) {
1902 MesPrint(
"&Illegal use of - sign in set. Can use only with vector or number");
1905 numset = AM.OffsetVector - numset;
1907 numset = AM.OffsetVector - numset;
1910 if ( name == 0 && *s ==
'?' ) {
1912 switch ( set->type ) {
1914 numset = -numset;
break;
1916 numset += WILDOFFSET;
break;
1918 numset |= WILDMASK;
break;
1920 numset |= WILDMASK;
break;
1927 e = (WORD *)FromVarList(&AC.SetElementList);
1931 else if ( FG.cTable[*s] == 1 ) {
1934 if ( x >= MAXPOWER || x <= -MAXPOWER ||
1935 ( set->type == CINDEX && ( x < 0 || x >= AM.OffsetIndex ) ) ) {
1936 MesPrint(
"&Illegal value for set element: %d",x);
1937 if ( AC.firstconstindex ) {
1938 MesPrint(
"&0 <= Fixed indices < ConstIndex(which is %d)",
1940 MesPrint(
"&For setting ConstIndex, read the chapter on the setup file");
1941 AC.firstconstindex = 0;
1949 if ( set->type == -1 ) {
1950 if ( x < 0 || x >= AM.OffsetIndex ) {
1951 for ( i = set->first; i < set->last; i++ ) {
1952 SetElements[i] += 2*MAXPOWER;
1954 set->type = CSYMBOL;
1956 else set->type = CNUMBER;
1958 else if ( set->type == CDUBIOUS ) {}
1959 else if ( set->type == CNUMBER && x < 0 ) {
1960 for ( i = set->first; i < set->last; i++ ) {
1961 SetElements[i] += 2*MAXPOWER;
1963 set->type = CSYMBOL;
1965 else if ( set->type != CSYMBOL && ( x < 0 ||
1966 ( set->type != CINDEX && set->type != CNUMBER ) ) ) {
1967 MesPrint(
"&Illegal mixture of element types in set");
1969 set->type = CDUBIOUS;
1974 e = (WORD *)FromVarList(&AC.SetElementList);
1976 if ( set->type == CSYMBOL ) *e = x + 2*MAXPOWER;
1981 MesPrint(
"&Illegal object in list of set elements");
1997 int type, error = 0;
1998 UBYTE *name, c, *ss;
2000 WORD numberofset, dim = MAXPOSITIVE;
2002 if ( ( s = SkipAName(s) ) == 0 ) {
2003 IllForm:MesPrint(
"&Illegal name for set");
2007 if ( TestName(name) )
goto IllForm;
2008 if ( ( ( type = GetName(AC.exprnames,name,&numberofset,NOAUTO) ) != NAMENOTFOUND )
2009 || ( ( type = GetName(AC.varnames,name,&numberofset,NOAUTO) ) != NAMENOTFOUND ) ) {
2010 if ( type != CSET ) NameConflict(type,name);
2012 MesPrint(
"&There is already a set with the name %s",name);
2017 numberofset = AddSet(name,0);
2018 set = Sets + numberofset;
2024 if ( ( *s ==
'd' || *s ==
'D' ) && s[1] ==
'=' ) {
2026 if ( *s ==
'-' || *s ==
'+' || FG.cTable[*s] == 1 ) {
2027 ParseSignedNumber(dim,s)
2028 if ( dim < -HALFMAX || dim > HALFMAX ) {
2029 MesPrint(
"&Warning: dimension of %s (%d) out of range" 2033 if ( *s !=
'}' )
goto IllDim;
2037 IllDim: MesPrint(
"&Error: Illegal dimension field for set %s",name);
2041 while ( *s ==
',' ) s++;
2044 numberofset = AddSet(name,dim);
2046 set = Sets + numberofset;
2048 MesPrint(
"&Proper syntax is `Set name:elements'");
2052 error = DoElements(s,
set,name);
2053 AC.SetList.numtemp = AC.SetList.num;
2054 AC.SetElementList.numtemp = AC.SetElementList.num;
2068 int DoTempSet(UBYTE *from, UBYTE *to)
2073 int setnum = AddSet(0,MAXPOSITIVE);
2074 SETS set = Sets + setnum, setp;
2079 while ( *from ==
',' ) from++;
2080 if ( *from ==
'<' || *from ==
'>' ) {
2082 set->first = 3*MAXPOWER;
2083 set->last = -3*MAXPOWER;
2084 while ( *from ==
'<' || *from ==
'>' ) {
2085 if ( *from ==
'<' ) {
2087 if ( *from ==
'=' ) { from++; j++; }
2091 if ( *from ==
'=' ) { from++; j--; }
2094 while ( *from ==
'-' || *from ==
'+' ) {
2095 if ( *from ==
'-' ) sgn = -sgn;
2098 ParseNumber(num,from)
2099 if ( *from && *from != ',' ) {
2100 MesPrint(
"&Illegal number in ranged set definition");
2103 if ( sgn < 0 ) num = -num;
2104 if ( num >= MAXPOWER || num <= -MAXPOWER ) {
2105 Warning(
"Value in ranged set too big. Adjusted to infinity.");
2106 if ( num > 0 ) num = 3*MAXPOWER;
2107 else num = -3*MAXPOWER;
2109 else if ( j == 2 ) num += 2*MAXPOWER;
2110 else if ( j == -2 ) num -= 2*MAXPOWER;
2111 if ( j > 0 )
set->first = num;
2112 else set->last = num;
2113 while ( *from ==
',' ) from++;
2116 MesPrint(
"&Definition of ranged set contains illegal objects");
2120 else if ( DoElements(from,
set,(UBYTE *)0) != 0 ) {
2121 AC.SetElementList.num =
set->first;
2122 AC.SetList.num--; *to = c;
2129 num =
set->last -
set->first;
2130 for ( setp = Sets, i = 0; i < AC.SetList.num-1; i++, setp++ ) {
2131 if ( num != setp->last - setp->first )
continue;
2132 if ( set->type != setp->type )
continue;
2133 if ( set->type == CRANGE ) {
2134 if ( set->first == setp->first )
return(setp-Sets);
2137 e = SetElements +
set->first;
2138 ep = SetElements + setp->first;
2140 while ( --j >= 0 )
if ( *e++ != *ep++ )
break;
2142 AC.SetElementList.num =
set->first;
2144 return(setp - Sets);
2160 int CoAuto(UBYTE *inp)
2164 AC.Symbols = &(AC.AutoSymbolList);
2165 AC.Vectors = &(AC.AutoVectorList);
2166 AC.Indices = &(AC.AutoIndexList);
2167 AC.Functions = &(AC.AutoFunctionList);
2168 AC.activenames = &(AC.autonames);
2169 AC.AutoDeclareFlag = WITHAUTO;
2171 while ( *inp ==
',' ) inp++;
2172 retval = CompileStatement(inp);
2174 AC.AutoDeclareFlag = 0;
2175 AC.Symbols = &(AC.SymbolList);
2176 AC.Vectors = &(AC.VectorList);
2177 AC.Indices = &(AC.IndexList);
2178 AC.Functions = &(AC.FunctionList);
2179 AC.activenames = &(AC.varnames);
2190 int AddDollar(UBYTE *name, WORD type, WORD *start, LONG size)
2192 int nodenum, numdollar = AP.DollarList.num;
2195 dol->name = AddName(AC.dollarnames,name,CDOLLAR,numdollar,&nodenum);
2197 dol->node = nodenum;
2199 dol->numdummies = 0;
2201 dol->pthreadslockread = dummylock;
2202 dol->pthreadslockwrite = dummylock;
2206 AddRHS(AM.dbufnum,1);
2208 if ( start && size > 0 ) {
2211 s = (WORD *)Malloc1((size+1)*
sizeof(WORD),
"$-variable contents");
2213 while ( --size >= 0 ) *s++ = *t++;
2216 else { dol->where = &(AM.dollarzero); dol->size = 0; }
2217 cbuf[AM.dbufnum].rhs[numdollar] = dol->where;
2218 cbuf[AM.dbufnum].CanCommu[numdollar] = 0;
2219 cbuf[AM.dbufnum].NumTerms[numdollar] = 0;
2234 int ReplaceDollar(WORD number, WORD newtype, WORD *newstart, LONG newsize)
2237 DOLLARS dol = Dollars + number;
2240 dol->type = newtype;
2241 if ( dol->size == newsize && newsize > 0 && newstart ) {
2242 s = dol->where; t = newstart; i = newsize;
2243 while ( --i >= 0 ) {
if ( *s++ != *t++ )
break; }
2244 if ( i < 0 )
return(0);
2246 if ( dol->where && dol->where != &(dol->zero) ) {
2247 M_free(dol->where,
"dollar->where"); dol->where = &(dol->zero); dol->size = 0;
2249 if ( newstart && newsize > 0 ) {
2250 dol->size = newsize;
2252 s = (WORD *)Malloc1((newsize+1)*
sizeof(WORD),
"$-variable contents");
2253 t = newstart; i = newsize;
2254 while ( --i >= 0 ) *s++ = *t++;
2267 int AddDubious(UBYTE *name)
2269 int nodenum, numdubious = AC.DubiousList.num;
2271 dub->name = AddName(AC.varnames,name,CDUBIOUS,numdubious,&nodenum);
2272 dub->node = nodenum;
2281 int MakeDubious(
NAMETREE *nametree, UBYTE *name, WORD *number)
2284 int node, newnode, i;
2285 if ( nametree->
namenode == 0 )
return(-1);
2292 else if ( i > 0 ) newnode = n->
right;
2294 if ( n->
type != CDUBIOUS ) {
2295 int numdubious = AC.DubiousList.num;
2303 }
while ( newnode >= 0 );
2312 static char *nametype[] = {
"symbol",
"index",
"vector",
"function",
2313 "set",
"expression" };
2314 static char *plural[] = {
"",
"n",
"",
"",
"",
"n" };
2316 int NameConflict(
int type, UBYTE *name)
2318 if ( type == NAMENOTFOUND ) {
2319 MesPrint(
"&%s has not been declared",name);
2321 else if ( type != CDUBIOUS )
2322 MesPrint(
"&%s has been declared as a%s %s already" 2323 ,name,plural[type],nametype[type]);
2332 int AddExpression(UBYTE *name,
int x,
int y)
2334 int nodenum, numexpr = AC.ExpressionList.num;
2338 expr->printflag = y;
2339 PUTZERO(expr->onfile);
2342 expr->hidelevel = 0;
2344 expr->bracketinfo = expr->newbracketinfo = 0;
2346 expr->name = AddName(AC.exprnames,name,CEXPRESSION,numexpr,&nodenum);
2347 expr->node = nodenum;
2348 expr->replace = NEWLYDEFINEDEXPRESSION ;
2351 expr->namesize = (s-name)+1;
2354 expr->replace = REDEFINEDEXPRESSION;
2355 expr->name = AC.TransEname;
2360 expr->numdummies = 0;
2361 expr->numfactors = 0;
2373 int GetLabel(UBYTE *name)
2377 UBYTE **NewLabelNames;
2379 for ( i = 0; i < AC.NumLabels; i++ ) {
2380 if ( StrCmp(name,AC.LabelNames[i]) == 0 )
return(i);
2382 if ( AC.NumLabels >= AC.MaxLabels ) {
2383 newnum = 2*AC.MaxLabels;
2384 if ( newnum == 0 ) newnum = 10;
2385 if ( newnum > 32765 ) newnum = 32765;
2386 if ( newnum == AC.MaxLabels ) {
2387 MesPrint(
"&More than 32765 labels in one module. Please simplify.");
2390 NewLabelNames = (UBYTE **)Malloc1((
sizeof(UBYTE *)+
sizeof(
int))
2392 NewLabel = (
int *)(NewLabelNames+newnum);
2393 for ( i = 0; i< AC.MaxLabels; i++ ) {
2394 NewLabelNames[i] = AC.LabelNames[i];
2395 NewLabel[i] = AC.Labels[i];
2397 if ( AC.LabelNames ) M_free(AC.LabelNames,
"Labels");
2398 AC.LabelNames = NewLabelNames;
2399 AC.Labels = NewLabel;
2400 AC.MaxLabels = newnum;
2403 AC.LabelNames[i] = strDup1(name,
"Labels");
2418 void ResetVariables(
int par)
2424 AC.SetList.num = AC.SetList.numtemp;
2425 AC.SetElementList.num = AC.SetElementList.numtemp;
2428 for ( i = AC.SymbolList.numclear; i < AC.SymbolList.num; i++ )
2429 AC.varnames->namenode[symbols[i].node].type = CDELETE;
2430 AC.SymbolList.num = AC.SymbolList.numglobal = AC.SymbolList.numclear;
2431 for ( i = AC.VectorList.numclear; i < AC.VectorList.num; i++ )
2432 AC.varnames->namenode[vectors[i].node].type = CDELETE;
2433 AC.VectorList.num = AC.VectorList.numglobal = AC.VectorList.numclear;
2434 for ( i = AC.IndexList.numclear; i < AC.IndexList.num; i++ )
2435 AC.varnames->namenode[indices[i].node].type = CDELETE;
2436 AC.IndexList.num = AC.IndexList.numglobal = AC.IndexList.numclear;
2437 for ( i = AC.FunctionList.numclear; i < AC.FunctionList.num; i++ ) {
2438 AC.varnames->namenode[functions[i].node].type = CDELETE;
2439 if ( ( T = functions[i].tabl ) != 0 ) {
2442 if ( T->
mm ) M_free(T->
mm,
"tableminmax");
2443 if ( T->
flags ) M_free(T->
flags,
"tableflags");
2455 if ( TT->
mm ) M_free(TT->
mm,
"tableminmax");
2456 if ( TT->
flags ) M_free(TT->
flags,
"tableflags");
2470 AC.FunctionList.num = AC.FunctionList.numglobal = AC.FunctionList.numclear;
2471 for ( i = AC.SetList.numclear; i < AC.SetList.num; i++ ) {
2472 if ( Sets[i].node >= 0 )
2473 AC.varnames->namenode[Sets[i].node].type = CDELETE;
2475 AC.SetList.numtemp = AC.SetList.num = AC.SetList.numglobal = AC.SetList.numclear;
2476 for ( i = AC.DubiousList.numclear; i < AC.DubiousList.num; i++ )
2477 AC.varnames->namenode[Dubious[i].node].type = CDELETE;
2478 AC.DubiousList.num = AC.DubiousList.numglobal = AC.DubiousList.numclear;
2479 AC.SetElementList.numtemp = AC.SetElementList.num =
2480 AC.SetElementList.numglobal = AC.SetElementList.numclear;
2481 CompactifyTree(AC.varnames,VARNAMES);
2482 AC.varnames->namefill = AC.varnames->globalnamefill = AC.varnames->clearnamefill;
2483 AC.varnames->nodefill = AC.varnames->globalnodefill = AC.varnames->clearnodefill;
2485 for ( i = AC.AutoSymbolList.numclear; i < AC.AutoSymbolList.num; i++ )
2486 AC.autonames->namenode[
2487 ((
SYMBOLS)(AC.AutoSymbolList.lijst))[i].node].type = CDELETE;
2488 AC.AutoSymbolList.num = AC.AutoSymbolList.numglobal
2489 = AC.AutoSymbolList.numclear;
2490 for ( i = AC.AutoVectorList.numclear; i < AC.AutoVectorList.num; i++ )
2491 AC.autonames->namenode[
2492 ((
VECTORS)(AC.AutoVectorList.lijst))[i].node].type = CDELETE;
2493 AC.AutoVectorList.num = AC.AutoVectorList.numglobal
2494 = AC.AutoVectorList.numclear;
2495 for ( i = AC.AutoIndexList.numclear; i < AC.AutoIndexList.num; i++ )
2496 AC.autonames->namenode[
2497 ((
INDICES)(AC.AutoIndexList.lijst))[i].node].type = CDELETE;
2498 AC.AutoIndexList.num = AC.AutoIndexList.numglobal
2499 = AC.AutoIndexList.numclear;
2500 for ( i = AC.AutoFunctionList.numclear; i < AC.AutoFunctionList.num; i++ ) {
2501 AC.autonames->namenode[
2502 ((
FUNCTIONS)(AC.AutoFunctionList.lijst))[i].node].type = CDELETE;
2503 if ( ( T = ((
FUNCTIONS)(AC.AutoFunctionList.lijst))[i].tabl ) != 0 ) {
2506 if ( T->
mm ) M_free(T->
mm,
"tableminmax");
2507 if ( T->
flags ) M_free(T->
flags,
"tableflags");
2515 if ( TT->
mm ) M_free(TT->
mm,
"tableminmax");
2516 if ( TT->
flags ) M_free(TT->
flags,
"tableflags");
2527 AC.AutoFunctionList.num = AC.AutoFunctionList.numglobal
2528 = AC.AutoFunctionList.numclear;
2529 CompactifyTree(AC.autonames,AUTONAMES);
2530 AC.autonames->namefill = AC.autonames->globalnamefill
2531 = AC.autonames->clearnamefill;
2532 AC.autonames->nodefill = AC.autonames->globalnodefill
2533 = AC.autonames->clearnodefill;
2537 for ( i = AC.SymbolList.numglobal; i < AC.SymbolList.num; i++ )
2538 AC.varnames->namenode[symbols[i].node].type = CDELETE;
2539 AC.SymbolList.num = AC.SymbolList.numglobal;
2540 for ( i = AC.VectorList.numglobal; i < AC.VectorList.num; i++ )
2541 AC.varnames->namenode[vectors[i].node].type = CDELETE;
2542 AC.VectorList.num = AC.VectorList.numglobal;
2543 for ( i = AC.IndexList.numglobal; i < AC.IndexList.num; i++ )
2544 AC.varnames->namenode[indices[i].node].type = CDELETE;
2545 AC.IndexList.num = AC.IndexList.numglobal;
2546 for ( i = AC.FunctionList.numglobal; i < AC.FunctionList.num; i++ ) {
2547 AC.varnames->namenode[functions[i].node].type = CDELETE;
2548 if ( ( T = functions[i].tabl ) != 0 ) {
2551 if ( T->
mm ) M_free(T->
mm,
"tableminmax");
2552 if ( T->
flags ) M_free(T->
flags,
"tableflags");
2564 if ( TT->
mm ) M_free(TT->
mm,
"tableminmax");
2565 if ( TT->
flags ) M_free(TT->
flags,
"tableflags");
2583 for ( i = 0; i < AC.FunctionList.numglobal; i++ ) {
2590 if ( ( T = functions[i].tabl ) != 0 ) {
2598 #if TABLEEXTENSION == 2 2605 tp += TABLEEXTENSION;
2607 RedoTableTree(T,T->
totind);
2611 for ( j = 0, tp = TT->
tablepointers; j < TT->totind; j++ ) {
2613 #if TABLEEXTENSION == 2 2620 tp += TABLEEXTENSION;
2622 RedoTableTree(TT,TT->
totind);
2629 #if TABLEEXTENSION == 2 2645 AC.FunctionList.num = AC.FunctionList.numglobal;
2646 for ( i = AC.SetList.numglobal; i < AC.SetList.num; i++ ) {
2647 if ( Sets[i].node >= 0 )
2648 AC.varnames->namenode[Sets[i].node].type = CDELETE;
2650 AC.SetList.numtemp = AC.SetList.num = AC.SetList.numglobal;
2651 for ( i = AC.DubiousList.numglobal; i < AC.DubiousList.num; i++ )
2652 AC.varnames->namenode[Dubious[i].node].type = CDELETE;
2653 AC.DubiousList.num = AC.DubiousList.numglobal;
2654 AC.SetElementList.numtemp = AC.SetElementList.num =
2655 AC.SetElementList.numglobal;
2656 CompactifyTree(AC.varnames,VARNAMES);
2657 AC.varnames->namefill = AC.varnames->globalnamefill;
2658 AC.varnames->nodefill = AC.varnames->globalnodefill;
2660 for ( i = AC.AutoSymbolList.numglobal; i < AC.AutoSymbolList.num; i++ )
2661 AC.autonames->namenode[
2662 ((
SYMBOLS)(AC.AutoSymbolList.lijst))[i].node].type = CDELETE;
2663 AC.AutoSymbolList.num = AC.AutoSymbolList.numglobal;
2664 for ( i = AC.AutoVectorList.numglobal; i < AC.AutoVectorList.num; i++ )
2665 AC.autonames->namenode[
2666 ((
VECTORS)(AC.AutoVectorList.lijst))[i].node].type = CDELETE;
2667 AC.AutoVectorList.num = AC.AutoVectorList.numglobal;
2668 for ( i = AC.AutoIndexList.numglobal; i < AC.AutoIndexList.num; i++ )
2669 AC.autonames->namenode[
2670 ((
INDICES)(AC.AutoIndexList.lijst))[i].node].type = CDELETE;
2671 AC.AutoIndexList.num = AC.AutoIndexList.numglobal;
2672 for ( i = AC.AutoFunctionList.numglobal; i < AC.AutoFunctionList.num; i++ ) {
2673 AC.autonames->namenode[
2674 ((
FUNCTIONS)(AC.AutoFunctionList.lijst))[i].node].type = CDELETE;
2675 if ( ( T = ((
FUNCTIONS)(AC.AutoFunctionList.lijst))[i].tabl ) != 0 ) {
2678 if ( T->
mm ) M_free(T->
mm,
"tableminmax");
2679 if ( T->
flags ) M_free(T->
flags,
"tableflags");
2687 if ( TT->
mm ) M_free(TT->
mm,
"tableminmax");
2688 if ( TT->
flags ) M_free(TT->
flags,
"tableflags");
2699 AC.AutoFunctionList.num = AC.AutoFunctionList.numglobal;
2701 CompactifyTree(AC.autonames,AUTONAMES);
2703 AC.autonames->namefill = AC.autonames->globalnamefill;
2704 AC.autonames->nodefill = AC.autonames->globalnodefill;
2714 void RemoveDollars()
2717 CBUF *C = cbuf + AM.dbufnum;
2718 int numdollar = AP.DollarList.num;
2719 if ( numdollar > 0 ) {
2720 while ( numdollar > AM.gcNumDollars ) {
2722 d = Dollars + numdollar;
2723 if ( d->where && d->where != &(d->zero) && d->where != &(AM.dollarzero) ) {
2724 M_free(d->where,
"dollar->where"); d->where = &(d->zero); d->size = 0;
2726 AC.dollarnames->namenode[d->node].type = CDELETE;
2728 AP.DollarList.num = AM.gcNumDollars;
2729 CompactifyTree(AC.dollarnames,DOLLARNAMES);
2731 C->numrhs = C->mnumrhs;
2732 C->numlhs = C->mnumlhs;
2741 void Globalize(
int par)
2746 AC.SymbolList.numclear = AC.SymbolList.num;
2747 AC.VectorList.numclear = AC.VectorList.num;
2748 AC.IndexList.numclear = AC.IndexList.num;
2749 AC.FunctionList.numclear = AC.FunctionList.num;
2750 AC.SetList.numclear = AC.SetList.num;
2751 AC.DubiousList.numclear = AC.DubiousList.num;
2752 AC.SetElementList.numclear = AC.SetElementList.num;
2753 AC.varnames->clearnamefill = AC.varnames->namefill;
2754 AC.varnames->clearnodefill = AC.varnames->nodefill;
2756 AC.AutoSymbolList.numclear = AC.AutoSymbolList.num;
2757 AC.AutoVectorList.numclear = AC.AutoVectorList.num;
2758 AC.AutoIndexList.numclear = AC.AutoIndexList.num;
2759 AC.AutoFunctionList.numclear = AC.AutoFunctionList.num;
2760 AC.autonames->clearnamefill = AC.autonames->namefill;
2761 AC.autonames->clearnodefill = AC.autonames->nodefill;
2764 for ( i = MAXBUILTINFUNCTION-FUNCTION; i < AC.FunctionList.num; i++ ) {
2769 if ( functions[i].tabl ) {
2770 TABLES T = functions[i].tabl;
2775 #if TABLEEXTENSION == 2 2778 tp[2] = tp[0]; tp[3] = tp[1]; tp[5] = tp[4] & (~ELEMENTUSED);
2780 tp += TABLEEXTENSION;
2785 for ( j = 0, tp = TT->
tablepointers; j < TT->totind; j++ ) {
2787 #if TABLEEXTENSION == 2 2790 tp[2] = tp[0]; tp[3] = tp[1]; tp[5] = tp[4] & (~ELEMENTUSED);
2792 tp += TABLEEXTENSION;
2801 #if TABLEEXTENSION == 2 2804 tp[2] = tp[0]; tp[3] = tp[1]; tp[5] = tp[4] & (~ELEMENTUSED);
2812 for ( i = AC.AutoFunctionList.numglobal; i < AC.AutoFunctionList.num; i++ ) {
2813 if ( ((
FUNCTIONS)(AC.AutoFunctionList.lijst))[i].tabl )
2814 ((
FUNCTIONS)(AC.AutoFunctionList.lijst))[i].tabl->mdefined =
2815 ((
FUNCTIONS)(AC.AutoFunctionList.lijst))[i].tabl->defined;
2817 AC.SymbolList.numglobal = AC.SymbolList.num;
2818 AC.VectorList.numglobal = AC.VectorList.num;
2819 AC.IndexList.numglobal = AC.IndexList.num;
2820 AC.FunctionList.numglobal = AC.FunctionList.num;
2821 AC.SetList.numglobal = AC.SetList.num;
2822 AC.DubiousList.numglobal = AC.DubiousList.num;
2823 AC.SetElementList.numglobal = AC.SetElementList.num;
2824 AC.varnames->globalnamefill = AC.varnames->namefill;
2825 AC.varnames->globalnodefill = AC.varnames->nodefill;
2827 AC.AutoSymbolList.numglobal = AC.AutoSymbolList.num;
2828 AC.AutoVectorList.numglobal = AC.AutoVectorList.num;
2829 AC.AutoIndexList.numglobal = AC.AutoIndexList.num;
2830 AC.AutoFunctionList.numglobal = AC.AutoFunctionList.num;
2831 AC.autonames->globalnamefill = AC.autonames->namefill;
2832 AC.autonames->globalnodefill = AC.autonames->nodefill;
2840 int TestName(UBYTE *name)
2842 if ( *name ==
'[' ) {
2843 while ( *name ) name++;
2844 if ( name[-1] ==
']' )
return(0);
2848 if ( *name ==
'_' )
return(-1);
void AddPotModdollar(WORD)
WORD SortWild(WORD *, WORD)
struct FuNcTiOn * FUNCTIONS