1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827
|
/** @file module.c
*
* A number of routines that deal with the moduleoption statement and the
* execution of modules.
* Additionally there are the execution of the exec and pipe instructions.
*/
/* #[ License : */
/*
* Copyright (C) 1984-2026 J.A.M. Vermaseren
* When using this file you are requested to refer to the publication
* J.A.M.Vermaseren "New features of FORM" math-ph/0010025
* This is considered a matter of courtesy as the development was paid
* for by FOM the Dutch physics granting agency and we would like to
* be able to track its scientific use to convince FOM of its value
* for the community.
*
* This file is part of FORM.
*
* FORM is free software: you can redistribute it and/or modify it under the
* terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* FORM is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along
* with FORM. If not, see <http://www.gnu.org/licenses/>.
*/
/* #] License : */
/*
#[ Includes :
*/
#include "form3.h"
/*
#] Includes :
#[ Modules :
#[ ModuleInstruction :
Enters after the . of .sort etc
We have word[[(options)][:commentary];]
Word is one of 'clear end global sort store'
Options are 'polyfun, endloopifunchanged, endloopifzero'
Additions for solving equations can be added to 'word'
The flag in the moduleoptions is for telling whether the current
option can be followed by others. If it is > 0 it cannot.
*/
static KEYWORD ModuleWords[] = {
{"clear", (TFUN)0, CLEARMODULE, 0}
,{"end", (TFUN)0, ENDMODULE, 0}
,{"global", (TFUN)0, GLOBALMODULE, 0}
,{"sort", (TFUN)0, SORTMODULE, 0}
,{"store", (TFUN)0, STOREMODULE, 0}
};
static KEYWORD ModuleOptions[] = {
{"inparallel", DoinParallel, 1, 1}
,{"local", DoModLocal, MODLOCAL, 0}
,{"maximum", DoModMax, MODMAX, 0}
,{"minimum", DoModMin, MODMIN, 0}
,{"noparallel", DoNoParallel, NOPARALLEL_USER,0}
,{"notinparallel", DonotinParallel,0, 1}
,{"parallel", DoParallel, PARALLELFLAG, 0}
,{"polyfun", DoPolyfun, POLYFUN, 0}
,{"polyratfun", DoPolyratfun, POLYFUN, 0}
,{"processbucketsize", DoProcessBucket,0, 0}
,{"sum", DoModSum, MODSUM, 0}
};
int ModuleInstruction(int *moduletype, int *specialtype)
{
UBYTE *t, *s, *u, c;
KEYWORD *key;
int addit = 0, error = 0, i, j;
DUMMYUSE(specialtype);
LoadInstruction(0);
AC.firstctypemessage = 0;
s = AP.preStart; SKIPBLANKS(s)
t = EndOfToken(s); c = *t; *t = 0;
AC.origin = FROMPOINTINSTRUCTION;
key = FindKeyWord(AP.preStart,ModuleWords,sizeof(ModuleWords)/sizeof(KEYWORD));
if ( key == 0 ) {
MesPrint("@Unrecognized module terminator: %s",s);
error = 1;
key = ModuleWords;
while ( StrCmp((UBYTE *)key->name,(UBYTE *)"end") ) key++;
}
*t = c;
*moduletype = key->type;
SKIPBLANKS(t);
while ( *t == '(' ) { /* There are options */
s = t+1; SKIPBRA3(t)
if ( *t == 0 ) {
MesPrint("@Improper options field in . instruction");
error = 1;
}
else {
*t = 0;
if ( CoModOption(s) ) error = 1;
*t++ = ')';
}
}
if ( *t == ':' ) { /* There is an 'advertisement' */
t++;
SKIPBLANKS(t)
s = t; i = 0;
while ( *t && *t != ';' ) {
if ( *t == '\\' ) t++;
t++; i++;
}
u = t;
while ( u > s && u[-1] == ' ' ) { u--; i--; }
if ( *u == '\\' ) { u++; i++; }
for ( j = COMMERCIALSIZE-1; j >= 0; j-- ) {
if ( i <= 0 ) break;
AC.Commercial[j] = *--u; i--;
if ( u > s && u[-1] == '\\' ) u--;
}
for ( ; j >= 0; j-- ) AC.Commercial[j] = ' ';
AC.Commercial[COMMERCIALSIZE] = 0;
addit += 2;
}
if ( addit && *t != ';' ) {
MesPrint("@Improper ending of . instruction");
error = -1;
}
return(error);
}
/*
#] ModuleInstruction :
#[ CoModuleOption :
ModuleOption, options;
*/
int CoModuleOption(UBYTE *s)
{
UBYTE *t,*tt,c;
KEYWORD *option;
int error = 0, polyflag = 0;
AC.origin = FROMMODULEOPTION;
if ( *s ) do {
s = ToToken(s);
t = EndOfToken(s);
c = *t; *t = 0;
option = FindKeyWord(s,ModuleOptions,
sizeof(ModuleOptions)/sizeof(KEYWORD));
if ( option == 0 ) {
if ( polyflag ) {
*t = c; t++; s = SkipAName(t);
polyflag = 0;
continue;
}
else {
MesPrint("@Unrecognized module option: %s",s);
error = 1;
polyflag = 0;
*t = c;
}
}
else {
*t = c;
SKIPBLANKS(t)
if ( (option->func)(t) ) error = 1;
}
if ( StrCmp((UBYTE *)(option->name),(UBYTE *)("polyfun")) == 0
|| StrCmp((UBYTE *)(option->name),(UBYTE *)("polyratfun")) == 0 ) {
polyflag = 1;
t++;
t = SkipAName(t);
}
else polyflag = 0;
if ( option->flags > 0 ) return(error);
while ( *t ) {
if ( *t == ',' ) {
tt = t+1;
while ( *tt == ',' ) tt++;
if ( *tt != '$' ) break;
t = tt+1;
}
if ( *t == ')' ) break;
if ( *t == '(' ) SKIPBRA3(t)
else if ( *t == '{' ) SKIPBRA2(t)
else if ( *t == '[' ) SKIPBRA1(t)
t++;
}
s = t;
} while ( *s == ',' );
if ( *s ) {
MesPrint("@Unrecognized module option: %s",s);
error = 1;
}
return(error);
}
/*
#] CoModuleOption :
#[ CoModOption :
To be called from a .instruction.
Only recognizes polyfun. The newer ones should be via the
ModuleOption statement.
*/
int CoModOption(UBYTE *s)
{
UBYTE *t,c;
int error = 0;
AC.origin = FROMPOINTINSTRUCTION;
if ( *s ) do {
s = ToToken(s);
t = EndOfToken(s);
c = *t; *t = 0;
if ( StrICmp(s,(UBYTE *)"polyfun") == 0 ) {
*t = c;
SKIPBLANKS(t)
if ( DoPolyfun(t) ) error = 1;
}
else if ( StrICmp(s,(UBYTE *)"polyratfun") == 0 ) {
*t = c;
SKIPBLANKS(t)
if ( DoPolyratfun(t) ) error = 1;
}
else {
MesPrint("@Unrecognized module option in .instruction: %s",s);
error = 1;
*t = c;
}
while ( *t ) {
if ( *t == ',' || *t == ')' ) break;
if ( *t == '(' ) SKIPBRA3(t)
else if ( *t == '{' ) SKIPBRA2(t)
else if ( *t == '[' ) SKIPBRA1(t)
t++;
}
s = t;
} while ( *s == ',' );
if ( *s ) {
MesPrint("@Unrecognized module option in .instruction: %s",s);
error = 1;
}
return(error);
}
/*
#] CoModOption :
#[ SetSpecialMode :
*/
void SetSpecialMode(int moduletype, int specialtype)
{
DUMMYUSE(moduletype); DUMMYUSE(specialtype);
}
/*
#] SetSpecialMode :
#[ MakeGlobal :
void MakeGlobal()
{
}
#] MakeGlobal :
#[ ExecModule :
*/
int ExecModule(int moduletype)
{
/*
Here we check module options and other things that should
be done at the start of a module.
*/
#ifdef WITHFLOAT
if ( ( AC.tMaxWeight != 0 && AC.tMaxWeight != AC.MaxWeight )
|| ( AC.tDefaultPrecision != 0 && AC.tDefaultPrecision != AC.DefaultPrecision ) ) {
AC.DefaultPrecision = AC.tDefaultPrecision;
AC.tDefaultPrecision = 0;
AC.MaxWeight = AC.tMaxWeight;
AC.tMaxWeight = 0;
ClearMZVTables();
SetupMZVTables();
}
#endif
return(DoExecute(moduletype,0));
}
/*
#] ExecModule :
#[ ExecStore :
*/
int ExecStore(void)
{
return(0);
}
/*
#] ExecStore :
#[ FullCleanUp :
Remark 27-oct-2005 by JV
This routine (and CleanUp in startup.c) may still need some work:
What to do with preprocessor variables
What to do with files we write to
*/
void FullCleanUp(void)
{
int j;
while ( AC.CurrentStream->previous >= 0 )
AC.CurrentStream = CloseStream(AC.CurrentStream);
AP.PreSwitchLevel = AP.PreIfLevel = 0;
for ( j = NumProcedures-1; j >= 0; j-- ) {
if ( Procedures[j].name ) M_free(Procedures[j].name,"name of procedure");
if ( Procedures[j].p.buffer ) M_free(Procedures[j].p.buffer,"buffer of procedure");
}
NumProcedures = 0;
while ( NumPre > AP.gNumPre ) {
NumPre--;
M_free(PreVar[NumPre].name,"PreVar[NumPre].name");
PreVar[NumPre].name = PreVar[NumPre].value = 0;
}
AC.DidClean = 0;
for ( j = 0; j < NumExpressions; j++ ) {
AC.exprnames->namenode[Expressions[j].node].type = CDELETE;
AC.DidClean = 1;
}
CompactifyTree(AC.exprnames,EXPRNAMES);
for ( j = AO.NumDictionaries-1; j >= 0; j-- ) {
RemoveDictionary(AO.Dictionaries[j]);
M_free(AO.Dictionaries[j],"Dictionary");
}
AO.NumDictionaries = AO.gNumDictionaries = 0;
M_free(AO.Dictionaries,"Dictionaries");
AO.Dictionaries = 0;
AO.SizeDictionaries = 0;
AP.OpenDictionary = 0;
AO.CurrentDictionary = 0;
AP.ComChar = AP.cComChar;
if ( AP.procedureExtension ) M_free(AP.procedureExtension,"procedureextension");
AP.procedureExtension = strDup1(AP.cprocedureExtension,"procedureextension");
AC.StatsFlag = AM.gStatsFlag = AM.ggStatsFlag;
AC.extrasymbols = AM.gextrasymbols = AM.ggextrasymbols;
AC.extrasym[0] = AM.gextrasym[0] = AM.ggextrasym[0] = 'Z';
AC.extrasym[1] = AM.gextrasym[1] = AM.ggextrasym[1] = 0;
AO.NoSpacesInNumbers = AM.gNoSpacesInNumbers = AM.ggNoSpacesInNumbers;
AO.IndentSpace = AM.gIndentSpace = AM.ggIndentSpace;
AC.ThreadStats = AM.gThreadStats = AM.ggThreadStats;
AC.OldFactArgFlag = AM.gOldFactArgFlag = AM.ggOldFactArgFlag;
AC.FinalStats = AM.gFinalStats = AM.ggFinalStats;
AC.OldGCDflag = AM.gOldGCDflag = AM.ggOldGCDflag;
AC.ThreadsFlag = AM.gThreadsFlag = AM.ggThreadsFlag;
if ( AC.ThreadsFlag && AM.totalnumberofthreads > 1 ) AS.MultiThreaded = 1;
AC.ThreadBucketSize = AM.gThreadBucketSize = AM.ggThreadBucketSize;
AC.ThreadBalancing = AM.gThreadBalancing = AM.ggThreadBalancing;
AC.ThreadSortFileSynch = AM.gThreadSortFileSynch = AM.ggThreadSortFileSynch;
AC.ShortStatsMax = AM.gShortStatsMax = AM.ggShortStatsMax;
AC.SizeCommuteInSet = AM.gSizeCommuteInSet = 0;
#ifdef WITHFLOAT
AC.MaxWeight = AM.gMaxWeight = AM.ggMaxWeight;
AC.DefaultPrecision = AM.gDefaultPrecision = AM.ggDefaultPrecision;
#endif
NumExpressions = 0;
if ( DeleteStore(0) < 0 ) {
MesPrint("@Cannot restart the storage file");
Terminate(-1);
}
RemoveDollars();
CleanUp(1);
ResetVariables(2);
IniVars();
}
/*
#] FullCleanUp :
#[ DoPolyfun :
*/
int DoPolyfun(UBYTE *s)
{
GETIDENTITY
UBYTE *t, c;
WORD funnum, eqsign = 0;
if ( AC.origin == FROMPOINTINSTRUCTION ) {
if ( *s == 0 || *s == ',' || *s == ')' ) {
AR.PolyFun = 0; AR.PolyFunType = 0;
return(0);
}
if ( *s != '=' ) {
MesPrint("@Proper use in point instructions is: PolyFun[=functionname]");
return(-1);
}
eqsign = 1;
}
else {
if ( *s == 0 ) {
AR.PolyFun = 0; AR.PolyFunType = 0;
return(0);
}
if ( *s != '=' && *s != ',' ) {
MesPrint("@Proper use is: PolyFun[{ ,=}functionname]");
return(-1);
}
if ( *s == '=' ) eqsign = 1;
}
s++;
SKIPBLANKS(s)
t = EndOfToken(s);
c = *t; *t = 0;
if ( GetName(AC.varnames,s,&funnum,WITHAUTO) != CFUNCTION ) {
if ( AC.origin != FROMPOINTINSTRUCTION && eqsign == 0 ) {
AR.PolyFun = 0; AR.PolyFunType = 0;
return(0);
}
MesPrint("@ %s is not a properly declared function",s);
*t = c;
return(-1);
}
if ( functions[funnum].spec > 0 || functions[funnum].commute != 0 ) {
MesPrint("@The PolyFun must be a regular commuting function!");
*t = c;
return(-1);
}
AR.PolyFun = funnum+FUNCTION; AR.PolyFunType = 1;
*t = c;
SKIPBLANKS(t)
if ( *t && *t != ',' && *t != ')' ) {
t++; c = *t; *t = 0;
MesPrint("@Improper ending of end-of-module instruction: %s",s);
*t = c;
return(-1);
}
return(0);
}
/*
#] DoPolyfun :
#[ DoPolyratfun :
*/
int DoPolyratfun(UBYTE *s)
{
GETIDENTITY
UBYTE *t, c;
WORD funnum;
if ( AC.origin == FROMPOINTINSTRUCTION ) {
if ( *s == 0 || *s == ',' || *s == ')' ) {
AR.PolyFun = 0; AR.PolyFunType = 0; AR.PolyFunInv = 0; AR.PolyFunExp = 0;
return(0);
}
if ( *s != '=' ) {
MesPrint("@Proper use in point instructions is: PolyRatFun[=functionname[+functionname]]");
return(-1);
}
}
else {
if ( *s == 0 ) {
AR.PolyFun = 0; AR.PolyFunType = 0; AR.PolyFunInv = 0; AR.PolyFunExp = 0;
return(0);
}
if ( *s != '=' && *s != ',' ) {
MesPrint("@Proper use is: PolyRatFun[{ ,=}functionname[+functionname]]");
return(-1);
}
}
s++;
SKIPBLANKS(s)
t = EndOfToken(s);
c = *t; *t = 0;
if ( GetName(AC.varnames,s,&funnum,WITHAUTO) != CFUNCTION ) {
Error1:;
MesPrint("@ %s is not a properly declared function",s);
*t = c;
return(-1);
}
if ( functions[funnum].spec > 0 || functions[funnum].commute != 0 ) {
Error2:;
MesPrint("@The PolyRatFun must be a regular commuting function!");
*t = c;
return(-1);
}
AR.PolyFun = funnum+FUNCTION; AR.PolyFunType = 2;
AR.PolyFunInv = 0;
AR.PolyFunExp = 0;
AC.PolyRatFunChanged = 1;
*t = c;
if ( *t == '+' ) {
t++; s = t;
t = EndOfToken(s);
c = *t; *t = 0;
if ( GetName(AC.varnames,s,&funnum,WITHAUTO) != CFUNCTION ) goto Error1;
if ( functions[funnum].spec > 0 || functions[funnum].commute != 0 ) goto Error2;
AR.PolyFunInv = funnum+FUNCTION;
*t = c;
}
SKIPBLANKS(t)
if ( *t && *t != ',' && *t != ')' ) {
t++; c = *t; *t = 0;
MesPrint("@Improper ending of end-of-module instruction: %s",s);
*t = c;
return(-1);
}
return(0);
}
/*
#] DoPolyratfun :
#[ DoNoParallel :
*/
int DoNoParallel(UBYTE *s)
{
if ( *s == 0 || *s == ',' || *s == ')' ) {
AC.mparallelflag |= NOPARALLEL_USER;
return(0);
}
MesPrint("@NoParallel should not have extra parameters");
return(-1);
}
/*
#] DoNoParallel :
#[ DoParallel :
*/
int DoParallel(UBYTE *s)
{
if ( *s == 0 || *s == ',' || *s == ')' ) {
AC.mparallelflag &= ~NOPARALLEL_USER;
return(0);
}
MesPrint("@Parallel should not have extra parameters");
return(-1);
}
/*
#] DoParallel :
#[ DoModSum :
*/
int DoModSum(UBYTE *s)
{
while ( *s == ',' ) s++;
if ( *s != '$' ) {
MesPrint("@Module Sum should mention which $-variables");
return(-1);
}
s = DoModDollar(s,MODSUM);
if ( s && *s != 0 && *s != ')' ) {
MesPrint("@Irregular end of Sum option of Module statement");
return(-1);
}
return(0);
}
/*
#] DoModSum :
#[ DoModMax :
*/
int DoModMax(UBYTE *s)
{
while ( *s == ',' ) s++;
if ( *s != '$' ) {
MesPrint("@Module Maximum should mention which $-variables");
return(-1);
}
s = DoModDollar(s,MODMAX);
if ( s && *s != 0 ) {
MesPrint("@Irregular end of Maximum option of Module statement");
return(-1);
}
return(0);
}
/*
#] DoModMax :
#[ DoModMin :
*/
int DoModMin(UBYTE *s)
{
while ( *s == ',' ) s++;
if ( *s != '$' ) {
MesPrint("@Module Minimum should mention which $-variables");
return(-1);
}
s = DoModDollar(s,MODMIN);
if ( s && *s != 0 ) {
MesPrint("@Irregular end of Minimum option of Module statement");
return(-1);
}
return(0);
}
/*
#] DoModMin :
#[ DoModLocal :
*/
int DoModLocal(UBYTE *s)
{
while ( *s == ',' ) s++;
if ( *s != '$' ) {
MesPrint("@ModuleOption Local should mention which $-variables");
return(-1);
}
s = DoModDollar(s,MODLOCAL);
if ( s && *s != 0 ) {
MesPrint("@Irregular end of Local option of ModuleOption statement");
return(-1);
}
return(0);
}
/*
#] DoModLocal :
#[ DoProcessBucket :
*/
int DoProcessBucket(UBYTE *s)
{
LONG x;
while ( *s == ',' || *s == '=' ) s++;
ParseNumber(x,s)
if ( *s && *s != ' ' && *s != '\t' ) {
MesPrint("&Numerical value expected for ProcessBucketSize");
return(1);
}
AC.mProcessBucketSize = x;
return(0);
}
/*
#] DoProcessBucket :
#[ DoModDollar :
*/
UBYTE * DoModDollar(UBYTE *s, int type)
{
UBYTE *name, c;
WORD number;
MODOPTDOLLAR *md;
int nummodopt;
while ( *s == '$' ) {
/*
Read the name of the dollar
Mark the type
*/
s++;
name = s;
if ( FG.cTable[*s] == 0 ) {
while ( FG.cTable[*s] == 0 || FG.cTable[*s] == 1 ) s++;
c = *s; *s = 0;
number = GetDollar(name);
if ( number < 0 ) {
UBYTE *s1;
number = AddDollar(s,0,0,0);
s1 = strDup1((UBYTE *)"Undefined $-variable in module option; option ignored: $","Undefined $-variable in ModuleOption");
s1 = AddToString(s1,name,0);
Warning((char *)s1);
M_free(s1,"Undefined $-variable in ModuleOption");
}
for ( nummodopt = 0; nummodopt < NumModOptdollars; nummodopt++ ) {
if ( number == ModOptdollars[nummodopt].number && type != ModOptdollars[nummodopt].type ) {
UBYTE *s1;
s1 = strDup1((UBYTE *)"Conflicting module options for $-variable; later option ignored: $","Conflicting $-variable in ModuleOption");
s1 = AddToString(s1,name,0);
Warning((char *)s1);
M_free(s1,"Conflicting $-variable in ModuleOption");
break;
}
}
md = (MODOPTDOLLAR *)FromList(&AC.ModOptDolList);
md->number = number;
md->type = type;
#ifdef WITHPTHREADS
if ( type == MODLOCAL ) {
int j, i;
DOLLARS dglobal, dlocal;
md->dstruct = (DOLLARS)Malloc1(
sizeof(struct DoLlArS)*AM.totalnumberofthreads,"Local DOLLARS");
/*
Now copy the global dollar into the local copies.
This can be nontrivial if the value needs an allocation.
We don't really need the locks.
*/
dglobal = Dollars + number;
for ( j = 0; j < AM.totalnumberofthreads; j++ ) {
dlocal = md->dstruct + j;
dlocal->index = dglobal->index;
dlocal->node = dglobal->node;
dlocal->type = dglobal->type;
dlocal->name = dglobal->name;
dlocal->size = dglobal->size;
dlocal->where = dglobal->where;
if ( dlocal->size > 0 ) {
dlocal->where = (WORD *)Malloc1((dlocal->size+1)*sizeof(WORD),"Local dollar value");
for ( i = 0; i < dlocal->size; i++ )
dlocal->where[i] = dglobal->where[i];
dlocal->where[dlocal->size] = 0;
}
dlocal->pthreadslockread = dummylock;
dlocal->pthreadslockwrite = dummylock;
dlocal->nfactors = dglobal->nfactors;
if ( dglobal->nfactors > 1 ) {
int nsize;
WORD *t, *m;
dlocal->factors = (FACDOLLAR *)Malloc1(dglobal->nfactors*sizeof(FACDOLLAR),"Dollar factors");
for ( i = 0; i < dglobal->nfactors; i++ ) {
nsize = dglobal->factors[i].size;
dlocal->factors[i].type = DOLUNDEFINED;
dlocal->factors[i].value = dglobal->factors[i].value;
if ( ( dlocal->factors[i].size = nsize ) > 0 ) {
dlocal->factors[i].where = t = (WORD *)Malloc1(sizeof(WORD)*(nsize+1),"DollarCopyFactor");
m = dglobal->factors[i].where;
NCOPY(t,m,nsize);
*t = 0;
}
else {
dlocal->factors[i].where = 0;
}
}
}
else { dlocal->factors = 0; }
}
}
else {
md->dstruct = 0;
}
#endif
*s = c;
}
else {
MesPrint("&Illegal name for $-variable in module option");
while ( *s != ',' && *s != 0 && *s != ')' ) s++;
}
while ( *s == ',' ) s++;
}
return(s);
}
/*
#] DoModDollar :
#[ DoinParallel :
The idea is that we should have the commands
ModuleOption,InParallel;
ModuleOption,InParallel,name1,name2,...,namen;
ModuleOption,NotInParallel,name1,name2,...,namen;
The advantage over the InParallel statement is that this statement
comes after the definition of the expressions.
*/
int DoinParallel(UBYTE *s)
{
return(DoInParallel(s,1));
}
/*
#] DoinParallel :
#[ DonotinParallel :
*/
int DonotinParallel(UBYTE *s)
{
return(DoInParallel(s,0));
}
/*
#] DonotinParallel :
#] Modules :
#[ External :
#[ DoExecStatement :
*/
int DoExecStatement(void)
{
#ifdef WITHSYSTEM
FLUSHCONSOLE;
if ( system((char *)(AP.preStart)) ) return(-1);
return(0);
#else
Error0("External programs not implemented on this computer/system");
return(-1);
#endif
}
/*
#] DoExecStatement :
#[ DoPipeStatement :
*/
int DoPipeStatement(void)
{
#ifdef WITHPIPE
FLUSHCONSOLE;
if ( OpenStream(AP.preStart,PIPESTREAM,0,PRENOACTION) == 0 ) return(-1);
return(0);
#else
Error0("Pipes not implemented on this computer/system");
return(-1);
#endif
}
/*
#] DoPipeStatement :
#] External :
*/
|