47int CleanExpr(WORD par)
57 e_in = e_out = Expressions;
59 e_in->vflags &= ~( TOBEFACTORED | TOBEUNFACTORED );
67 M_free(e_in->renum,
"Renumber"); e_in->renum = 0;
70 if ( e_in->status == HIDDENLEXPRESSION
71 || e_in->status == HIDDENGEXPRESSION ) numhid++;
72 switch ( e_in->status ) {
73 case SPECTATOREXPRESSION:
75 case HIDDENLEXPRESSION:
77 AC.exprnames->namenode[e_in->node].type = CDELETE;
79 if ( e_in->status != HIDDENLEXPRESSION )
80 ClearBracketIndex(e_in-Expressions);
84 case GLOBALEXPRESSION:
85 case HIDDENGEXPRESSION:
91 if (
PF_BroadcastExpr(e_in, e_in->status == HIDDENGEXPRESSION ? AR.hidefile : AR.outfile) ) return -1;
92 if ( PF.me == MASTER ) {
98 if ( e_in->status == HIDDENGEXPRESSION ) {
99 if ( e->status == HIDDENGEXPRESSION
100 || e->status == HIDDENLEXPRESSION )
break;
103 if ( e->status == GLOBALEXPRESSION
104 || e->status == LOCALEXPRESSION )
break;
118 DIFPOS(length,e->onfile,e_in->onfile);
121 FILEHANDLE *f = e_in->status == HIDDENGEXPRESSION ? AR.hidefile : AR.outfile;
123 SETBASELENGTH(length,TOLONG(f->POfull)
124 - TOLONG(f->PObuffer)
125 - BASEPOSITION(e_in->onfile));
128 SeekFile(f->
handle,&(f->filesize),SEEK_SET);
129 DIFPOS(length,f->filesize,e_in->onfile);
132 if ( ToStorage(e_in,&length) ) {
133 return(MesCall(
"CleanExpr"));
135 e_in->status = STOREDEXPRESSION;
136 if ( e_in->status != HIDDENGEXPRESSION )
137 ClearBracketIndex(e_in-Expressions);
140 case SKIPLEXPRESSION:
141 case DROPLEXPRESSION:
142 case DROPHLEXPRESSION:
143 case DROPGEXPRESSION:
144 case DROPHGEXPRESSION:
145 case STOREDEXPRESSION:
146 case DROPSPECTATOREXPRESSION:
147 if ( e_out != e_in ) {
148 node = AC.exprnames->namenode + e_in->node;
149 node->number = e_out - Expressions;
151 e_out->onfile = e_in->onfile;
152 e_out->size = e_in->size;
153 e_out->printflag = 0;
154 if ( par ) e_out->status = STOREDEXPRESSION;
155 else e_out->status = e_in->status;
156 e_out->name = e_in->name;
157 e_out->node = e_in->node;
158 e_out->renum = e_in->renum;
160 e_out->counter = e_in->counter;
161 e_out->hidelevel = e_in->hidelevel;
162 e_out->inmem = e_in->inmem;
163 e_out->bracketinfo = e_in->bracketinfo;
164 e_out->newbracketinfo = e_in->newbracketinfo;
165 e_out->numdummies = e_in->numdummies;
166 e_out->numfactors = e_in->numfactors;
167 e_out->vflags = e_in->vflags;
168 e_out->uflags = e_in->uflags;
169 e_out->sizeprototype = e_in->sizeprototype;
177 case DROPPEDEXPRESSION:
180 AC.exprnames->namenode[e_in->node].type = CDELETE;
185 }
while ( --n > 0 ); }
188 if ( numhid == 0 && AR.hidefile->PObuffer ) {
189 if ( AR.hidefile->handle >= 0 ) {
190 CloseFile(AR.hidefile->handle);
191 remove(AR.hidefile->name);
192 AR.hidefile->handle = -1;
194 AR.hidefile->POfull =
195 AR.hidefile->POfill = AR.hidefile->PObuffer;
196 PUTZERO(AR.hidefile->POposition);
211int PopVariables(
void)
218 retval = CleanExpr(1);
221 if ( AC.DidClean ) CompactifyTree(AC.exprnames,EXPRNAMES);
223 AC.CodesFlag = AM.gCodesFlag;
224 AC.NamesFlag = AM.gNamesFlag;
225 AC.StatsFlag = AM.gStatsFlag;
227 AC.MaxWeight = AM.gMaxWeight;
228 AC.DefaultPrecision = AM.gDefaultPrecision;
230 AC.OldFactArgFlag = AM.gOldFactArgFlag;
231 AC.TokensWriteFlag = AM.gTokensWriteFlag;
232 AC.extrasymbols = AM.gextrasymbols;
233 if ( AC.extrasym ) { M_free(AC.extrasym,
"extrasym"); AC.extrasym = 0; }
234 i = 1; s = AM.gextrasym;
while ( *s ) { s++; i++; }
235 AC.extrasym = (UBYTE *)Malloc1(i*
sizeof(UBYTE),
"extrasym");
236 for ( j = 0; j < i; j++ ) AC.extrasym[j] = AM.gextrasym[j];
237 AO.NoSpacesInNumbers = AM.gNoSpacesInNumbers;
238 AO.IndentSpace = AM.gIndentSpace;
239 AC.lUnitTrace = AM.gUnitTrace;
240 AC.lDefDim = AM.gDefDim;
241 AC.lDefDim4 = AM.gDefDim4;
243 if ( AC.ncmod == AM.gncmod && AC.modmode == AM.gmodmode ) {
246 if ( AC.cmod[j] != AM.gcmod[j] )
break;
249 M_free(AC.halfmod,
"halfmod");
250 AC.halfmod = 0; AC.nhalfmod = 0;
254 M_free(AC.halfmod,
"halfmod");
255 AC.halfmod = 0; AC.nhalfmod = 0;
258 if ( AC.modinverses ) {
259 if ( AC.ncmod == AM.gncmod && AC.modmode == AM.gmodmode ) {
262 if ( AC.cmod[j] != AM.gcmod[j] )
break;
265 M_free(AC.modinverses,
"modinverses");
270 M_free(AC.modinverses,
"modinverses");
274 AN.ncmod = AC.ncmod = AM.gncmod;
275 AC.npowmod = AM.gnpowmod;
276 AC.modmode = AM.gmodmode;
277 if ( ( ( AC.modmode & INVERSETABLE ) != 0 ) && ( AC.modinverses == 0 ) )
279 AC.funpowers = AM.gfunpowers;
280 AC.lPolyFun = AM.gPolyFun;
281 AC.lPolyFunInv = AM.gPolyFunInv;
282 AC.lPolyFunType = AM.gPolyFunType;
283 AC.lPolyFunExp = AM.gPolyFunExp;
284 AR.PolyFunVar = AC.lPolyFunVar = AM.gPolyFunVar;
285 AC.lPolyFunPow = AM.gPolyFunPow;
286 AC.parallelflag = AM.gparallelflag;
287 AC.ProcessBucketSize = AC.mProcessBucketSize = AM.gProcessBucketSize;
288 AC.properorderflag = AM.gproperorderflag;
289 AC.ThreadBucketSize = AM.gThreadBucketSize;
290 AC.ThreadStats = AM.gThreadStats;
291 AC.FinalStats = AM.gFinalStats;
292 AC.OldGCDflag = AM.gOldGCDflag;
293 AC.WTimeStatsFlag = AM.gWTimeStatsFlag;
294 AC.ThreadsFlag = AM.gThreadsFlag;
295 AC.ThreadBalancing = AM.gThreadBalancing;
296 AC.ThreadSortFileSynch = AM.gThreadSortFileSynch;
297 AC.ProcessStats = AM.gProcessStats;
298 AC.OldParallelStats = AM.gOldParallelStats;
299 AC.IsFortran90 = AM.gIsFortran90;
300 AC.SizeCommuteInSet = AM.gSizeCommuteInSet;
301 PruneExtraSymbols(AM.gnumextrasym);
303 if ( AC.Fortran90Kind ) {
304 M_free(AC.Fortran90Kind,
"Fortran90 Kind");
305 AC.Fortran90Kind = 0;
307 if ( AM.gFortran90Kind ) {
308 AC.Fortran90Kind = strDup1(AM.gFortran90Kind,
"Fortran90 Kind");
310 if ( AC.ThreadsFlag && AM.totalnumberofthreads > 1 ) AS.MultiThreaded = 1;
322 if ( MakeModTable() ) {
323 MesPrint(
"===No printing in powers of generator");
335 AC.Cnumpows = AM.gCnumpows;
336 AC.OutputMode = AM.gOutputMode;
337 AC.OutputSpaces = AM.gOutputSpaces;
338 AC.OutNumberType = AM.gOutNumberType;
339 AR.SortType = AC.SortType = AM.gSortType;
340 AC.ShortStatsMax = AM.gShortStatsMax;
344 for ( i = 0; i < NumFunctions; i++ ) functions[i].flags &= ~COULDCOMMUTE;
345 if ( AC.CommuteInSet ) {
351 if ( *gg <= GAMMASEVEN && *gg >= GAMMA ) {
352 functions[GAMMA-FUNCTION].flags |= COULDCOMMUTE;
353 functions[GAMMAI-FUNCTION].flags |= COULDCOMMUTE;
354 functions[GAMMAFIVE-FUNCTION].flags |= COULDCOMMUTE;
355 functions[GAMMASIX-FUNCTION].flags |= COULDCOMMUTE;
356 functions[GAMMASEVEN-FUNCTION].flags |= COULDCOMMUTE;
359 functions[*gg-FUNCTION].flags |= COULDCOMMUTE;
367 for ( i = AO.NumDictionaries-1; i >= AO.gNumDictionaries; i-- ) {
368 RemoveDictionary(AO.Dictionaries[i]);
369 M_free(AO.Dictionaries[i],
"Dictionary");
371 for( ; i >= 0; i-- ) {
372 ShrinkDictionary(AO.Dictionaries[i]);
374 AO.NumDictionaries = AO.gNumDictionaries;
390 AM.gCodesFlag = AC.CodesFlag;
391 AM.gNamesFlag = AC.NamesFlag;
392 AM.gStatsFlag = AC.StatsFlag;
394 AM.gMaxWeight = AC.MaxWeight;
395 AM.gDefaultPrecision = AC.DefaultPrecision;
397 AM.gOldFactArgFlag = AC.OldFactArgFlag;
398 AM.gextrasymbols = AC.extrasymbols;
399 if ( AM.gextrasym ) { M_free(AM.gextrasym,
"extrasym"); AM.gextrasym = 0; }
400 i = 1; s = AC.extrasym;
while ( *s ) { s++; i++; }
401 AM.gextrasym = (UBYTE *)Malloc1(i*
sizeof(UBYTE),
"extrasym");
402 for ( j = 0; j < i; j++ ) AM.gextrasym[j] = AC.extrasym[j];
403 AM.gTokensWriteFlag= AC.TokensWriteFlag;
404 AM.gNoSpacesInNumbers = AO.NoSpacesInNumbers;
405 AM.gIndentSpace = AO.IndentSpace;
406 AM.gUnitTrace = AC.lUnitTrace;
407 AM.gDefDim = AC.lDefDim;
408 AM.gDefDim4 = AC.lDefDim4;
409 AM.gncmod = AC.ncmod;
410 AM.gnpowmod = AC.npowmod;
411 AM.gmodmode = AC.modmode;
412 AM.gCnumpows = AC.Cnumpows;
413 AM.gOutputMode = AC.OutputMode;
414 AM.gOutputSpaces = AC.OutputSpaces;
415 AM.gOutNumberType = AC.OutNumberType;
416 AM.gfunpowers = AC.funpowers;
417 AM.gPolyFun = AC.lPolyFun;
418 AM.gPolyFunInv = AC.lPolyFunInv;
419 AM.gPolyFunType = AC.lPolyFunType;
420 AM.gPolyFunExp = AC.lPolyFunExp;
421 AM.gPolyFunVar = AC.lPolyFunVar;
422 AM.gPolyFunPow = AC.lPolyFunPow;
423 AM.gparallelflag = AC.parallelflag;
424 AM.gProcessBucketSize = AC.ProcessBucketSize;
425 AM.gproperorderflag = AC.properorderflag;
426 AM.gThreadBucketSize = AC.ThreadBucketSize;
427 AM.gThreadStats = AC.ThreadStats;
428 AM.gFinalStats = AC.FinalStats;
429 AM.gOldGCDflag = AC.OldGCDflag;
430 AM.gWTimeStatsFlag = AC.WTimeStatsFlag;
431 AM.gThreadsFlag = AC.ThreadsFlag;
432 AM.gThreadBalancing = AC.ThreadBalancing;
433 AM.gThreadSortFileSynch = AC.ThreadSortFileSynch;
434 AM.gProcessStats = AC.ProcessStats;
435 AM.gOldParallelStats = AC.OldParallelStats;
436 AM.gIsFortran90 = AC.IsFortran90;
437 AM.gSizeCommuteInSet = AC.SizeCommuteInSet;
438 AM.gnumextrasym = (cbuf+AM.sbufnum)->numrhs;
439 if ( AM.gFortran90Kind ) {
440 M_free(AM.gFortran90Kind,
"Fortran 90 Kind");
441 AM.gFortran90Kind = 0;
443 if ( AC.Fortran90Kind ) {
444 AM.gFortran90Kind = strDup1(AC.Fortran90Kind,
"Fortran 90 Kind");
458 AM.gSortType = AC.SortType;
459 AM.gShortStatsMax = AC.ShortStatsMax;
461 if ( AO.CurrentDictionary > 0 || AP.OpenDictionary > 0 ) {
462 Warning(
"You cannot have an open or selected dictionary at a .global. Dictionary closed.");
463 AP.OpenDictionary = 0;
464 AO.CurrentDictionary = 0;
467 AO.gNumDictionaries = AO.NumDictionaries;
468 for ( i = 0; i < AO.NumDictionaries; i++ ) {
469 AO.Dictionaries[i]->gnumelements = AO.Dictionaries[i]->numelements;
471 if ( AM.NumSpectatorFiles > 0 ) {
472 for ( i = 0; i < AM.SizeForSpectatorFiles; i++ ) {
473 if ( AM.SpectatorFiles[i].name != 0 )
474 AM.SpectatorFiles[i].flags |= GLOBALSPECTATORFLAG;
488 for ( j = 0, e = Expressions; j < NumExpressions; j++, e++ ) {
489 switch ( e->status ) {
490 case SKIPLEXPRESSION:
491 e->status = LOCALEXPRESSION;
493 case UNHIDELEXPRESSION:
494 e->status = LOCALEXPRESSION;
495 ClearBracketIndex(j);
496 e->bracketinfo = e->newbracketinfo; e->newbracketinfo = 0;
498 case HIDELEXPRESSION:
499 e->status = HIDDENLEXPRESSION;
501 case SKIPGEXPRESSION:
502 e->status = GLOBALEXPRESSION;
504 case UNHIDEGEXPRESSION:
505 e->status = GLOBALEXPRESSION;
506 ClearBracketIndex(j);
507 e->bracketinfo = e->newbracketinfo; e->newbracketinfo = 0;
509 case HIDEGEXPRESSION:
510 e->status = HIDDENGEXPRESSION;
512 case DROPLEXPRESSION:
513 case DROPGEXPRESSION:
514 case DROPHLEXPRESSION:
515 case DROPHGEXPRESSION:
516 case DROPSPECTATOREXPRESSION:
517 e->status = DROPPEDEXPRESSION;
518 ClearBracketIndex(j);
519 e->bracketinfo = e->newbracketinfo; e->newbracketinfo = 0;
520 if ( e->replace >= 0 ) {
521 Expressions[e->replace].replace = REGULAREXPRESSION;
522 AC.exprnames->namenode[e->node].number = e->replace;
523 e->replace = REGULAREXPRESSION;
526 AC.exprnames->namenode[e->node].type = CDELETE;
530 case LOCALEXPRESSION:
531 case GLOBALEXPRESSION:
532 ClearBracketIndex(j);
533 e->bracketinfo = e->newbracketinfo; e->newbracketinfo = 0;
535 case HIDDENLEXPRESSION:
536 case HIDDENGEXPRESSION:
538 case INTOHIDELEXPRESSION:
539 ClearBracketIndex(j);
540 e->bracketinfo = e->newbracketinfo; e->newbracketinfo = 0;
541 e->status = HIDDENLEXPRESSION;
543 case INTOHIDEGEXPRESSION:
544 ClearBracketIndex(j);
545 e->bracketinfo = e->newbracketinfo; e->newbracketinfo = 0;
546 e->status = HIDDENGEXPRESSION;
549 ClearBracketIndex(j);
553 if ( e->replace == NEWLYDEFINEDEXPRESSION ) e->replace = REGULAREXPRESSION;
562void PutInVflags(WORD nexpr)
569 if ( AS.OldOnFile == 0 ) {
570 AS.NumOldOnFile = 20;
571 AS.OldOnFile = (
POSITION *)Malloc1(AS.NumOldOnFile*
sizeof(
POSITION),
"file pointers");
573 else if ( nexpr >= AS.NumOldOnFile ) {
575 AS.OldOnFile = (
POSITION *)Malloc1(2*AS.NumOldOnFile*
sizeof(
POSITION),
"file pointers");
576 for ( i = 0; i < AS.NumOldOnFile; i++ ) AS.OldOnFile[i] = old[i];
577 AS.NumOldOnFile = 2*AS.NumOldOnFile;
578 M_free(old,
"process file pointers");
580 if ( AS.OldNumFactors == 0 ) {
581 AS.NumOldNumFactors = 20;
582 AS.OldNumFactors = (WORD *)Malloc1(AS.NumOldNumFactors*
sizeof(WORD),
"numfactors pointers");
583 AS.Oldvflags = (WORD *)Malloc1(AS.NumOldNumFactors*
sizeof(WORD),
"vflags pointers");
584 AS.Olduflags = (WORD *)Malloc1(AS.NumOldNumFactors*
sizeof(WORD),
"uflags pointers");
586 else if ( nexpr >= AS.NumOldNumFactors ) {
587 oldw = AS.OldNumFactors;
588 AS.OldNumFactors = (WORD *)Malloc1(2*AS.NumOldNumFactors*
sizeof(WORD),
"numfactors pointers");
589 for ( i = 0; i < AS.NumOldNumFactors; i++ ) AS.OldNumFactors[i] = oldw[i];
590 M_free(oldw,
"numfactors pointers");
592 AS.Oldvflags = (WORD *)Malloc1(2*AS.NumOldNumFactors*
sizeof(WORD),
"vflags pointers");
593 for ( i = 0; i < AS.NumOldNumFactors; i++ ) AS.Oldvflags[i] = oldw[i];
594 M_free(oldw,
"vflags pointers");
596 AS.Olduflags = (WORD *)Malloc1(2*AS.NumOldNumFactors*
sizeof(WORD),
"uflags pointers");
597 for ( i = 0; i < AS.NumOldNumFactors; i++ ) AS.Olduflags[i] = oldw[i];
598 M_free(oldw,
"uflags pointers");
599 AS.NumOldNumFactors = 2*AS.NumOldNumFactors;
604 if ( nexpr >= AS.NumOldOnFile || nexpr >= AS.NumOldNumFactors )
goto restart;
605 AS.OldOnFile[nexpr] = e->onfile;
606 AS.OldNumFactors[nexpr] = e->numfactors;
607 AS.Oldvflags[nexpr] = e->vflags;
608 AS.Olduflags[nexpr] = e->uflags;
616int DoExecute(WORD par, WORD skip)
620 int i, oldmultithreaded = AS.MultiThreaded;
625 SpecialCleanup(BHEAD0);
626 if ( skip )
goto skipexec;
627 if ( AC.IfLevel > 0 ) {
628 MesPrint(
" %d endif statement(s) missing",AC.IfLevel);
631 if ( AC.WhileLevel > 0 ) {
632 MesPrint(
" %d endwhile statement(s) missing",AC.WhileLevel);
635 if ( AC.arglevel > 0 ) {
636 MesPrint(
" %d endargument statement(s) missing",AC.arglevel);
639 if ( AC.termlevel > 0 ) {
640 MesPrint(
" %d endterm statement(s) missing",AC.termlevel);
643 if ( AC.insidelevel > 0 ) {
644 MesPrint(
" %d endinside statement(s) missing",AC.insidelevel);
647 if ( AC.inexprlevel > 0 ) {
648 MesPrint(
" %d endinexpression statement(s) missing",AC.inexprlevel);
651 if ( AC.NumLabels > 0 ) {
652 for ( i = 0; i < AC.NumLabels; i++ ) {
653 if ( AC.Labels[i] < 0 ) {
654 MesPrint(
" -->Label %s missing",AC.LabelNames[i]);
659 if ( AC.SwitchLevel > 0 ) {
660 MesPrint(
" %d endswitch statement(s) missing",AC.SwitchLevel);
663 if ( AC.dolooplevel > 0 ) {
664 MesPrint(
" %d enddo statement(s) missing",AC.dolooplevel);
667 if ( AP.OpenDictionary > 0 ) {
668 MesPrint(
" Dictionary %s has not been closed.",
669 AO.Dictionaries[AP.OpenDictionary-1]->name);
670 AP.OpenDictionary = 0;
673 if ( RetCode )
return(RetCode);
674 AR.Cnumlhs = cbuf[AM.rbufnum].numlhs;
676 if ( ( AS.ExecMode = par ) == GLOBALMODULE ) AS.ExecMode = 0;
685 if ( NumPotModdollars >= 0 ) {
686 for ( i = 0; i < NumExpressions; i++ ) {
687 if ( Expressions[i].partodo ) { AC.partodoflag = 1;
break; }
691 if ( AC.partodoflag > 0 && PF.numtasks < 3 ) {
695 if ( AC.partodoflag > 0 || ( NumPotModdollars > 0 && AC.mparallelflag == PARALLELFLAG ) ) {
696 if ( NumPotModdollars > NumModOptdollars ) {
697 AC.mparallelflag |= NOPARALLEL_DOLLAR;
699 AS.MultiThreaded = 0;
704 for ( i = 0; i < NumPotModdollars; i++ ) {
705 for ( j = 0; j < NumModOptdollars; j++ )
706 if ( PotModdollars[i] == ModOptdollars[j].number )
break;
707 if ( j >= NumModOptdollars ) {
708 AC.mparallelflag |= NOPARALLEL_DOLLAR;
710 AS.MultiThreaded = 0;
715 switch ( ModOptdollars[j].type ) {
722 AC.mparallelflag |= NOPARALLEL_DOLLAR;
723 AS.MultiThreaded = 0;
730 else if ( ( AC.mparallelflag & NOPARALLEL_USER ) != 0 ) {
732 AS.MultiThreaded = 0;
736 if ( AC.partodoflag == 0 ) {
737 for ( i = 0; i < NumExpressions; i++ ) {
738 Expressions[i].partodo = 0;
741 else if ( AC.partodoflag == -1 ) {
749 if ( AC.RhsExprInModuleFlag && (AC.mparallelflag == PARALLELFLAG || AC.partodoflag) ) {
750 if (PF.rhsInParallel) {
753 PF.slavebuf.PObuffer=(WORD *)Malloc1(AM.ScratSize*
sizeof(WORD),
"PF inbuf");
754 PF.slavebuf.POsize=AM.ScratSize*
sizeof(WORD);
755 PF.slavebuf.POfull = PF.slavebuf.POfill = PF.slavebuf.PObuffer;
756 PF.slavebuf.POstop= PF.slavebuf.PObuffer+AM.ScratSize;
757 PUTZERO(PF.slavebuf.POposition);
761 AC.mparallelflag |= NOPARALLEL_RHS;
763 for ( i = 0; i < NumExpressions; i++ ) {
764 Expressions[i].partodo = 0;
771 if ( (AC.mparallelflag == PARALLELFLAG || AC.partodoflag) && PF.me != MASTER ) {
772 for ( i = 0; i < NumModOptdollars; i++ ) {
773 if ( ModOptdollars[i].type == MODSUM ) {
774 DOLLARS d = Dollars + ModOptdollars[i].number;
776 if ( d->where && d->where != &AM.dollarzero ) M_free(d->where,
"old content of dollar");
777 d->where = &AM.dollarzero;
779 CleanDollarFactors(d);
784 AR.SortType = AC.SortType;
786 if ( PF.me == MASTER )
789 if ( AC.SetupFlag ) WriteSetup();
790 if ( AC.NamesFlag || AC.CodesFlag ) WriteLists();
792 if ( par == GLOBALMODULE ) MakeGlobal();
793 if ( RevertScratch() )
return(-1);
794 if ( AC.ncmod ) SetMods();
799 if ( PF.me == MASTER )
802 if ( !AC.ThreadsFlag || AC.mparallelflag & NOPARALLEL_USER ) {
805 else if ( AC.mparallelflag & NOPARALLEL_DOLLAR ) {
806 if ( AC.WarnFlag >= 1 ) {
809 s = strDup1((UBYTE *)
"",
"NOPARALLEL_DOLLAR s");
811 j = NumPotModdollars;
812 for ( i = 0; i < j; i++ ) {
813 for ( k = 0; k < NumModOptdollars; k++ )
814 if ( ModOptdollars[k].number == PotModdollars[i] )
break;
815 if ( k >= NumModOptdollars ) {
818 s = AddToString(s,(UBYTE *)
", ",0);
819 s = AddToString(s,(UBYTE *)
"$",0);
820 s = AddToString(s,DOLLARNAME(Dollars,PotModdollars[i]),0);
824 s1 = strDup1((UBYTE *)
"This module is forced to run in sequential mode due to $-variable",
"NOPARALLEL_DOLLAR s1");
826 s1 = AddToString(s1,(UBYTE *)
"s",0);
827 s1 = AddToString(s1,(UBYTE *)
": ",0);
828 s1 = AddToString(s1,s,0);
830 M_free(s,
"NOPARALLEL_DOLLAR s");
831 M_free(s1,
"NOPARALLEL_DOLLAR s1");
834 else if ( AC.mparallelflag & NOPARALLEL_RHS ) {
835 HighWarning(
"This module is forced to run in sequential mode due to RHS expression names");
837 else if ( AC.mparallelflag & NOPARALLEL_CONVPOLY ) {
838 HighWarning(
"This module is forced to run in sequential mode due to conversion to extra symbols");
840 else if ( AC.mparallelflag & NOPARALLEL_SPECTATOR ) {
841 HighWarning(
"This module is forced to run in sequential mode due to tospectator/copyspectator");
843 else if ( AC.mparallelflag & NOPARALLEL_TBLDOLLAR ) {
844 HighWarning(
"This module is forced to run in sequential mode due to $-variable assignments in tables");
846 else if ( AC.mparallelflag & NOPARALLEL_NPROC ) {
847 HighWarning(
"This module is forced to run in sequential mode because there is only one processor");
859 if ( AP.preError == 0 && (
Processor() || WriteAll() ) ) RetCode = -1;
866 if ( AC.ncmod ) UnSetMods();
867 AS.MultiThreaded = oldmultithreaded;
873 if ( NumPotModdollars > 0 ) {
875 if ( RetCode )
return RetCode;
877 if ( RetCode )
return RetCode;
880 if ( AC.topolynomialflag & TOPOLYNOMIALFLAG ) {
882 if ( RetCode )
return RetCode;
889 if ( RetCode )
return RetCode;
894 if ( PF.me != MASTER && AR.hidefile->PObuffer ) {
895 if ( AR.hidefile->handle >= 0 ) {
896 CloseFile(AR.hidefile->handle);
897 AR.hidefile->handle = -1;
898 remove(AR.hidefile->name);
900 AR.hidefile->POfull = AR.hidefile->POfill = AR.hidefile->PObuffer;
901 PUTZERO(AR.hidefile->POposition);
905 for ( j = 0; j < NumModOptdollars; j++ ) {
906 if ( ModOptdollars[j].dstruct ) {
912 if ( ModOptdollars[j].type == MODMAX || ModOptdollars[j].type == MODMIN ) {
913 const WORD globalnumber = ModOptdollars[j].number;
914 const DOLLARS gd = Dollars + globalnumber;
918 if ( gd->type == DOLZERO ) {
919 gd->type = DOLNUMBER;
920 if ( ! gd->where || gd->where == &(AM.dollarzero) ) {
922 gd->where = (WORD*)Malloc1(gd->size*
sizeof(WORD),
"dollar contents");
931 for ( i = 0; i < AM.totalnumberofthreads; i++ ) {
932 const DOLLARS ld = &(ModOptdollars[j].dstruct[i]);
935 if ( ld->type == DOLUNDEFINED )
continue;
937 if ( ld->type != DOLZERO && ld->type != DOLNUMBER ) {
938 MLOCK(ErrorMessageLock);
939 MesPrint(
"Illegal dollar variable type in MODMIN/MODMAX case: %d", ld->type);
940 MUNLOCK(ErrorMessageLock);
945 if ( ld->type == DOLZERO ) {
946 ld->type = DOLNUMBER;
947 if ( ! ld->where || ld->where == &(AM.dollarzero) ) {
949 ld->where = (WORD*)Malloc1(ld->size*
sizeof(WORD),
"dollar contents");
962 if ( gd->type == DOLUNDEFINED ) {
964 if ( ! gd->where || gd->where == &(AM.dollarzero) ) {
966 gd->where = (WORD*)Malloc1(gd->size*
sizeof(WORD),
"dollar contents");
968 for (
int v = 0; v < 5; v++ ) {
969 gd->where[v] = ld->where[v];
976 const WORD cmp =
CompCoef(gd->where, ld->where);
977 if ( ( ModOptdollars[j].type == MODMAX && cmp < 0 ) ||
978 ( ModOptdollars[j].type == MODMIN && cmp > 0 ) ) {
980 for (
int v = 0; v < 5; v++ ) {
981 gd->where[v] = ld->where[v];
983 if ( gd->where[4] != 0 ) {
986 MLOCK(ErrorMessageLock);
987 MesPrint(
"Missing trailing zero in MODMIN/MODMAX global dollar %d",
989 MUNLOCK(ErrorMessageLock);
996 if ( gd->where[1] == 0 ) {
998 if ( gd->where && gd->where != &(AM.dollarzero) ) {
999 M_free(gd->where,
"dollar contents");
1002 gd->where = &(AM.dollarzero);
1007 for ( i = 0; i < AM.totalnumberofthreads; i++ ) {
1008 if ( ModOptdollars[j].dstruct[i].size > 0 ) {
1009 CleanDollarFactors(&(ModOptdollars[j].dstruct[i]));
1010 if ( ModOptdollars[j].dstruct[i].where
1011 && ModOptdollars[j].dstruct[i].where != &(AM.dollarzero) ) {
1012 M_free(ModOptdollars[j].dstruct[i].where,
"Local dollar value");
1019 M_free(ModOptdollars[j].dstruct,
"Local DOLLARS");
1020 ModOptdollars[j].dstruct = 0;
1041 if ( ModOptdollars ) M_free(ModOptdollars,
"ModOptdollars pointer");
1042 if ( PotModdollars ) M_free(PotModdollars,
"PotModdollars pointer");
1045 AC.ModOptDolList.lijst = NULL;
1047 AC.PotModDolList.lijst = NULL;
1049 NumPotModdollars = 0;
1050 NumModOptdollars = 0;
1057if ( AC.SwitchInArray > 0 ) {
1058 for ( i = 0; i < AC.SwitchInArray; i++ ) {
1059 SWITCH *sw = AC.SwitchArray + i;
1060 if ( sw->table ) M_free(sw->table,
"Switch table");
1062 sw->defaultcase.ncase = 0;
1063 sw->defaultcase.value = 0;
1064 sw->defaultcase.compbuffer = 0;
1065 sw->endswitch.ncase = 0;
1066 sw->endswitch.value = 0;
1067 sw->endswitch.compbuffer = 0;
1078 AC.SwitchInArray = 0;
1082 AC.numpfirstnum = 0;
1085 AC.PolyRatFunChanged = 0;
1087 if ( par == STOREMODULE || par == CLEARMODULE ) {
1089 if ( par == STOREMODULE && PopVariables() ) RetCode = -1;
1090 if ( AR.infile->handle >= 0 ) {
1091 CloseFile(AR.infile->handle);
1092 remove(AR.infile->name);
1093 AR.infile->handle = -1;
1095 AR.infile->POfill = AR.infile->PObuffer;
1096 PUTZERO(AR.infile->POposition);
1097 AR.infile->POfull = AR.infile->PObuffer;
1098 if ( AR.outfile->handle >= 0 ) {
1099 CloseFile(AR.outfile->handle);
1100 remove(AR.outfile->name);
1101 AR.outfile->handle = -1;
1103 AR.outfile->POfull =
1104 AR.outfile->POfill = AR.outfile->PObuffer;
1105 PUTZERO(AR.outfile->POposition);
1106 if ( AR.hidefile->handle >= 0 ) {
1107 CloseFile(AR.hidefile->handle);
1108 remove(AR.hidefile->name);
1109 AR.hidefile->handle = -1;
1111 AR.hidefile->POfull =
1112 AR.hidefile->POfill = AR.hidefile->PObuffer;
1113 PUTZERO(AR.hidefile->POposition);
1115 if ( par == CLEARMODULE ) {
1116 if ( DeleteStore(0) < 0 ) {
1118 MesPrint(
"!>Cannot restart the storage file");
1125 AM.gProcessBucketSize = AM.hProcessBucketSize;
1126 AM.gparallelflag = PARALLELFLAG;
1127 AM.gnumextrasym = AM.ggnumextrasym;
1128 PruneExtraSymbols(AM.ggnumextrasym);
1131 ClearSpectators(par);
1134 if ( CleanExpr(0) ) RetCode = -1;
1135 if ( AC.DidClean ) CompactifyTree(AC.exprnames,EXPRNAMES);
1140 if ( AC.MultiBracketBuf != 0 ) {
1141 for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
1142 if ( AC.MultiBracketBuf[i] ) {
1143 M_free(AC.MultiBracketBuf[i],
"bracket buffer i");
1144 AC.MultiBracketBuf[i] = 0;
1147 AC.MultiBracketLevels = 0;
1148 M_free(AC.MultiBracketBuf,
"multi bracket buffer");
1149 AC.MultiBracketBuf = 0;
1152 if ( AC.SortReallocateFlag ) {
1156 M_free(S->lBuffer,
"SortReallocate lBuffer+sBuffer");
1157 S->lBuffer = Malloc1(
sizeof(*(S->lBuffer))*(S->LargeSize+S->SmallEsize),
"SortReallocate lBuffer+sBuffer");
1158 S->lTop = S->lBuffer+S->LargeSize;
1159 S->sBuffer = S->lTop;
1160 if ( S->LargeSize == 0 ) { S->lBuffer = 0; S->lTop = 0; }
1161 S->sTop = S->sBuffer + S->SmallSize;
1162 S->sTop2 = S->sBuffer + S->SmallEsize;
1163 S->sHalf = S->sBuffer + (LONG)((S->SmallSize+S->SmallEsize)>>1);
1167 UpdateSortBlocks(AM.totalnumberofthreads-1);
1171 for ( i = 1; i < AM.totalnumberofthreads; i++ ) {
1173 M_free(S->lBuffer,
"SortReallocate lBuffer+sBuffer");
1174 S->lBuffer = Malloc1(
sizeof(*(S->lBuffer))*(S->LargeSize+S->SmallEsize),
"SortReallocate lBuffer+sBuffer");
1175 S->lTop = S->lBuffer+S->LargeSize;
1176 S->sBuffer = S->lTop;
1177 if ( S->LargeSize == 0 ) { S->lBuffer = 0; S->lTop = 0; }
1178 S->sTop = S->sBuffer + S->SmallSize;
1179 S->sTop2 = S->sBuffer + S->SmallEsize;
1180 S->sHalf = S->sBuffer + (LONG)((S->SmallSize+S->SmallEsize)>>1);
1184 if ( AC.SortReallocateFlag == 2 ) {
1187 AC.SortReallocateFlag = 0;
1214int PutBracket(PHEAD WORD *termin)
1217 WORD *t, *t1, *b, i, j, *lastfun;
1219 WORD *bStop, *bb, *bf, *tStop;
1220 WORD *term1,*term2, *m1, *m2, *tStopa;
1221 WORD *bbb = 0, *bind, *binst = 0, bwild = 0, *bss = 0, *bns = 0, bset = 0;
1222 term1 = AT.WorkPointer+1;
1223 term2 = (WORD *)(((UBYTE *)(term1)) + AM.MaxTer);
1224 if ( ( (WORD *)(((UBYTE *)(term2)) + AM.MaxTer) ) > AT.WorkTop ) {
1227 if ( AR.BracketOn < 0 ) {
1228 t2 = term1; t1 = term2;
1231 t1 = term1; t2 = term2;
1233 b = AT.BrackBuf; bStop = b+*b; b++;
1234 while ( b < bStop ) {
1235 if ( *b == INDEX ) { bwild = 1; bbb = b+2; binst = b + b[1]; }
1236 if ( *b == SETSET ) { bset = 1; bss = b+2; bns = b + b[1]; }
1240 t = termin; tStopa = t + *t; i = *(t + *t -1); i = ABS(i);
1241 if ( AR.PolyFun && AT.PolyAct ) tStop = termin + AT.PolyAct;
1243 else if ( AT.FloatPos ) tStop = termin + AT.FloatPos;
1245 else tStop = tStopa - i;
1247 if ( AR.BracketOn < 0 ) {
1249 while ( t < tStop && *t >= FUNCTION
1250 && functions[*t-FUNCTION].commute ) {
1252 while ( b < bStop ) {
1255 while ( t < tStop && *t >= FUNCTION
1256 && functions[*t-FUNCTION].commute ) t += t[1];
1264 if ( b[1] == CFUNCTION ) {
1265 SETS set = Sets+b[0]; WORD i;
1266 for ( i = set->first; i < set->last; i++ ) {
1267 if ( SetElements[i] == *t ) {
1269 while ( t < tStop && *t >= FUNCTION
1270 && functions[*t-FUNCTION].commute ) t += t[1];
1278 if ( bwild && *t >= FUNCTION && functions[*t-FUNCTION].spec ) {
1283 while ( bind < binst ) {
1284 if ( *bind == *s2 ) {
1286 while ( t < tStop && *t >= FUNCTION
1287 && functions[*t-FUNCTION].commute ) t += t[1];
1300 while ( s1 < lastfun ) *t2++ = *s1++;
1301 while ( s1 < t ) *t1++ = *s1++;
1304 while ( s1 < t ) *t2++ = *s1++;
1310 while ( t < tStop && *t >= FUNCTION
1311 && functions[*t-FUNCTION].commute ) {
1313 while ( b < bStop ) {
1314 if ( *b == *t ) { lastfun = t + t[1];
goto NextNcom; }
1320 if ( b[1] == CFUNCTION ) {
1321 SETS set = Sets+b[0]; WORD i;
1322 for ( i = set->first; i < set->last; i++ ) {
1323 if ( SetElements[i] == *t ) {
1332 if ( bwild && *t >= FUNCTION && functions[*t-FUNCTION].spec ) {
1337 while ( bind < binst ) {
1338 if ( *bind == *s2 ) { lastfun = t + t[1];
goto NextNcom; }
1348 while ( s1 < lastfun ) *t1++ = *s1++;
1349 while ( s1 < t ) *t2++ = *s1++;
1354 b = AT.BrackBuf + 1;
1355 while ( b < bStop && *b >= FUNCTION
1356 && ( *b < FUNCTION || functions[*b-FUNCTION].commute ) ) {
1361 while ( t < tStop && ( bf < bStop || bwild || bset ) ) {
1363 while ( b < bStop && *b != *t ) { b += b[1]; }
1365 if ( *t >= FUNCTION ) {
1366 if ( b < bStop && *b == *t )
goto FunBrac;
1370 if ( b[1] == CFUNCTION ) {
1371 SETS set = Sets+b[0]; WORD i;
1372 for ( i = set->first; i < set->last; i++ ) {
1373 if ( SetElements[i] == *t )
goto FunBrac;
1379 if ( bwild && *t >= FUNCTION && functions[*t-FUNCTION].spec ) {
1384 while ( bind < binst ) {
1385 if ( *bind == *s2 )
goto FunBrac;
1393FunBrac: NCOPY(t1,t,i);
1399 if ( *t == DELTA ) {
1400 if ( b < bStop && *b == DELTA ) {
1404 else { NCOPY(t2,t,i); }
1406 else if ( *t == INDEX ) {
1409 *t1++ = *t; t1++; *t2++ = *t; t2++;
1413 while ( --j >= 0 ) {
1414 while ( *bind < *t && bind < binst ) bind++;
1415 if ( *bind == *t && bind < binst ) {
1420 while ( b3 < bns ) {
1421 if ( b3[1] == CVECTOR ) {
1422 SETS set = Sets+b3[0]; WORD i;
1423 for ( i = set->first; i < set->last; i++ ) {
1424 if ( SetElements[i] == *t ) {
1437 m1[1] = WORDDIF(t1,m1);
1438 if ( m1[1] == 2 ) t1 = m1;
1439 m2[1] = WORDDIF(t2,m2);
1440 if ( m2[1] == 2 ) t2 = m2;
1444 *t1++ = *t; t1++; *t2++ = *t; t2++;
1447 while ( --j >= 0 ) {
1449 while ( b3 < bns ) {
1450 if ( b3[1] == CVECTOR ) {
1451 SETS set = Sets+b3[0]; WORD i;
1452 for ( i = set->first; i < set->last; i++ ) {
1453 if ( SetElements[i] == *t ) {
1464 m1[1] = WORDDIF(t1,m1);
1465 if ( m1[1] == 2 ) t1 = m1;
1466 m2[1] = WORDDIF(t2,m2);
1467 if ( m2[1] == 2 ) t2 = m2;
1473 else if ( *t == VECTOR ) {
1474 if ( ( b < bStop && *b == VECTOR ) || bwild ) {
1475 if ( b < bStop && *b == VECTOR ) {
1476 bb = b + b[1]; b += 2;
1480 m1 = t1; m2 = t2; *t1++ = *t; *t2++ = *t; t1++; t2++; t += 2;
1483 while ( b < bb && ( *b < *t ||
1484 ( *b == *t && b[1] < t[1] ) ) ) b += 2;
1485 if ( b < bb && ( *t == *b && t[1] == b[1] ) ) {
1486 *t1++ = *t++; *t1++ = *t++;
goto nextvec;
1490 while ( bind < binst ) {
1491 if ( *t == *bind || t[1] == *bind ) {
1492 *t1++ = *t++; *t1++ = *t++;
1500 while ( b3 < bns ) {
1501 if ( b3[1] == CVECTOR ) {
1502 SETS set = Sets+b3[0]; WORD i;
1503 for ( i = set->first; i < set->last; i++ ) {
1504 if ( SetElements[i] == *t ) {
1505 *t1++ = *t++; *t1++ = *t++;
1513 *t2++ = *t++; *t2++ = *t++;
1516 m1[1] = WORDDIF(t1,m1);
1517 if ( m1[1] == 2 ) t1 = m1;
1518 m2[1] = WORDDIF(t2,m2);
1519 if ( m2[1] == 2 ) t2 = m2;
1522 m1 = t1; *t1++ = *t; t1++;
1523 m2 = t2; *t2++ = *t; t2++;
1527 while ( b3 < bns ) {
1528 if ( b3[1] == CVECTOR ) {
1529 SETS set = Sets+b3[0]; WORD i;
1530 for ( i = set->first; i < set->last; i++ ) {
1531 if ( SetElements[i] == *t ) {
1532 *t1++ = *t++; *t1++ = *t++;
1539 *t2++ = *t++; *t2++ = *t++;
1542 m1[1] = WORDDIF(t1,m1);
1543 if ( m1[1] == 2 ) t1 = m1;
1544 m2[1] = WORDDIF(t2,m2);
1545 if ( m2[1] == 2 ) t2 = m2;
1551 else if ( *t == DOTPRODUCT ) {
1552 if ( ( b < bStop && *b == *t ) || bwild ) {
1553 m1 = t1; *t1++ = *t; t1++;
1554 m2 = t2; *t2++ = *t; t2++;
1555 if ( b >= bStop || *b != *t ) { bb = b; s1 = b; }
1557 s1 = b + b[1]; bb = b + 2;
1560 while ( t < s2 && ( bb < s1 || bwild || bset ) ) {
1561 while ( bb < s1 && ( *bb < *t ||
1562 ( *bb == *t && bb[1] < t[1] ) ) ) bb += 3;
1563 if ( bb < s1 && *bb == *t && bb[1] == t[1] ) {
1564 *t1++ = *t++; *t1++ = *t++; *t1++ = *t++; bb += 3;
1569 while ( bind < binst ) {
1570 if ( *bind == *t || *bind == t[1] ) {
1571 *t1++ = *t++; *t1++ = *t++; *t1++ = *t++;
1579 while ( b3 < bns ) {
1580 if ( b3[1] == CVECTOR ) {
1581 SETS set = Sets+b3[0]; WORD i;
1582 for ( i = set->first; i < set->last; i++ ) {
1583 if ( SetElements[i] == *t || SetElements[i] == t[1] ) {
1584 *t1++ = *t++; *t1++ = *t++; *t1++ = *t++;
1592 *t2++ = *t++; *t2++ = *t++; *t2++ = *t++;
1595 while ( t < s2 ) *t2++ = *t++;
1596 m1[1] = WORDDIF(t1,m1);
1597 if ( m1[1] == 2 ) t1 = m1;
1598 m2[1] = WORDDIF(t2,m2);
1599 if ( m2[1] == 2 ) t2 = m2;
1602 m1 = t1; *t1++ = *t; t1++;
1603 m2 = t2; *t2++ = *t; t2++;
1607 while ( b3 < bns ) {
1608 if ( b3[1] == CVECTOR ) {
1609 SETS set = Sets+b3[0]; WORD i;
1610 for ( i = set->first; i < set->last; i++ ) {
1611 if ( SetElements[i] == *t || SetElements[i] == t[1] ) {
1612 *t1++ = *t++; *t1++ = *t++; *t1++ = *t++;
1619 *t2++ = *t++; *t2++ = *t++; *t2++ = *t++;
1622 m1[1] = WORDDIF(t1,m1);
1623 if ( m1[1] == 2 ) t1 = m1;
1624 m2[1] = WORDDIF(t2,m2);
1625 if ( m2[1] == 2 ) t2 = m2;
1627 else { NCOPY(t2,t,i); }
1629 else if ( *t == SYMBOL ) {
1630 if ( b < bStop && *b == *t ) {
1631 m1 = t1; *t1++ = *t; t1++;
1632 m2 = t2; *t2++ = *t; t2++;
1633 s1 = b + b[1]; bb = b+2;
1635 while ( bb < s1 && t < s2 ) {
1636 while ( bb < s1 && *bb < *t ) bb += 2;
1638 if ( bset )
goto TrySymbolSet;
1641 if ( *bb == *t ) { *t1++ = *t++; *t1++ = *t++; }
1646 while ( bbb < bns ) {
1647 if ( bbb[1] == CSYMBOL ) {
1648 SETS set = Sets+bbb[0]; WORD i;
1649 for ( i = set->first; i < set->last; i++ ) {
1650 if ( SetElements[i] == *t ) {
1651 *t1++ = *t++; *t1++ = *t++;
1658 *t2++ = *t++; *t2++ = *t++;
1660 else { *t2++ = *t++; *t2++ = *t++; }
1663 while ( t < s2 ) *t2++ = *t++;
1664 m1[1] = WORDDIF(t1,m1);
1665 if ( m1[1] == 2 ) t1 = m1;
1666 m2[1] = WORDDIF(t2,m2);
1667 if ( m2[1] == 2 ) t2 = m2;
1671 m1 = t1; *t1++ = *t; t1++;
1672 m2 = t2; *t2++ = *t; t2++;
1676 while ( bbb < bns ) {
1677 if ( bbb[1] == CSYMBOL ) {
1678 SETS set = Sets+bbb[0]; WORD i;
1679 for ( i = set->first; i < set->last; i++ ) {
1680 if ( SetElements[i] == *t ) {
1681 *t1++ = *t++; *t1++ = *t++;
1688 *t2++ = *t++; *t2++ = *t++;
1691 m1[1] = WORDDIF(t1,m1);
1692 if ( m1[1] == 2 ) t1 = m1;
1693 m2[1] = WORDDIF(t2,m2);
1694 if ( m2[1] == 2 ) t2 = m2;
1696 else { NCOPY(t2,t,i); }
1702 if ( ( i = WORDDIF(tStop,t) ) > 0 ) NCOPY(t2,t,i);
1703 if ( AR.BracketOn < 0 ) {
1704 s1 = t1; t1 = t2; t2 = s1;
1706 do { *t2++ = *t++; }
while ( t < (WORD *)tStopa );
1708 i = WORDDIF(t1,term1);
1709 *t++ = 4 + i + WORDDIF(t2,term2);
1714 i = WORDDIF(t2,term2);
1716 if ( i > 0 ) NCOPY(t,t1,i);
1728void SpecialCleanup(PHEAD0)
1731 if ( AT.previousEfactor ) M_free(AT.previousEfactor,
"Efactor cache");
1732 AT.previousEfactor = 0;
1745 if ( AN.cmod != 0 ) M_free(AN.cmod,
"AN.cmod");
1747 AN.cmod = (UWORD *)Malloc1(
sizeof(WORD)*n,
"AN.cmod");
1748 for ( i = 0; i < n; i++ ) AN.cmod[i] = AC.cmod[i];
1762 if ( AN.cmod != 0 ) M_free(AN.cmod,
"AN.cmod");
1775void ExchangeExpressions(
int num1,
int num2)
1778 WORD node1, node2, namesize, TMproto[SUBEXPSIZE];
1784 e1 = Expressions + num1;
1785 e2 = Expressions + num2;
1788 AC.exprnames->namenode[node1].number = num2;
1789 AC.exprnames->namenode[node2].number = num1;
1790 a = e1->name; e1->name = e2->name; e2->name = a;
1791 namesize = e1->namesize; e1->namesize = e2->namesize; e2->namesize = namesize;
1794 if ( e1->status == STOREDEXPRESSION ) {
1798 TMproto[0] = EXPRESSION;
1799 TMproto[1] = SUBEXPSIZE;
1802 {
int ie;
for ( ie = 4; ie < SUBEXPSIZE; ie++ ) TMproto[ie] = 0; }
1803 AT.TMaddr = TMproto;
1804 ind = FindInIndex(num1,&AR.StoreData,0,0);
1805 s1 = (SBYTE *)(AC.exprnames->namebuffer+e1->name);
1810 SeekFile(AR.StoreData.Handle,&(e1->onfile),SEEK_SET);
1811 if ( WriteFile(AR.StoreData.Handle,(UBYTE *)ind,
1814 MesPrint(
"!>File error while exchanging expressions");
1818 FlushFile(AR.StoreData.Handle);
1820 if ( e2->status == STOREDEXPRESSION ) {
1824 TMproto[0] = EXPRESSION;
1825 TMproto[1] = SUBEXPSIZE;
1828 {
int ie;
for ( ie = 4; ie < SUBEXPSIZE; ie++ ) TMproto[ie] = 0; }
1829 AT.TMaddr = TMproto;
1830 ind = FindInIndex(num1,&AR.StoreData,0,0);
1831 s1 = (SBYTE *)(AC.exprnames->namebuffer+e2->name);
1836 SeekFile(AR.StoreData.Handle,&(e2->onfile),SEEK_SET);
1837 if ( WriteFile(AR.StoreData.Handle,(UBYTE *)ind,
1840 MesPrint(
"!>File error while exchanging expressions");
1844 FlushFile(AR.StoreData.Handle);
1853int GetFirstBracket(WORD *term,
int num)
1864 WORD type, *oldcomppointer, oldonefile, numword;
1867 oldcomppointer = AR.CompressPointer;
1868 type = Expressions[num].status;
1869 if ( type == STOREDEXPRESSION ) {
1870 WORD TMproto[SUBEXPSIZE];
1871 TMproto[0] = EXPRESSION;
1872 TMproto[1] = SUBEXPSIZE;
1875 {
int ie;
for ( ie = 4; ie < SUBEXPSIZE; ie++ ) TMproto[ie] = 0; }
1876 AT.TMaddr = TMproto;
1878 if ( ( renumber = GetTable(num,&position,0) ) == 0 ) {
1879 MesCall(
"GetFirstBracket");
1882 if ( GetFromStore(term,&position,renumber,&numword,num) < 0 ) {
1883 MesCall(
"GetFirstBracket");
1889 if ( renumber->
symb.
lo != AN.dummyrenumlist )
1890 M_free(renumber->
symb.
lo,
"VarSpace");
1891 M_free(renumber,
"Renumber");
1897 oldonefile = AR.GetOneFile;
1898 if ( type == HIDDENLEXPRESSION || type == HIDDENGEXPRESSION ) {
1899 AR.GetOneFile = 2; fi = AR.hidefile;
1902 AR.GetOneFile = 0; fi = AR.infile;
1905 PUTZERO(oldposition);
1911 SETBASEPOSITION(oldposition,fi->POfill-fi->PObuffer);
1913 position = AS.OldOnFile[num];
1914 if ( GetOneTerm(BHEAD term,fi,&position,1) < 0
1915 || ( GetOneTerm(BHEAD term,fi,&position,1) < 0 ) ) {
1916 MLOCK(ErrorMessageLock);
1917 MesCall(
"GetFirstBracket");
1918 MUNLOCK(ErrorMessageLock);
1933 fi->POfill = fi->PObuffer+BASEPOSITION(oldposition);
1935 AR.GetOneFile = oldonefile;
1937 AR.CompressPointer = oldcomppointer;
1939 tstop = term + *term; tstop -= ABS(tstop[-1]);
1941 while ( t < tstop ) {
1942 if ( *t == HAAKJE )
break;
1946 term[0] = 4; term[1] = 1; term[2] = 1; term[3] = 3;
1949 *t++ = 1; *t++ = 1; *t++ = 3; *term = t - term;
1953 term[0] = 4; term[1] = 1; term[2] = 1; term[3] = 3;
1978 WORD type, *oldcomppointer, oldonefile, numword;
1980 oldcomppointer = AR.CompressPointer;
1981 type = Expressions[num].status;
1982 if ( type == STOREDEXPRESSION ) {
1983 WORD TMproto[SUBEXPSIZE];
1984 TMproto[0] = EXPRESSION;
1985 TMproto[1] = SUBEXPSIZE;
1988 {
int ie;
for ( ie = 4; ie < SUBEXPSIZE; ie++ ) TMproto[ie] = 0; }
1989 AT.TMaddr = TMproto;
1991 if ( ( renumber = GetTable(num,&position,0) ) == 0 ) {
1992 MesCall(
"GetFirstTerm");
1995 if ( GetFromStore(term,&position,renumber,&numword,num) < 0 ) {
1996 MesCall(
"GetFirstTerm");
2002 if ( renumber->
symb.
lo != AN.dummyrenumlist )
2003 M_free(renumber->
symb.
lo,
"VarSpace");
2004 M_free(renumber,
"Renumber");
2010 oldonefile = AR.GetOneFile;
2011 if ( type == HIDDENLEXPRESSION || type == HIDDENGEXPRESSION ) {
2012 AR.GetOneFile = 2; fi = AR.hidefile;
2016 if ( Expressions[num].replace == NEWLYDEFINEDEXPRESSION ) {
2020 if ( pre == 0 ) { fi = AR.outfile; }
2024 MesPrint(
"&isnumerical: expression is not yet defined!");
2031 if ( pre == 0 ) { fi = AR.infile; }
2035 else { fi = AR.outfile; }
2039 PUTZERO(oldposition);
2045 SETBASEPOSITION(oldposition,fi->POfill-fi->PObuffer);
2047 position = AS.OldOnFile[num];
2048 if ( GetOneTerm(BHEAD term,fi,&position,1) < 0
2049 || ( GetOneTerm(BHEAD term,fi,&position,1) < 0 ) ) {
2050 MLOCK(ErrorMessageLock);
2051 MesCall(
"GetFirstTerm");
2052 MUNLOCK(ErrorMessageLock);
2067 fi->POfill = fi->PObuffer+BASEPOSITION(oldposition);
2069 AR.GetOneFile = oldonefile;
2071 AR.CompressPointer = oldcomppointer;
2080int GetContent(WORD *content,
int num)
2095 WORD type, *oldcomppointer, oldonefile, numword, *term, i;
2096 WORD *cbuffer = TermMalloc(
"GetContent");
2097 WORD *oldworkpointer = AT.WorkPointer;
2099 oldcomppointer = AR.CompressPointer;
2100 type = Expressions[num].status;
2101 if ( type == STOREDEXPRESSION ) {
2102 WORD TMproto[SUBEXPSIZE];
2103 TMproto[0] = EXPRESSION;
2104 TMproto[1] = SUBEXPSIZE;
2107 {
int ie;
for ( ie = 4; ie < SUBEXPSIZE; ie++ ) TMproto[ie] = 0; }
2108 AT.TMaddr = TMproto;
2110 if ( ( renumber = GetTable(num,&position,0) ) == 0 )
goto CalledFrom;
2111 if ( GetFromStore(cbuffer,&position,renumber,&numword,num) < 0 )
goto CalledFrom;
2113 term = oldworkpointer;
2114 AR.CompressPointer = oldcomppointer;
2115 if ( GetFromStore(term,&position,renumber,&numword,num) < 0 )
goto CalledFrom;
2116 if ( *term == 0 )
break;
2120 if ( ContentMerge(BHEAD cbuffer,term) < 0 )
goto CalledFrom;
2125 if ( renumber->
symb.
lo != AN.dummyrenumlist )
2126 M_free(renumber->
symb.
lo,
"VarSpace");
2127 M_free(renumber,
"Renumber");
2133 oldonefile = AR.GetOneFile;
2134 if ( type == HIDDENLEXPRESSION || type == HIDDENGEXPRESSION ) {
2135 AR.GetOneFile = 2; fi = AR.hidefile;
2139 if ( Expressions[num].replace == NEWLYDEFINEDEXPRESSION )
2141 else fi = AR.infile;
2144 PUTZERO(oldposition);
2150 SETBASEPOSITION(oldposition,fi->POfill-fi->PObuffer);
2152 position = AS.OldOnFile[num];
2153 if ( GetOneTerm(BHEAD cbuffer,fi,&position,1) < 0 )
goto CalledFrom;
2154 AR.CompressPointer = oldcomppointer;
2155 if ( GetOneTerm(BHEAD cbuffer,fi,&position,1) < 0 )
goto CalledFrom;
2164 term = oldworkpointer;
2165 AR.CompressPointer = oldcomppointer;
2166 if ( GetOneTerm(BHEAD term,fi,&position,1) < 0 )
goto CalledFrom;
2167 if ( *term == 0 )
break;
2171 if ( ContentMerge(BHEAD cbuffer,term) < 0 )
goto CalledFrom;
2174 fi->POfill = fi->PObuffer+BASEPOSITION(oldposition);
2176 AR.GetOneFile = oldonefile;
2178 AR.CompressPointer = oldcomppointer;
2179 for ( i = 0; i < *cbuffer; i++ ) content[i] = cbuffer[i];
2180 TermFree(cbuffer,
"GetContent");
2181 AT.WorkPointer = oldworkpointer;
2184 MLOCK(ErrorMessageLock);
2185 MesCall(
"GetContent");
2186 MUNLOCK(ErrorMessageLock);
2197int CleanupTerm(WORD *term)
2199 WORD *tstop, *t, *tfill, *tt;
2200 GETSTOP(term,tstop);
2202 while ( t < tstop ) {
2203 if ( *t >= FUNCTION && ( functions[*t-FUNCTION].commute || *t == DENOMINATOR ) ) {
2204 tfill = t; tt = t + t[1]; tstop = term + *term;
2205 while ( tt < tstop ) *tfill++ = *tt++;
2206 *term = tfill - term;
2207 tstop -= ABS(tfill[-1]);
2221WORD ContentMerge(PHEAD WORD *content, WORD *term)
2224 WORD *cstop, csize, crsize, sign = 1, numsize, densize, i, tnsize, tdsize;
2225 UWORD *num, *den, *tnum, *tden;
2226 WORD *outfill, *outb = TermMalloc(
"ContentMerge"), *ct;
2227 WORD *t, *tstop, tsize, trsize, *told;
2228 WORD *t1, *t2, *c1, *c2, i1, i2, *out1;
2229 WORD didsymbol = 0, diddotp = 0, tfirst;
2230 cstop = content + *content;
2232 if ( csize < 0 ) { sign = -sign; csize = -csize; }
2234 numsize = densize = crsize = (csize-1)/2;
2235 num = NumberMalloc(
"ContentMerge");
2236 den = NumberMalloc(
"ContentMerge");
2237 for ( i = 0; i < numsize; i++ ) num[i] = (UWORD)(cstop[i]);
2238 for ( i = 0; i < densize; i++ ) den[i] = (UWORD)(cstop[i+crsize]);
2239 while ( num[numsize-1] == 0 ) numsize--;
2240 while ( den[densize-1] == 0 ) densize--;
2244 tstop = term + *term;
2246 if ( tsize < 0 ) tsize = -tsize;
2248 tstop = tstop - tsize;
2249 tnsize = tdsize = trsize = (tsize-1)/2;
2250 tnum = (UWORD *)tstop; tden = (UWORD *)(tstop + trsize);
2251 while ( tnum[tnsize-1] == 0 ) tnsize--;
2252 while ( tden[tdsize-1] == 0 ) tdsize--;
2253 GcdLong(BHEAD num, numsize, tnum, tnsize, num, &numsize);
2254 if ( LcmLong(BHEAD den, densize, tden, tdsize, den, &densize) )
goto CalledFrom;
2258 while ( ct < cstop ) {
2263 while ( t < tstop && *t != *ct ) t += t[1];
2264 if ( t >= tstop )
break;
2265 t1 = t+2; t2 = t+t[1];
2266 c1 = ct+2; c2 = ct+ct[1];
2267 out1 = outfill; *outfill++ = *ct; outfill++;
2268 while ( c1 < c2 && t1 < t2 ) {
2270 if ( t1[1] <= c1[1] ) {
2271 *outfill++ = *t1++; *outfill++ = *t1++;
2275 *outfill++ = *c1++; *outfill++ = *c1++;
2279 else if ( *c1 < *t1 ) {
2281 *outfill++ = *c1++; *outfill++ = *c1++;
2287 *outfill++ = *t1++; *outfill++ = *t1++;
2293 if ( c1[1] < 0 ) { *outfill++ = c1[0]; *outfill++ = c1[1]; }
2297 if ( t1[1] < 0 ) { *outfill++ = t1[0]; *outfill++ = t1[1]; }
2300 out1[1] = outfill - out1;
2301 if ( out1[1] == 2 ) outfill = out1;
2306 while ( t < tstop && *t != *ct ) t += t[1];
2307 if ( t >= tstop )
break;
2308 t1 = t+2; t2 = t+t[1];
2309 c1 = ct+2; c2 = ct+ct[1];
2310 out1 = outfill; *outfill++ = *ct; outfill++;
2311 while ( c1 < c2 && t1 < t2 ) {
2312 if ( *c1 == *t1 && c1[1] == t1[1] ) {
2313 if ( t1[2] <= c1[2] ) {
2314 *outfill++ = *t1++; *outfill++ = *t1++; *outfill++ = *t1++;
2318 *outfill++ = *c1++; *outfill++ = *c1++; *outfill++ = *c1++;
2322 else if ( *c1 < *t1 || ( *c1 == *t1 && c1[1] < t1[1] ) ) {
2324 *outfill++ = *c1++; *outfill++ = *c1++; *outfill++ = *c1++;
2330 *outfill++ = *t1++; *outfill++ = *t1++; *outfill++ = *t1++;
2336 if ( c1[2] < 0 ) { *outfill++ = c1[0]; *outfill++ = c1[1]; *outfill++ = c1[1]; }
2340 if ( t1[2] < 0 ) { *outfill++ = t1[0]; *outfill++ = t1[1]; *outfill++ = t1[1]; }
2343 out1[1] = outfill - out1;
2344 if ( out1[1] == 2 ) outfill = out1;
2348 while ( t < tstop && *t != *ct ) t += t[1];
2349 if ( t >= tstop )
break;
2350 t1 = t+2; t2 = t+t[1];
2351 c1 = ct+2; c2 = ct+ct[1];
2352 out1 = outfill; *outfill++ = *ct; outfill++;
2353 while ( c1 < c2 && t1 < t2 ) {
2358 else if ( *c1 < *t1 ) { c1 += 1; }
2361 out1[1] = outfill - out1;
2362 if ( out1[1] == 2 ) outfill = out1;
2367 while ( t < tstop && *t != *ct ) t += t[1];
2368 if ( t >= tstop )
break;
2369 t1 = t+2; t2 = t+t[1];
2370 c1 = ct+2; c2 = ct+ct[1];
2371 out1 = outfill; *outfill++ = *ct; outfill++;
2372 while ( c1 < c2 && t1 < t2 ) {
2373 if ( *c1 == *t1 && c1[1] && t1[1] ) {
2374 *outfill++ = *c1++; *outfill++ = *c1++;
2377 else if ( *c1 < *t1 || ( *c1 == *t1 && c1[1] < t1[1] ) ) {
2384 out1[1] = outfill - out1;
2385 if ( out1[1] == 2 ) outfill = out1;
2391 while ( t < tstop ) {
2392 if ( *t != *ct ) { t += t[1];
continue; }
2393 if ( ct[1] != t[1] ) { t += t[1];
continue; }
2394 if ( ct[2] != t[2] ) { t += t[1];
continue; }
2395 t1 = t; t2 = ct; i1 = t1[1]; i2 = t2[1];
2397 if ( *t1 != *t2 )
break;
2400 if ( i1 != 0 ) { t += t[1];
continue; }
2402 for ( i = 0; i < i2; i++ ) { *outfill++ = *t++; }
2406 t1[2] |= SUBTERMUSED1;
2407 ct[2] |= SUBTERMUSED2;
2415 if ( diddotp == 0 ) {
2416 t = term+1;
while ( t < tstop && *t != DOTPRODUCT ) t += t[1];
2418 tfirst = 1; told = outfill;
2419 for ( i = 2; i < t[1]; i += 3 ) {
2421 if ( tfirst ) { *outfill++ = DOTPRODUCT; *outfill++ = 0; tfirst = 0; }
2422 *outfill++ = t[i]; *outfill++ = t[i+1]; *outfill++ = t[i+2];
2425 if ( outfill > told ) told[1] = outfill-told;
2428 if ( didsymbol == 0 ) {
2429 t = term+1;
while ( t < tstop && *t != SYMBOL ) t += t[1];
2431 tfirst = 1; told = outfill;
2432 for ( i = 2; i < t[1]; i += 2 ) {
2434 if ( tfirst ) { *outfill++ = SYMBOL; *outfill++ = 0; tfirst = 0; }
2435 *outfill++ = t[i]; *outfill++ = t[i+1];
2438 if ( outfill > told ) told[1] = outfill-told;
2444 if ( numsize < densize ) {
2445 for ( i = numsize; i < densize; i++ ) num[i] = 0;
2448 else if ( densize < numsize ) {
2449 for ( i = densize; i < numsize; i++ ) den[i] = 0;
2452 for ( i = 0; i < numsize; i++ ) *outfill++ = num[i];
2453 for ( i = 0; i < densize; i++ ) *outfill++ = den[i];
2454 csize = numsize+densize+1;
2455 if ( sign < 0 ) csize = -csize;
2457 *outb = outfill-outb;
2458 NumberFree(den,
"ContentMerge");
2459 NumberFree(num,
"ContentMerge");
2460 for ( i = 0; i < *outb; i++ ) content[i] = outb[i];
2461 TermFree(outb,
"ContentMerge");
2468 while ( t < tstop ) {
2469 if ( *t >= FUNCTION ) t[2] &= ~SUBTERMUSED1;
2474 MLOCK(ErrorMessageLock);
2475 MesCall(
"GetContent");
2476 MUNLOCK(ErrorMessageLock);
2485LONG TermsInExpression(WORD num)
2487 LONG x = Expressions[num].counter;
2488 if ( x >= 0 )
return(x);
2497LONG SizeOfExpression(WORD num)
2499 LONG x = (LONG)(DIVPOS(Expressions[num].size,
sizeof(WORD)));
2500 if ( x >= 0 )
return(x);
2509void UpdatePositions(
void)
2515 if ( NumExpressions > 0 &&
2516 ( AS.OldOnFile == 0 || AS.NumOldOnFile < NumExpressions ) ) {
2517 if ( AS.OldOnFile ) {
2519 AS.OldOnFile = (
POSITION *)Malloc1(NumExpressions*
sizeof(
POSITION),
"file pointers");
2520 for ( i = 0; i < AS.NumOldOnFile; i++ ) AS.OldOnFile[i] = old[i];
2521 AS.NumOldOnFile = NumExpressions;
2522 M_free(old,
"process file pointers");
2525 AS.OldOnFile = (
POSITION *)Malloc1(NumExpressions*
sizeof(
POSITION),
"file pointers");
2526 AS.NumOldOnFile = NumExpressions;
2529 if ( NumExpressions > 0 &&
2530 ( AS.OldNumFactors == 0 || AS.NumOldNumFactors < NumExpressions ) ) {
2531 if ( AS.OldNumFactors ) {
2532 oldw = AS.OldNumFactors;
2533 AS.OldNumFactors = (WORD *)Malloc1(NumExpressions*
sizeof(WORD),
"numfactors pointers");
2534 for ( i = 0; i < AS.NumOldNumFactors; i++ ) AS.OldNumFactors[i] = oldw[i];
2535 M_free(oldw,
"numfactors pointers");
2536 oldw = AS.Oldvflags;
2537 AS.Oldvflags = (WORD *)Malloc1(NumExpressions*
sizeof(WORD),
"vflags pointers");
2538 for ( i = 0; i < AS.NumOldNumFactors; i++ ) AS.Oldvflags[i] = oldw[i];
2539 M_free(oldw,
"vflags pointers");
2540 oldw = AS.Olduflags;
2541 AS.Olduflags = (WORD *)Malloc1(NumExpressions*
sizeof(WORD),
"uflags pointers");
2542 for ( i = 0; i < AS.NumOldNumFactors; i++ ) AS.Olduflags[i] = oldw[i];
2543 M_free(oldw,
"uflags pointers");
2544 AS.NumOldNumFactors = NumExpressions;
2547 AS.OldNumFactors = (WORD *)Malloc1(NumExpressions*
sizeof(WORD),
"numfactors pointers");
2548 AS.Oldvflags = (WORD *)Malloc1(NumExpressions*
sizeof(WORD),
"vflags pointers");
2549 AS.Olduflags = (WORD *)Malloc1(NumExpressions*
sizeof(WORD),
"uflags pointers");
2550 AS.NumOldNumFactors = NumExpressions;
2553 for ( i = 0; i < NumExpressions; i++ ) {
2554 AS.OldOnFile[i] = e[i].onfile;
2555 AS.OldNumFactors[i] = e[i].numfactors;
2556 AS.Oldvflags[i] = e[i].vflags;
2557 AS.Olduflags[i] = e[i].uflags;
2569LONG CountTerms1(PHEAD0)
2572 POSITION oldposition, startposition;
2573 WORD *t, *m, *mstop, decr, i, *oldwork, retval;
2574 WORD *oldipointer = AR.CompressPointer;
2575 WORD oldGetOneFile = AR.GetOneFile, olddeferflag = AR.DeferFlag;
2578 oldwork = AT.WorkPointer;
2579 AT.WorkPointer = (WORD *)(((UBYTE *)(AT.WorkPointer)) + AM.MaxTer);
2581 startposition = AR.DefPosition;
2585 if ( AR.infile->handle >= 0 ) {
2586 PUTZERO(oldposition);
2592 SETBASEPOSITION(oldposition,AR.infile->POfill-AR.infile->PObuffer);
2593 AR.infile->POfill = (WORD *)((UBYTE *)(AR.infile->PObuffer)
2594 +BASEPOSITION(startposition));
2599 t = m = AR.CompressBuffer;
2601 mstop = t - ABS(t[-1]);
2603 while ( *m != HAAKJE && m < mstop ) m += m[1];
2606 AR.DeferFlag = olddeferflag;
2607 AT.WorkPointer = oldwork;
2608 AR.GetOneFile = oldGetOneFile;
2612 decr = WORDDIF(mstop,AR.CompressBuffer)-1;
2614 m = AR.CompressBuffer;
2615 t = AR.CompressPointer;
2627 AR.CompressPointer = oldipointer;
2630 retval = GetOneTerm(BHEAD AT.WorkPointer,AR.infile,&startposition,0);
2631 if ( retval >= 0 ) AR.CompressPointer = oldipointer;
2632 if ( retval <= 0 )
break;
2633 t = AR.CompressPointer;
2634 if ( *t < (1 + decr + ABS(*(t+*t-1))) )
break;
2636 m = AR.CompressBuffer+1;
2637 while ( m < mstop ) {
2638 if ( *m != *t )
goto Thatsit;
2646 AT.WorkPointer = oldwork;
2647 if ( AR.infile->handle >= 0 ) {
2653 AR.infile->POfill = AR.infile->PObuffer + BASEPOSITION(oldposition);
2655 AR.DeferFlag = olddeferflag;
2656 AR.GetOneFile = oldGetOneFile;
2672#define CURRENTBRACKET 1
2673#define BRACKETCURRENTEXPR 2
2674#define BRACKETOTHEREXPR 3
2675#define NOBRACKETACTIVE 4
2677LONG TermsInBracket(PHEAD WORD *term, WORD level)
2679 WORD *t, *tstop, *b, *tt, *n1, *n2;
2680 int type = 0, i, num;
2682 WORD *bracketbuffer = AT.WorkPointer;
2683 t = term; GETSTOP(t,tstop);
2684 t++; b = bracketbuffer;
2685 while ( t < tstop ) {
2686 if ( *t != TERMSINBRACKET ) { t += t[1];
continue; }
2687 if ( t[1] == FUNHEAD || (
2689 && t[FUNHEAD] == -SNUMBER
2690 && t[FUNHEAD+1] == 0
2692 if ( AC.ComDefer == 0 ) {
2693 type = NOBRACKETACTIVE;
2696 type = CURRENTBRACKET;
2701 if ( t[FUNHEAD] == -EXPRESSION ) {
2702 if ( t[FUNHEAD+2] < 0 ) {
2703 if ( ( t[FUNHEAD+2] <= -FUNCTION ) && ( t[1] == FUNHEAD+3 ) ) {
2704 type = BRACKETOTHEREXPR;
2705 *b++ = FUNHEAD+4; *b++ = -t[FUNHEAD+2]; *b++ = FUNHEAD;
2706 for ( i = 2; i < FUNHEAD; i++ ) *b++ = 0;
2707 *b++ = 1; *b++ = 1; *b++ = 3;
2710 else if ( ( t[FUNHEAD+2] > -FUNCTION ) && ( t[1] == FUNHEAD+4 ) ) {
2711 type = BRACKETOTHEREXPR;
2715 *b++ = 8; *b++ = SYMBOL; *b++ = 4; *b++ = tt[1];
2716 *b++ = 1; *b++ = 1; *b++ = 1; *b++ = 3;
2720 *b++ = 4; *b++ = 1; *b++ = 1; *b++ = 3;
2722 else goto IllBraReq;
2730 else if ( ( t[FUNHEAD+2] == (t[1]-FUNHEAD-2) ) &&
2731 ( t[FUNHEAD+2+ARGHEAD] == (t[FUNHEAD+2]-ARGHEAD) ) ) {
2732 type = BRACKETOTHEREXPR;
2733 tt = t + FUNHEAD + ARGHEAD; num = *tt;
2734 for ( i = 0; i < num; i++ ) *b++ = *tt++;
2739 if ( t[FUNHEAD] < 0 ) {
2740 if ( ( t[FUNHEAD] <= -FUNCTION ) && ( t[1] == FUNHEAD+1 ) ) {
2741 type = BRACKETCURRENTEXPR;
2742 *b++ = FUNHEAD+4; *b++ = -t[FUNHEAD+2]; *b++ = FUNHEAD;
2743 for ( i = 2; i < FUNHEAD; i++ ) *b++ = 0;
2744 *b++ = 1; *b++ = 1; *b++ = 3; *b = 0;
2747 else if ( ( t[FUNHEAD] > -FUNCTION ) && ( t[1] == FUNHEAD+2 ) ) {
2748 type = BRACKETCURRENTEXPR;
2752 *b++ = 8; *b++ = SYMBOL; *b++ = 4; *b++ = tt[1];
2753 *b++ = 1; *b++ = 1; *b++ = 1; *b++ = 3;
2757 *b++ = 4; *b++ = 1; *b++ = 1; *b++ = 3;
2759 else goto IllBraReq;
2767 else if ( ( t[FUNHEAD] == (t[1]-FUNHEAD) ) &&
2768 ( t[FUNHEAD+ARGHEAD] == (t[FUNHEAD]-ARGHEAD) ) ) {
2769 type = BRACKETCURRENTEXPR;
2770 tt = t + FUNHEAD + ARGHEAD; num = *tt;
2771 for ( i = 0; i < num; i++ ) *b++ = *tt++;
2776 MLOCK(ErrorMessageLock);
2777 MesPrint(
"Illegal bracket request in termsinbracket_ function.");
2778 MUNLOCK(ErrorMessageLock);
2785 if ( AT.WorkPointer + *term +4 > AT.WorkTop ) {
2786 MLOCK(ErrorMessageLock);
2788 MesPrint(
"Called from termsinbracket_ function.");
2789 MUNLOCK(ErrorMessageLock);
2796 case CURRENTBRACKET:
2802 numterms = CountTerms1(BHEAD0);
2804 case BRACKETCURRENTEXPR:
2808 MLOCK(ErrorMessageLock);
2809 MesPrint(
"termsinbracket_ function currently only handles Keep Brackets.");
2810 MUNLOCK(ErrorMessageLock);
2812 case BRACKETOTHEREXPR:
2813 MLOCK(ErrorMessageLock);
2814 MesPrint(
"termsinbracket_ function currently only handles Keep Brackets.");
2815 MUNLOCK(ErrorMessageLock);
2817 case NOBRACKETACTIVE:
2824 n1 = term; n2 = AT.WorkPointer; tstop = n1 + *n1;
2825 while ( n1 < t ) *n2++ = *n1++;
2826 i = numterms >> BITSINWORD;
2828 *n2++ = LNUMBER; *n2++ = 4; *n2++ = 1; *n2++ = (WORD)(numterms & WORDMASK);
2831 *n2++ = LNUMBER; *n2++ = 5; *n2++ = 2;
2832 *n2++ = (WORD)(numterms & WORDMASK); *n2++ = i;
2835 while ( n1 < tstop ) *n2++ = *n1++;
2836 AT.WorkPointer[0] = n2 - AT.WorkPointer;
2837 AT.WorkPointer = n2;
2839 AT.WorkPointer = bracketbuffer;
2840 MLOCK(ErrorMessageLock);
2841 MesPrint(
"Called from termsinbracket_ function.");
2842 MUNLOCK(ErrorMessageLock);
2848 AT.WorkPointer = bracketbuffer;
WORD CompCoef(WORD *, WORD *)
int Generator(PHEAD WORD *, WORD)
int GetFirstTerm(WORD *term, int num, int pre)
int PF_BroadcastExpFlags(void)
int PF_BroadcastModifiedDollars(void)
int PF_BroadcastCBuf(int bufnum)
int PF_CollectModifiedDollars(void)
int PF_BroadcastExpr(EXPRESSIONS e, FILEHANDLE *file)