00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #define _MODULPSR_SOURCE_
00025
00026 #include "setup.h"
00027
00028 #if DEFMODULE_CONSTRUCT && (! RUN_TIME) && (! BLOAD_ONLY)
00029
00030 #include <stdio.h>
00031 #include <string.h>
00032 #define _STDIO_INCLUDED_
00033
00034 #include "memalloc.h"
00035 #include "constant.h"
00036 #include "router.h"
00037 #include "extnfunc.h"
00038 #include "argacces.h"
00039 #include "cstrcpsr.h"
00040 #include "constrct.h"
00041 #include "modulutl.h"
00042 #include "utility.h"
00043 #include "envrnmnt.h"
00044
00045 #if BLOAD || BLOAD_AND_BSAVE
00046 #include "bload.h"
00047 #endif
00048
00049 #include "modulpsr.h"
00050
00051
00052
00053
00054
00055 static int ParsePortSpecifications(void *,
00056 char *,struct token *,
00057 struct defmodule *);
00058 static int ParseImportSpec(void *,char *,struct token *,
00059 struct defmodule *);
00060 static int ParseExportSpec(void *,char *,struct token *,
00061 struct defmodule *,
00062 struct defmodule *);
00063 static intBool DeleteDefmodule(void *,void *);
00064 static int FindMultiImportConflict(void *,struct defmodule *);
00065 static void NotExportedErrorMessage(void *,char *,char *,char *);
00066
00067
00068
00069
00070
00071 globle long GetNumberOfDefmodules(
00072 void *theEnv)
00073 {
00074 return(DefmoduleData(theEnv)->NumberOfDefmodules);
00075 }
00076
00077
00078
00079
00080
00081 globle void SetNumberOfDefmodules(
00082 void *theEnv,
00083 long value)
00084 {
00085 DefmoduleData(theEnv)->NumberOfDefmodules = value;
00086 }
00087
00088
00089
00090
00091
00092
00093 globle void AddAfterModuleDefinedFunction(
00094 void *theEnv,
00095 char *name,
00096 void (*func)(void *),
00097 int priority)
00098 {
00099 DefmoduleData(theEnv)->AfterModuleDefinedFunctions =
00100 AddFunctionToCallList(theEnv,name,priority,func,DefmoduleData(theEnv)->AfterModuleDefinedFunctions,TRUE);
00101 }
00102
00103
00104
00105
00106
00107 globle void AddPortConstructItem(
00108 void *theEnv,
00109 char *theName,
00110 int theType)
00111 {
00112 struct portConstructItem *newItem;
00113
00114 newItem = get_struct(theEnv,portConstructItem);
00115 newItem->constructName = theName;
00116 newItem->typeExpected = theType;
00117 newItem->next = DefmoduleData(theEnv)->ListOfPortConstructItems;
00118 DefmoduleData(theEnv)->ListOfPortConstructItems = newItem;
00119 }
00120
00121
00122
00123
00124
00125
00126 globle int ParseDefmodule(
00127 void *theEnv,
00128 char *readSource)
00129 {
00130 SYMBOL_HN *defmoduleName;
00131 struct defmodule *newDefmodule;
00132 struct token inputToken;
00133 int i;
00134 struct moduleItem *theItem;
00135 struct portItem *portSpecs, *nextSpec;
00136 struct defmoduleItemHeader *theHeader;
00137 struct callFunctionItem *defineFunctions;
00138 struct defmodule *redefiningMainModule = NULL;
00139 int parseError;
00140 struct portItem *oldImportList = NULL, *oldExportList = NULL;
00141 short overwrite = FALSE;
00142
00143
00144
00145
00146
00147
00148
00149 SetPPBufferStatus(theEnv,ON);
00150 FlushPPBuffer(theEnv);
00151 SetIndentDepth(theEnv,3);
00152 SavePPBuffer(theEnv,"(defmodule ");
00153
00154
00155
00156
00157
00158
00159 #if BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE
00160 if ((Bloaded(theEnv) == TRUE) && (! ConstructData(theEnv)->CheckSyntaxMode))
00161 {
00162 CannotLoadWithBloadMessage(theEnv,"defmodule");
00163 return(TRUE);
00164 }
00165 #endif
00166
00167
00168
00169
00170
00171
00172 defmoduleName = GetConstructNameAndComment(theEnv,readSource,&inputToken,"defmodule",
00173 EnvFindDefmodule,DeleteDefmodule,"+",
00174 TRUE,TRUE,FALSE);
00175 if (defmoduleName == NULL) { return(TRUE); }
00176
00177 if (strcmp(ValueToString(defmoduleName),"MAIN") == 0)
00178 { redefiningMainModule = (struct defmodule *) EnvFindDefmodule(theEnv,"MAIN"); }
00179
00180
00181
00182
00183
00184 if (redefiningMainModule == NULL)
00185 {
00186 newDefmodule = (struct defmodule *) EnvFindDefmodule(theEnv,ValueToString(defmoduleName));
00187 if (newDefmodule)
00188 { overwrite = TRUE; }
00189 else
00190 {
00191 newDefmodule = get_struct(theEnv,defmodule);
00192 newDefmodule->name = defmoduleName;
00193 newDefmodule->usrData = NULL;
00194 newDefmodule->next = NULL;
00195 }
00196 }
00197 else
00198 {
00199 overwrite = TRUE;
00200 newDefmodule = redefiningMainModule;
00201 }
00202
00203 if (overwrite)
00204 {
00205 oldImportList = newDefmodule->importList;
00206 oldExportList = newDefmodule->exportList;
00207 }
00208
00209 newDefmodule->importList = NULL;
00210 newDefmodule->exportList = NULL;
00211
00212
00213
00214
00215
00216
00217 parseError = ParsePortSpecifications(theEnv,readSource,&inputToken,newDefmodule);
00218
00219
00220
00221
00222
00223 if (! parseError) parseError = FindMultiImportConflict(theEnv,newDefmodule);
00224
00225
00226
00227
00228
00229
00230
00231
00232 if (parseError || ConstructData(theEnv)->CheckSyntaxMode)
00233 {
00234 while (newDefmodule->importList != NULL)
00235 {
00236 nextSpec = newDefmodule->importList->next;
00237 rtn_struct(theEnv,portItem,newDefmodule->importList);
00238 newDefmodule->importList = nextSpec;
00239 }
00240
00241 while (newDefmodule->exportList != NULL)
00242 {
00243 nextSpec = newDefmodule->exportList->next;
00244 rtn_struct(theEnv,portItem,newDefmodule->exportList);
00245 newDefmodule->exportList = nextSpec;
00246 }
00247
00248 if ((redefiningMainModule == NULL) && (! overwrite))
00249 { rtn_struct(theEnv,defmodule,newDefmodule); }
00250
00251 if (overwrite)
00252 {
00253 newDefmodule->importList = oldImportList;
00254 newDefmodule->exportList = oldExportList;
00255 }
00256
00257 if (parseError) return(TRUE);
00258 return(FALSE);
00259 }
00260
00261
00262
00263
00264
00265
00266 if (redefiningMainModule == NULL)
00267 { IncrementSymbolCount(newDefmodule->name); }
00268 else
00269 {
00270 if ((newDefmodule->importList != NULL) ||
00271 (newDefmodule->exportList != NULL))
00272 { DefmoduleData(theEnv)->MainModuleRedefinable = FALSE; }
00273 }
00274
00275 for (portSpecs = newDefmodule->importList; portSpecs != NULL; portSpecs = portSpecs->next)
00276 {
00277 if (portSpecs->moduleName != NULL) IncrementSymbolCount(portSpecs->moduleName);
00278 if (portSpecs->constructType != NULL) IncrementSymbolCount(portSpecs->constructType);
00279 if (portSpecs->constructName != NULL) IncrementSymbolCount(portSpecs->constructName);
00280 }
00281
00282 for (portSpecs = newDefmodule->exportList; portSpecs != NULL; portSpecs = portSpecs->next)
00283 {
00284 if (portSpecs->moduleName != NULL) IncrementSymbolCount(portSpecs->moduleName);
00285 if (portSpecs->constructType != NULL) IncrementSymbolCount(portSpecs->constructType);
00286 if (portSpecs->constructName != NULL) IncrementSymbolCount(portSpecs->constructName);
00287 }
00288
00289
00290
00291
00292
00293 if (redefiningMainModule != NULL) { }
00294 else if (DefmoduleData(theEnv)->NumberOfModuleItems == 0) newDefmodule->itemsArray = NULL;
00295 else
00296 {
00297 newDefmodule->itemsArray = (struct defmoduleItemHeader **) gm2(theEnv,sizeof(void *) * DefmoduleData(theEnv)->NumberOfModuleItems);
00298 for (i = 0, theItem = DefmoduleData(theEnv)->ListOfModuleItems;
00299 (i < DefmoduleData(theEnv)->NumberOfModuleItems) && (theItem != NULL);
00300 i++, theItem = theItem->next)
00301 {
00302 if (theItem->allocateFunction == NULL)
00303 { newDefmodule->itemsArray[i] = NULL; }
00304 else
00305 {
00306 newDefmodule->itemsArray[i] = (struct defmoduleItemHeader *)
00307 (*theItem->allocateFunction)(theEnv);
00308 theHeader = (struct defmoduleItemHeader *) newDefmodule->itemsArray[i];
00309 theHeader->theModule = newDefmodule;
00310 theHeader->firstItem = NULL;
00311 theHeader->lastItem = NULL;
00312 }
00313 }
00314 }
00315
00316
00317
00318
00319
00320 SavePPBuffer(theEnv,"\n");
00321
00322 if (EnvGetConserveMemory(theEnv) == TRUE)
00323 { newDefmodule->ppForm = NULL; }
00324 else
00325 { newDefmodule->ppForm = CopyPPBuffer(theEnv); }
00326
00327
00328
00329
00330
00331 if (redefiningMainModule == NULL)
00332 {
00333 if (DefmoduleData(theEnv)->LastDefmodule == NULL) DefmoduleData(theEnv)->ListOfDefmodules = newDefmodule;
00334 else DefmoduleData(theEnv)->LastDefmodule->next = newDefmodule;
00335 DefmoduleData(theEnv)->LastDefmodule = newDefmodule;
00336 newDefmodule->bsaveID = DefmoduleData(theEnv)->NumberOfDefmodules++;
00337 }
00338
00339 EnvSetCurrentModule(theEnv,(void *) newDefmodule);
00340
00341
00342
00343
00344
00345
00346 for (defineFunctions = DefmoduleData(theEnv)->AfterModuleDefinedFunctions;
00347 defineFunctions != NULL;
00348 defineFunctions = defineFunctions->next)
00349 { (* (void (*)(void *)) defineFunctions->func)(theEnv); }
00350
00351
00352
00353
00354
00355 return(FALSE);
00356 }
00357
00358
00359
00360
00361
00362
00363 static intBool DeleteDefmodule(
00364 void *theEnv,
00365 void *theConstruct)
00366 {
00367 if (strcmp(EnvGetDefmoduleName(theEnv,theConstruct),"MAIN") == 0)
00368 { return(DefmoduleData(theEnv)->MainModuleRedefinable); }
00369
00370 return(FALSE);
00371 }
00372
00373
00374
00375
00376
00377 static int ParsePortSpecifications(
00378 void *theEnv,
00379 char *readSource,
00380 struct token *theToken,
00381 struct defmodule *theDefmodule)
00382 {
00383 int error;
00384
00385
00386
00387
00388
00389
00390 theDefmodule->importList = NULL;
00391 theDefmodule->exportList = NULL;
00392
00393
00394
00395
00396
00397
00398 while (theToken->type != RPAREN)
00399 {
00400
00401
00402
00403
00404 if (theToken->type != LPAREN)
00405 {
00406 SyntaxErrorMessage(theEnv,"defmodule");
00407 return(TRUE);
00408 }
00409
00410
00411
00412
00413
00414
00415
00416 GetToken(theEnv,readSource,theToken);
00417
00418 if (theToken->type != SYMBOL)
00419 {
00420 SyntaxErrorMessage(theEnv,"defmodule");
00421 return(TRUE);
00422 }
00423
00424 if (strcmp(ValueToString(theToken->value),"import") == 0)
00425 {
00426 error = ParseImportSpec(theEnv,readSource,theToken,theDefmodule);
00427 }
00428 else if (strcmp(ValueToString(theToken->value),"export") == 0)
00429 {
00430 error = ParseExportSpec(theEnv,readSource,theToken,theDefmodule,NULL);
00431 }
00432 else
00433 {
00434 SyntaxErrorMessage(theEnv,"defmodule");
00435 return(TRUE);
00436 }
00437
00438 if (error) return(TRUE);
00439
00440
00441
00442
00443
00444 PPCRAndIndent(theEnv);
00445 GetToken(theEnv,readSource,theToken);
00446
00447 if (theToken->type == RPAREN)
00448 {
00449 PPBackup(theEnv);
00450 PPBackup(theEnv);
00451 SavePPBuffer(theEnv,")");
00452 }
00453 }
00454
00455
00456
00457
00458
00459
00460
00461 return(FALSE);
00462 }
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476 static int ParseImportSpec(
00477 void *theEnv,
00478 char *readSource,
00479 struct token *theToken,
00480 struct defmodule *newModule)
00481 {
00482 struct defmodule *theModule;
00483 struct portItem *thePort, *oldImportSpec;
00484 int found, count;
00485
00486
00487
00488
00489
00490 SavePPBuffer(theEnv," ");
00491
00492 GetToken(theEnv,readSource,theToken);
00493
00494 if (theToken->type != SYMBOL)
00495 {
00496 SyntaxErrorMessage(theEnv,"defmodule import specification");
00497 return(TRUE);
00498 }
00499
00500
00501
00502
00503
00504 if ((theModule = (struct defmodule *)
00505 EnvFindDefmodule(theEnv,ValueToString(theToken->value))) == NULL)
00506 {
00507 CantFindItemErrorMessage(theEnv,"defmodule",ValueToString(theToken->value));
00508 return(TRUE);
00509 }
00510
00511
00512
00513
00514
00515
00516
00517 if (theModule->exportList == NULL)
00518 {
00519 NotExportedErrorMessage(theEnv,EnvGetDefmoduleName(theEnv,theModule),NULL,NULL);
00520 return(TRUE);
00521 }
00522
00523
00524
00525
00526
00527
00528 oldImportSpec = newModule->importList;
00529 if (ParseExportSpec(theEnv,readSource,theToken,newModule,theModule)) return(TRUE);
00530
00531
00532
00533
00534
00535
00536
00537 if (newModule->importList == oldImportSpec) return(FALSE);
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547 if (newModule->importList->constructType != NULL)
00548 {
00549
00550
00551
00552
00553
00554 found = FALSE;
00555 for (thePort = theModule->exportList;
00556 (thePort != NULL) && (! found);
00557 thePort = thePort->next)
00558 {
00559 if (thePort->constructType == NULL) found = TRUE;
00560 else if (thePort->constructType == newModule->importList->constructType)
00561 {
00562 if (newModule->importList->constructName == NULL) found = TRUE;
00563 else if (thePort->constructName == NULL) found = TRUE;
00564 else if (thePort->constructName == newModule->importList->constructName)
00565 { found = TRUE; }
00566 }
00567 }
00568
00569
00570
00571
00572
00573
00574 if (! found)
00575 {
00576 if (newModule->importList->constructName == NULL)
00577 {
00578 NotExportedErrorMessage(theEnv,EnvGetDefmoduleName(theEnv,theModule),
00579 ValueToString(newModule->importList->constructType),
00580 NULL);
00581 }
00582 else
00583 {
00584 NotExportedErrorMessage(theEnv,EnvGetDefmoduleName(theEnv,theModule),
00585 ValueToString(newModule->importList->constructType),
00586 ValueToString(newModule->importList->constructName));
00587 }
00588 return(TRUE);
00589 }
00590 }
00591
00592
00593
00594
00595
00596
00597 SaveCurrentModule(theEnv);
00598 EnvSetCurrentModule(theEnv,(void *) newModule);
00599
00600 for (thePort = newModule->importList;
00601 thePort != NULL;
00602 thePort = thePort->next)
00603 {
00604 if ((thePort->constructType == NULL) || (thePort->constructName == NULL))
00605 { continue; }
00606
00607 theModule = (struct defmodule *)
00608 EnvFindDefmodule(theEnv,ValueToString(thePort->moduleName));
00609 EnvSetCurrentModule(theEnv,theModule);
00610 if (FindImportedConstruct(theEnv,ValueToString(thePort->constructType),NULL,
00611 ValueToString(thePort->constructName),&count,
00612 TRUE,FALSE) == NULL)
00613 {
00614 NotExportedErrorMessage(theEnv,EnvGetDefmoduleName(theEnv,theModule),
00615 ValueToString(thePort->constructType),
00616 ValueToString(thePort->constructName));
00617 RestoreCurrentModule(theEnv);
00618 return(TRUE);
00619 }
00620 }
00621
00622 RestoreCurrentModule(theEnv);
00623
00624
00625
00626
00627
00628 return(FALSE);
00629 }
00630
00631
00632
00633
00634
00635
00636
00637 static int ParseExportSpec(
00638 void *theEnv,
00639 char *readSource,
00640 struct token *theToken,
00641 struct defmodule *newModule,
00642 struct defmodule *importModule)
00643 {
00644 struct portItem *newPort;
00645 SYMBOL_HN *theConstruct, *moduleName;
00646 struct portConstructItem *thePortConstruct;
00647 char *errorMessage;
00648
00649
00650
00651
00652
00653 if (importModule != NULL)
00654 {
00655 errorMessage = "defmodule import specification";
00656 moduleName = importModule->name;
00657 }
00658 else
00659 {
00660 errorMessage = "defmodule export specification";
00661 moduleName = NULL;
00662 }
00663
00664
00665
00666
00667
00668
00669 SavePPBuffer(theEnv," ");
00670 GetToken(theEnv,readSource,theToken);
00671
00672 if (theToken->type == SF_VARIABLE)
00673 {
00674
00675
00676
00677
00678
00679 if (strcmp(ValueToString(theToken->value),"ALL") == 0)
00680 {
00681 newPort = (struct portItem *) get_struct(theEnv,portItem);
00682 newPort->moduleName = moduleName;
00683 newPort->constructType = NULL;
00684 newPort->constructName = NULL;
00685 newPort->next = NULL;
00686 }
00687 else if (strcmp(ValueToString(theToken->value),"NONE") == 0)
00688 { newPort = NULL; }
00689 else
00690 {
00691 SyntaxErrorMessage(theEnv,errorMessage);
00692 return(TRUE);
00693 }
00694
00695
00696
00697
00698
00699
00700 GetToken(theEnv,readSource,theToken);
00701
00702 if (theToken->type != RPAREN)
00703 {
00704 if (newPort != NULL) rtn_struct(theEnv,portItem,newPort);
00705 PPBackup(theEnv);
00706 SavePPBuffer(theEnv," ");
00707 SavePPBuffer(theEnv,theToken->printForm);
00708 SyntaxErrorMessage(theEnv,errorMessage);
00709 return(TRUE);
00710 }
00711
00712
00713
00714
00715
00716
00717 if (newPort != NULL)
00718 {
00719 if (importModule != NULL)
00720 {
00721 newPort->next = newModule->importList;
00722 newModule->importList = newPort;
00723 }
00724 else
00725 {
00726 newPort->next = newModule->exportList;
00727 newModule->exportList = newPort;
00728 }
00729 }
00730
00731
00732
00733
00734
00735
00736 return(FALSE);
00737 }
00738
00739
00740
00741
00742
00743
00744 if (theToken->type != SYMBOL)
00745 {
00746 SyntaxErrorMessage(theEnv,errorMessage);
00747 return(TRUE);
00748 }
00749
00750 theConstruct = (SYMBOL_HN *) theToken->value;
00751
00752 if ((thePortConstruct = ValidPortConstructItem(theEnv,ValueToString(theConstruct))) == NULL)
00753 {
00754 SyntaxErrorMessage(theEnv,errorMessage);
00755 return(TRUE);
00756 }
00757
00758
00759
00760
00761
00762
00763
00764
00765 SavePPBuffer(theEnv," ");
00766 GetToken(theEnv,readSource,theToken);
00767
00768 if (theToken->type == SF_VARIABLE)
00769 {
00770
00771
00772
00773
00774
00775 if (strcmp(ValueToString(theToken->value),"ALL") == 0)
00776 {
00777 newPort = (struct portItem *) get_struct(theEnv,portItem);
00778 newPort->moduleName = moduleName;
00779 newPort->constructType = theConstruct;
00780 newPort->constructName = NULL;
00781 newPort->next = NULL;
00782 }
00783 else if (strcmp(ValueToString(theToken->value),"NONE") == 0)
00784 { newPort = NULL; }
00785 else
00786 {
00787 SyntaxErrorMessage(theEnv,errorMessage);
00788 return(TRUE);
00789 }
00790
00791
00792
00793
00794
00795
00796 GetToken(theEnv,readSource,theToken);
00797
00798 if (theToken->type != RPAREN)
00799 {
00800 if (newPort != NULL) rtn_struct(theEnv,portItem,newPort);
00801 PPBackup(theEnv);
00802 SavePPBuffer(theEnv," ");
00803 SavePPBuffer(theEnv,theToken->printForm);
00804 SyntaxErrorMessage(theEnv,errorMessage);
00805 return(TRUE);
00806 }
00807
00808
00809
00810
00811
00812
00813 if (newPort != NULL)
00814 {
00815 if (importModule != NULL)
00816 {
00817 newPort->next = newModule->importList;
00818 newModule->importList = newPort;
00819 }
00820 else
00821 {
00822 newPort->next = newModule->exportList;
00823 newModule->exportList = newPort;
00824 }
00825 }
00826
00827
00828
00829
00830
00831
00832 return(FALSE);
00833 }
00834
00835
00836
00837
00838
00839
00840 if (theToken->type == RPAREN)
00841 {
00842 SyntaxErrorMessage(theEnv,errorMessage);
00843 return(TRUE);
00844 }
00845
00846
00847
00848
00849
00850 while (theToken->type != RPAREN)
00851 {
00852 if (theToken->type != thePortConstruct->typeExpected)
00853 {
00854 SyntaxErrorMessage(theEnv,errorMessage);
00855 return(TRUE);
00856 }
00857
00858
00859
00860
00861
00862
00863
00864 newPort = (struct portItem *) get_struct(theEnv,portItem);
00865 newPort->moduleName = moduleName;
00866 newPort->constructType = theConstruct;
00867 newPort->constructName = (SYMBOL_HN *) theToken->value;
00868
00869
00870
00871
00872
00873
00874 if (importModule != NULL)
00875 {
00876 newPort->next = newModule->importList;
00877 newModule->importList = newPort;
00878 }
00879 else
00880 {
00881 newPort->next = newModule->exportList;
00882 newModule->exportList = newPort;
00883 }
00884
00885
00886
00887
00888
00889
00890 SavePPBuffer(theEnv," ");
00891 GetToken(theEnv,readSource,theToken);
00892 }
00893
00894
00895
00896
00897
00898 PPBackup(theEnv);
00899 PPBackup(theEnv);
00900 SavePPBuffer(theEnv,")");
00901
00902
00903
00904
00905
00906
00907 return(FALSE);
00908 }
00909
00910
00911
00912
00913
00914
00915 globle struct portConstructItem *ValidPortConstructItem(
00916 void *theEnv,
00917 char *theName)
00918 {
00919 struct portConstructItem *theItem;
00920
00921 for (theItem = DefmoduleData(theEnv)->ListOfPortConstructItems;
00922 theItem != NULL;
00923 theItem = theItem->next)
00924 { if (strcmp(theName,theItem->constructName) == 0) return(theItem); }
00925
00926 return(NULL);
00927 }
00928
00929
00930
00931
00932
00933
00934 static int FindMultiImportConflict(
00935 void *theEnv,
00936 struct defmodule *theModule)
00937 {
00938 struct defmodule *testModule;
00939 int count;
00940 struct portConstructItem *thePCItem;
00941 struct construct *theConstruct;
00942 void *theCItem;
00943
00944
00945
00946
00947
00948 SaveCurrentModule(theEnv);
00949
00950
00951
00952
00953
00954 for (testModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL);
00955 testModule != NULL;
00956 testModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,testModule))
00957 {
00958
00959
00960
00961
00962
00963 for (thePCItem = DefmoduleData(theEnv)->ListOfPortConstructItems;
00964 thePCItem != NULL;
00965 thePCItem = thePCItem->next)
00966 {
00967 EnvSetCurrentModule(theEnv,(void *) testModule);
00968
00969
00970
00971
00972
00973 theConstruct = FindConstruct(theEnv,thePCItem->constructName);
00974
00975 for (theCItem = (*theConstruct->getNextItemFunction)(theEnv,NULL);
00976 theCItem != NULL;
00977 theCItem = (*theConstruct->getNextItemFunction)(theEnv,theCItem))
00978 {
00979
00980
00981
00982
00983
00984
00985
00986 EnvSetCurrentModule(theEnv,(void *) theModule);
00987 FindImportedConstruct(theEnv,thePCItem->constructName,NULL,
00988 ValueToString((*theConstruct->getConstructNameFunction)
00989 ((struct constructHeader *) theCItem)),
00990 &count,FALSE,NULL);
00991 if (count > 1)
00992 {
00993 ImportExportConflictMessage(theEnv,"defmodule",EnvGetDefmoduleName(theEnv,theModule),
00994 thePCItem->constructName,
00995 ValueToString((*theConstruct->getConstructNameFunction)
00996 ((struct constructHeader *) theCItem)));
00997 RestoreCurrentModule(theEnv);
00998 return(TRUE);
00999 }
01000
01001 EnvSetCurrentModule(theEnv,(void *) testModule);
01002 }
01003 }
01004 }
01005
01006
01007
01008
01009
01010 RestoreCurrentModule(theEnv);
01011
01012
01013
01014
01015
01016
01017 return(FALSE);
01018 }
01019
01020
01021
01022
01023
01024
01025 static void NotExportedErrorMessage(
01026 void *theEnv,
01027 char *theModule,
01028 char *theConstruct,
01029 char *theName)
01030 {
01031 PrintErrorID(theEnv,"MODULPSR",1,TRUE);
01032 EnvPrintRouter(theEnv,WERROR,"Module ");
01033 EnvPrintRouter(theEnv,WERROR,theModule);
01034 EnvPrintRouter(theEnv,WERROR," does not export ");
01035
01036 if (theConstruct == NULL) EnvPrintRouter(theEnv,WERROR,"any constructs");
01037 else if (theName == NULL)
01038 {
01039 EnvPrintRouter(theEnv,WERROR,"any ");
01040 EnvPrintRouter(theEnv,WERROR,theConstruct);
01041 EnvPrintRouter(theEnv,WERROR," constructs");
01042 }
01043 else
01044 {
01045 EnvPrintRouter(theEnv,WERROR,"the ");
01046 EnvPrintRouter(theEnv,WERROR,theConstruct);
01047 EnvPrintRouter(theEnv,WERROR," ");
01048 EnvPrintRouter(theEnv,WERROR,theName);
01049 }
01050
01051 EnvPrintRouter(theEnv,WERROR,".\n");
01052 }
01053
01054
01055
01056
01057
01058
01059
01060
01061 globle int FindImportExportConflict(
01062 void *theEnv,
01063 char *constructName,
01064 struct defmodule *matchModule,
01065 char *findName)
01066 {
01067 struct defmodule *theModule;
01068 struct moduleItem *theModuleItem;
01069 int count;
01070
01071
01072
01073
01074
01075
01076 if (ValidPortConstructItem(theEnv,constructName) == NULL) return(FALSE);
01077
01078
01079
01080
01081
01082
01083 if (FindModuleSeparator(findName)) return(FALSE);
01084
01085
01086
01087
01088
01089
01090
01091
01092 if ((theModuleItem = FindModuleItem(theEnv,constructName)) == NULL) return(FALSE);
01093
01094 if (theModuleItem->findFunction == NULL) return(FALSE);
01095
01096
01097
01098
01099
01100 SaveCurrentModule(theEnv);
01101
01102
01103
01104
01105
01106
01107
01108
01109 for (theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,NULL);
01110 theModule != NULL;
01111 theModule = (struct defmodule *) EnvGetNextDefmodule(theEnv,theModule))
01112 {
01113 EnvSetCurrentModule(theEnv,(void *) theModule);
01114
01115 FindImportedConstruct(theEnv,constructName,NULL,findName,&count,TRUE,matchModule);
01116 if (count > 1)
01117 {
01118 RestoreCurrentModule(theEnv);
01119 return(TRUE);
01120 }
01121 }
01122
01123
01124
01125
01126
01127
01128 RestoreCurrentModule(theEnv);
01129 return(FALSE);
01130 }
01131
01132 #endif
01133
01134