memory.c 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  1. /* ------------------------------------------------------------------------- */
  2. /* "memory" : Memory management and ICL memory setting commands */
  3. /* (For "memoryerror", see "errors.c") */
  4. /* */
  5. /* Part of Inform 6.33 */
  6. /* copyright (c) Graham Nelson 1993 - 2014 */
  7. /* */
  8. /* ------------------------------------------------------------------------- */
  9. #include "header.h"
  10. int32 malloced_bytes=0; /* Total amount of memory allocated */
  11. #ifdef PC_QUICKC
  12. extern void *my_malloc(int32 size, char *whatfor)
  13. { char _huge *c;
  14. if (memout_switch)
  15. printf("Allocating %ld bytes for %s\n",size,whatfor);
  16. if (size==0) return(NULL);
  17. c=(char _huge *)halloc(size,1); malloced_bytes+=size;
  18. if (c==0) memory_out_error(size, 1, whatfor);
  19. return(c);
  20. }
  21. extern void my_realloc(void *pointer, int32 oldsize, int32 size,
  22. char *whatfor)
  23. { char _huge *c;
  24. if (size==0) {
  25. my_free(pointer, whatfor);
  26. return;
  27. }
  28. c=halloc(size,1); malloced_bytes+=size;
  29. if (c==0) memory_out_error(size, 1, whatfor);
  30. if (memout_switch)
  31. printf("Increasing allocation to %ld bytes for %s was (%08lx) \
  32. now (%08lx)\n",
  33. (long int) size,whatfor,(long int) (*(int **)pointer),
  34. (long int) c);
  35. memcpy(c, *(int **)pointer, MIN(oldsize, size));
  36. hfree(*(int **)pointer);
  37. *(int **)pointer = c;
  38. }
  39. extern void *my_calloc(int32 size, int32 howmany, char *whatfor)
  40. { void _huge *c;
  41. if (memout_switch)
  42. printf("Allocating %d bytes: array (%ld entries size %ld) for %s\n",
  43. size*howmany,howmany,size,whatfor);
  44. if ((size*howmany) == 0) return(NULL);
  45. c=(void _huge *)halloc(howmany*size,1); malloced_bytes+=size*howmany;
  46. if (c==0) memory_out_error(size, howmany, whatfor);
  47. return(c);
  48. }
  49. extern void my_recalloc(void *pointer, int32 size, int32 oldhowmany,
  50. int32 howmany, char *whatfor)
  51. { void _huge *c;
  52. if (size*howmany==0) {
  53. my_free(pointer, whatfor);
  54. return;
  55. }
  56. c=(void _huge *)halloc(size*howmany,1); malloced_bytes+=size*howmany;
  57. if (c==0) memory_out_error(size, howmany, whatfor);
  58. if (memout_switch)
  59. printf("Increasing allocation to %ld bytes: array (%ld entries size %ld) \
  60. for %s was (%08lx) now (%08lx)\n",
  61. ((long int)size) * ((long int)howmany),
  62. (long int)howmany,(long int)size,whatfor,
  63. (long int) *(int **)pointer, (long int) c);
  64. memcpy(c, *(int **)pointer, MIN(size*oldhowmany, size*howmany));
  65. hfree(*(int **)pointer);
  66. *(int **)pointer = c;
  67. }
  68. #else
  69. extern void *my_malloc(int32 size, char *whatfor)
  70. { char *c;
  71. if (size==0) return(NULL);
  72. c=malloc((size_t) size); malloced_bytes+=size;
  73. if (c==0) memory_out_error(size, 1, whatfor);
  74. if (memout_switch)
  75. printf("Allocating %ld bytes for %s at (%08lx)\n",
  76. (long int) size,whatfor,(long int) c);
  77. return(c);
  78. }
  79. extern void my_realloc(void *pointer, int32 oldsize, int32 size,
  80. char *whatfor)
  81. { void *c;
  82. if (size==0) {
  83. my_free(pointer, whatfor);
  84. return;
  85. }
  86. c=realloc(*(int **)pointer, (size_t) size); malloced_bytes+=size;
  87. if (c==0) memory_out_error(size, 1, whatfor);
  88. if (memout_switch)
  89. printf("Increasing allocation to %ld bytes for %s was (%08lx) \
  90. now (%08lx)\n",
  91. (long int) size,whatfor,(long int) (*(int **)pointer),
  92. (long int) c);
  93. *(int **)pointer = c;
  94. }
  95. extern void *my_calloc(int32 size, int32 howmany, char *whatfor)
  96. { void *c;
  97. if (size*howmany==0) return(NULL);
  98. c=calloc(howmany,(size_t) size); malloced_bytes+=size*howmany;
  99. if (c==0) memory_out_error(size, howmany, whatfor);
  100. if (memout_switch)
  101. printf("Allocating %ld bytes: array (%ld entries size %ld) \
  102. for %s at (%08lx)\n",
  103. ((long int)size) * ((long int)howmany),
  104. (long int)howmany,(long int)size,whatfor,
  105. (long int) c);
  106. return(c);
  107. }
  108. extern void my_recalloc(void *pointer, int32 size, int32 oldhowmany,
  109. int32 howmany, char *whatfor)
  110. { void *c;
  111. if (size*howmany==0) {
  112. my_free(pointer, whatfor);
  113. return;
  114. }
  115. c=realloc(*(int **)pointer, (size_t)size*(size_t)howmany);
  116. malloced_bytes+=size*howmany;
  117. if (c==0) memory_out_error(size, howmany, whatfor);
  118. if (memout_switch)
  119. printf("Increasing allocation to %ld bytes: array (%ld entries size %ld) \
  120. for %s was (%08lx) now (%08lx)\n",
  121. ((long int)size) * ((long int)howmany),
  122. (long int)howmany,(long int)size,whatfor,
  123. (long int) *(int **)pointer, (long int) c);
  124. *(int **)pointer = c;
  125. }
  126. #endif
  127. extern void my_free(void *pointer, char *whatitwas)
  128. {
  129. if (*(int **)pointer != NULL)
  130. { if (memout_switch)
  131. printf("Freeing memory for %s at (%08lx)\n",
  132. whatitwas, (long int) (*(int **)pointer));
  133. #ifdef PC_QUICKC
  134. hfree(*(int **)pointer);
  135. #else
  136. free(*(int **)pointer);
  137. #endif
  138. *(int **)pointer = NULL;
  139. }
  140. }
  141. /* ------------------------------------------------------------------------- */
  142. /* Extensible blocks of memory, providing a kind of RAM disc as an */
  143. /* alternative to the temporary files option */
  144. /* ------------------------------------------------------------------------- */
  145. static char chunk_name_buffer[60];
  146. static char *chunk_name(memory_block *MB, int no)
  147. { char *p = "(unknown)";
  148. if (MB == &static_strings_area) p = "static strings area";
  149. if (MB == &zcode_area) p = "Z-code area";
  150. if (MB == &link_data_area) p = "link data area";
  151. if (MB == &zcode_backpatch_table) p = "Z-code backpatch table";
  152. if (MB == &zmachine_backpatch_table) p = "Z-machine backpatch table";
  153. sprintf(chunk_name_buffer, "%s chunk %d", p, no);
  154. return(chunk_name_buffer);
  155. }
  156. extern void initialise_memory_block(memory_block *MB)
  157. { int i;
  158. MB->chunks = 0;
  159. for (i=0; i<72; i++) MB->chunk[i] = NULL;
  160. MB->extent_of_last = 0;
  161. MB->write_pos = 0;
  162. }
  163. extern void deallocate_memory_block(memory_block *MB)
  164. { int i;
  165. for (i=0; i<72; i++)
  166. if (MB->chunk[i] != NULL)
  167. my_free(&(MB->chunk[i]), chunk_name(MB, i));
  168. MB->chunks = 0;
  169. MB->extent_of_last = 0;
  170. }
  171. extern int read_byte_from_memory_block(memory_block *MB, int32 index)
  172. { uchar *p;
  173. p = MB->chunk[index/ALLOC_CHUNK_SIZE];
  174. if (p == NULL)
  175. { compiler_error_named("memory: read from unwritten byte in",
  176. chunk_name(MB, index/ALLOC_CHUNK_SIZE));
  177. return 0;
  178. }
  179. return p[index % ALLOC_CHUNK_SIZE];
  180. }
  181. extern void write_byte_to_memory_block(memory_block *MB, int32 index, int value)
  182. { uchar *p; int ch = index/ALLOC_CHUNK_SIZE;
  183. if (ch < 0)
  184. { compiler_error_named("memory: negative index to", chunk_name(MB, 0));
  185. return;
  186. }
  187. if (ch >= 72) memoryerror("ALLOC_CHUNK_SIZE", ALLOC_CHUNK_SIZE);
  188. if (MB->chunk[ch] == NULL)
  189. { int i;
  190. MB->chunk[ch] = my_malloc(ALLOC_CHUNK_SIZE, chunk_name(MB, ch));
  191. p = MB->chunk[ch];
  192. for (i=0; i<ALLOC_CHUNK_SIZE; i++) p[i] = 255;
  193. }
  194. p = MB->chunk[ch];
  195. p[index % ALLOC_CHUNK_SIZE] = value;
  196. }
  197. /* ------------------------------------------------------------------------- */
  198. /* Where the memory settings are declared as variables */
  199. /* ------------------------------------------------------------------------- */
  200. int MAX_QTEXT_SIZE;
  201. int MAX_SYMBOLS;
  202. int SYMBOLS_CHUNK_SIZE;
  203. int HASH_TAB_SIZE;
  204. int MAX_OBJECTS;
  205. int MAX_ARRAYS;
  206. int MAX_ACTIONS;
  207. int MAX_ADJECTIVES;
  208. int MAX_DICT_ENTRIES;
  209. int MAX_STATIC_DATA;
  210. int MAX_PROP_TABLE_SIZE;
  211. int MAX_ABBREVS;
  212. int MAX_EXPRESSION_NODES;
  213. int MAX_VERBS;
  214. int MAX_VERBSPACE;
  215. int MAX_LABELS;
  216. int MAX_LINESPACE;
  217. int32 MAX_STATIC_STRINGS;
  218. int32 MAX_ZCODE_SIZE;
  219. int MAX_LOW_STRINGS;
  220. int32 MAX_TRANSCRIPT_SIZE;
  221. int MAX_CLASSES;
  222. int32 MAX_LINK_DATA_SIZE;
  223. int MAX_INCLUSION_DEPTH;
  224. int MAX_SOURCE_FILES;
  225. int32 MAX_INDIV_PROP_TABLE_SIZE;
  226. int32 MAX_OBJ_PROP_TABLE_SIZE;
  227. int MAX_OBJ_PROP_COUNT;
  228. int MAX_LOCAL_VARIABLES;
  229. int MAX_GLOBAL_VARIABLES;
  230. int DICT_WORD_SIZE; /* number of characters in a dict word */
  231. int DICT_CHAR_SIZE; /* (glulx) 1 for one-byte chars, 4 for Unicode chars */
  232. int DICT_WORD_BYTES; /* DICT_WORD_SIZE*DICT_CHAR_SIZE */
  233. int ZCODE_HEADER_EXT_WORDS; /* (zcode 1.0) requested header extension size */
  234. int ZCODE_HEADER_FLAGS_3; /* (zcode 1.1) value to place in Flags 3 word */
  235. int NUM_ATTR_BYTES;
  236. int GLULX_OBJECT_EXT_BYTES; /* (glulx) extra bytes for each object record */
  237. int32 MAX_NUM_STATIC_STRINGS;
  238. int32 MAX_UNICODE_CHARS;
  239. int32 MAX_STACK_SIZE;
  240. int32 MEMORY_MAP_EXTENSION;
  241. int ALLOC_CHUNK_SIZE;
  242. int WARN_UNUSED_ROUTINES; /* 0: no, 1: yes except in system files, 2: yes always */
  243. int OMIT_UNUSED_ROUTINES; /* 0: no, 1: yes */
  244. /* The way memory sizes are set causes great nuisance for those parameters
  245. which have different defaults under Z-code and Glulx. We have to get
  246. the defaults right whether the user sets "-G $HUGE" or "$HUGE -G".
  247. And an explicit value set by the user should override both defaults. */
  248. static int32 MAX_ZCODE_SIZE_z, MAX_ZCODE_SIZE_g;
  249. static int MAX_PROP_TABLE_SIZE_z, MAX_PROP_TABLE_SIZE_g;
  250. static int MAX_GLOBAL_VARIABLES_z, MAX_GLOBAL_VARIABLES_g;
  251. static int MAX_LOCAL_VARIABLES_z, MAX_LOCAL_VARIABLES_g;
  252. static int DICT_WORD_SIZE_z, DICT_WORD_SIZE_g;
  253. static int NUM_ATTR_BYTES_z, NUM_ATTR_BYTES_g;
  254. static int ALLOC_CHUNK_SIZE_z, ALLOC_CHUNK_SIZE_g;
  255. /* ------------------------------------------------------------------------- */
  256. /* Memory control from the command line */
  257. /* ------------------------------------------------------------------------- */
  258. static void list_memory_sizes(void)
  259. { printf("+--------------------------------------+\n");
  260. printf("| %25s = %-7s |\n","Memory setting","Value");
  261. printf("+--------------------------------------+\n");
  262. printf("| %25s = %-7d |\n","MAX_ABBREVS",MAX_ABBREVS);
  263. printf("| %25s = %-7d |\n","MAX_ACTIONS",MAX_ACTIONS);
  264. printf("| %25s = %-7d |\n","MAX_ADJECTIVES",MAX_ADJECTIVES);
  265. printf("| %25s = %-7d |\n","ALLOC_CHUNK_SIZE",ALLOC_CHUNK_SIZE);
  266. printf("| %25s = %-7d |\n","NUM_ATTR_BYTES",NUM_ATTR_BYTES);
  267. printf("| %25s = %-7d |\n","MAX_CLASSES",MAX_CLASSES);
  268. printf("| %25s = %-7d |\n","MAX_DICT_ENTRIES",MAX_DICT_ENTRIES);
  269. printf("| %25s = %-7d |\n","DICT_WORD_SIZE",DICT_WORD_SIZE);
  270. if (glulx_mode)
  271. printf("| %25s = %-7d |\n","DICT_CHAR_SIZE",DICT_CHAR_SIZE);
  272. printf("| %25s = %-7d |\n","MAX_EXPRESSION_NODES",MAX_EXPRESSION_NODES);
  273. printf("| %25s = %-7d |\n","MAX_GLOBAL_VARIABLES",MAX_GLOBAL_VARIABLES);
  274. printf("| %25s = %-7d |\n","HASH_TAB_SIZE",HASH_TAB_SIZE);
  275. if (!glulx_mode)
  276. printf("| %25s = %-7d |\n","ZCODE_HEADER_EXT_WORDS",ZCODE_HEADER_EXT_WORDS);
  277. if (!glulx_mode)
  278. printf("| %25s = %-7d |\n","ZCODE_HEADER_FLAGS_3",ZCODE_HEADER_FLAGS_3);
  279. printf("| %25s = %-7d |\n","MAX_INCLUSION_DEPTH",MAX_INCLUSION_DEPTH);
  280. printf("| %25s = %-7d |\n","MAX_INDIV_PROP_TABLE_SIZE",
  281. MAX_INDIV_PROP_TABLE_SIZE);
  282. printf("| %25s = %-7d |\n","MAX_LABELS",MAX_LABELS);
  283. printf("| %25s = %-7d |\n","MAX_LINESPACE",MAX_LINESPACE);
  284. printf("| %25s = %-7d |\n","MAX_LINK_DATA_SIZE",MAX_LINK_DATA_SIZE);
  285. if (glulx_mode)
  286. printf("| %25s = %-7d |\n","MAX_LOCAL_VARIABLES",MAX_LOCAL_VARIABLES);
  287. printf("| %25s = %-7d |\n","MAX_LOW_STRINGS",MAX_LOW_STRINGS);
  288. if (glulx_mode)
  289. printf("| %25s = %-7d |\n","MEMORY_MAP_EXTENSION",
  290. MEMORY_MAP_EXTENSION);
  291. if (glulx_mode)
  292. printf("| %25s = %-7d |\n","MAX_NUM_STATIC_STRINGS",
  293. MAX_NUM_STATIC_STRINGS);
  294. printf("| %25s = %-7d |\n","MAX_OBJECTS",MAX_OBJECTS);
  295. if (glulx_mode)
  296. printf("| %25s = %-7d |\n","GLULX_OBJECT_EXT_BYTES",
  297. GLULX_OBJECT_EXT_BYTES);
  298. if (glulx_mode)
  299. printf("| %25s = %-7d |\n","MAX_OBJ_PROP_COUNT",
  300. MAX_OBJ_PROP_COUNT);
  301. if (glulx_mode)
  302. printf("| %25s = %-7d |\n","MAX_OBJ_PROP_TABLE_SIZE",
  303. MAX_OBJ_PROP_TABLE_SIZE);
  304. printf("| %25s = %-7d |\n","MAX_PROP_TABLE_SIZE",MAX_PROP_TABLE_SIZE);
  305. printf("| %25s = %-7d |\n","MAX_QTEXT_SIZE",MAX_QTEXT_SIZE);
  306. printf("| %25s = %-7d |\n","MAX_SOURCE_FILES",MAX_SOURCE_FILES);
  307. if (glulx_mode)
  308. printf("| %25s = %-7ld |\n","MAX_STACK_SIZE",
  309. (long int) MAX_STACK_SIZE);
  310. printf("| %25s = %-7d |\n","MAX_STATIC_DATA",MAX_STATIC_DATA);
  311. printf("| %25s = %-7ld |\n","MAX_STATIC_STRINGS",
  312. (long int) MAX_STATIC_STRINGS);
  313. printf("| %25s = %-7d |\n","MAX_SYMBOLS",MAX_SYMBOLS);
  314. printf("| %25s = %-7d |\n","SYMBOLS_CHUNK_SIZE",SYMBOLS_CHUNK_SIZE);
  315. printf("| %25s = %-7ld |\n","MAX_TRANSCRIPT_SIZE",
  316. (long int) MAX_TRANSCRIPT_SIZE);
  317. if (glulx_mode)
  318. printf("| %25s = %-7ld |\n","MAX_UNICODE_CHARS",
  319. (long int) MAX_UNICODE_CHARS);
  320. printf("| %25s = %-7d |\n","WARN_UNUSED_ROUTINES",WARN_UNUSED_ROUTINES);
  321. printf("| %25s = %-7d |\n","OMIT_UNUSED_ROUTINES",OMIT_UNUSED_ROUTINES);
  322. printf("| %25s = %-7d |\n","MAX_VERBS",MAX_VERBS);
  323. printf("| %25s = %-7d |\n","MAX_VERBSPACE",MAX_VERBSPACE);
  324. printf("| %25s = %-7ld |\n","MAX_ZCODE_SIZE",
  325. (long int) MAX_ZCODE_SIZE);
  326. printf("+--------------------------------------+\n");
  327. }
  328. extern void set_memory_sizes(int size_flag)
  329. {
  330. if (size_flag == HUGE_SIZE)
  331. {
  332. MAX_QTEXT_SIZE = 4000;
  333. MAX_SYMBOLS = 10000;
  334. SYMBOLS_CHUNK_SIZE = 5000;
  335. HASH_TAB_SIZE = 512;
  336. MAX_OBJECTS = 640;
  337. MAX_ACTIONS = 200;
  338. MAX_ADJECTIVES = 50;
  339. MAX_DICT_ENTRIES = 2000;
  340. MAX_STATIC_DATA = 10000;
  341. MAX_PROP_TABLE_SIZE_z = 30000;
  342. MAX_PROP_TABLE_SIZE_g = 60000;
  343. MAX_ABBREVS = 64;
  344. MAX_EXPRESSION_NODES = 100;
  345. MAX_VERBS = 200;
  346. MAX_VERBSPACE = 4096;
  347. MAX_LABELS = 1000;
  348. MAX_LINESPACE = 16000;
  349. MAX_STATIC_STRINGS = 8000;
  350. MAX_ZCODE_SIZE_z = 20000;
  351. MAX_ZCODE_SIZE_g = 40000;
  352. MAX_LINK_DATA_SIZE = 2000;
  353. MAX_LOW_STRINGS = 2048;
  354. MAX_TRANSCRIPT_SIZE = 200000;
  355. MAX_NUM_STATIC_STRINGS = 20000;
  356. MAX_CLASSES = 64;
  357. MAX_OBJ_PROP_COUNT = 128;
  358. MAX_OBJ_PROP_TABLE_SIZE = 4096;
  359. MAX_INDIV_PROP_TABLE_SIZE = 15000;
  360. MAX_ARRAYS = 128;
  361. MAX_GLOBAL_VARIABLES_z = 240;
  362. MAX_GLOBAL_VARIABLES_g = 512;
  363. ALLOC_CHUNK_SIZE_z = 8192;
  364. ALLOC_CHUNK_SIZE_g = 32768;
  365. }
  366. if (size_flag == LARGE_SIZE)
  367. {
  368. MAX_QTEXT_SIZE = 4000;
  369. MAX_SYMBOLS = 6400;
  370. SYMBOLS_CHUNK_SIZE = 5000;
  371. HASH_TAB_SIZE = 512;
  372. MAX_OBJECTS = 512;
  373. MAX_ACTIONS = 200;
  374. MAX_ADJECTIVES = 50;
  375. MAX_DICT_ENTRIES = 1300;
  376. MAX_STATIC_DATA = 10000;
  377. MAX_PROP_TABLE_SIZE_z = 15000;
  378. MAX_PROP_TABLE_SIZE_g = 30000;
  379. MAX_ABBREVS = 64;
  380. MAX_EXPRESSION_NODES = 100;
  381. MAX_VERBS = 140;
  382. MAX_VERBSPACE = 4096;
  383. MAX_LINESPACE = 10000;
  384. MAX_LABELS = 1000;
  385. MAX_STATIC_STRINGS = 8000;
  386. MAX_ZCODE_SIZE_z = 20000;
  387. MAX_ZCODE_SIZE_g = 40000;
  388. MAX_LINK_DATA_SIZE = 2000;
  389. MAX_LOW_STRINGS = 2048;
  390. MAX_TRANSCRIPT_SIZE = 200000;
  391. MAX_NUM_STATIC_STRINGS = 20000;
  392. MAX_CLASSES = 64;
  393. MAX_OBJ_PROP_COUNT = 64;
  394. MAX_OBJ_PROP_TABLE_SIZE = 2048;
  395. MAX_INDIV_PROP_TABLE_SIZE = 10000;
  396. MAX_ARRAYS = 128;
  397. MAX_GLOBAL_VARIABLES_z = 240;
  398. MAX_GLOBAL_VARIABLES_g = 512;
  399. ALLOC_CHUNK_SIZE_z = 8192;
  400. ALLOC_CHUNK_SIZE_g = 16384;
  401. }
  402. if (size_flag == SMALL_SIZE)
  403. {
  404. MAX_QTEXT_SIZE = 4000;
  405. MAX_SYMBOLS = 3000;
  406. SYMBOLS_CHUNK_SIZE = 2500;
  407. HASH_TAB_SIZE = 512;
  408. MAX_OBJECTS = 300;
  409. MAX_ACTIONS = 200;
  410. MAX_ADJECTIVES = 50;
  411. MAX_DICT_ENTRIES = 700;
  412. MAX_STATIC_DATA = 10000;
  413. MAX_PROP_TABLE_SIZE_z = 8000;
  414. MAX_PROP_TABLE_SIZE_g = 16000;
  415. MAX_ABBREVS = 64;
  416. MAX_EXPRESSION_NODES = 40;
  417. MAX_VERBS = 110;
  418. MAX_VERBSPACE = 2048;
  419. MAX_LINESPACE = 10000;
  420. MAX_LABELS = 1000;
  421. MAX_STATIC_STRINGS = 8000;
  422. MAX_ZCODE_SIZE_z = 10000;
  423. MAX_ZCODE_SIZE_g = 20000;
  424. MAX_LINK_DATA_SIZE = 1000;
  425. MAX_LOW_STRINGS = 1024;
  426. MAX_TRANSCRIPT_SIZE = 100000;
  427. MAX_NUM_STATIC_STRINGS = 10000;
  428. MAX_CLASSES = 32;
  429. MAX_OBJ_PROP_COUNT = 64;
  430. MAX_OBJ_PROP_TABLE_SIZE = 1024;
  431. MAX_INDIV_PROP_TABLE_SIZE = 5000;
  432. MAX_ARRAYS = 64;
  433. MAX_GLOBAL_VARIABLES_z = 240;
  434. MAX_GLOBAL_VARIABLES_g = 256;
  435. ALLOC_CHUNK_SIZE_z = 8192;
  436. ALLOC_CHUNK_SIZE_g = 8192;
  437. }
  438. /* Regardless of size_flag... */
  439. MAX_SOURCE_FILES = 256;
  440. MAX_INCLUSION_DEPTH = 5;
  441. MAX_LOCAL_VARIABLES_z = 16;
  442. MAX_LOCAL_VARIABLES_g = 32;
  443. DICT_CHAR_SIZE = 1;
  444. DICT_WORD_SIZE_z = 6;
  445. DICT_WORD_SIZE_g = 9;
  446. NUM_ATTR_BYTES_z = 6;
  447. NUM_ATTR_BYTES_g = 7;
  448. /* Backwards-compatible behavior: allow for a unicode table
  449. whether we need one or not. The user can set this to zero if
  450. there's no unicode table. */
  451. ZCODE_HEADER_EXT_WORDS = 3;
  452. ZCODE_HEADER_FLAGS_3 = 0;
  453. GLULX_OBJECT_EXT_BYTES = 0;
  454. MAX_UNICODE_CHARS = 64;
  455. MEMORY_MAP_EXTENSION = 0;
  456. /* We estimate the default Glulx stack size at 4096. That's about
  457. enough for 90 nested function calls with 8 locals each -- the
  458. same capacity as the Z-Spec's suggestion for Z-machine stack
  459. size. Note that Inform 7 wants more stack; I7-generated code
  460. sets MAX_STACK_SIZE to 65536 by default. */
  461. MAX_STACK_SIZE = 4096;
  462. OMIT_UNUSED_ROUTINES = 0;
  463. WARN_UNUSED_ROUTINES = 0;
  464. adjust_memory_sizes();
  465. }
  466. extern void adjust_memory_sizes()
  467. {
  468. if (!glulx_mode) {
  469. MAX_ZCODE_SIZE = MAX_ZCODE_SIZE_z;
  470. MAX_PROP_TABLE_SIZE = MAX_PROP_TABLE_SIZE_z;
  471. MAX_GLOBAL_VARIABLES = MAX_GLOBAL_VARIABLES_z;
  472. MAX_LOCAL_VARIABLES = MAX_LOCAL_VARIABLES_z;
  473. DICT_WORD_SIZE = DICT_WORD_SIZE_z;
  474. NUM_ATTR_BYTES = NUM_ATTR_BYTES_z;
  475. ALLOC_CHUNK_SIZE = ALLOC_CHUNK_SIZE_z;
  476. }
  477. else {
  478. MAX_ZCODE_SIZE = MAX_ZCODE_SIZE_g;
  479. MAX_PROP_TABLE_SIZE = MAX_PROP_TABLE_SIZE_g;
  480. MAX_GLOBAL_VARIABLES = MAX_GLOBAL_VARIABLES_g;
  481. MAX_LOCAL_VARIABLES = MAX_LOCAL_VARIABLES_g;
  482. DICT_WORD_SIZE = DICT_WORD_SIZE_g;
  483. NUM_ATTR_BYTES = NUM_ATTR_BYTES_g;
  484. ALLOC_CHUNK_SIZE = ALLOC_CHUNK_SIZE_g;
  485. }
  486. }
  487. static void explain_parameter(char *command)
  488. { printf("\n");
  489. if (strcmp(command,"MAX_QTEXT_SIZE")==0)
  490. { printf(
  491. " MAX_QTEXT_SIZE is the maximum length of a quoted string. Increasing\n\
  492. by 1 costs 5 bytes (for lexical analysis memory). Inform automatically\n\
  493. ensures that MAX_STATIC_STRINGS is at least twice the size of this.");
  494. return;
  495. }
  496. if (strcmp(command,"MAX_SYMBOLS")==0)
  497. { printf(
  498. " MAX_SYMBOLS is the maximum number of symbols - names of variables, \n\
  499. objects, routines, the many internal Inform-generated names and so on.\n");
  500. return;
  501. }
  502. if (strcmp(command,"SYMBOLS_CHUNK_SIZE")==0)
  503. { printf(
  504. " The symbols names are stored in memory which is allocated in chunks \n\
  505. of size SYMBOLS_CHUNK_SIZE.\n");
  506. return;
  507. }
  508. if (strcmp(command,"HASH_TAB_SIZE")==0)
  509. { printf(
  510. " HASH_TAB_SIZE is the size of the hash tables used for the heaviest \n\
  511. symbols banks.\n");
  512. return;
  513. }
  514. if (strcmp(command,"MAX_OBJECTS")==0)
  515. { printf(
  516. " MAX_OBJECTS is the maximum number of objects. (If compiling a version-3 \n\
  517. game, 255 is an absolute maximum in any event.)\n");
  518. return;
  519. }
  520. if (strcmp(command,"MAX_ACTIONS")==0)
  521. { printf(
  522. " MAX_ACTIONS is the maximum number of actions - that is, routines such as \n\
  523. TakeSub which are referenced in the grammar table.\n");
  524. return;
  525. }
  526. if (strcmp(command,"MAX_ADJECTIVES")==0)
  527. { printf(
  528. " MAX_ADJECTIVES is the maximum number of different \"adjectives\" in the \n\
  529. grammar table. Adjectives are misleadingly named: they are words such as \n\
  530. \"in\", \"under\" and the like.\n");
  531. return;
  532. }
  533. if (strcmp(command,"MAX_DICT_ENTRIES")==0)
  534. { printf(
  535. " MAX_DICT_ENTRIES is the maximum number of words which can be entered \n\
  536. into the game's dictionary. It costs 29 bytes to increase this by one.\n");
  537. return;
  538. }
  539. if (strcmp(command,"DICT_WORD_SIZE")==0)
  540. { printf(
  541. " DICT_WORD_SIZE is the number of characters in a dictionary word. In \n\
  542. Z-code this is always 6 (only 4 are used in v3 games). In Glulx it \n\
  543. can be any number.\n");
  544. return;
  545. }
  546. if (strcmp(command,"DICT_CHAR_SIZE")==0)
  547. { printf(
  548. " DICT_CHAR_SIZE is the byte size of one character in the dictionary. \n\
  549. (This is only meaningful in Glulx, since Z-code has compressed dictionary \n\
  550. words.) It can be either 1 (the default) or 4 (to enable full Unicode \n\
  551. input.)\n");
  552. return;
  553. }
  554. if (strcmp(command,"NUM_ATTR_BYTES")==0)
  555. { printf(
  556. " NUM_ATTR_BYTES is the space used to store attribute flags. Each byte \n\
  557. stores eight attributes. In Z-code this is always 6 (only 4 are used in \n\
  558. v3 games). In Glulx it can be any number which is a multiple of four, \n\
  559. plus three.\n");
  560. return;
  561. }
  562. if (strcmp(command,"ZCODE_HEADER_EXT_WORDS")==0)
  563. { printf(
  564. " ZCODE_HEADER_EXT_WORDS is the number of words in the Z-code header \n\
  565. extension table (Z-Spec 1.0). The -W switch also sets this. It defaults \n\
  566. to 3, but can be set higher. (It can be set lower if no Unicode \n\
  567. translation table is created.)\n");
  568. return;
  569. }
  570. if (strcmp(command,"ZCODE_HEADER_FLAGS_3")==0)
  571. { printf(
  572. " ZCODE_HEADER_FLAGS_3 is the value to store in the Flags 3 word of the \n\
  573. header extension table (Z-Spec 1.1).\n");
  574. return;
  575. }
  576. if (strcmp(command,"GLULX_OBJECT_EXT_BYTES")==0)
  577. { printf(
  578. " GLULX_OBJECT_EXT_BYTES is an amount of additional space to add to each \n\
  579. object record. It is initialized to zero bytes, and the game is free to \n\
  580. use it as desired. (This is only meaningful in Glulx, since Z-code \n\
  581. specifies the object structure.)\n");
  582. return;
  583. }
  584. if (strcmp(command,"MAX_STATIC_DATA")==0)
  585. { printf(
  586. " MAX_STATIC_DATA is the size of an array of integers holding initial \n\
  587. values for arrays and strings stored as ASCII inside the Z-machine. It \n\
  588. should be at least 1024 but seldom needs much more.\n");
  589. return;
  590. }
  591. if (strcmp(command,"MAX_PROP_TABLE_SIZE")==0)
  592. { printf(
  593. " MAX_PROP_TABLE_SIZE is the number of bytes allocated to hold the \n\
  594. properties table.\n");
  595. return;
  596. }
  597. if (strcmp(command,"MAX_ABBREVS")==0)
  598. { printf(
  599. " MAX_ABBREVS is the maximum number of declared abbreviations. It is not \n\
  600. allowed to exceed 64.\n");
  601. return;
  602. }
  603. if (strcmp(command,"MAX_ARRAYS")==0)
  604. { printf(
  605. " MAX_ARRAYS is the maximum number of declared arrays.\n");
  606. return;
  607. }
  608. if (strcmp(command,"MAX_EXPRESSION_NODES")==0)
  609. { printf(
  610. " MAX_EXPRESSION_NODES is the maximum number of nodes in the expression \n\
  611. evaluator's storage for parse trees. In effect, it measures how \n\
  612. complicated algebraic expressions are allowed to be. Increasing it by \n\
  613. one costs about 80 bytes.\n");
  614. return;
  615. }
  616. if (strcmp(command,"MAX_VERBS")==0)
  617. { printf(
  618. " MAX_VERBS is the maximum number of verbs (such as \"take\") which can be \n\
  619. defined, each with its own grammar. To increase it by one costs about\n\
  620. 128 bytes. A full game will contain at least 100.\n");
  621. return;
  622. }
  623. if (strcmp(command,"MAX_VERBSPACE")==0)
  624. { printf(
  625. " MAX_VERBSPACE is the size of workspace used to store verb words, so may\n\
  626. need increasing in games with many synonyms: unlikely to exceed 4K.\n");
  627. return;
  628. }
  629. if (strcmp(command,"MAX_LABELS")==0)
  630. { printf(
  631. " MAX_LABELS is the maximum number of label points in any one routine.\n\
  632. (If the -k debugging information switch is set, MAX_LABELS is raised to\n\
  633. a minimum level of 2000, as about twice the normal number of label points\n\
  634. are needed to generate tables of how source code corresponds to positions\n\
  635. in compiled code.)");
  636. return;
  637. }
  638. if (strcmp(command,"MAX_LINESPACE")==0)
  639. { printf(
  640. " MAX_LINESPACE is the size of workspace used to store grammar lines, so \n\
  641. may need increasing in games with complex or extensive grammars.\n");
  642. return;
  643. }
  644. if (strcmp(command,"MAX_STATIC_STRINGS")==0)
  645. {
  646. printf(
  647. " MAX_STATIC_STRINGS is the size in bytes of a buffer to hold compiled\n\
  648. strings before they're written into longer-term storage. 2000 bytes is \n\
  649. plenty, allowing string constants of up to about 3000 characters long.\n\
  650. Inform automatically ensures that this is at least twice the size of\n\
  651. MAX_QTEXT_SIZE, to be on the safe side.");
  652. return;
  653. }
  654. if (strcmp(command,"MAX_ZCODE_SIZE")==0)
  655. {
  656. printf(
  657. " MAX_ZCODE_SIZE is the size in bytes of a buffer to hold compiled \n\
  658. code for a single routine. (It applies to both Z-code and Glulx, \n\
  659. despite the name.) As a guide, the longest library routine is \n\
  660. about 6500 bytes long in Z-code; about twice that in Glulx.");
  661. return;
  662. }
  663. if (strcmp(command,"MAX_LINK_DATA_SIZE")==0)
  664. {
  665. printf(
  666. " MAX_LINK_DATA_SIZE is the size in bytes of a buffer to hold module \n\
  667. link data before it's written into longer-term storage. 2000 bytes \n\
  668. is plenty.");
  669. return;
  670. }
  671. if (strcmp(command,"MAX_LOW_STRINGS")==0)
  672. { printf(
  673. " MAX_LOW_STRINGS is the size in bytes of a buffer to hold all the \n\
  674. compiled \"low strings\" which are to be written above the synonyms table \n\
  675. in the Z-machine. 1024 is plenty.\n");
  676. return;
  677. }
  678. if (strcmp(command,"MAX_TRANSCRIPT_SIZE")==0)
  679. { printf(
  680. " MAX_TRANSCRIPT_SIZE is only allocated for the abbreviations optimisation \n\
  681. switch, and has the size in bytes of a buffer to hold the entire text of\n\
  682. the game being compiled: it has to be enormous, say 100000 to 200000.\n");
  683. return;
  684. }
  685. if (strcmp(command,"MAX_CLASSES")==0)
  686. { printf(
  687. " MAX_CLASSES maximum number of object classes which can be defined. This\n\
  688. is cheap to increase.\n");
  689. return;
  690. }
  691. if (strcmp(command,"MAX_INCLUSION_DEPTH")==0)
  692. { printf(
  693. " MAX_INCLUSION_DEPTH is the number of nested includes permitted.\n");
  694. return;
  695. }
  696. if (strcmp(command,"MAX_SOURCE_FILES")==0)
  697. { printf(
  698. " MAX_SOURCE_FILES is the number of source files that can be read in the \n\
  699. compilation.\n");
  700. return;
  701. }
  702. if (strcmp(command,"MAX_INDIV_PROP_TABLE_SIZE")==0)
  703. { printf(
  704. " MAX_INDIV_PROP_TABLE_SIZE is the number of bytes allocated to hold the \n\
  705. table of ..variable values.\n");
  706. return;
  707. }
  708. if (strcmp(command,"MAX_OBJ_PROP_COUNT")==0)
  709. { printf(
  710. " MAX_OBJ_PROP_COUNT is the maximum number of properties a single object \n\
  711. can have. (Glulx only)\n");
  712. return;
  713. }
  714. if (strcmp(command,"MAX_OBJ_PROP_TABLE_SIZE")==0)
  715. { printf(
  716. " MAX_OBJ_PROP_TABLE_SIZE is the number of words allocated to hold a \n\
  717. single object's properties. (Glulx only)\n");
  718. return;
  719. }
  720. if (strcmp(command,"MAX_LOCAL_VARIABLES")==0)
  721. { printf(
  722. " MAX_LOCAL_VARIABLES is the number of local variables (including \n\
  723. arguments) allowed in a procedure. (Glulx only)\n");
  724. return;
  725. }
  726. if (strcmp(command,"MAX_GLOBAL_VARIABLES")==0)
  727. { printf(
  728. " MAX_GLOBAL_VARIABLES is the number of global variables allowed in the \n\
  729. program. (Glulx only)\n");
  730. return;
  731. }
  732. if (strcmp(command,"MAX_NUM_STATIC_STRINGS")==0)
  733. {
  734. printf(
  735. " MAX_NUM_STATIC_STRINGS is the maximum number of compiled strings \n\
  736. allowed in the program. (Glulx only)\n");
  737. return;
  738. }
  739. if (strcmp(command,"MAX_UNICODE_CHARS")==0)
  740. {
  741. printf(
  742. " MAX_UNICODE_CHARS is the maximum number of different Unicode characters \n\
  743. (beyond the Latin-1 range, $00..$FF) which the game text can use. \n\
  744. (Glulx only)\n");
  745. return;
  746. }
  747. if (strcmp(command,"ALLOC_CHUNK_SIZE")==0)
  748. {
  749. printf(
  750. " ALLOC_CHUNK_SIZE is a base unit of Inform's internal memory allocation \n\
  751. for various structures.\n");
  752. return;
  753. }
  754. if (strcmp(command,"MAX_STACK_SIZE")==0)
  755. {
  756. printf(
  757. " MAX_STACK_SIZE is the maximum size (in bytes) of the interpreter stack \n\
  758. during gameplay. (Glulx only)\n");
  759. return;
  760. }
  761. if (strcmp(command,"MEMORY_MAP_EXTENSION")==0)
  762. {
  763. printf(
  764. " MEMORY_MAP_EXTENSION is the number of bytes (all zeroes) to map into \n\
  765. memory after the game file. (Glulx only)\n");
  766. return;
  767. }
  768. if (strcmp(command,"WARN_UNUSED_ROUTINES")==0)
  769. {
  770. printf(
  771. " WARN_UNUSED_ROUTINES, if set to 2, will display a warning for each \n\
  772. routine in the game file which is never called. (This includes \n\
  773. routines called only from uncalled routines, etc.) If set to 1, will warn \n\
  774. only about functions in game code, not in the system library.\n");
  775. return;
  776. }
  777. if (strcmp(command,"OMIT_UNUSED_ROUTINES")==0)
  778. {
  779. printf(
  780. " OMIT_UNUSED_ROUTINES, if set to 1, will avoid compiling unused routines \n\
  781. into the game file.\n");
  782. return;
  783. }
  784. printf("No such memory setting as \"%s\"\n",command);
  785. return;
  786. }
  787. extern void memory_command(char *command)
  788. { int i, k, flag=0; int32 j;
  789. for (k=0; command[k]!=0; k++)
  790. if (islower(command[k])) command[k]=toupper(command[k]);
  791. if (command[0]=='?') { explain_parameter(command+1); return; }
  792. if (strcmp(command, "HUGE")==0) { set_memory_sizes(HUGE_SIZE); return; }
  793. if (strcmp(command, "LARGE")==0) { set_memory_sizes(LARGE_SIZE); return; }
  794. if (strcmp(command, "SMALL")==0) { set_memory_sizes(SMALL_SIZE); return; }
  795. if (strcmp(command, "LIST")==0) { list_memory_sizes(); return; }
  796. for (i=0; command[i]!=0; i++)
  797. { if (command[i]=='=')
  798. { command[i]=0;
  799. j=(int32) atoi(command+i+1);
  800. if ((j==0) && (command[i+1]!='0'))
  801. { printf("Bad numerical setting in $ command \"%s=%s\"\n",
  802. command,command+i+1);
  803. return;
  804. }
  805. if (strcmp(command,"BUFFER_LENGTH")==0)
  806. flag=2;
  807. if (strcmp(command,"MAX_QTEXT_SIZE")==0)
  808. { MAX_QTEXT_SIZE=j, flag=1;
  809. if (2*MAX_QTEXT_SIZE > MAX_STATIC_STRINGS)
  810. MAX_STATIC_STRINGS = 2*MAX_QTEXT_SIZE;
  811. }
  812. if (strcmp(command,"MAX_SYMBOLS")==0)
  813. MAX_SYMBOLS=j, flag=1;
  814. if (strcmp(command,"MAX_BANK_SIZE")==0)
  815. flag=2;
  816. if (strcmp(command,"SYMBOLS_CHUNK_SIZE")==0)
  817. SYMBOLS_CHUNK_SIZE=j, flag=1;
  818. if (strcmp(command,"BANK_CHUNK_SIZE")==0)
  819. flag=2;
  820. if (strcmp(command,"HASH_TAB_SIZE")==0)
  821. HASH_TAB_SIZE=j, flag=1;
  822. if (strcmp(command,"MAX_OBJECTS")==0)
  823. MAX_OBJECTS=j, flag=1;
  824. if (strcmp(command,"MAX_ACTIONS")==0)
  825. MAX_ACTIONS=j, flag=1;
  826. if (strcmp(command,"MAX_ADJECTIVES")==0)
  827. MAX_ADJECTIVES=j, flag=1;
  828. if (strcmp(command,"MAX_DICT_ENTRIES")==0)
  829. MAX_DICT_ENTRIES=j, flag=1;
  830. if (strcmp(command,"DICT_WORD_SIZE")==0)
  831. { DICT_WORD_SIZE=j, flag=1;
  832. DICT_WORD_SIZE_g=DICT_WORD_SIZE_z=j;
  833. }
  834. if (strcmp(command,"DICT_CHAR_SIZE")==0)
  835. DICT_CHAR_SIZE=j, flag=1;
  836. if (strcmp(command,"NUM_ATTR_BYTES")==0)
  837. { NUM_ATTR_BYTES=j, flag=1;
  838. NUM_ATTR_BYTES_g=NUM_ATTR_BYTES_z=j;
  839. }
  840. if (strcmp(command,"ZCODE_HEADER_EXT_WORDS")==0)
  841. ZCODE_HEADER_EXT_WORDS=j, flag=1;
  842. if (strcmp(command,"ZCODE_HEADER_FLAGS_3")==0)
  843. ZCODE_HEADER_FLAGS_3=j, flag=1;
  844. if (strcmp(command,"GLULX_OBJECT_EXT_BYTES")==0)
  845. GLULX_OBJECT_EXT_BYTES=j, flag=1;
  846. if (strcmp(command,"MAX_STATIC_DATA")==0)
  847. MAX_STATIC_DATA=j, flag=1;
  848. if (strcmp(command,"MAX_OLDEPTH")==0)
  849. flag=2;
  850. if (strcmp(command,"MAX_ROUTINES")==0)
  851. flag=2;
  852. if (strcmp(command,"MAX_GCONSTANTS")==0)
  853. flag=2;
  854. if (strcmp(command,"MAX_PROP_TABLE_SIZE")==0)
  855. { MAX_PROP_TABLE_SIZE=j, flag=1;
  856. MAX_PROP_TABLE_SIZE_g=MAX_PROP_TABLE_SIZE_z=j;
  857. }
  858. if (strcmp(command,"MAX_FORWARD_REFS")==0)
  859. flag=2;
  860. if (strcmp(command,"STACK_SIZE")==0)
  861. flag=2;
  862. if (strcmp(command,"STACK_LONG_SLOTS")==0)
  863. flag=2;
  864. if (strcmp(command,"STACK_SHORT_LENGTH")==0)
  865. flag=2;
  866. if (strcmp(command,"MAX_ABBREVS")==0)
  867. MAX_ABBREVS=j, flag=1;
  868. if (strcmp(command,"MAX_ARRAYS")==0)
  869. MAX_ARRAYS=j, flag=1;
  870. if (strcmp(command,"MAX_EXPRESSION_NODES")==0)
  871. MAX_EXPRESSION_NODES=j, flag=1;
  872. if (strcmp(command,"MAX_VERBS")==0)
  873. MAX_VERBS=j, flag=1;
  874. if (strcmp(command,"MAX_VERBSPACE")==0)
  875. MAX_VERBSPACE=j, flag=1;
  876. if (strcmp(command,"MAX_LABELS")==0)
  877. MAX_LABELS=j, flag=1;
  878. if (strcmp(command,"MAX_LINESPACE")==0)
  879. MAX_LINESPACE=j, flag=1;
  880. if (strcmp(command,"MAX_NUM_STATIC_STRINGS")==0)
  881. MAX_NUM_STATIC_STRINGS=j, flag=1;
  882. if (strcmp(command,"MAX_STATIC_STRINGS")==0)
  883. { MAX_STATIC_STRINGS=j, flag=1;
  884. if (2*MAX_QTEXT_SIZE > MAX_STATIC_STRINGS)
  885. MAX_STATIC_STRINGS = 2*MAX_QTEXT_SIZE;
  886. }
  887. if (strcmp(command,"MAX_ZCODE_SIZE")==0)
  888. { MAX_ZCODE_SIZE=j, flag=1;
  889. MAX_ZCODE_SIZE_g=MAX_ZCODE_SIZE_z=j;
  890. }
  891. if (strcmp(command,"MAX_LINK_DATA_SIZE")==0)
  892. MAX_LINK_DATA_SIZE=j, flag=1;
  893. if (strcmp(command,"MAX_LOW_STRINGS")==0)
  894. MAX_LOW_STRINGS=j, flag=1;
  895. if (strcmp(command,"MAX_TRANSCRIPT_SIZE")==0)
  896. MAX_TRANSCRIPT_SIZE=j, flag=1;
  897. if (strcmp(command,"MAX_CLASSES")==0)
  898. MAX_CLASSES=j, flag=1;
  899. if (strcmp(command,"MAX_INCLUSION_DEPTH")==0)
  900. MAX_INCLUSION_DEPTH=j, flag=1;
  901. if (strcmp(command,"MAX_SOURCE_FILES")==0)
  902. MAX_SOURCE_FILES=j, flag=1;
  903. if (strcmp(command,"MAX_INDIV_PROP_TABLE_SIZE")==0)
  904. MAX_INDIV_PROP_TABLE_SIZE=j, flag=1;
  905. if (strcmp(command,"MAX_OBJ_PROP_TABLE_SIZE")==0)
  906. MAX_OBJ_PROP_TABLE_SIZE=j, flag=1;
  907. if (strcmp(command,"MAX_OBJ_PROP_COUNT")==0)
  908. MAX_OBJ_PROP_COUNT=j, flag=1;
  909. if (strcmp(command,"MAX_LOCAL_VARIABLES")==0)
  910. { MAX_LOCAL_VARIABLES=j, flag=1;
  911. MAX_LOCAL_VARIABLES_g=MAX_LOCAL_VARIABLES_z=j;
  912. }
  913. if (strcmp(command,"MAX_GLOBAL_VARIABLES")==0)
  914. { MAX_GLOBAL_VARIABLES=j, flag=1;
  915. MAX_GLOBAL_VARIABLES_g=MAX_GLOBAL_VARIABLES_z=j;
  916. }
  917. if (strcmp(command,"ALLOC_CHUNK_SIZE")==0)
  918. { ALLOC_CHUNK_SIZE=j, flag=1;
  919. ALLOC_CHUNK_SIZE_g=ALLOC_CHUNK_SIZE_z=j;
  920. }
  921. if (strcmp(command,"MAX_UNICODE_CHARS")==0)
  922. MAX_UNICODE_CHARS=j, flag=1;
  923. if (strcmp(command,"MAX_STACK_SIZE")==0)
  924. {
  925. MAX_STACK_SIZE=j, flag=1;
  926. /* Adjust up to a 256-byte boundary. */
  927. MAX_STACK_SIZE = (MAX_STACK_SIZE + 0xFF) & (~0xFF);
  928. }
  929. if (strcmp(command,"MEMORY_MAP_EXTENSION")==0)
  930. {
  931. MEMORY_MAP_EXTENSION=j, flag=1;
  932. /* Adjust up to a 256-byte boundary. */
  933. MEMORY_MAP_EXTENSION = (MEMORY_MAP_EXTENSION + 0xFF) & (~0xFF);
  934. }
  935. if (strcmp(command,"WARN_UNUSED_ROUTINES")==0)
  936. {
  937. WARN_UNUSED_ROUTINES=j, flag=1;
  938. if (WARN_UNUSED_ROUTINES > 2 || WARN_UNUSED_ROUTINES < 0)
  939. WARN_UNUSED_ROUTINES = 2;
  940. }
  941. if (strcmp(command,"OMIT_UNUSED_ROUTINES")==0)
  942. {
  943. OMIT_UNUSED_ROUTINES=j, flag=1;
  944. if (OMIT_UNUSED_ROUTINES > 1 || OMIT_UNUSED_ROUTINES < 0)
  945. OMIT_UNUSED_ROUTINES = 1;
  946. }
  947. if (flag==0)
  948. printf("No such memory setting as \"%s\"\n", command);
  949. if (flag==2)
  950. printf("The Inform 5 memory setting \"%s\" has been withdrawn.\n\
  951. It should be safe to omit it (putting nothing in its place).\n", command);
  952. return;
  953. }
  954. }
  955. printf("No such memory $ command as \"%s\"\n",command);
  956. }
  957. extern void print_memory_usage(void)
  958. {
  959. printf("Properties table used %d\n",
  960. properties_table_size);
  961. printf("Allocated a total of %ld bytes of memory\n",
  962. (long int) malloced_bytes);
  963. }
  964. /* ========================================================================= */
  965. /* Data structure management routines */
  966. /* ------------------------------------------------------------------------- */
  967. extern void init_memory_vars(void)
  968. { malloced_bytes = 0;
  969. }
  970. extern void memory_begin_pass(void) { }
  971. extern void memory_allocate_arrays(void) { }
  972. extern void memory_free_arrays(void) { }
  973. /* ========================================================================= */