⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 genrccmp.c

📁 NASA 开发使用的一个专家系统
💻 C
📖 第 1 页 / 共 2 页
字号:
              goto GenericCodeError;                       for (i = 0 ; i < theDefgeneric->mcnt ; i++)              {               theMethod = &theDefgeneric->methods[i];               if (i > 0)                 fprintf(itemFiles[METHODI],",\n");               MethodToCode(itemFiles[METHODI],imageID,theMethod,                            itemArrayVersions[RESTRICTIONI],itemArrayCounts[RESTRICTIONI]);               if (theMethod->restrictionCount > 0)                 {                  /* ========================================                     Make sure that all restrictions for a                     particular method go into the same array                     ======================================== */                  itemFiles[RESTRICTIONI] =                      OpenFileIfNeeded(itemFiles[RESTRICTIONI],fileName,fileID,                                      imageID,&fileCount,                                      itemArrayVersions[RESTRICTIONI],headerFP,                                      "RESTRICTION",RestrictionPrefix(),                                      itemReopenFlags[RESTRICTIONI],&itemCodeFiles[RESTRICTIONI]);                  if (itemFiles[RESTRICTIONI] == NULL)                    goto GenericCodeError;                  for (j = 0 ; j < theMethod->restrictionCount ; j++)                    {                     theRestriction = &theMethod->restrictions[j];                     if (j > 0)                       fprintf(itemFiles[RESTRICTIONI],",\n");                     RestrictionToCode(itemFiles[RESTRICTIONI],imageID,theRestriction,                                       itemArrayVersions[TYPEI],itemArrayCounts[TYPEI]);                                          if (theRestriction->tcnt > 0)                       {                        /* =========================================                           Make sure that all types for a particular                           restriction go into the same array                           ========================================= */                        itemFiles[TYPEI] =                            OpenFileIfNeeded(itemFiles[TYPEI],fileName,fileID,                                            imageID,&fileCount,                                            itemArrayVersions[TYPEI],headerFP,                                            "VOID *",TypePrefix(),                                            itemReopenFlags[TYPEI],&itemCodeFiles[TYPEI]);                        if (itemFiles[TYPEI] == NULL)                          goto GenericCodeError;                        for (k = 0 ; k < theRestriction->tcnt ; k++)                          {                           if (k > 0)                             fprintf(itemFiles[TYPEI],",\n");                           TypeToCode(itemFiles[TYPEI],imageID,                                      theRestriction->types[k],maxIndices);                          }                        itemArrayCounts[TYPEI] += theRestriction->tcnt;                        itemFiles[TYPEI] =                            CloseFileIfNeeded(itemFiles[TYPEI],&itemArrayCounts[TYPEI],                                             &itemArrayVersions[TYPEI],maxIndices,                                             &itemReopenFlags[TYPEI],&itemCodeFiles[TYPEI]);                       }                    }                  itemArrayCounts[RESTRICTIONI] += theMethod->restrictionCount;                  itemFiles[RESTRICTIONI] =                      CloseFileIfNeeded(itemFiles[RESTRICTIONI],&itemArrayCounts[RESTRICTIONI],                                       &itemArrayVersions[RESTRICTIONI],maxIndices,                                       &itemReopenFlags[RESTRICTIONI],&itemCodeFiles[RESTRICTIONI]);                 }              }            itemArrayCounts[METHODI] += theDefgeneric->mcnt;            itemFiles[METHODI] =                CloseFileIfNeeded(itemFiles[METHODI],&itemArrayCounts[METHODI],                                 &itemArrayVersions[METHODI],maxIndices,                                 &itemReopenFlags[METHODI],&itemCodeFiles[METHODI]);           }         theDefgeneric = (DEFGENERIC *) GetNextDefgeneric(theDefgeneric);        }              theModule = (struct defmodule *) GetNextDefmodule(theModule);      moduleCount++;      itemArrayCounts[MODULEI]++;     }   CloseDefgenericFiles(itemFiles,itemReopenFlags,itemCodeFiles,maxIndices);   return(1);GenericCodeError:   CloseDefgenericFiles(itemFiles,itemReopenFlags,itemCodeFiles,maxIndices);   return(0);  }/******************************************************  NAME         : CloseDefgenericFiles  DESCRIPTION  : Closes construct compiler files                  for defgeneric structures  INPUTS       : 1) An array containing all the                    pertinent file pointers                 2) An array containing all the                    pertinent file reopen flags                 3) An array containing all the                    pertinent file name/id/version info                 4) The maximum number of indices                    allowed in an array  RETURNS      : Nothing useful  SIDE EFFECTS : Files closed  NOTES        : None *****************************************************/static VOID CloseDefgenericFiles(itemFiles,itemReopenFlags,itemCodeFiles,maxIndices)  FILE *itemFiles[SAVE_ITEMS];  int itemReopenFlags[SAVE_ITEMS];  struct CodeGeneratorFile itemCodeFiles[SAVE_ITEMS];   int maxIndices;    {   int count = maxIndices;   int arrayVersion = 0;   register int i;      for (i = 0 ; i < SAVE_ITEMS ; i++)     {      count = maxIndices;      itemFiles[i] = CloseFileIfNeeded(itemFiles[i],&count,&arrayVersion,                                       maxIndices,&itemReopenFlags[i],                                       &itemCodeFiles[i]);     }  }/***************************************************  NAME         : DefgenericModuleToCode  DESCRIPTION  : Writes out the C values for a                 defgeneric module item  INPUTS       : 1) The output file                 2) The module for the defgenerics                 3) The compile image id                 4) The maximum number of elements                    in an array  RETURNS      : Nothing useful  SIDE EFFECTS : Defgeneric module item written  NOTES        : None ***************************************************/static VOID DefgenericModuleToCode(theFile,theModule,imageID,maxIndices)  FILE *theFile;  struct defmodule *theModule;  int imageID;  int maxIndices;  {   fprintf(theFile,"{");    ConstructModuleToCode(theFile,theModule,imageID,maxIndices,                         DefgenericModuleIndex,ConstructPrefix(DefgenericCodeItem));   fprintf(theFile,"}");   }  /****************************************************************  NAME         : SingleDefgenericToCode  DESCRIPTION  : Writes out a single defgeneric's                 data to the file  INPUTS       : 1)  The output file                 2)  The compile image id                 3)  The maximum number of                     elements in an array                 4)  The defgeneric                 5)  The module index                 6)  The partition holding the                     generic methods                 7) The relative index of the                    generics methods in the partition  RETURNS      : Nothing useful  SIDE EFFECTS : Defgeneric data written  NOTES        : None ***************************************************************/static VOID SingleDefgenericToCode(theFile,imageID,maxIndices,theDefgeneric,moduleCount,                                   methodArrayVersion,methodArrayCount)  FILE *theFile;  int imageID,maxIndices;  DEFGENERIC *theDefgeneric;  int moduleCount,methodArrayVersion,methodArrayCount;  {   /* ==================      Defgeneric Header      ================== */   fprintf(theFile,"{");   ConstructHeaderToCode(theFile,&theDefgeneric->header,imageID,maxIndices,moduleCount,                         ModulePrefix(DefgenericCodeItem),                         ConstructPrefix(DefgenericCodeItem));        /* =========================      Defgeneric specific data      ========================= */   fprintf(theFile,",0,0,");   if (theDefgeneric->methods == NULL)     fprintf(theFile,"NULL");   else     {      fprintf(theFile,"&%s%d_%d[%d]",MethodPrefix(),imageID,                      methodArrayVersion,methodArrayCount);     }   fprintf(theFile,",%u,0}",theDefgeneric->mcnt);  }  /****************************************************************  NAME         : MethodToCode  DESCRIPTION  : Writes out a single method's                 data to the file  INPUTS       : 1)  The output file                 2)  The compile image id                 3)  The method                 4)  The partition holding the                     method restrictions                 5) The relative index of the                    method restrictions in the partition  RETURNS      : Nothing useful  SIDE EFFECTS : Method data written  NOTES        : None ***************************************************************/static VOID MethodToCode(theFile,imageID,theMethod,                         restrictionArrayVersion,restrictionArrayCount)  FILE *theFile;  int imageID;  DEFMETHOD *theMethod;  int restrictionArrayVersion,restrictionArrayCount;  {   fprintf(theFile,"{%u,0,%d,%d,%d,%d,%u,0,",                   theMethod->index,theMethod->restrictionCount,                   theMethod->minRestrictions,theMethod->maxRestrictions,                   theMethod->localVarCount,theMethod->system);   if (theMethod->restrictions == NULL)     fprintf(theFile,"NULL,");   else     fprintf(theFile,"&%s%d_%d[%d],",RestrictionPrefix(),imageID,                                     restrictionArrayVersion,restrictionArrayCount);   ExpressionToCode(theFile,theMethod->actions);   fprintf(theFile,",NULL}");  }  /****************************************************************  NAME         : RestrictionToCode  DESCRIPTION  : Writes out a single restriction's                 data to the file  INPUTS       : 1)  The output file                 2)  The compile image id                 3)  The restriction                 4)  The partition holding the                     restriction types                 5) The relative index of the                    restriction types in the partition  RETURNS      : Nothing useful  SIDE EFFECTS : Restriction data written  NOTES        : None ***************************************************************/static VOID RestrictionToCode(theFile,imageID,theRestriction,                              typeArrayVersion,typeArrayCount)  FILE *theFile;  int imageID;  RESTRICTION *theRestriction;  int typeArrayVersion,typeArrayCount;  {   fprintf(theFile,"{");   if (theRestriction->types == NULL)     fprintf(theFile,"NULL,");   else     fprintf(theFile,"&%s%d_%d[%d],",TypePrefix(),imageID,                                     typeArrayVersion,typeArrayCount);   ExpressionToCode(theFile,theRestriction->query);   fprintf(theFile,",%u}",theRestriction->tcnt);  }  /****************************************************************  NAME         : TypeToCode  DESCRIPTION  : Writes out a single type's                 data to the file  INPUTS       : 1)  The output file                 2)  The compile image id                 3)  The type  RETURNS      : Nothing useful  SIDE EFFECTS : Type data written  NOTES        : None ***************************************************************/static VOID TypeToCode(theFile,imageID,theType,maxIndices)  FILE *theFile;  int imageID;  VOID *theType;  int maxIndices;  {#if OBJECT_SYSTEM       fprintf(theFile,"VS ");              PrintClassReference(theFile,(DEFCLASS *) theType,imageID,maxIndices);#else   PrintIntegerReference(theFile,(INTEGER_HN *) theType);#endif                 }#endif/***************************************************  NAME         :   DESCRIPTION  :   INPUTS       :   RETURNS      :   SIDE EFFECTS :   NOTES        :  ***************************************************/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -