00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #define _CONSCOMP_SOURCE_
00043
00044 #include "setup.h"
00045
00046 #if CONSTRUCT_COMPILER && (! RUN_TIME)
00047
00048 #include <stdio.h>
00049 #define _STDIO_INCLUDED_
00050 #include <stdlib.h>
00051 #include <string.h>
00052
00053 #include "symbol.h"
00054 #include "memalloc.h"
00055 #include "constant.h"
00056 #include "exprnpsr.h"
00057 #include "cstrccom.h"
00058 #include "constrct.h"
00059 #include "argacces.h"
00060 #include "cstrncmp.h"
00061 #include "router.h"
00062 #include "sysdep.h"
00063 #include "utility.h"
00064 #include "modulcmp.h"
00065 #include "envrnmnt.h"
00066
00067 #if DEFRULE_CONSTRUCT
00068 #include "network.h"
00069 #endif
00070
00071 #if DEFFUNCTION_CONSTRUCT
00072 #include "dffnxcmp.h"
00073 #endif
00074
00075 #if DEFTEMPLATE_CONSTRUCT
00076 #include "tmpltcmp.h"
00077 #endif
00078
00079 #if DEFGLOBAL_CONSTRUCT
00080 #include "globlcmp.h"
00081 #endif
00082
00083 #if DEFGENERIC_CONSTRUCT
00084 #include "genrccmp.h"
00085 #endif
00086
00087 #if OBJECT_SYSTEM
00088 #include "objcmp.h"
00089 #endif
00090
00091 #include "conscomp.h"
00092
00093
00094
00095
00096
00097 #define EXTRA_FILE_NAME 20
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114 #define PRIMARY_CODES "ADGHJKMNOQRTUVWXYZ"
00115 #define PRIMARY_LEN 18
00116 #define SECONDARY_CODES "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
00117 #define SECONDARY_LEN 26
00118
00119
00120
00121
00122
00123 void ConstructsToCCommand(void *);
00124 static int ConstructsToC(void *,char *,char *,char *,long long,long long);
00125 static void WriteFunctionExternDeclarations(void *,FILE *);
00126 static int FunctionsToCode(void *theEnv,char *,char *,char *);
00127 static int WriteInitializationFunction(void *,char *,char *,char *);
00128 static void DumpExpression(void *,struct expr *);
00129 static void MarkConstruct(void *,struct constructHeader *,void *);
00130 static void HashedExpressionsToCode(void *);
00131 static void DeallocateConstructCompilerData(void *);
00132
00133
00134
00135
00136
00137 globle void InitializeConstructCompilerData(
00138 void *theEnv)
00139 {
00140 AllocateEnvironmentData(theEnv,CONSTRUCT_COMPILER_DATA,sizeof(struct constructCompilerData),DeallocateConstructCompilerData);
00141
00142 ConstructCompilerData(theEnv)->MaxIndices = 2000;
00143 ConstructCompilerData(theEnv)->CodeGeneratorCount = 0;
00144 }
00145
00146
00147
00148
00149
00150 static void DeallocateConstructCompilerData(
00151 void *theEnv)
00152 {
00153 struct CodeGeneratorItem *tmpPtr, *nextPtr;
00154 int i;
00155
00156 tmpPtr = ConstructCompilerData(theEnv)->ListOfCodeGeneratorItems;
00157 while (tmpPtr != NULL)
00158 {
00159 nextPtr = tmpPtr->next;
00160
00161 for (i = 0; i < tmpPtr->arrayCount ; i++)
00162 { rm(theEnv,tmpPtr->arrayNames[i],strlen(tmpPtr->arrayNames[i]) + 1); }
00163
00164 if (tmpPtr->arrayCount != 0)
00165 { rm(theEnv,tmpPtr->arrayNames,sizeof(char *) * tmpPtr->arrayCount); }
00166
00167 rtn_struct(theEnv,CodeGeneratorItem,tmpPtr);
00168 tmpPtr = nextPtr;
00169 }
00170 }
00171
00172
00173
00174
00175
00176 globle void ConstructsToCCommand(
00177 void *theEnv)
00178 {
00179 char *fileName, *pathName, *fileNameBuffer;
00180 DATA_OBJECT theArg;
00181 int argCount;
00182 long long id, max;
00183 int nameLength, pathLength;
00184 #if VAX_VMS || WIN_MVC || WIN_BTC
00185 int i;
00186 #endif
00187
00188
00189
00190
00191
00192 if ((argCount = EnvArgRangeCheck(theEnv,"constructs-to-c",2,4)) == -1) return;
00193
00194
00195
00196
00197
00198 if (EnvArgTypeCheck(theEnv,"constructs-to-c",1,SYMBOL_OR_STRING,&theArg) == FALSE)
00199 { return; }
00200
00201 fileName = DOToString(theArg);
00202 nameLength = (int) strlen(fileName);
00203
00204
00205
00206
00207
00208
00209 #if VAX_VMS || WIN_MVC || WIN_BTC
00210 for (i = 0 ; *(fileName+i) ; i++)
00211 {
00212 if (*(fileName+i) == '.')
00213 {
00214 PrintErrorID(theEnv,"CONSCOMP",1,FALSE);
00215 EnvPrintRouter(theEnv,WERROR,"Invalid file name ");
00216 EnvPrintRouter(theEnv,WERROR,fileName);
00217 EnvPrintRouter(theEnv,WERROR," contains \'.\'\n");
00218 return;
00219 }
00220 }
00221 #endif
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231 if ((nameLength + EXTRA_FILE_NAME) > FILENAME_MAX)
00232 {
00233 PrintErrorID(theEnv,"CONSCOMP",1,FALSE);
00234 EnvPrintRouter(theEnv,WERROR,"Aborting because the base file name may cause the fopen maximum of ");
00235 PrintLongInteger(theEnv,WERROR,FILENAME_MAX);
00236 EnvPrintRouter(theEnv,WERROR," to be violated when file names are generated.\n");
00237 return;
00238 }
00239
00240
00241
00242
00243
00244
00245
00246
00247 if (nameLength > 3)
00248 {
00249 PrintWarningID(theEnv,"CONSCOMP",1,FALSE);
00250 EnvPrintRouter(theEnv,WWARNING,"Base file name exceeds 3 characters.\n");
00251 EnvPrintRouter(theEnv,WWARNING," This may cause files to be overwritten if file name length\n");
00252 EnvPrintRouter(theEnv,WWARNING," is limited on your platform.\n");
00253 }
00254
00255
00256
00257
00258
00259 if (EnvArgTypeCheck(theEnv,"constructs-to-c",2,INTEGER,&theArg) == FALSE)
00260 { return; }
00261
00262 id = DOToLong(theArg);
00263 if (id < 0)
00264 {
00265 ExpectedTypeError1(theEnv,"constructs-to-c",2,"positive integer");
00266 return;
00267 }
00268
00269
00270
00271
00272
00273 if (argCount == 3)
00274 {
00275 if (EnvArgTypeCheck(theEnv,"constructs-to-c",3,SYMBOL_OR_STRING,&theArg) == FALSE)
00276 { return; }
00277
00278 pathName = DOToString(theArg);
00279 pathLength = (int) strlen(pathName);
00280 }
00281 else
00282 {
00283 pathName = "";
00284 pathLength = 0;
00285 }
00286
00287
00288
00289
00290
00291
00292 if (argCount == 4)
00293 {
00294 if (EnvArgTypeCheck(theEnv,"constructs-to-c",4,INTEGER,&theArg) == FALSE)
00295 { return; }
00296
00297 max = DOToLong(theArg);
00298
00299 if (max < 0)
00300 {
00301 ExpectedTypeError1(theEnv,"constructs-to-c",4,"positive integer");
00302 return;
00303 }
00304 }
00305 else
00306 { max = 10000; }
00307
00308
00309
00310
00311
00312
00313 fileNameBuffer = (char *) genalloc(theEnv,nameLength + pathLength + EXTRA_FILE_NAME);
00314
00315 ConstructsToC(theEnv,fileName,pathName,fileNameBuffer,id,max);
00316
00317 genfree(theEnv,fileNameBuffer,nameLength + pathLength + EXTRA_FILE_NAME);
00318 }
00319
00320
00321
00322
00323
00324 static int ConstructsToC(
00325 void *theEnv,
00326 char *fileName,
00327 char *pathName,
00328 char *fileNameBuffer,
00329 long long theImageID,
00330 long long max)
00331 {
00332 int fileVersion;
00333 struct CodeGeneratorItem *cgPtr;
00334
00335
00336
00337
00338
00339
00340
00341 ConstructCompilerData(theEnv)->MaxIndices = (int) max;
00342
00343
00344
00345
00346
00347
00348 for (cgPtr = ConstructCompilerData(theEnv)->ListOfCodeGeneratorItems;
00349 cgPtr != NULL;
00350 cgPtr = cgPtr->next)
00351 { if (cgPtr->beforeFunction != NULL) (*cgPtr->beforeFunction)(theEnv); }
00352
00353
00354
00355
00356
00357
00358
00359 PeriodicCleanup(theEnv,FALSE,FALSE);
00360
00361
00362
00363
00364
00365 ConstructCompilerData(theEnv)->FilePrefix = fileName;
00366 ConstructCompilerData(theEnv)->PathName = pathName;
00367 ConstructCompilerData(theEnv)->FileNameBuffer = fileNameBuffer;
00368 ConstructCompilerData(theEnv)->ImageID = (int) theImageID;
00369 ConstructCompilerData(theEnv)->ExpressionFP = NULL;
00370 ConstructCompilerData(theEnv)->ExpressionVersion = 1;
00371 ConstructCompilerData(theEnv)->ExpressionHeader = TRUE;
00372 ConstructCompilerData(theEnv)->ExpressionCount = 0;
00373
00374
00375
00376
00377
00378 gensprintf(fileNameBuffer,"%s%s.h",pathName,fileName);
00379 if ((ConstructCompilerData(theEnv)->HeaderFP = GenOpen(theEnv,fileNameBuffer,"w")) == NULL)
00380 {
00381 OpenErrorMessage(theEnv,"constructs-to-c",fileNameBuffer);
00382 return(0);
00383 }
00384
00385 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"#ifndef _CONSTRUCT_COMPILER_HEADER_\n");
00386 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"#define _CONSTRUCT_COMPILER_HEADER_\n\n");
00387
00388 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"#include <stdio.h>\n");
00389 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"#include \"setup.h\"\n");
00390 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"#include \"expressn.h\"\n");
00391 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"#include \"extnfunc.h\"\n");
00392 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"#include \"%s\"\n",API_HEADER);
00393 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"\n#define VS (void *)\n");
00394 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"\n");
00395
00396
00397
00398
00399
00400 WriteFunctionExternDeclarations(theEnv,ConstructCompilerData(theEnv)->HeaderFP);
00401
00402 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"\n#endif\n\n");
00403 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"/****************************/\n");
00404 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"/* EXTERN ARRAY DEFINITIONS */\n");
00405 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"/****************************/\n\n");
00406
00407
00408
00409
00410
00411 gensprintf(fileNameBuffer,"%s%s_init.c",pathName,fileName);
00412 if ((ConstructCompilerData(theEnv)->FixupFP = GenOpen(theEnv,fileNameBuffer,"w")) == NULL)
00413 {
00414 OpenErrorMessage(theEnv,"constructs-to-c",fileNameBuffer);
00415 return(0);
00416 }
00417
00418 fprintf(ConstructCompilerData(theEnv)->FixupFP,"#include \"%s.h\"\n",fileName);
00419 fprintf(ConstructCompilerData(theEnv)->FixupFP,"\n");
00420
00421 fprintf(ConstructCompilerData(theEnv)->FixupFP,"\n");
00422 fprintf(ConstructCompilerData(theEnv)->FixupFP,"/**********************************/\n");
00423 fprintf(ConstructCompilerData(theEnv)->FixupFP,"/* CONSTRUCT IMAGE FIXUP FUNCTION */\n");
00424 fprintf(ConstructCompilerData(theEnv)->FixupFP,"/**********************************/\n");
00425
00426 fprintf(ConstructCompilerData(theEnv)->FixupFP,"\nvoid FixupCImage_%d(\n",ConstructCompilerData(theEnv)->ImageID);
00427 fprintf(ConstructCompilerData(theEnv)->FixupFP," void *theEnv)\n");
00428 fprintf(ConstructCompilerData(theEnv)->FixupFP," {\n");
00429
00430
00431
00432
00433
00434
00435
00436 AtomicValuesToCode(theEnv,fileName,pathName,fileNameBuffer);
00437
00438 FunctionsToCode(theEnv,fileName,pathName,fileNameBuffer);
00439
00440 HashedExpressionsToCode(theEnv);
00441
00442 ConstraintsToCode(theEnv,fileName,pathName,fileNameBuffer,4,
00443 ConstructCompilerData(theEnv)->HeaderFP,
00444 ConstructCompilerData(theEnv)->ImageID,
00445 ConstructCompilerData(theEnv)->MaxIndices);
00446
00447
00448
00449
00450
00451
00452 fileVersion = 5;
00453 for (cgPtr = ConstructCompilerData(theEnv)->ListOfCodeGeneratorItems;
00454 cgPtr != NULL;
00455 cgPtr = cgPtr->next)
00456 {
00457 if (cgPtr->generateFunction != NULL)
00458 {
00459 (*cgPtr->generateFunction)(theEnv,fileName,pathName,fileNameBuffer,fileVersion,ConstructCompilerData(theEnv)->HeaderFP,ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->MaxIndices);
00460 fileVersion++;
00461 }
00462 }
00463
00464
00465
00466
00467
00468
00469 RestoreAtomicValueBuckets(theEnv);
00470
00471
00472
00473
00474
00475 if (ConstructCompilerData(theEnv)->ExpressionFP != NULL)
00476 {
00477 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"};\n");
00478 GenClose(theEnv,ConstructCompilerData(theEnv)->ExpressionFP);
00479 }
00480
00481
00482
00483
00484
00485 if (ConstructCompilerData(theEnv)->FixupFP != NULL)
00486 {
00487 fprintf(ConstructCompilerData(theEnv)->FixupFP," }\n");
00488 GenClose(theEnv,ConstructCompilerData(theEnv)->FixupFP);
00489 }
00490
00491
00492
00493
00494
00495 WriteInitializationFunction(theEnv,fileName,pathName,fileNameBuffer);
00496
00497
00498
00499
00500
00501 GenClose(theEnv,ConstructCompilerData(theEnv)->HeaderFP);
00502
00503
00504
00505
00506
00507
00508 return(TRUE);
00509 }
00510
00511
00512
00513
00514
00515
00516 static void WriteFunctionExternDeclarations(
00517 void *theEnv,
00518 FILE *fp)
00519 {
00520 struct FunctionDefinition *theFunction;
00521
00522 fprintf(fp,"\n");
00523 fprintf(fp,"/************************************/\n");
00524 fprintf(fp,"/* EXTERNAL FUNCTION DEFINITIONS */\n");
00525 fprintf(fp,"/************************************/\n\n");
00526
00527 for (theFunction = GetFunctionList(theEnv);
00528 theFunction != NULL;
00529 theFunction = theFunction->next)
00530 {
00531 fprintf(fp,"extern ");
00532 switch(theFunction->returnValueType)
00533 {
00534 case 'i':
00535 case 'b':
00536 fprintf(fp,"int ");
00537 break;
00538
00539 case 'g':
00540 fprintf(fp,"long long ");
00541 break;
00542
00543 case 'l':
00544 fprintf(fp,"long ");
00545 break;
00546
00547 case 'f':
00548 fprintf(fp,"float ");
00549 break;
00550
00551 case 'd':
00552 fprintf(fp,"double ");
00553 break;
00554
00555 case 'w':
00556 case 's':
00557 case 'o':
00558 fprintf(fp,"void *");
00559 break;
00560
00561 case 'c':
00562 fprintf(fp,"char ");
00563 break;
00564
00565 case 'a':
00566 case 'x':
00567 fprintf(fp,"void * ");
00568 break;
00569
00570 case 'v':
00571 case 'm':
00572 case 'u':
00573 case 'n':
00574 case 'j':
00575 case 'k':
00576 fprintf(fp,"void ");
00577 break;
00578
00579 default:
00580 SystemError(theEnv,"CONSCOMP",1);
00581 break;
00582 }
00583
00584 fprintf(fp,"%s(",theFunction->actualFunctionName);
00585
00586 switch(theFunction->returnValueType)
00587 {
00588 case 'i':
00589 case 'b':
00590 case 'l':
00591 case 'f':
00592 case 'd':
00593 case 'w':
00594 case 's':
00595 case 'o':
00596 case 'c':
00597 case 'a':
00598 case 'x':
00599 case 'v':
00600 if (theFunction->environmentAware)
00601 { fprintf(fp,"void *"); }
00602 else
00603 { fprintf(fp,"void"); }
00604 break;
00605
00606 case 'm':
00607 case 'u':
00608 case 'n':
00609 case 'j':
00610 case 'k':
00611 if (theFunction->environmentAware)
00612 { fprintf(fp,"void *,DATA_OBJECT_PTR_ARG"); }
00613 else
00614 { fprintf(fp,"DATA_OBJECT_PTR_ARG"); }
00615 break;
00616 }
00617
00618 fprintf(fp,");\n");
00619 }
00620 }
00621
00622
00623
00624
00625
00626
00627 static int FunctionsToCode(
00628 void *theEnv,
00629 char *fileName,
00630 char *pathName,
00631 char *fileNameBuffer)
00632 {
00633 short i = 0;
00634 FILE *fp;
00635 int version = 1;
00636 int newHeader = TRUE;
00637 struct FunctionDefinition *fctnPtr;
00638
00639
00640
00641
00642
00643
00644 for (fctnPtr = GetFunctionList(theEnv);
00645 fctnPtr != NULL;
00646 fctnPtr = fctnPtr->next)
00647 { fctnPtr->bsaveIndex = i++; }
00648
00649
00650
00651
00652
00653
00654 if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,2,version,FALSE)) == NULL)
00655 { return(0); }
00656
00657
00658
00659
00660
00661
00662 fprintf(fp,"\n\n");
00663 fprintf(fp,"/************************************/\n");
00664 fprintf(fp,"/* FUNCTION LIST DEFINITION */\n");
00665 fprintf(fp,"/************************************/\n\n");
00666
00667 i = 1;
00668 fctnPtr = GetFunctionList(theEnv);
00669 while (fctnPtr != NULL)
00670 {
00671 if (newHeader)
00672 {
00673 fprintf(fp,"struct FunctionDefinition P%d_%d[] = {\n",ConstructCompilerData(theEnv)->ImageID,version);
00674 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern struct FunctionDefinition P%d_%d[];\n",ConstructCompilerData(theEnv)->ImageID,version);
00675 newHeader = FALSE;
00676 }
00677
00678 fprintf(fp,"{");
00679 PrintSymbolReference(theEnv,fp,fctnPtr->callFunctionName);
00680 fprintf(fp,",\"%s\",",fctnPtr->actualFunctionName);
00681 fprintf(fp,"'%c',",fctnPtr->returnValueType);
00682 fprintf(fp,"PTIF %s,",fctnPtr->actualFunctionName);
00683 fprintf(fp,"NULL,");
00684 if (fctnPtr->restrictions != NULL) fprintf(fp,"\"%s\",",fctnPtr->restrictions);
00685 else fprintf(fp,"NULL,");
00686 fprintf(fp,"0,0,%d,0,",(fctnPtr->environmentAware ? 1 : 0));
00687 PrintFunctionReference(theEnv,fp,fctnPtr->next);
00688
00689 i++;
00690 fctnPtr = fctnPtr->next;
00691 if ((i > ConstructCompilerData(theEnv)->MaxIndices) || (fctnPtr == NULL))
00692 {
00693 fprintf(fp,"}};\n");
00694 GenClose(theEnv,fp);
00695 i = 1;
00696 version++;
00697 if (fctnPtr != NULL)
00698 {
00699 if ((fp = NewCFile(theEnv,fileName,pathName,fileNameBuffer,2,version,FALSE)) == NULL) return(0);
00700 newHeader = TRUE;
00701 }
00702 }
00703 else
00704 { fprintf(fp,"},\n"); }
00705 }
00706
00707 return(TRUE);
00708 }
00709
00710
00711
00712
00713
00714 globle void PrintFunctionReference(
00715 void *theEnv,
00716 FILE *fp,
00717 struct FunctionDefinition *funcPtr)
00718 {
00719 if (funcPtr == NULL) fprintf(fp,"NULL");
00720 else
00721 fprintf(fp,"&P%d_%d[%d]",ConstructCompilerData(theEnv)->ImageID,
00722 (funcPtr->bsaveIndex / ConstructCompilerData(theEnv)->MaxIndices) + 1,
00723 funcPtr->bsaveIndex % ConstructCompilerData(theEnv)->MaxIndices);
00724 }
00725
00726
00727
00728
00729
00730
00731 static int WriteInitializationFunction(
00732 void *theEnv,
00733 char *fileName,
00734 char *pathName,
00735 char *fileNameBuffer)
00736 {
00737 FILE *fp;
00738 struct CodeGeneratorItem *cgPtr;
00739
00740
00741
00742
00743
00744 gensprintf(fileNameBuffer,"%s%s.c",pathName,fileName);
00745 if ((fp = GenOpen(theEnv,fileNameBuffer,"w")) == NULL)
00746 {
00747 OpenErrorMessage(theEnv,"constructs-to-c",fileNameBuffer);
00748 return(FALSE);
00749 }
00750
00751
00752
00753
00754
00755 fprintf(fp,"#include \"%s.h\"\n",fileName);
00756 fprintf(fp,"\n");
00757 fprintf(fp,"#include \"utility.h\"\n");
00758 fprintf(fp,"#include \"generate.h\"\n");
00759 fprintf(fp,"#include \"envrnmnt.h\"\n");
00760 fprintf(fp,"#include \"expressn.h\"\n");
00761 fprintf(fp,"#include \"extnfunc.h\"\n");
00762 fprintf(fp,"#include \"objrtmch.h\"\n");
00763 fprintf(fp,"#include \"rulebld.h\"\n\n");
00764
00765 fprintf(ConstructCompilerData(theEnv)->HeaderFP," void *InitCImage_%d(void);\n",ConstructCompilerData(theEnv)->ImageID);
00766 fprintf(ConstructCompilerData(theEnv)->HeaderFP," void FixupCImage_%d(void *);\n",ConstructCompilerData(theEnv)->ImageID);
00767
00768
00769
00770
00771
00772 fprintf(fp,"\n");
00773 fprintf(fp,"/*******************************************/\n");
00774 fprintf(fp,"/* CONSTRUCT IMAGE INITIALIZATION FUNCTION */\n");
00775 fprintf(fp,"/*******************************************/\n");
00776
00777 fprintf(fp,"\nvoid *InitCImage_%d()\n",ConstructCompilerData(theEnv)->ImageID);
00778 fprintf(fp," {\n");
00779 fprintf(fp," static void *theEnv = NULL;\n\n");
00780 fprintf(fp," if (theEnv != NULL) return(NULL);\n\n");
00781 fprintf(fp," theEnv = CreateRuntimeEnvironment(sht%d,fht%d,iht%d,bmht%d);\n\n",
00782 ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->ImageID,
00783 ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->ImageID);
00784
00785 fprintf(fp," EnvClear(theEnv);\n");
00786 fprintf(fp," PeriodicCleanup(theEnv,TRUE,FALSE);\n");
00787
00788 fprintf(fp," RefreshSpecialSymbols(theEnv);\n");
00789 fprintf(fp," InstallFunctionList(theEnv,P%d_1);\n\n",ConstructCompilerData(theEnv)->ImageID);
00790 fprintf(fp," InitExpressionPointers(theEnv);\n");
00791 fprintf(fp," FixupCImage_%d(theEnv);\n\n",ConstructCompilerData(theEnv)->ImageID);
00792
00793
00794
00795
00796
00797 cgPtr = ConstructCompilerData(theEnv)->ListOfCodeGeneratorItems;
00798 while (cgPtr != NULL)
00799 {
00800 if (cgPtr->initFunction != NULL)
00801 {
00802 (*cgPtr->initFunction)(theEnv,fp,ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->MaxIndices);
00803 fprintf(fp,"\n");
00804 }
00805 cgPtr = cgPtr->next;
00806 }
00807
00808
00809
00810
00811
00812 fprintf(fp," return(theEnv);\n");
00813 fprintf(fp," }\n");
00814
00815 GenClose(theEnv,fp);
00816
00817
00818
00819
00820
00821
00822 return(TRUE);
00823 }
00824
00825
00826
00827
00828
00829 globle FILE *NewCFile(
00830 void *theEnv,
00831 char *fileName,
00832 char *pathName,
00833 char *fileNameBuffer,
00834 int id,
00835 int version,
00836 int reopenOldFile)
00837 {
00838 FILE *newFP;
00839
00840 gensprintf(fileNameBuffer,"%s%s%d_%d.c",pathName,fileName,id,version);
00841
00842 if (reopenOldFile)
00843 { newFP = GenOpen(theEnv,fileNameBuffer,"a"); }
00844 else
00845 { newFP = GenOpen(theEnv,fileNameBuffer,"w"); }
00846
00847 if (newFP == NULL)
00848 {
00849 OpenErrorMessage(theEnv,"constructs-to-c",fileNameBuffer);
00850 return(NULL);
00851 }
00852
00853 if (reopenOldFile == FALSE)
00854 {
00855 fprintf(newFP,"#include \"%s.h\"\n",fileName);
00856 fprintf(newFP,"\n");
00857 }
00858
00859 return(newFP);
00860 }
00861
00862
00863
00864
00865
00866
00867
00868 static void HashedExpressionsToCode(
00869 void *theEnv)
00870 {
00871 unsigned i;
00872 EXPRESSION_HN *exphash;
00873
00874 for (i = 0; i < EXPRESSION_HASH_SIZE; i++)
00875 {
00876 for (exphash = ExpressionData(theEnv)->ExpressionHashTable[i];
00877 exphash != NULL;
00878 exphash = exphash->next)
00879 {
00880 exphash->bsaveID = ConstructCompilerData(theEnv)->ExpressionCount + (ConstructCompilerData(theEnv)->MaxIndices * ConstructCompilerData(theEnv)->ExpressionVersion);
00881 ExpressionToCode(theEnv,NULL,exphash->exp);
00882 }
00883 }
00884 }
00885
00886
00887
00888
00889
00890
00891 globle void PrintHashedExpressionReference(
00892 void *theEnv,
00893 FILE *theFile,
00894 struct expr *theExpression,
00895 int imageID,
00896 int maxIndices)
00897 {
00898 long theIDValue;
00899
00900 if (theExpression == NULL)
00901 { fprintf(theFile,"NULL"); }
00902 else
00903 {
00904 theIDValue = HashedExpressionIndex(theEnv,theExpression);
00905
00906 fprintf(theFile,"&E%d_%ld[%ld]",
00907 imageID,
00908 theIDValue / maxIndices,
00909 theIDValue % maxIndices);
00910 }
00911 }
00912
00913
00914
00915
00916
00917
00918 globle int ExpressionToCode(
00919 void *theEnv,
00920 FILE *fp,
00921 struct expr *exprPtr)
00922 {
00923
00924
00925
00926
00927 if (exprPtr == NULL)
00928 {
00929 if (fp != NULL) fprintf(fp,"NULL");
00930 return(FALSE);
00931 }
00932 else if (fp != NULL)
00933 { fprintf(fp,"&E%d_%d[%ld]",ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->ExpressionVersion,ConstructCompilerData(theEnv)->ExpressionCount); }
00934
00935
00936
00937
00938
00939 if (ConstructCompilerData(theEnv)->ExpressionHeader == TRUE)
00940 {
00941 if ((ConstructCompilerData(theEnv)->ExpressionFP = NewCFile(theEnv,ConstructCompilerData(theEnv)->FilePrefix,
00942 ConstructCompilerData(theEnv)->PathName,
00943 ConstructCompilerData(theEnv)->FileNameBuffer,
00944 3,ConstructCompilerData(theEnv)->ExpressionVersion,FALSE)) == NULL)
00945 { return(-1); }
00946
00947 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"struct expr E%d_%d[] = {\n",ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->ExpressionVersion);
00948 fprintf(ConstructCompilerData(theEnv)->HeaderFP,"extern struct expr E%d_%d[];\n",ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->ExpressionVersion);
00949 ConstructCompilerData(theEnv)->ExpressionHeader = FALSE;
00950 }
00951 else
00952 { fprintf(ConstructCompilerData(theEnv)->ExpressionFP,",\n"); }
00953
00954
00955
00956
00957
00958 DumpExpression(theEnv,exprPtr);
00959
00960
00961
00962
00963
00964 if (ConstructCompilerData(theEnv)->ExpressionCount >= ConstructCompilerData(theEnv)->MaxIndices)
00965 {
00966 ConstructCompilerData(theEnv)->ExpressionCount = 0;
00967 ConstructCompilerData(theEnv)->ExpressionVersion++;
00968 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"};\n");
00969 GenClose(theEnv,ConstructCompilerData(theEnv)->ExpressionFP);
00970 ConstructCompilerData(theEnv)->ExpressionFP = NULL;
00971 ConstructCompilerData(theEnv)->ExpressionHeader = TRUE;
00972 }
00973
00974
00975
00976
00977
00978
00979
00980 return(TRUE);
00981 }
00982
00983
00984
00985
00986
00987 static void DumpExpression(
00988 void *theEnv,
00989 struct expr *exprPtr)
00990 {
00991 while (exprPtr != NULL)
00992 {
00993 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"{");
00994 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"%d,",exprPtr->type);
00995 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"VS ");
00996 switch (exprPtr->type)
00997 {
00998 case FCALL:
00999 PrintFunctionReference(theEnv,ConstructCompilerData(theEnv)->ExpressionFP,(struct FunctionDefinition *) exprPtr->value);
01000 break;
01001
01002 case INTEGER:
01003 PrintIntegerReference(theEnv,ConstructCompilerData(theEnv)->ExpressionFP,(INTEGER_HN *) exprPtr->value);
01004 break;
01005
01006 case FLOAT:
01007 PrintFloatReference(theEnv,ConstructCompilerData(theEnv)->ExpressionFP,(FLOAT_HN *) exprPtr->value);
01008 break;
01009
01010 case PCALL:
01011 #if DEFFUNCTION_CONSTRUCT
01012 PrintDeffunctionReference(theEnv,ConstructCompilerData(theEnv)->ExpressionFP,(DEFFUNCTION *) exprPtr->value,
01013 ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->MaxIndices);
01014 #else
01015 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL");
01016 #endif
01017 break;
01018
01019 case GCALL:
01020 #if DEFGENERIC_CONSTRUCT
01021 PrintGenericFunctionReference(theEnv,ConstructCompilerData(theEnv)->ExpressionFP,(DEFGENERIC *) exprPtr->value,
01022 ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->MaxIndices);
01023 #else
01024 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL");
01025 #endif
01026 break;
01027
01028 case DEFTEMPLATE_PTR:
01029 #if DEFTEMPLATE_CONSTRUCT
01030 DeftemplateCConstructReference(theEnv,ConstructCompilerData(theEnv)->ExpressionFP,exprPtr->value,ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->MaxIndices);
01031 #else
01032 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL");
01033 #endif
01034 break;
01035
01036 case DEFGLOBAL_PTR:
01037 #if DEFGLOBAL_CONSTRUCT
01038 DefglobalCConstructReference(theEnv,ConstructCompilerData(theEnv)->ExpressionFP,exprPtr->value,ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->MaxIndices);
01039 #else
01040 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL");
01041 #endif
01042 break;
01043
01044 case DEFCLASS_PTR:
01045 #if OBJECT_SYSTEM
01046 PrintClassReference(theEnv,ConstructCompilerData(theEnv)->ExpressionFP,(DEFCLASS *) exprPtr->value,ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->MaxIndices);
01047 #else
01048 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL");
01049 #endif
01050 break;
01051
01052 case FACT_ADDRESS:
01053 #if DEFTEMPLATE_CONSTRUCT
01054 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL");
01055 fprintf(ConstructCompilerData(theEnv)->FixupFP,
01056 " E%d_%d[%ld].value = &FactData(theEnv)->DummyFact;\n",
01057 ConstructCompilerData(theEnv)->ImageID,
01058 ConstructCompilerData(theEnv)->ExpressionVersion,
01059 ConstructCompilerData(theEnv)->ExpressionCount);
01060 #else
01061 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL");
01062 #endif
01063 break;
01064
01065 case INSTANCE_ADDRESS:
01066 #if OBJECT_SYSTEM
01067 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL");
01068 fprintf(ConstructCompilerData(theEnv)->FixupFP,
01069 " E%d_%d[%ld].value = &InstanceData(theEnv)->DummyInstance;\n",
01070 ConstructCompilerData(theEnv)->ImageID,
01071 ConstructCompilerData(theEnv)->ExpressionVersion,
01072 ConstructCompilerData(theEnv)->ExpressionCount);
01073 #else
01074 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL");
01075 #endif
01076 break;
01077
01078 case STRING:
01079 case SYMBOL:
01080 case INSTANCE_NAME:
01081 case GBL_VARIABLE:
01082 PrintSymbolReference(theEnv,ConstructCompilerData(theEnv)->ExpressionFP,(SYMBOL_HN *) exprPtr->value);
01083 break;
01084
01085 case RVOID:
01086 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL");
01087 break;
01088
01089 default:
01090 if (EvaluationData(theEnv)->PrimitivesArray[exprPtr->type] == NULL)
01091 { fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL"); }
01092 else if (EvaluationData(theEnv)->PrimitivesArray[exprPtr->type]->bitMap)
01093 { PrintBitMapReference(theEnv,ConstructCompilerData(theEnv)->ExpressionFP,(BITMAP_HN *) exprPtr->value); }
01094 else
01095 { fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL"); }
01096 break;
01097 }
01098
01099 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,",");
01100
01101 ConstructCompilerData(theEnv)->ExpressionCount++;
01102 if (exprPtr->argList == NULL)
01103 { fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL,"); }
01104 else
01105 {
01106 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"&E%d_%d[%ld],",ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->ExpressionVersion,
01107 ConstructCompilerData(theEnv)->ExpressionCount);
01108 }
01109
01110 if (exprPtr->nextArg == NULL)
01111 { fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"NULL}"); }
01112 else
01113 {
01114 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,"&E%d_%d[%ld]}",ConstructCompilerData(theEnv)->ImageID,ConstructCompilerData(theEnv)->ExpressionVersion,
01115 ConstructCompilerData(theEnv)->ExpressionCount + ExpressionSize(exprPtr->argList));
01116 }
01117
01118 if (exprPtr->argList != NULL)
01119 {
01120 fprintf(ConstructCompilerData(theEnv)->ExpressionFP,",\n");
01121 DumpExpression(theEnv,exprPtr->argList);
01122 }
01123
01124 exprPtr = exprPtr->nextArg;
01125 if (exprPtr != NULL) fprintf(ConstructCompilerData(theEnv)->ExpressionFP,",\n");
01126 }
01127 }
01128
01129
01130
01131
01132
01133 globle void ConstructsToCCommandDefinition(
01134 void *theEnv)
01135 {
01136 EnvDefineFunction2(theEnv,"constructs-to-c",'v',
01137 PTIEF ConstructsToCCommand,
01138 "ConstructsToCCommand", "24*kiki");
01139 }
01140
01141
01142
01143
01144
01145
01146
01147 globle struct CodeGeneratorItem *AddCodeGeneratorItem(
01148 void *theEnv,
01149 char *name,
01150 int priority,
01151 void (*beforeFunction)(void *),
01152 void (*initFunction)(void *,FILE *,int,int),
01153 int (*generateFunction)(void *,char *,char *,char *,int,FILE *,int,int),
01154 int arrayCount)
01155 {
01156 struct CodeGeneratorItem *newPtr, *currentPtr, *lastPtr = NULL;
01157 register int i;
01158 char theBuffer[3];
01159
01160
01161
01162
01163
01164
01165 newPtr = get_struct(theEnv,CodeGeneratorItem);
01166
01167 newPtr->name = name;
01168 newPtr->beforeFunction = beforeFunction;
01169 newPtr->initFunction = initFunction;
01170 newPtr->generateFunction = generateFunction;
01171 newPtr->priority = priority;
01172 newPtr->arrayCount = arrayCount;
01173
01174
01175
01176
01177
01178
01179
01180
01181 if (arrayCount != 0)
01182 {
01183 if ((arrayCount + ConstructCompilerData(theEnv)->CodeGeneratorCount) > (PRIMARY_LEN + SECONDARY_LEN))
01184 {
01185 SystemError(theEnv,"CONSCOMP",2);
01186 EnvExitRouter(theEnv,EXIT_FAILURE);
01187 }
01188
01189 newPtr->arrayNames = (char **) gm2(theEnv,(sizeof(char *) * arrayCount));
01190
01191 for (i = 0 ; i < arrayCount ; i++)
01192 {
01193 if (ConstructCompilerData(theEnv)->CodeGeneratorCount < PRIMARY_LEN)
01194 { gensprintf(theBuffer,"%c",PRIMARY_CODES[ConstructCompilerData(theEnv)->CodeGeneratorCount]); }
01195 else
01196 { gensprintf(theBuffer,"%c_",SECONDARY_CODES[ConstructCompilerData(theEnv)->CodeGeneratorCount - PRIMARY_LEN]); }
01197 ConstructCompilerData(theEnv)->CodeGeneratorCount++;
01198 newPtr->arrayNames[i] = (char *) gm2(theEnv,(strlen(theBuffer) + 1));
01199 genstrcpy(newPtr->arrayNames[i],theBuffer);
01200 }
01201 }
01202 else
01203 { newPtr->arrayNames = NULL; }
01204
01205
01206
01207
01208
01209
01210 if (ConstructCompilerData(theEnv)->ListOfCodeGeneratorItems == NULL)
01211 {
01212 newPtr->next = NULL;
01213 ConstructCompilerData(theEnv)->ListOfCodeGeneratorItems = newPtr;
01214 return(newPtr);
01215 }
01216
01217 currentPtr = ConstructCompilerData(theEnv)->ListOfCodeGeneratorItems;
01218 while ((currentPtr != NULL) ? (priority < currentPtr->priority) : FALSE)
01219 {
01220 lastPtr = currentPtr;
01221 currentPtr = currentPtr->next;
01222 }
01223
01224 if (lastPtr == NULL)
01225 {
01226 newPtr->next = ConstructCompilerData(theEnv)->ListOfCodeGeneratorItems;
01227 ConstructCompilerData(theEnv)->ListOfCodeGeneratorItems = newPtr;
01228 }
01229 else
01230 {
01231 newPtr->next = currentPtr;
01232 lastPtr->next = newPtr;
01233 }
01234
01235
01236
01237
01238
01239
01240 return(newPtr);
01241 }
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251 globle FILE *CloseFileIfNeeded(
01252 void *theEnv,
01253 FILE *theFile,
01254 int *theCount,
01255 int *arrayVersion,
01256 int maxIndices,
01257 int *canBeReopened,
01258 struct CodeGeneratorFile *codeFile)
01259 {
01260
01261
01262
01263
01264
01265 if (*theCount < maxIndices)
01266 {
01267
01268
01269
01270
01271
01272 if (canBeReopened != NULL)
01273 {
01274 *canBeReopened = TRUE;
01275 GenClose(theEnv,theFile);
01276 return(NULL);
01277 }
01278
01279 return(theFile);
01280 }
01281
01282
01283
01284
01285
01286
01287
01288 if (canBeReopened != NULL)
01289 { *canBeReopened = FALSE; }
01290
01291
01292
01293
01294
01295
01296 if (theFile == NULL)
01297 {
01298 if ((canBeReopened == NULL) || (codeFile == NULL))
01299 {
01300 SystemError(theEnv,"CONSCOMP",3);
01301 EnvExitRouter(theEnv,EXIT_FAILURE);
01302 }
01303
01304 if (codeFile->filePrefix == NULL)
01305 { return(NULL); }
01306
01307 theFile = NewCFile(theEnv,codeFile->filePrefix,codeFile->pathName,codeFile->fileNameBuffer,codeFile->id,codeFile->version,TRUE);
01308 if (theFile == NULL)
01309 {
01310 SystemError(theEnv,"CONSCOMP",4);
01311 EnvExitRouter(theEnv,EXIT_FAILURE);
01312 }
01313 }
01314
01315
01316
01317
01318
01319 fprintf(theFile,"};\n");
01320 GenClose(theEnv,theFile);
01321
01322
01323
01324
01325
01326
01327 *theCount = 0;
01328 (*arrayVersion)++;
01329
01330
01331
01332
01333
01334
01335 return(NULL);
01336 }
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346 globle FILE *OpenFileIfNeeded(
01347 void *theEnv,
01348 FILE *theFile,
01349 char *fileName,
01350 char *pathName,
01351 char *fileNameBuffer,
01352 int fileID,
01353 int imageID,
01354 int *fileCount,
01355 int arrayVersion,
01356 FILE *headerFP,
01357 char *structureName,
01358 char *structPrefix,
01359 int reopenOldFile,
01360 struct CodeGeneratorFile *codeFile)
01361 {
01362 char arrayName[80];
01363 char *newName;
01364 int newID, newVersion;
01365
01366
01367
01368
01369
01370
01371 if (reopenOldFile)
01372 {
01373 if (codeFile == NULL)
01374 {
01375 SystemError(theEnv,"CONSCOMP",5);
01376 EnvExitRouter(theEnv,EXIT_FAILURE);
01377 }
01378
01379 newName = codeFile->filePrefix;
01380 newID = codeFile->id;
01381 newVersion = codeFile->version;
01382 }
01383
01384
01385
01386
01387
01388
01389
01390 else
01391 {
01392 newName = fileName;
01393 newVersion = *fileCount;
01394 newID = fileID;
01395
01396 if (codeFile != NULL)
01397 {
01398 codeFile->version = newVersion;
01399 codeFile->filePrefix = newName;
01400 codeFile->id = newID;
01401 }
01402 }
01403
01404
01405
01406
01407
01408 if (theFile != NULL)
01409 {
01410 fprintf(theFile,",\n");
01411 return(theFile);
01412 }
01413
01414
01415
01416
01417
01418 if ((theFile = NewCFile(theEnv,newName,pathName,fileNameBuffer,newID,newVersion,reopenOldFile)) == NULL)
01419 { return(NULL); }
01420
01421
01422
01423
01424
01425
01426
01427 if (reopenOldFile == FALSE)
01428 {
01429 (*fileCount)++;
01430 gensprintf(arrayName,"%s%d_%d",structPrefix,imageID,arrayVersion);
01431 fprintf(theFile,"%s %s[] = {\n",structureName,arrayName);
01432 fprintf(headerFP,"extern %s %s[];\n",structureName,arrayName);
01433 }
01434 else
01435 { fprintf(theFile,",\n"); }
01436
01437
01438
01439
01440
01441 return(theFile);
01442 }
01443
01444
01445
01446
01447
01448 globle void MarkConstructBsaveIDs(
01449 void *theEnv,
01450 int constructModuleIndex)
01451 {
01452 long theCount = 0;
01453
01454 DoForAllConstructs(theEnv,MarkConstruct,constructModuleIndex,FALSE,&theCount);
01455 }
01456
01457
01458
01459
01460
01461
01462 #if WIN_BTC
01463 #pragma argsused
01464 #endif
01465 static void MarkConstruct(
01466 void *theEnv,
01467 struct constructHeader *theConstruct,
01468 void *vTheBuffer)
01469 {
01470 long *count = (long *) vTheBuffer;
01471 #if MAC_MCW || WIN_MCW || MAC_XCD
01472 #pragma unused(theEnv)
01473 #endif
01474
01475 theConstruct->bsaveID = (*count)++;
01476 }
01477
01478
01479
01480
01481
01482 globle void ConstructHeaderToCode(
01483 void *theEnv,
01484 FILE *theFile,
01485 struct constructHeader *theConstruct,
01486 int imageID,
01487 int maxIndices,
01488 int moduleCount,
01489 char *constructModulePrefix,
01490 char *constructPrefix)
01491 {
01492
01493
01494
01495
01496 fprintf(theFile,"{");
01497
01498 PrintSymbolReference(theEnv,theFile,theConstruct->name);
01499
01500
01501
01502
01503
01504 fprintf(theFile,",NULL,");
01505
01506
01507
01508
01509
01510 fprintf(theFile,"MIHS &%s%d_%d[%d],",
01511 constructModulePrefix,
01512 imageID,
01513 (moduleCount / maxIndices) + 1,
01514 moduleCount % maxIndices);
01515
01516
01517
01518
01519
01520 fprintf(theFile,"0,");
01521
01522
01523
01524
01525
01526 if (theConstruct->next == NULL)
01527 { fprintf(theFile,"NULL}"); }
01528 else
01529 {
01530 fprintf(theFile,"CHS &%s%d_%ld[%ld]}",
01531 constructPrefix,
01532 imageID,
01533 (theConstruct->next->bsaveID / maxIndices) + 1,
01534 theConstruct->next->bsaveID % maxIndices);
01535 }
01536 }
01537
01538
01539
01540
01541
01542 globle void ConstructModuleToCode(
01543 void *theEnv,
01544 FILE *theFile,
01545 struct defmodule *theModule,
01546 int imageID,
01547 int maxIndices,
01548 int constructIndex,
01549 char *constructPrefix)
01550 {
01551 struct defmoduleItemHeader *theModuleItem;
01552
01553
01554
01555
01556
01557 fprintf(theFile,"{");
01558
01559 theModuleItem = (struct defmoduleItemHeader *)
01560 GetModuleItem(theEnv,theModule,constructIndex);
01561
01562 PrintDefmoduleReference(theEnv,theFile,theModule);
01563
01564 fprintf(theFile,",");
01565
01566
01567
01568
01569
01570 if (theModuleItem->firstItem == NULL) fprintf(theFile,"NULL,");
01571 else fprintf(theFile,"CHS &%s%d_%ld[%ld],",
01572 constructPrefix,
01573 imageID,
01574 (long) (theModuleItem->firstItem->bsaveID / maxIndices) + 1,
01575 (long) theModuleItem->firstItem->bsaveID % maxIndices);
01576
01577
01578
01579
01580
01581 if (theModuleItem->lastItem == NULL) fprintf(theFile,"NULL");
01582 else fprintf(theFile,"CHS &%s%d_%ld[%ld]",
01583 constructPrefix,
01584 imageID,
01585 (long) (theModuleItem->lastItem->bsaveID / maxIndices) + 1,
01586 (long) theModuleItem->lastItem->bsaveID % maxIndices);
01587
01588 fprintf(theFile,"}");
01589 }
01590
01591 #else
01592
01593 void ConstructsToCCommand(void *);
01594
01595
01596
01597
01598
01599 void ConstructsToCCommand(
01600 void *theEnv)
01601 {
01602 #if MAC_MCW || WIN_MCW || MAC_XCD
01603 #pragma unused(theEnv)
01604 #endif
01605 }
01606
01607 #endif