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 WORD replacement = e->replace;
522 while ( Expressions[replacement].replace >= 0 )
523 replacement = Expressions[replacement].replace;
524 Expressions[replacement].replace = REGULAREXPRESSION;
525 AC.exprnames->namenode[e->node].number = replacement;
526 e->replace = REGULAREXPRESSION;
529 AC.exprnames->namenode[e->node].type = CDELETE;
533 case LOCALEXPRESSION:
534 case GLOBALEXPRESSION:
535 ClearBracketIndex(j);
536 e->bracketinfo = e->newbracketinfo; e->newbracketinfo = 0;
538 case HIDDENLEXPRESSION:
539 case HIDDENGEXPRESSION:
541 case INTOHIDELEXPRESSION:
542 ClearBracketIndex(j);
543 e->bracketinfo = e->newbracketinfo; e->newbracketinfo = 0;
544 e->status = HIDDENLEXPRESSION;
546 case INTOHIDEGEXPRESSION:
547 ClearBracketIndex(j);
548 e->bracketinfo = e->newbracketinfo; e->newbracketinfo = 0;
549 e->status = HIDDENGEXPRESSION;
552 ClearBracketIndex(j);
556 if ( e->replace == NEWLYDEFINEDEXPRESSION ) e->replace = REGULAREXPRESSION;
565void PutInVflags(WORD nexpr)
572 if ( AS.OldOnFile == 0 ) {
573 AS.NumOldOnFile = 20;
574 AS.OldOnFile = (
POSITION *)Malloc1(AS.NumOldOnFile*
sizeof(
POSITION),
"file pointers");
576 else if ( nexpr >= AS.NumOldOnFile ) {
578 AS.OldOnFile = (
POSITION *)Malloc1(2*AS.NumOldOnFile*
sizeof(
POSITION),
"file pointers");
579 for ( i = 0; i < AS.NumOldOnFile; i++ ) AS.OldOnFile[i] = old[i];
580 AS.NumOldOnFile = 2*AS.NumOldOnFile;
581 M_free(old,
"process file pointers");
583 if ( AS.OldNumFactors == 0 ) {
584 AS.NumOldNumFactors = 20;
585 AS.OldNumFactors = (WORD *)Malloc1(AS.NumOldNumFactors*
sizeof(WORD),
"numfactors pointers");
586 AS.Oldvflags = (WORD *)Malloc1(AS.NumOldNumFactors*
sizeof(WORD),
"vflags pointers");
587 AS.Olduflags = (WORD *)Malloc1(AS.NumOldNumFactors*
sizeof(WORD),
"uflags pointers");
589 else if ( nexpr >= AS.NumOldNumFactors ) {
590 oldw = AS.OldNumFactors;
591 AS.OldNumFactors = (WORD *)Malloc1(2*AS.NumOldNumFactors*
sizeof(WORD),
"numfactors pointers");
592 for ( i = 0; i < AS.NumOldNumFactors; i++ ) AS.OldNumFactors[i] = oldw[i];
593 M_free(oldw,
"numfactors pointers");
595 AS.Oldvflags = (WORD *)Malloc1(2*AS.NumOldNumFactors*
sizeof(WORD),
"vflags pointers");
596 for ( i = 0; i < AS.NumOldNumFactors; i++ ) AS.Oldvflags[i] = oldw[i];
597 M_free(oldw,
"vflags pointers");
599 AS.Olduflags = (WORD *)Malloc1(2*AS.NumOldNumFactors*
sizeof(WORD),
"uflags pointers");
600 for ( i = 0; i < AS.NumOldNumFactors; i++ ) AS.Olduflags[i] = oldw[i];
601 M_free(oldw,
"uflags pointers");
602 AS.NumOldNumFactors = 2*AS.NumOldNumFactors;
607 if ( nexpr >= AS.NumOldOnFile || nexpr >= AS.NumOldNumFactors )
goto restart;
608 AS.OldOnFile[nexpr] = e->onfile;
609 AS.OldNumFactors[nexpr] = e->numfactors;
610 AS.Oldvflags[nexpr] = e->vflags;
611 AS.Olduflags[nexpr] = e->uflags;
619int DoExecute(WORD par, WORD skip)
623 int i, oldmultithreaded = AS.MultiThreaded;
628 SpecialCleanup(BHEAD0);
629 if ( skip )
goto skipexec;
630 if ( AC.IfLevel > 0 ) {
631 MesPrint(
" %d endif statement(s) missing",AC.IfLevel);
634 if ( AC.WhileLevel > 0 ) {
635 MesPrint(
" %d endwhile statement(s) missing",AC.WhileLevel);
638 if ( AC.arglevel > 0 ) {
639 MesPrint(
" %d endargument statement(s) missing",AC.arglevel);
642 if ( AC.termlevel > 0 ) {
643 MesPrint(
" %d endterm statement(s) missing",AC.termlevel);
646 if ( AC.insidelevel > 0 ) {
647 MesPrint(
" %d endinside statement(s) missing",AC.insidelevel);
650 if ( AC.inexprlevel > 0 ) {
651 MesPrint(
" %d endinexpression statement(s) missing",AC.inexprlevel);
654 if ( AC.NumLabels > 0 ) {
655 for ( i = 0; i < AC.NumLabels; i++ ) {
656 if ( AC.Labels[i] < 0 ) {
657 MesPrint(
" -->Label %s missing",AC.LabelNames[i]);
662 if ( AC.SwitchLevel > 0 ) {
663 MesPrint(
" %d endswitch statement(s) missing",AC.SwitchLevel);
666 if ( AC.dolooplevel > 0 ) {
667 MesPrint(
" %d enddo statement(s) missing",AC.dolooplevel);
670 if ( AP.OpenDictionary > 0 ) {
671 MesPrint(
" Dictionary %s has not been closed.",
672 AO.Dictionaries[AP.OpenDictionary-1]->name);
673 AP.OpenDictionary = 0;
676 if ( RetCode )
return(RetCode);
677 AR.Cnumlhs = cbuf[AM.rbufnum].numlhs;
679 if ( ( AS.ExecMode = par ) == GLOBALMODULE ) AS.ExecMode = 0;
688 if ( NumPotModdollars >= 0 ) {
689 for ( i = 0; i < NumExpressions; i++ ) {
690 if ( Expressions[i].partodo ) { AC.partodoflag = 1;
break; }
694 if ( AC.partodoflag > 0 && PF.numtasks < 3 ) {
698 if ( AC.partodoflag > 0 || ( NumPotModdollars > 0 && AC.mparallelflag == PARALLELFLAG ) ) {
699 if ( NumPotModdollars > NumModOptdollars ) {
700 AC.mparallelflag |= NOPARALLEL_DOLLAR;
702 AS.MultiThreaded = 0;
707 for ( i = 0; i < NumPotModdollars; i++ ) {
708 for ( j = 0; j < NumModOptdollars; j++ )
709 if ( PotModdollars[i] == ModOptdollars[j].number )
break;
710 if ( j >= NumModOptdollars ) {
711 AC.mparallelflag |= NOPARALLEL_DOLLAR;
713 AS.MultiThreaded = 0;
718 switch ( ModOptdollars[j].type ) {
725 AC.mparallelflag |= NOPARALLEL_DOLLAR;
726 AS.MultiThreaded = 0;
733 else if ( ( AC.mparallelflag & NOPARALLEL_USER ) != 0 ) {
735 AS.MultiThreaded = 0;
739 if ( AC.partodoflag == 0 ) {
740 for ( i = 0; i < NumExpressions; i++ ) {
741 Expressions[i].partodo = 0;
744 else if ( AC.partodoflag == -1 ) {
752 if ( AC.RhsExprInModuleFlag && (AC.mparallelflag == PARALLELFLAG || AC.partodoflag) ) {
753 if (PF.rhsInParallel) {
756 PF.slavebuf.PObuffer=(WORD *)Malloc1(AM.ScratSize*
sizeof(WORD),
"PF inbuf");
757 PF.slavebuf.POsize=AM.ScratSize*
sizeof(WORD);
758 PF.slavebuf.POfull = PF.slavebuf.POfill = PF.slavebuf.PObuffer;
759 PF.slavebuf.POstop= PF.slavebuf.PObuffer+AM.ScratSize;
760 PUTZERO(PF.slavebuf.POposition);
764 AC.mparallelflag |= NOPARALLEL_RHS;
766 for ( i = 0; i < NumExpressions; i++ ) {
767 Expressions[i].partodo = 0;
774 if ( (AC.mparallelflag == PARALLELFLAG || AC.partodoflag) && PF.me != MASTER ) {
775 for ( i = 0; i < NumModOptdollars; i++ ) {
776 if ( ModOptdollars[i].type == MODSUM ) {
777 DOLLARS d = Dollars + ModOptdollars[i].number;
779 if ( d->where && d->where != &AM.dollarzero ) M_free(d->where,
"old content of dollar");
780 d->where = &AM.dollarzero;
782 CleanDollarFactors(d);
787 AR.SortType = AC.SortType;
789 if ( PF.me == MASTER )
792 if ( AC.SetupFlag ) WriteSetup();
793 if ( AC.NamesFlag || AC.CodesFlag ) WriteLists();
795 if ( par == GLOBALMODULE ) MakeGlobal();
796 if ( RevertScratch() )
return(-1);
797 if ( AC.ncmod ) SetMods();
802 if ( PF.me == MASTER )
805 if ( !AC.ThreadsFlag || AC.mparallelflag & NOPARALLEL_USER ) {
808 else if ( AC.mparallelflag & NOPARALLEL_DOLLAR ) {
809 if ( AC.WarnFlag >= 1 ) {
812 s = strDup1((UBYTE *)
"",
"NOPARALLEL_DOLLAR s");
814 j = NumPotModdollars;
815 for ( i = 0; i < j; i++ ) {
816 for ( k = 0; k < NumModOptdollars; k++ )
817 if ( ModOptdollars[k].number == PotModdollars[i] )
break;
818 if ( k >= NumModOptdollars ) {
821 s = AddToString(s,(UBYTE *)
", ",0);
822 s = AddToString(s,(UBYTE *)
"$",0);
823 s = AddToString(s,DOLLARNAME(Dollars,PotModdollars[i]),0);
827 s1 = strDup1((UBYTE *)
"This module is forced to run in sequential mode due to $-variable",
"NOPARALLEL_DOLLAR s1");
829 s1 = AddToString(s1,(UBYTE *)
"s",0);
830 s1 = AddToString(s1,(UBYTE *)
": ",0);
831 s1 = AddToString(s1,s,0);
833 M_free(s,
"NOPARALLEL_DOLLAR s");
834 M_free(s1,
"NOPARALLEL_DOLLAR s1");
837 else if ( AC.mparallelflag & NOPARALLEL_RHS ) {
838 HighWarning(
"This module is forced to run in sequential mode due to RHS expression names");
840 else if ( AC.mparallelflag & NOPARALLEL_CONVPOLY ) {
841 HighWarning(
"This module is forced to run in sequential mode due to conversion to extra symbols");
843 else if ( AC.mparallelflag & NOPARALLEL_SPECTATOR ) {
844 HighWarning(
"This module is forced to run in sequential mode due to tospectator/copyspectator");
846 else if ( AC.mparallelflag & NOPARALLEL_TBLDOLLAR ) {
847 HighWarning(
"This module is forced to run in sequential mode due to $-variable assignments in tables");
849 else if ( AC.mparallelflag & NOPARALLEL_NPROC ) {
850 HighWarning(
"This module is forced to run in sequential mode because there is only one processor");
862 if ( AP.preError == 0 && (
Processor() || WriteAll() ) ) RetCode = -1;
869 if ( AC.ncmod ) UnSetMods();
870 AS.MultiThreaded = oldmultithreaded;
876 if ( NumPotModdollars > 0 ) {
878 if ( RetCode )
return RetCode;
880 if ( RetCode )
return RetCode;
883 if ( AC.topolynomialflag & TOPOLYNOMIALFLAG ) {
885 if ( RetCode )
return RetCode;
892 if ( RetCode )
return RetCode;
897 if ( PF.me != MASTER && AR.hidefile->PObuffer ) {
898 if ( AR.hidefile->handle >= 0 ) {
899 CloseFile(AR.hidefile->handle);
900 AR.hidefile->handle = -1;
901 remove(AR.hidefile->name);
903 AR.hidefile->POfull = AR.hidefile->POfill = AR.hidefile->PObuffer;
904 PUTZERO(AR.hidefile->POposition);
908 for ( j = 0; j < NumModOptdollars; j++ ) {
909 if ( ModOptdollars[j].dstruct ) {
915 if ( ModOptdollars[j].type == MODMAX || ModOptdollars[j].type == MODMIN ) {
916 const WORD globalnumber = ModOptdollars[j].number;
917 const DOLLARS gd = Dollars + globalnumber;
921 if ( gd->type == DOLZERO ) {
922 gd->type = DOLNUMBER;
923 if ( ! gd->where || gd->where == &(AM.dollarzero) ) {
925 gd->where = (WORD*)Malloc1(gd->size*
sizeof(WORD),
"dollar contents");
934 for ( i = 0; i < AM.totalnumberofthreads; i++ ) {
935 const DOLLARS ld = &(ModOptdollars[j].dstruct[i]);
938 if ( ld->type == DOLUNDEFINED )
continue;
940 if ( ld->type != DOLZERO && ld->type != DOLNUMBER ) {
941 MLOCK(ErrorMessageLock);
942 MesPrint(
"Illegal dollar variable type in MODMIN/MODMAX case: %d", ld->type);
943 MUNLOCK(ErrorMessageLock);
948 if ( ld->type == DOLZERO ) {
949 ld->type = DOLNUMBER;
950 if ( ! ld->where || ld->where == &(AM.dollarzero) ) {
952 ld->where = (WORD*)Malloc1(ld->size*
sizeof(WORD),
"dollar contents");
965 if ( gd->type == DOLUNDEFINED ) {
967 if ( ! gd->where || gd->where == &(AM.dollarzero) ) {
969 gd->where = (WORD*)Malloc1(gd->size*
sizeof(WORD),
"dollar contents");
971 for (
int v = 0; v < 5; v++ ) {
972 gd->where[v] = ld->where[v];
979 const WORD cmp =
CompCoef(gd->where, ld->where);
980 if ( ( ModOptdollars[j].type == MODMAX && cmp < 0 ) ||
981 ( ModOptdollars[j].type == MODMIN && cmp > 0 ) ) {
983 for (
int v = 0; v < 5; v++ ) {
984 gd->where[v] = ld->where[v];
986 if ( gd->where[4] != 0 ) {
989 MLOCK(ErrorMessageLock);
990 MesPrint(
"Missing trailing zero in MODMIN/MODMAX global dollar %d",
992 MUNLOCK(ErrorMessageLock);
999 if ( gd->where[1] == 0 ) {
1001 if ( gd->where && gd->where != &(AM.dollarzero) ) {
1002 M_free(gd->where,
"dollar contents");
1005 gd->where = &(AM.dollarzero);
1010 for ( i = 0; i < AM.totalnumberofthreads; i++ ) {
1011 if ( ModOptdollars[j].dstruct[i].size > 0 ) {
1012 CleanDollarFactors(&(ModOptdollars[j].dstruct[i]));
1013 if ( ModOptdollars[j].dstruct[i].where
1014 && ModOptdollars[j].dstruct[i].where != &(AM.dollarzero) ) {
1015 M_free(ModOptdollars[j].dstruct[i].where,
"Local dollar value");
1022 M_free(ModOptdollars[j].dstruct,
"Local DOLLARS");
1023 ModOptdollars[j].dstruct = 0;
1044 if ( ModOptdollars ) M_free(ModOptdollars,
"ModOptdollars pointer");
1045 if ( PotModdollars ) M_free(PotModdollars,
"PotModdollars pointer");
1048 AC.ModOptDolList.lijst = NULL;
1050 AC.PotModDolList.lijst = NULL;
1052 NumPotModdollars = 0;
1053 NumModOptdollars = 0;
1060if ( AC.SwitchInArray > 0 ) {
1061 for ( i = 0; i < AC.SwitchInArray; i++ ) {
1062 SWITCH *sw = AC.SwitchArray + i;
1063 if ( sw->table ) M_free(sw->table,
"Switch table");
1065 sw->defaultcase.ncase = 0;
1066 sw->defaultcase.value = 0;
1067 sw->defaultcase.compbuffer = 0;
1068 sw->endswitch.ncase = 0;
1069 sw->endswitch.value = 0;
1070 sw->endswitch.compbuffer = 0;
1081 AC.SwitchInArray = 0;
1085 AC.numpfirstnum = 0;
1088 AC.PolyRatFunChanged = 0;
1090 if ( par == STOREMODULE || par == CLEARMODULE ) {
1092 if ( par == STOREMODULE && PopVariables() ) RetCode = -1;
1093 if ( AR.infile->handle >= 0 ) {
1094 CloseFile(AR.infile->handle);
1095 remove(AR.infile->name);
1096 AR.infile->handle = -1;
1098 AR.infile->POfill = AR.infile->PObuffer;
1099 PUTZERO(AR.infile->POposition);
1100 AR.infile->POfull = AR.infile->PObuffer;
1101 if ( AR.outfile->handle >= 0 ) {
1102 CloseFile(AR.outfile->handle);
1103 remove(AR.outfile->name);
1104 AR.outfile->handle = -1;
1106 AR.outfile->POfull =
1107 AR.outfile->POfill = AR.outfile->PObuffer;
1108 PUTZERO(AR.outfile->POposition);
1109 if ( AR.hidefile->handle >= 0 ) {
1110 CloseFile(AR.hidefile->handle);
1111 remove(AR.hidefile->name);
1112 AR.hidefile->handle = -1;
1114 AR.hidefile->POfull =
1115 AR.hidefile->POfill = AR.hidefile->PObuffer;
1116 PUTZERO(AR.hidefile->POposition);
1118 if ( par == CLEARMODULE ) {
1119 if ( DeleteStore(0) < 0 ) {
1121 MesPrint(
"!>Cannot restart the storage file");
1128 AM.gProcessBucketSize = AM.hProcessBucketSize;
1129 AM.gparallelflag = PARALLELFLAG;
1130 AM.gnumextrasym = AM.ggnumextrasym;
1131 PruneExtraSymbols(AM.ggnumextrasym);
1134 ClearSpectators(par);
1137 if ( CleanExpr(0) ) RetCode = -1;
1138 if ( AC.DidClean ) CompactifyTree(AC.exprnames,EXPRNAMES);
1143 if ( AC.MultiBracketBuf != 0 ) {
1144 for ( i = 0; i < MAXMULTIBRACKETLEVELS; i++ ) {
1145 if ( AC.MultiBracketBuf[i] ) {
1146 M_free(AC.MultiBracketBuf[i],
"bracket buffer i");
1147 AC.MultiBracketBuf[i] = 0;
1150 AC.MultiBracketLevels = 0;
1151 M_free(AC.MultiBracketBuf,
"multi bracket buffer");
1152 AC.MultiBracketBuf = 0;
1155 if ( AC.SortReallocateFlag ) {
1159 M_free(S->lBuffer,
"SortReallocate lBuffer+sBuffer");
1160 S->lBuffer = Malloc1(
sizeof(*(S->lBuffer))*(S->LargeSize+S->SmallEsize),
"SortReallocate lBuffer+sBuffer");
1161 S->lTop = S->lBuffer+S->LargeSize;
1162 S->sBuffer = S->lTop;
1163 if ( S->LargeSize == 0 ) { S->lBuffer = 0; S->lTop = 0; }
1164 S->sTop = S->sBuffer + S->SmallSize;
1165 S->sTop2 = S->sBuffer + S->SmallEsize;
1166 S->sHalf = S->sBuffer + (LONG)((S->SmallSize+S->SmallEsize)>>1);
1170 UpdateSortBlocks(AM.totalnumberofthreads-1);
1174 for ( i = 1; i < AM.totalnumberofthreads; i++ ) {
1176 M_free(S->lBuffer,
"SortReallocate lBuffer+sBuffer");
1177 S->lBuffer = Malloc1(
sizeof(*(S->lBuffer))*(S->LargeSize+S->SmallEsize),
"SortReallocate lBuffer+sBuffer");
1178 S->lTop = S->lBuffer+S->LargeSize;
1179 S->sBuffer = S->lTop;
1180 if ( S->LargeSize == 0 ) { S->lBuffer = 0; S->lTop = 0; }
1181 S->sTop = S->sBuffer + S->SmallSize;
1182 S->sTop2 = S->sBuffer + S->SmallEsize;
1183 S->sHalf = S->sBuffer + (LONG)((S->SmallSize+S->SmallEsize)>>1);
1187 if ( AC.SortReallocateFlag == 2 ) {
1190 AC.SortReallocateFlag = 0;
1217int PutBracket(PHEAD WORD *termin)
1220 WORD *t, *t1, *b, i, j, *lastfun;
1222 WORD *bStop, *bb, *bf, *tStop;
1223 WORD *term1,*term2, *m1, *m2, *tStopa;
1224 WORD *bbb = 0, *bind, *binst = 0, bwild = 0, *bss = 0, *bns = 0, bset = 0;
1225 term1 = AT.WorkPointer+1;
1226 term2 = (WORD *)(((UBYTE *)(term1)) + AM.MaxTer);
1227 if ( ( (WORD *)(((UBYTE *)(term2)) + AM.MaxTer) ) > AT.WorkTop ) {
1230 if ( AR.BracketOn < 0 ) {
1231 t2 = term1; t1 = term2;
1234 t1 = term1; t2 = term2;
1236 b = AT.BrackBuf; bStop = b+*b; b++;
1237 while ( b < bStop ) {
1238 if ( *b == INDEX ) { bwild = 1; bbb = b+2; binst = b + b[1]; }
1239 if ( *b == SETSET ) { bset = 1; bss = b+2; bns = b + b[1]; }
1243 t = termin; tStopa = t + *t; i = *(t + *t -1); i = ABS(i);
1244 if ( AR.PolyFun && AT.PolyAct ) tStop = termin + AT.PolyAct;
1246 else if ( AT.FloatPos ) tStop = termin + AT.FloatPos;
1248 else tStop = tStopa - i;
1250 if ( AR.BracketOn < 0 ) {
1252 while ( t < tStop && *t >= FUNCTION
1253 && functions[*t-FUNCTION].commute ) {
1255 while ( b < bStop ) {
1258 while ( t < tStop && *t >= FUNCTION
1259 && functions[*t-FUNCTION].commute ) t += t[1];
1267 if ( b[1] == CFUNCTION ) {
1268 SETS set = Sets+b[0]; WORD i;
1269 for ( i = set->first; i < set->last; i++ ) {
1270 if ( SetElements[i] == *t ) {
1272 while ( t < tStop && *t >= FUNCTION
1273 && functions[*t-FUNCTION].commute ) t += t[1];
1281 if ( bwild && *t >= FUNCTION && functions[*t-FUNCTION].spec ) {
1286 while ( bind < binst ) {
1287 if ( *bind == *s2 ) {
1289 while ( t < tStop && *t >= FUNCTION
1290 && functions[*t-FUNCTION].commute ) t += t[1];
1303 while ( s1 < lastfun ) *t2++ = *s1++;
1304 while ( s1 < t ) *t1++ = *s1++;
1307 while ( s1 < t ) *t2++ = *s1++;
1313 while ( t < tStop && *t >= FUNCTION
1314 && functions[*t-FUNCTION].commute ) {
1316 while ( b < bStop ) {
1317 if ( *b == *t ) { lastfun = t + t[1];
goto NextNcom; }
1323 if ( b[1] == CFUNCTION ) {
1324 SETS set = Sets+b[0]; WORD i;
1325 for ( i = set->first; i < set->last; i++ ) {
1326 if ( SetElements[i] == *t ) {
1335 if ( bwild && *t >= FUNCTION && functions[*t-FUNCTION].spec ) {
1340 while ( bind < binst ) {
1341 if ( *bind == *s2 ) { lastfun = t + t[1];
goto NextNcom; }
1351 while ( s1 < lastfun ) *t1++ = *s1++;
1352 while ( s1 < t ) *t2++ = *s1++;
1357 b = AT.BrackBuf + 1;
1358 while ( b < bStop && *b >= FUNCTION
1359 && ( *b < FUNCTION || functions[*b-FUNCTION].commute ) ) {
1364 while ( t < tStop && ( bf < bStop || bwild || bset ) ) {
1366 while ( b < bStop && *b != *t ) { b += b[1]; }
1368 if ( *t >= FUNCTION ) {
1369 if ( b < bStop && *b == *t )
goto FunBrac;
1373 if ( b[1] == CFUNCTION ) {
1374 SETS set = Sets+b[0]; WORD i;
1375 for ( i = set->first; i < set->last; i++ ) {
1376 if ( SetElements[i] == *t )
goto FunBrac;
1382 if ( bwild && *t >= FUNCTION && functions[*t-FUNCTION].spec ) {
1387 while ( bind < binst ) {
1388 if ( *bind == *s2 )
goto FunBrac;
1396FunBrac: NCOPY(t1,t,i);
1402 if ( *t == DELTA ) {
1403 if ( b < bStop && *b == DELTA ) {
1407 else { NCOPY(t2,t,i); }
1409 else if ( *t == INDEX ) {
1412 *t1++ = *t; t1++; *t2++ = *t; t2++;
1416 while ( --j >= 0 ) {
1417 while ( *bind < *t && bind < binst ) bind++;
1418 if ( *bind == *t && bind < binst ) {
1423 while ( b3 < bns ) {
1424 if ( b3[1] == CVECTOR ) {
1425 SETS set = Sets+b3[0]; WORD i;
1426 for ( i = set->first; i < set->last; i++ ) {
1427 if ( SetElements[i] == *t ) {
1440 m1[1] = WORDDIF(t1,m1);
1441 if ( m1[1] == 2 ) t1 = m1;
1442 m2[1] = WORDDIF(t2,m2);
1443 if ( m2[1] == 2 ) t2 = m2;
1447 *t1++ = *t; t1++; *t2++ = *t; t2++;
1450 while ( --j >= 0 ) {
1452 while ( b3 < bns ) {
1453 if ( b3[1] == CVECTOR ) {
1454 SETS set = Sets+b3[0]; WORD i;
1455 for ( i = set->first; i < set->last; i++ ) {
1456 if ( SetElements[i] == *t ) {
1467 m1[1] = WORDDIF(t1,m1);
1468 if ( m1[1] == 2 ) t1 = m1;
1469 m2[1] = WORDDIF(t2,m2);
1470 if ( m2[1] == 2 ) t2 = m2;
1476 else if ( *t == VECTOR ) {
1477 if ( ( b < bStop && *b == VECTOR ) || bwild ) {
1478 if ( b < bStop && *b == VECTOR ) {
1479 bb = b + b[1]; b += 2;
1483 m1 = t1; m2 = t2; *t1++ = *t; *t2++ = *t; t1++; t2++; t += 2;
1486 while ( b < bb && ( *b < *t ||
1487 ( *b == *t && b[1] < t[1] ) ) ) b += 2;
1488 if ( b < bb && ( *t == *b && t[1] == b[1] ) ) {
1489 *t1++ = *t++; *t1++ = *t++;
goto nextvec;
1493 while ( bind < binst ) {
1494 if ( *t == *bind || t[1] == *bind ) {
1495 *t1++ = *t++; *t1++ = *t++;
1503 while ( b3 < bns ) {
1504 if ( b3[1] == CVECTOR ) {
1505 SETS set = Sets+b3[0]; WORD i;
1506 for ( i = set->first; i < set->last; i++ ) {
1507 if ( SetElements[i] == *t ) {
1508 *t1++ = *t++; *t1++ = *t++;
1516 *t2++ = *t++; *t2++ = *t++;
1519 m1[1] = WORDDIF(t1,m1);
1520 if ( m1[1] == 2 ) t1 = m1;
1521 m2[1] = WORDDIF(t2,m2);
1522 if ( m2[1] == 2 ) t2 = m2;
1525 m1 = t1; *t1++ = *t; t1++;
1526 m2 = t2; *t2++ = *t; t2++;
1530 while ( b3 < bns ) {
1531 if ( b3[1] == CVECTOR ) {
1532 SETS set = Sets+b3[0]; WORD i;
1533 for ( i = set->first; i < set->last; i++ ) {
1534 if ( SetElements[i] == *t ) {
1535 *t1++ = *t++; *t1++ = *t++;
1542 *t2++ = *t++; *t2++ = *t++;
1545 m1[1] = WORDDIF(t1,m1);
1546 if ( m1[1] == 2 ) t1 = m1;
1547 m2[1] = WORDDIF(t2,m2);
1548 if ( m2[1] == 2 ) t2 = m2;
1554 else if ( *t == DOTPRODUCT ) {
1555 if ( ( b < bStop && *b == *t ) || bwild ) {
1556 m1 = t1; *t1++ = *t; t1++;
1557 m2 = t2; *t2++ = *t; t2++;
1558 if ( b >= bStop || *b != *t ) { bb = b; s1 = b; }
1560 s1 = b + b[1]; bb = b + 2;
1563 while ( t < s2 && ( bb < s1 || bwild || bset ) ) {
1564 while ( bb < s1 && ( *bb < *t ||
1565 ( *bb == *t && bb[1] < t[1] ) ) ) bb += 3;
1566 if ( bb < s1 && *bb == *t && bb[1] == t[1] ) {
1567 *t1++ = *t++; *t1++ = *t++; *t1++ = *t++; bb += 3;
1572 while ( bind < binst ) {
1573 if ( *bind == *t || *bind == t[1] ) {
1574 *t1++ = *t++; *t1++ = *t++; *t1++ = *t++;
1582 while ( b3 < bns ) {
1583 if ( b3[1] == CVECTOR ) {
1584 SETS set = Sets+b3[0]; WORD i;
1585 for ( i = set->first; i < set->last; i++ ) {
1586 if ( SetElements[i] == *t || SetElements[i] == t[1] ) {
1587 *t1++ = *t++; *t1++ = *t++; *t1++ = *t++;
1595 *t2++ = *t++; *t2++ = *t++; *t2++ = *t++;
1598 while ( t < s2 ) *t2++ = *t++;
1599 m1[1] = WORDDIF(t1,m1);
1600 if ( m1[1] == 2 ) t1 = m1;
1601 m2[1] = WORDDIF(t2,m2);
1602 if ( m2[1] == 2 ) t2 = m2;
1605 m1 = t1; *t1++ = *t; t1++;
1606 m2 = t2; *t2++ = *t; t2++;
1610 while ( b3 < bns ) {
1611 if ( b3[1] == CVECTOR ) {
1612 SETS set = Sets+b3[0]; WORD i;
1613 for ( i = set->first; i < set->last; i++ ) {
1614 if ( SetElements[i] == *t || SetElements[i] == t[1] ) {
1615 *t1++ = *t++; *t1++ = *t++; *t1++ = *t++;
1622 *t2++ = *t++; *t2++ = *t++; *t2++ = *t++;
1625 m1[1] = WORDDIF(t1,m1);
1626 if ( m1[1] == 2 ) t1 = m1;
1627 m2[1] = WORDDIF(t2,m2);
1628 if ( m2[1] == 2 ) t2 = m2;
1630 else { NCOPY(t2,t,i); }
1632 else if ( *t == SYMBOL ) {
1633 if ( b < bStop && *b == *t ) {
1634 m1 = t1; *t1++ = *t; t1++;
1635 m2 = t2; *t2++ = *t; t2++;
1636 s1 = b + b[1]; bb = b+2;
1638 while ( bb < s1 && t < s2 ) {
1639 while ( bb < s1 && *bb < *t ) bb += 2;
1641 if ( bset )
goto TrySymbolSet;
1644 if ( *bb == *t ) { *t1++ = *t++; *t1++ = *t++; }
1649 while ( bbb < bns ) {
1650 if ( bbb[1] == CSYMBOL ) {
1651 SETS set = Sets+bbb[0]; WORD i;
1652 for ( i = set->first; i < set->last; i++ ) {
1653 if ( SetElements[i] == *t ) {
1654 *t1++ = *t++; *t1++ = *t++;
1661 *t2++ = *t++; *t2++ = *t++;
1663 else { *t2++ = *t++; *t2++ = *t++; }
1666 while ( t < s2 ) *t2++ = *t++;
1667 m1[1] = WORDDIF(t1,m1);
1668 if ( m1[1] == 2 ) t1 = m1;
1669 m2[1] = WORDDIF(t2,m2);
1670 if ( m2[1] == 2 ) t2 = m2;
1674 m1 = t1; *t1++ = *t; t1++;
1675 m2 = t2; *t2++ = *t; t2++;
1679 while ( bbb < bns ) {
1680 if ( bbb[1] == CSYMBOL ) {
1681 SETS set = Sets+bbb[0]; WORD i;
1682 for ( i = set->first; i < set->last; i++ ) {
1683 if ( SetElements[i] == *t ) {
1684 *t1++ = *t++; *t1++ = *t++;
1691 *t2++ = *t++; *t2++ = *t++;
1694 m1[1] = WORDDIF(t1,m1);
1695 if ( m1[1] == 2 ) t1 = m1;
1696 m2[1] = WORDDIF(t2,m2);
1697 if ( m2[1] == 2 ) t2 = m2;
1699 else { NCOPY(t2,t,i); }
1705 if ( ( i = WORDDIF(tStop,t) ) > 0 ) NCOPY(t2,t,i);
1706 if ( AR.BracketOn < 0 ) {
1707 s1 = t1; t1 = t2; t2 = s1;
1709 do { *t2++ = *t++; }
while ( t < (WORD *)tStopa );
1711 i = WORDDIF(t1,term1);
1712 *t++ = 4 + i + WORDDIF(t2,term2);
1717 i = WORDDIF(t2,term2);
1719 if ( i > 0 ) NCOPY(t,t1,i);
1731void SpecialCleanup(PHEAD0)
1734 if ( AT.previousEfactor ) M_free(AT.previousEfactor,
"Efactor cache");
1735 AT.previousEfactor = 0;
1748 if ( AN.cmod != 0 ) M_free(AN.cmod,
"AN.cmod");
1750 AN.cmod = (UWORD *)Malloc1(
sizeof(WORD)*n,
"AN.cmod");
1751 for ( i = 0; i < n; i++ ) AN.cmod[i] = AC.cmod[i];
1765 if ( AN.cmod != 0 ) M_free(AN.cmod,
"AN.cmod");
1778void ExchangeExpressions(
int num1,
int num2)
1781 WORD node1, node2, namesize, TMproto[SUBEXPSIZE];
1787 e1 = Expressions + num1;
1788 e2 = Expressions + num2;
1791 AC.exprnames->namenode[node1].number = num2;
1792 AC.exprnames->namenode[node2].number = num1;
1793 a = e1->name; e1->name = e2->name; e2->name = a;
1794 namesize = e1->namesize; e1->namesize = e2->namesize; e2->namesize = namesize;
1797 if ( e1->status == STOREDEXPRESSION ) {
1801 TMproto[0] = EXPRESSION;
1802 TMproto[1] = SUBEXPSIZE;
1805 {
int ie;
for ( ie = 4; ie < SUBEXPSIZE; ie++ ) TMproto[ie] = 0; }
1806 AT.TMaddr = TMproto;
1807 ind = FindInIndex(num1,&AR.StoreData,0,0);
1808 s1 = (SBYTE *)(AC.exprnames->namebuffer+e1->name);
1813 SeekFile(AR.StoreData.Handle,&(e1->onfile),SEEK_SET);
1814 if ( WriteFile(AR.StoreData.Handle,(UBYTE *)ind,
1817 MesPrint(
"!>File error while exchanging expressions");
1821 FlushFile(AR.StoreData.Handle);
1823 if ( e2->status == STOREDEXPRESSION ) {
1827 TMproto[0] = EXPRESSION;
1828 TMproto[1] = SUBEXPSIZE;
1831 {
int ie;
for ( ie = 4; ie < SUBEXPSIZE; ie++ ) TMproto[ie] = 0; }
1832 AT.TMaddr = TMproto;
1833 ind = FindInIndex(num1,&AR.StoreData,0,0);
1834 s1 = (SBYTE *)(AC.exprnames->namebuffer+e2->name);
1839 SeekFile(AR.StoreData.Handle,&(e2->onfile),SEEK_SET);
1840 if ( WriteFile(AR.StoreData.Handle,(UBYTE *)ind,
1843 MesPrint(
"!>File error while exchanging expressions");
1847 FlushFile(AR.StoreData.Handle);
1856int GetFirstBracket(WORD *term,
int num)
1867 WORD type, *oldcomppointer, oldonefile, numword;
1870 oldcomppointer = AR.CompressPointer;
1871 type = Expressions[num].status;
1872 if ( type == STOREDEXPRESSION ) {
1873 WORD TMproto[SUBEXPSIZE];
1874 TMproto[0] = EXPRESSION;
1875 TMproto[1] = SUBEXPSIZE;
1878 {
int ie;
for ( ie = 4; ie < SUBEXPSIZE; ie++ ) TMproto[ie] = 0; }
1879 AT.TMaddr = TMproto;
1881 if ( ( renumber = GetTable(num,&position,0) ) == 0 ) {
1882 MesCall(
"GetFirstBracket");
1885 if ( GetFromStore(term,&position,renumber,&numword,num) < 0 ) {
1886 MesCall(
"GetFirstBracket");
1892 if ( renumber->
symb.
lo != AN.dummyrenumlist )
1893 M_free(renumber->
symb.
lo,
"VarSpace");
1894 M_free(renumber,
"Renumber");
1900 oldonefile = AR.GetOneFile;
1901 if ( type == HIDDENLEXPRESSION || type == HIDDENGEXPRESSION ) {
1902 AR.GetOneFile = 2; fi = AR.hidefile;
1905 AR.GetOneFile = 0; fi = AR.infile;
1908 PUTZERO(oldposition);
1914 SETBASEPOSITION(oldposition,fi->POfill-fi->PObuffer);
1916 position = AS.OldOnFile[num];
1917 if ( GetOneTerm(BHEAD term,fi,&position,1) < 0
1918 || ( GetOneTerm(BHEAD term,fi,&position,1) < 0 ) ) {
1919 MLOCK(ErrorMessageLock);
1920 MesCall(
"GetFirstBracket");
1921 MUNLOCK(ErrorMessageLock);
1936 fi->POfill = fi->PObuffer+BASEPOSITION(oldposition);
1938 AR.GetOneFile = oldonefile;
1940 AR.CompressPointer = oldcomppointer;
1942 tstop = term + *term; tstop -= ABS(tstop[-1]);
1944 while ( t < tstop ) {
1945 if ( *t == HAAKJE )
break;
1949 term[0] = 4; term[1] = 1; term[2] = 1; term[3] = 3;
1952 *t++ = 1; *t++ = 1; *t++ = 3; *term = t - term;
1956 term[0] = 4; term[1] = 1; term[2] = 1; term[3] = 3;
1981 WORD type, *oldcomppointer, oldonefile, numword;
1983 oldcomppointer = AR.CompressPointer;
1984 type = Expressions[num].status;
1985 if ( type == STOREDEXPRESSION ) {
1986 WORD TMproto[SUBEXPSIZE];
1987 TMproto[0] = EXPRESSION;
1988 TMproto[1] = SUBEXPSIZE;
1991 {
int ie;
for ( ie = 4; ie < SUBEXPSIZE; ie++ ) TMproto[ie] = 0; }
1992 AT.TMaddr = TMproto;
1994 if ( ( renumber = GetTable(num,&position,0) ) == 0 ) {
1995 MesCall(
"GetFirstTerm");
1998 if ( GetFromStore(term,&position,renumber,&numword,num) < 0 ) {
1999 MesCall(
"GetFirstTerm");
2005 if ( renumber->
symb.
lo != AN.dummyrenumlist )
2006 M_free(renumber->
symb.
lo,
"VarSpace");
2007 M_free(renumber,
"Renumber");
2013 oldonefile = AR.GetOneFile;
2014 if ( type == HIDDENLEXPRESSION || type == HIDDENGEXPRESSION ) {
2015 AR.GetOneFile = 2; fi = AR.hidefile;
2019 if ( Expressions[num].replace == NEWLYDEFINEDEXPRESSION ) {
2023 if ( pre == 0 ) { fi = AR.outfile; }
2027 MesPrint(
"&isnumerical: expression is not yet defined!");
2034 if ( pre == 0 ) { fi = AR.infile; }
2038 else { fi = AR.outfile; }
2042 PUTZERO(oldposition);
2048 SETBASEPOSITION(oldposition,fi->POfill-fi->PObuffer);
2050 position = AS.OldOnFile[num];
2051 if ( GetOneTerm(BHEAD term,fi,&position,1) < 0
2052 || ( GetOneTerm(BHEAD term,fi,&position,1) < 0 ) ) {
2053 MLOCK(ErrorMessageLock);
2054 MesCall(
"GetFirstTerm");
2055 MUNLOCK(ErrorMessageLock);
2070 fi->POfill = fi->PObuffer+BASEPOSITION(oldposition);
2072 AR.GetOneFile = oldonefile;
2074 AR.CompressPointer = oldcomppointer;
2083int GetContent(WORD *content,
int num)
2098 WORD type, *oldcomppointer, oldonefile, numword, *term, i;
2099 WORD *cbuffer = TermMalloc(
"GetContent");
2100 WORD *oldworkpointer = AT.WorkPointer;
2102 oldcomppointer = AR.CompressPointer;
2103 type = Expressions[num].status;
2104 if ( type == STOREDEXPRESSION ) {
2105 WORD TMproto[SUBEXPSIZE];
2106 TMproto[0] = EXPRESSION;
2107 TMproto[1] = SUBEXPSIZE;
2110 {
int ie;
for ( ie = 4; ie < SUBEXPSIZE; ie++ ) TMproto[ie] = 0; }
2111 AT.TMaddr = TMproto;
2113 if ( ( renumber = GetTable(num,&position,0) ) == 0 )
goto CalledFrom;
2114 if ( GetFromStore(cbuffer,&position,renumber,&numword,num) < 0 )
goto CalledFrom;
2116 term = oldworkpointer;
2117 AR.CompressPointer = oldcomppointer;
2118 if ( GetFromStore(term,&position,renumber,&numword,num) < 0 )
goto CalledFrom;
2119 if ( *term == 0 )
break;
2123 if ( ContentMerge(BHEAD cbuffer,term) < 0 )
goto CalledFrom;
2128 if ( renumber->
symb.
lo != AN.dummyrenumlist )
2129 M_free(renumber->
symb.
lo,
"VarSpace");
2130 M_free(renumber,
"Renumber");
2136 oldonefile = AR.GetOneFile;
2137 if ( type == HIDDENLEXPRESSION || type == HIDDENGEXPRESSION ) {
2138 AR.GetOneFile = 2; fi = AR.hidefile;
2142 if ( Expressions[num].replace == NEWLYDEFINEDEXPRESSION )
2144 else fi = AR.infile;
2147 PUTZERO(oldposition);
2153 SETBASEPOSITION(oldposition,fi->POfill-fi->PObuffer);
2155 position = AS.OldOnFile[num];
2156 if ( GetOneTerm(BHEAD cbuffer,fi,&position,1) < 0 )
goto CalledFrom;
2157 AR.CompressPointer = oldcomppointer;
2158 if ( GetOneTerm(BHEAD cbuffer,fi,&position,1) < 0 )
goto CalledFrom;
2167 term = oldworkpointer;
2168 AR.CompressPointer = oldcomppointer;
2169 if ( GetOneTerm(BHEAD term,fi,&position,1) < 0 )
goto CalledFrom;
2170 if ( *term == 0 )
break;
2174 if ( ContentMerge(BHEAD cbuffer,term) < 0 )
goto CalledFrom;
2177 fi->POfill = fi->PObuffer+BASEPOSITION(oldposition);
2179 AR.GetOneFile = oldonefile;
2181 AR.CompressPointer = oldcomppointer;
2182 for ( i = 0; i < *cbuffer; i++ ) content[i] = cbuffer[i];
2183 TermFree(cbuffer,
"GetContent");
2184 AT.WorkPointer = oldworkpointer;
2187 MLOCK(ErrorMessageLock);
2188 MesCall(
"GetContent");
2189 MUNLOCK(ErrorMessageLock);
2200int CleanupTerm(WORD *term)
2202 WORD *tstop, *t, *tfill, *tt;
2203 GETSTOP(term,tstop);
2205 while ( t < tstop ) {
2206 if ( *t >= FUNCTION && ( functions[*t-FUNCTION].commute || *t == DENOMINATOR ) ) {
2207 tfill = t; tt = t + t[1]; tstop = term + *term;
2208 while ( tt < tstop ) *tfill++ = *tt++;
2209 *term = tfill - term;
2210 tstop -= ABS(tfill[-1]);
2224WORD ContentMerge(PHEAD WORD *content, WORD *term)
2227 WORD *cstop, csize, crsize, sign = 1, numsize, densize, i, tnsize, tdsize;
2228 UWORD *num, *den, *tnum, *tden;
2229 WORD *outfill, *outb = TermMalloc(
"ContentMerge"), *ct;
2230 WORD *t, *tstop, tsize, trsize, *told;
2231 WORD *t1, *t2, *c1, *c2, i1, i2, *out1;
2232 WORD didsymbol = 0, diddotp = 0, tfirst;
2233 cstop = content + *content;
2235 if ( csize < 0 ) { sign = -sign; csize = -csize; }
2237 numsize = densize = crsize = (csize-1)/2;
2238 num = NumberMalloc(
"ContentMerge");
2239 den = NumberMalloc(
"ContentMerge");
2240 for ( i = 0; i < numsize; i++ ) num[i] = (UWORD)(cstop[i]);
2241 for ( i = 0; i < densize; i++ ) den[i] = (UWORD)(cstop[i+crsize]);
2242 while ( num[numsize-1] == 0 ) numsize--;
2243 while ( den[densize-1] == 0 ) densize--;
2247 tstop = term + *term;
2249 if ( tsize < 0 ) tsize = -tsize;
2251 tstop = tstop - tsize;
2252 tnsize = tdsize = trsize = (tsize-1)/2;
2253 tnum = (UWORD *)tstop; tden = (UWORD *)(tstop + trsize);
2254 while ( tnum[tnsize-1] == 0 ) tnsize--;
2255 while ( tden[tdsize-1] == 0 ) tdsize--;
2256 GcdLong(BHEAD num, numsize, tnum, tnsize, num, &numsize);
2257 if ( LcmLong(BHEAD den, densize, tden, tdsize, den, &densize) )
goto CalledFrom;
2261 while ( ct < cstop ) {
2266 while ( t < tstop && *t != *ct ) t += t[1];
2267 if ( t >= tstop )
break;
2268 t1 = t+2; t2 = t+t[1];
2269 c1 = ct+2; c2 = ct+ct[1];
2270 out1 = outfill; *outfill++ = *ct; outfill++;
2271 while ( c1 < c2 && t1 < t2 ) {
2273 if ( t1[1] <= c1[1] ) {
2274 *outfill++ = *t1++; *outfill++ = *t1++;
2278 *outfill++ = *c1++; *outfill++ = *c1++;
2282 else if ( *c1 < *t1 ) {
2284 *outfill++ = *c1++; *outfill++ = *c1++;
2290 *outfill++ = *t1++; *outfill++ = *t1++;
2296 if ( c1[1] < 0 ) { *outfill++ = c1[0]; *outfill++ = c1[1]; }
2300 if ( t1[1] < 0 ) { *outfill++ = t1[0]; *outfill++ = t1[1]; }
2303 out1[1] = outfill - out1;
2304 if ( out1[1] == 2 ) outfill = out1;
2309 while ( t < tstop && *t != *ct ) t += t[1];
2310 if ( t >= tstop )
break;
2311 t1 = t+2; t2 = t+t[1];
2312 c1 = ct+2; c2 = ct+ct[1];
2313 out1 = outfill; *outfill++ = *ct; outfill++;
2314 while ( c1 < c2 && t1 < t2 ) {
2315 if ( *c1 == *t1 && c1[1] == t1[1] ) {
2316 if ( t1[2] <= c1[2] ) {
2317 *outfill++ = *t1++; *outfill++ = *t1++; *outfill++ = *t1++;
2321 *outfill++ = *c1++; *outfill++ = *c1++; *outfill++ = *c1++;
2325 else if ( *c1 < *t1 || ( *c1 == *t1 && c1[1] < t1[1] ) ) {
2327 *outfill++ = *c1++; *outfill++ = *c1++; *outfill++ = *c1++;
2333 *outfill++ = *t1++; *outfill++ = *t1++; *outfill++ = *t1++;
2339 if ( c1[2] < 0 ) { *outfill++ = c1[0]; *outfill++ = c1[1]; *outfill++ = c1[1]; }
2343 if ( t1[2] < 0 ) { *outfill++ = t1[0]; *outfill++ = t1[1]; *outfill++ = t1[1]; }
2346 out1[1] = outfill - out1;
2347 if ( out1[1] == 2 ) outfill = out1;
2351 while ( t < tstop && *t != *ct ) t += t[1];
2352 if ( t >= tstop )
break;
2353 t1 = t+2; t2 = t+t[1];
2354 c1 = ct+2; c2 = ct+ct[1];
2355 out1 = outfill; *outfill++ = *ct; outfill++;
2356 while ( c1 < c2 && t1 < t2 ) {
2361 else if ( *c1 < *t1 ) { c1 += 1; }
2364 out1[1] = outfill - out1;
2365 if ( out1[1] == 2 ) outfill = out1;
2370 while ( t < tstop && *t != *ct ) t += t[1];
2371 if ( t >= tstop )
break;
2372 t1 = t+2; t2 = t+t[1];
2373 c1 = ct+2; c2 = ct+ct[1];
2374 out1 = outfill; *outfill++ = *ct; outfill++;
2375 while ( c1 < c2 && t1 < t2 ) {
2376 if ( *c1 == *t1 && c1[1] && t1[1] ) {
2377 *outfill++ = *c1++; *outfill++ = *c1++;
2380 else if ( *c1 < *t1 || ( *c1 == *t1 && c1[1] < t1[1] ) ) {
2387 out1[1] = outfill - out1;
2388 if ( out1[1] == 2 ) outfill = out1;
2394 while ( t < tstop ) {
2395 if ( *t != *ct ) { t += t[1];
continue; }
2396 if ( ct[1] != t[1] ) { t += t[1];
continue; }
2397 if ( ct[2] != t[2] ) { t += t[1];
continue; }
2398 t1 = t; t2 = ct; i1 = t1[1]; i2 = t2[1];
2400 if ( *t1 != *t2 )
break;
2403 if ( i1 != 0 ) { t += t[1];
continue; }
2405 for ( i = 0; i < i2; i++ ) { *outfill++ = *t++; }
2409 t1[2] |= SUBTERMUSED1;
2410 ct[2] |= SUBTERMUSED2;
2418 if ( diddotp == 0 ) {
2419 t = term+1;
while ( t < tstop && *t != DOTPRODUCT ) t += t[1];
2421 tfirst = 1; told = outfill;
2422 for ( i = 2; i < t[1]; i += 3 ) {
2424 if ( tfirst ) { *outfill++ = DOTPRODUCT; *outfill++ = 0; tfirst = 0; }
2425 *outfill++ = t[i]; *outfill++ = t[i+1]; *outfill++ = t[i+2];
2428 if ( outfill > told ) told[1] = outfill-told;
2431 if ( didsymbol == 0 ) {
2432 t = term+1;
while ( t < tstop && *t != SYMBOL ) t += t[1];
2434 tfirst = 1; told = outfill;
2435 for ( i = 2; i < t[1]; i += 2 ) {
2437 if ( tfirst ) { *outfill++ = SYMBOL; *outfill++ = 0; tfirst = 0; }
2438 *outfill++ = t[i]; *outfill++ = t[i+1];
2441 if ( outfill > told ) told[1] = outfill-told;
2447 if ( numsize < densize ) {
2448 for ( i = numsize; i < densize; i++ ) num[i] = 0;
2451 else if ( densize < numsize ) {
2452 for ( i = densize; i < numsize; i++ ) den[i] = 0;
2455 for ( i = 0; i < numsize; i++ ) *outfill++ = num[i];
2456 for ( i = 0; i < densize; i++ ) *outfill++ = den[i];
2457 csize = numsize+densize+1;
2458 if ( sign < 0 ) csize = -csize;
2460 *outb = outfill-outb;
2461 NumberFree(den,
"ContentMerge");
2462 NumberFree(num,
"ContentMerge");
2463 for ( i = 0; i < *outb; i++ ) content[i] = outb[i];
2464 TermFree(outb,
"ContentMerge");
2471 while ( t < tstop ) {
2472 if ( *t >= FUNCTION ) t[2] &= ~SUBTERMUSED1;
2477 MLOCK(ErrorMessageLock);
2478 MesCall(
"GetContent");
2479 MUNLOCK(ErrorMessageLock);
2488LONG TermsInExpression(WORD num)
2490 LONG x = Expressions[num].counter;
2491 if ( x >= 0 )
return(x);
2500LONG SizeOfExpression(WORD num)
2502 LONG x = (LONG)(DIVPOS(Expressions[num].size,
sizeof(WORD)));
2503 if ( x >= 0 )
return(x);
2512void UpdatePositions(
void)
2518 if ( NumExpressions > 0 &&
2519 ( AS.OldOnFile == 0 || AS.NumOldOnFile < NumExpressions ) ) {
2520 if ( AS.OldOnFile ) {
2522 AS.OldOnFile = (
POSITION *)Malloc1(NumExpressions*
sizeof(
POSITION),
"file pointers");
2523 for ( i = 0; i < AS.NumOldOnFile; i++ ) AS.OldOnFile[i] = old[i];
2524 AS.NumOldOnFile = NumExpressions;
2525 M_free(old,
"process file pointers");
2528 AS.OldOnFile = (
POSITION *)Malloc1(NumExpressions*
sizeof(
POSITION),
"file pointers");
2529 AS.NumOldOnFile = NumExpressions;
2532 if ( NumExpressions > 0 &&
2533 ( AS.OldNumFactors == 0 || AS.NumOldNumFactors < NumExpressions ) ) {
2534 if ( AS.OldNumFactors ) {
2535 oldw = AS.OldNumFactors;
2536 AS.OldNumFactors = (WORD *)Malloc1(NumExpressions*
sizeof(WORD),
"numfactors pointers");
2537 for ( i = 0; i < AS.NumOldNumFactors; i++ ) AS.OldNumFactors[i] = oldw[i];
2538 M_free(oldw,
"numfactors pointers");
2539 oldw = AS.Oldvflags;
2540 AS.Oldvflags = (WORD *)Malloc1(NumExpressions*
sizeof(WORD),
"vflags pointers");
2541 for ( i = 0; i < AS.NumOldNumFactors; i++ ) AS.Oldvflags[i] = oldw[i];
2542 M_free(oldw,
"vflags pointers");
2543 oldw = AS.Olduflags;
2544 AS.Olduflags = (WORD *)Malloc1(NumExpressions*
sizeof(WORD),
"uflags pointers");
2545 for ( i = 0; i < AS.NumOldNumFactors; i++ ) AS.Olduflags[i] = oldw[i];
2546 M_free(oldw,
"uflags pointers");
2547 AS.NumOldNumFactors = NumExpressions;
2550 AS.OldNumFactors = (WORD *)Malloc1(NumExpressions*
sizeof(WORD),
"numfactors pointers");
2551 AS.Oldvflags = (WORD *)Malloc1(NumExpressions*
sizeof(WORD),
"vflags pointers");
2552 AS.Olduflags = (WORD *)Malloc1(NumExpressions*
sizeof(WORD),
"uflags pointers");
2553 AS.NumOldNumFactors = NumExpressions;
2556 for ( i = 0; i < NumExpressions; i++ ) {
2557 AS.OldOnFile[i] = e[i].onfile;
2558 AS.OldNumFactors[i] = e[i].numfactors;
2559 AS.Oldvflags[i] = e[i].vflags;
2560 AS.Olduflags[i] = e[i].uflags;
2572LONG CountTerms1(PHEAD0)
2575 POSITION oldposition, startposition;
2576 WORD *t, *m, *mstop, decr, i, *oldwork, retval;
2577 WORD *oldipointer = AR.CompressPointer;
2578 WORD oldGetOneFile = AR.GetOneFile, olddeferflag = AR.DeferFlag;
2581 oldwork = AT.WorkPointer;
2582 AT.WorkPointer = (WORD *)(((UBYTE *)(AT.WorkPointer)) + AM.MaxTer);
2584 startposition = AR.DefPosition;
2588 if ( AR.infile->handle >= 0 ) {
2589 PUTZERO(oldposition);
2595 SETBASEPOSITION(oldposition,AR.infile->POfill-AR.infile->PObuffer);
2596 AR.infile->POfill = (WORD *)((UBYTE *)(AR.infile->PObuffer)
2597 +BASEPOSITION(startposition));
2602 t = m = AR.CompressBuffer;
2604 mstop = t - ABS(t[-1]);
2606 while ( *m != HAAKJE && m < mstop ) m += m[1];
2609 AR.DeferFlag = olddeferflag;
2610 AT.WorkPointer = oldwork;
2611 AR.GetOneFile = oldGetOneFile;
2615 decr = WORDDIF(mstop,AR.CompressBuffer)-1;
2617 m = AR.CompressBuffer;
2618 t = AR.CompressPointer;
2630 AR.CompressPointer = oldipointer;
2633 retval = GetOneTerm(BHEAD AT.WorkPointer,AR.infile,&startposition,0);
2634 if ( retval >= 0 ) AR.CompressPointer = oldipointer;
2635 if ( retval <= 0 )
break;
2636 t = AR.CompressPointer;
2637 if ( *t < (1 + decr + ABS(*(t+*t-1))) )
break;
2639 m = AR.CompressBuffer+1;
2640 while ( m < mstop ) {
2641 if ( *m != *t )
goto Thatsit;
2649 AT.WorkPointer = oldwork;
2650 if ( AR.infile->handle >= 0 ) {
2656 AR.infile->POfill = AR.infile->PObuffer + BASEPOSITION(oldposition);
2658 AR.DeferFlag = olddeferflag;
2659 AR.GetOneFile = oldGetOneFile;
2675#define CURRENTBRACKET 1
2676#define BRACKETCURRENTEXPR 2
2677#define BRACKETOTHEREXPR 3
2678#define NOBRACKETACTIVE 4
2680LONG TermsInBracket(PHEAD WORD *term, WORD level)
2682 WORD *t, *tstop, *b, *tt, *n1, *n2;
2683 int type = 0, i, num;
2685 WORD *bracketbuffer = AT.WorkPointer;
2686 t = term; GETSTOP(t,tstop);
2687 t++; b = bracketbuffer;
2688 while ( t < tstop ) {
2689 if ( *t != TERMSINBRACKET ) { t += t[1];
continue; }
2690 if ( t[1] == FUNHEAD || (
2692 && t[FUNHEAD] == -SNUMBER
2693 && t[FUNHEAD+1] == 0
2695 if ( AC.ComDefer == 0 ) {
2696 type = NOBRACKETACTIVE;
2699 type = CURRENTBRACKET;
2704 if ( t[FUNHEAD] == -EXPRESSION ) {
2705 if ( t[FUNHEAD+2] < 0 ) {
2706 if ( ( t[FUNHEAD+2] <= -FUNCTION ) && ( t[1] == FUNHEAD+3 ) ) {
2707 type = BRACKETOTHEREXPR;
2708 *b++ = FUNHEAD+4; *b++ = -t[FUNHEAD+2]; *b++ = FUNHEAD;
2709 for ( i = 2; i < FUNHEAD; i++ ) *b++ = 0;
2710 *b++ = 1; *b++ = 1; *b++ = 3;
2713 else if ( ( t[FUNHEAD+2] > -FUNCTION ) && ( t[1] == FUNHEAD+4 ) ) {
2714 type = BRACKETOTHEREXPR;
2718 *b++ = 8; *b++ = SYMBOL; *b++ = 4; *b++ = tt[1];
2719 *b++ = 1; *b++ = 1; *b++ = 1; *b++ = 3;
2723 *b++ = 4; *b++ = 1; *b++ = 1; *b++ = 3;
2725 else goto IllBraReq;
2733 else if ( ( t[FUNHEAD+2] == (t[1]-FUNHEAD-2) ) &&
2734 ( t[FUNHEAD+2+ARGHEAD] == (t[FUNHEAD+2]-ARGHEAD) ) ) {
2735 type = BRACKETOTHEREXPR;
2736 tt = t + FUNHEAD + ARGHEAD; num = *tt;
2737 for ( i = 0; i < num; i++ ) *b++ = *tt++;
2742 if ( t[FUNHEAD] < 0 ) {
2743 if ( ( t[FUNHEAD] <= -FUNCTION ) && ( t[1] == FUNHEAD+1 ) ) {
2744 type = BRACKETCURRENTEXPR;
2745 *b++ = FUNHEAD+4; *b++ = -t[FUNHEAD+2]; *b++ = FUNHEAD;
2746 for ( i = 2; i < FUNHEAD; i++ ) *b++ = 0;
2747 *b++ = 1; *b++ = 1; *b++ = 3; *b = 0;
2750 else if ( ( t[FUNHEAD] > -FUNCTION ) && ( t[1] == FUNHEAD+2 ) ) {
2751 type = BRACKETCURRENTEXPR;
2755 *b++ = 8; *b++ = SYMBOL; *b++ = 4; *b++ = tt[1];
2756 *b++ = 1; *b++ = 1; *b++ = 1; *b++ = 3;
2760 *b++ = 4; *b++ = 1; *b++ = 1; *b++ = 3;
2762 else goto IllBraReq;
2770 else if ( ( t[FUNHEAD] == (t[1]-FUNHEAD) ) &&
2771 ( t[FUNHEAD+ARGHEAD] == (t[FUNHEAD]-ARGHEAD) ) ) {
2772 type = BRACKETCURRENTEXPR;
2773 tt = t + FUNHEAD + ARGHEAD; num = *tt;
2774 for ( i = 0; i < num; i++ ) *b++ = *tt++;
2779 MLOCK(ErrorMessageLock);
2780 MesPrint(
"Illegal bracket request in termsinbracket_ function.");
2781 MUNLOCK(ErrorMessageLock);
2788 if ( AT.WorkPointer + *term +4 > AT.WorkTop ) {
2789 MLOCK(ErrorMessageLock);
2791 MesPrint(
"Called from termsinbracket_ function.");
2792 MUNLOCK(ErrorMessageLock);
2799 case CURRENTBRACKET:
2805 numterms = CountTerms1(BHEAD0);
2807 case BRACKETCURRENTEXPR:
2811 MLOCK(ErrorMessageLock);
2812 MesPrint(
"termsinbracket_ function currently only handles Keep Brackets.");
2813 MUNLOCK(ErrorMessageLock);
2815 case BRACKETOTHEREXPR:
2816 MLOCK(ErrorMessageLock);
2817 MesPrint(
"termsinbracket_ function currently only handles Keep Brackets.");
2818 MUNLOCK(ErrorMessageLock);
2820 case NOBRACKETACTIVE:
2827 n1 = term; n2 = AT.WorkPointer; tstop = n1 + *n1;
2828 while ( n1 < t ) *n2++ = *n1++;
2829 i = numterms >> BITSINWORD;
2831 *n2++ = LNUMBER; *n2++ = 4; *n2++ = 1; *n2++ = (WORD)(numterms & WORDMASK);
2834 *n2++ = LNUMBER; *n2++ = 5; *n2++ = 2;
2835 *n2++ = (WORD)(numterms & WORDMASK); *n2++ = i;
2838 while ( n1 < tstop ) *n2++ = *n1++;
2839 AT.WorkPointer[0] = n2 - AT.WorkPointer;
2840 AT.WorkPointer = n2;
2842 AT.WorkPointer = bracketbuffer;
2843 MLOCK(ErrorMessageLock);
2844 MesPrint(
"Called from termsinbracket_ function.");
2845 MUNLOCK(ErrorMessageLock);
2851 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)