1 /*******************************************************/ 2 /* "C" Language Integrated Production System */ 3 /* */ 4 /* CLIPS Version 6.30 08/16/14 */ 5 /* */ 6 /* CONSTRUCT COMPILER HEADER FILE */ 7 /*******************************************************/ 8 9 /*************************************************************/ 10 /* Purpose: */ 11 /* */ 12 /* Principal Programmer(s): */ 13 /* Gary D. Riley */ 14 /* */ 15 /* Contributing Programmer(s): */ 16 /* */ 17 /* Revision History: */ 18 /* */ 19 /* 6.23: Modifications to use the system constant */ 20 /* FILENAME_MAX to check file name lengths. */ 21 /* DR0856 */ 22 /* */ 23 /* Corrected compilation errors for files */ 24 /* generated by constructs-to-c. DR0861 */ 25 /* */ 26 /* 6.24: Used EnvClear rather than Clear in */ 27 /* InitCImage initialization code. */ 28 /* */ 29 /* Added environment parameter to GenClose. */ 30 /* Added environment parameter to GenOpen. */ 31 /* */ 32 /* Removed SHORT_LINK_NAMES code as this option */ 33 /* is no longer supported. */ 34 /* */ 35 /* Support for run-time programs directly passing */ 36 /* the hash tables for initialization. */ 37 /* */ 38 /* 6.30: Added path name argument to constructs-to-c. */ 39 /* */ 40 /* Changed integer type/precision. */ 41 /* */ 42 /* Removed conditional code for unsupported */ 43 /* compilers/operating systems (IBM_MCW, MAC_MCW, */ 44 /* IBM_TBC, IBM_MSC, IBM_ICB, IBM_ZTC, and */ 45 /* IBM_SC). */ 46 /* */ 47 /* Use genstrcpy instead of strcpy. */ 48 /* */ 49 /* Added const qualifiers to remove C++ */ 50 /* deprecation warnings. */ 51 /* */ 52 /*************************************************************/ 53 54 #ifndef _H_conscomp 55 #define _H_conscomp 56 57 #define ArbitraryPrefix(codeItem,i) (codeItem)->arrayNames[(i)] 58 59 #define ModulePrefix(codeItem) (codeItem)->arrayNames[0] 60 #define ConstructPrefix(codeItem) (codeItem)->arrayNames[1] 61 62 #ifndef _H_constrct 63 #include "constrct.h" 64 #endif 65 #ifndef _H_extnfunc 66 #include "extnfunc.h" 67 #endif 68 #ifndef _H_symblcmp 69 #include "symblcmp.h" 70 #endif 71 #ifndef _H_moduldef 72 #include "moduldef.h" 73 #endif 74 75 #define CONSTRUCT_COMPILER_DATA 41 76 77 struct CodeGeneratorItem 78 { 79 const char *name; 80 void (*beforeFunction)(void *); 81 void (*initFunction)(void *,FILE *,int,int); 82 int (*generateFunction)(void *,const char *,const char *,char *,int,FILE *,int,int); 83 int priority; 84 char **arrayNames; 85 int arrayCount; 86 struct CodeGeneratorItem *next; 87 }; 88 89 struct constructCompilerData 90 { 91 int ImageID; 92 FILE *HeaderFP; 93 int MaxIndices; 94 FILE *ExpressionFP; 95 FILE *FixupFP; 96 const char *FilePrefix; 97 const char *PathName; 98 char *FileNameBuffer; 99 intBool ExpressionHeader; 100 long ExpressionCount; 101 int ExpressionVersion; 102 int CodeGeneratorCount; 103 struct CodeGeneratorItem *ListOfCodeGeneratorItems; 104 }; 105 106 #define ConstructCompilerData(theEnv) ((struct constructCompilerData *) GetEnvironmentData(theEnv,CONSTRUCT_COMPILER_DATA)) 107 108 #ifdef LOCALE 109 #undef LOCALE 110 #endif 111 112 #ifndef _STDIO_INCLUDED_ 113 #define _STDIO_INCLUDED_ 114 #include <stdio.h> 115 #endif 116 117 struct CodeGeneratorFile 118 { 119 const char *filePrefix; 120 const char *pathName; 121 char *fileNameBuffer; 122 int id,version; 123 }; 124 125 #ifdef _CONSCOMP_SOURCE_ 126 #define LOCALE 127 #else 128 #define LOCALE extern 129 #endif 130 131 LOCALE void InitializeConstructCompilerData(void *); 132 LOCALE void ConstructsToCCommandDefinition(void *); 133 LOCALE FILE *NewCFile(void *,const char *,const char *,char *,int,int,int); 134 LOCALE int ExpressionToCode(void *,FILE *,struct expr *); 135 LOCALE void PrintFunctionReference(void *,FILE *,struct FunctionDefinition *); 136 LOCALE struct CodeGeneratorItem *AddCodeGeneratorItem(void *,const char *,int, 137 void (*)(void *), 138 void (*)(void *,FILE *,int,int), 139 int (*)(void *,const char *,const char *,char *,int,FILE *,int,int),int); 140 LOCALE FILE *CloseFileIfNeeded(void *,FILE *,int *,int *,int,int *,struct CodeGeneratorFile *); 141 LOCALE FILE *OpenFileIfNeeded(void *,FILE *,const char *,const char *,char *,int,int,int *, 142 int,FILE *,const char *,char *,int,struct CodeGeneratorFile *); 143 LOCALE void MarkConstructBsaveIDs(void *,int); 144 LOCALE void ConstructHeaderToCode(void *,FILE *,struct constructHeader *,int,int, 145 int,const char *,const char *); 146 LOCALE void ConstructModuleToCode(void *,FILE *,struct defmodule *,int,int, 147 int,const char *); 148 LOCALE void PrintHashedExpressionReference(void *,FILE *,struct expr *,int,int); 149 150 #endif 151 152 153 154 155