arrays.c 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  1. /* ------------------------------------------------------------------------- */
  2. /* "arrays" : Parses array declarations and constructs arrays from them; */
  3. /* likewise global variables, which are in some ways a */
  4. /* simpler form of the same thing. */
  5. /* */
  6. /* Part of Inform 6.33 */
  7. /* copyright (c) Graham Nelson 1993 - 2014 */
  8. /* */
  9. /* ------------------------------------------------------------------------- */
  10. #include "header.h"
  11. /* ------------------------------------------------------------------------- */
  12. /* Arrays defined below: */
  13. /* */
  14. /* int dynamic_array_area[] Initial values for the bytes of */
  15. /* the dynamic array area */
  16. /* int32 global_initial_value[n] The initialised value of the nth */
  17. /* global variable (counting 0 - 239) */
  18. /* */
  19. /* The "dynamic array area" is the Z-machine area holding the current */
  20. /* values of the global variables (in 240x2 = 480 bytes) followed by any */
  21. /* (dynamic) arrays which may be defined. Owing to a poor choice of name */
  22. /* some years ago, this is also called the "static data area", which is */
  23. /* why the memory setting for its maximum extent is "MAX_STATIC_DATA". */
  24. /* */
  25. /* In Glulx, that 240 is changed to MAX_GLOBAL_VAR_NUMBER, and we take */
  26. /* correspondingly more space for the globals. This *really* ought to be */
  27. /* split into two segments. */
  28. /* ------------------------------------------------------------------------- */
  29. int *dynamic_array_area; /* See above */
  30. int32 *global_initial_value;
  31. int no_globals; /* Number of global variables used
  32. by the programmer (Inform itself
  33. uses the top seven -- but these do
  34. not count) */
  35. /* In Glulx, Inform uses the bottom
  36. ten. */
  37. int dynamic_array_area_size; /* Size in bytes */
  38. int no_arrays;
  39. int32 *array_symbols;
  40. int *array_sizes, *array_types;
  41. static int array_entry_size, /* 1 for byte array, 2 for word array */
  42. array_base; /* Offset in dynamic array area of the
  43. array being constructed. During the
  44. same time, dynamic_array_area_size
  45. is the offset of the initial entry
  46. in the array: so for "table" and
  47. "string" arrays, these numbers are
  48. different (by 2 and 1 bytes resp) */
  49. /* In Glulx, of course, that will be
  50. 4 instead of 2. */
  51. extern void finish_array(int32 i)
  52. {
  53. /* Write the array size into the 0th byte/word of the array, if it's
  54. a "table" or "string" array */
  55. if (!glulx_mode) {
  56. if (array_base!=dynamic_array_area_size)
  57. { if (dynamic_array_area_size-array_base==2)
  58. { dynamic_array_area[array_base] = i/256;
  59. dynamic_array_area[array_base+1] = i%256;
  60. }
  61. else
  62. { if (i>=256)
  63. error("A 'string' array can have at most 256 entries");
  64. dynamic_array_area[array_base] = i;
  65. }
  66. }
  67. }
  68. else {
  69. if (array_base!=dynamic_array_area_size)
  70. { if (dynamic_array_area_size-array_base==4)
  71. {
  72. dynamic_array_area[array_base] = (i >> 24) & 0xFF;
  73. dynamic_array_area[array_base+1] = (i >> 16) & 0xFF;
  74. dynamic_array_area[array_base+2] = (i >> 8) & 0xFF;
  75. dynamic_array_area[array_base+3] = (i) & 0xFF;
  76. }
  77. else
  78. { if (i>=256)
  79. error("A 'string' array can have at most 256 entries");
  80. dynamic_array_area[array_base] = i;
  81. }
  82. }
  83. }
  84. /* Move on the dynamic array size so that it now points to the next
  85. available free space */
  86. dynamic_array_area_size += i*array_entry_size;
  87. }
  88. extern void array_entry(int32 i, assembly_operand VAL)
  89. {
  90. if (!glulx_mode) {
  91. /* Array entry i (initial entry has i=0) is set to Z-machine value j */
  92. if (dynamic_array_area_size+(i+1)*array_entry_size > MAX_STATIC_DATA)
  93. memoryerror("MAX_STATIC_DATA", MAX_STATIC_DATA);
  94. if (array_entry_size==1)
  95. { dynamic_array_area[dynamic_array_area_size+i] = (VAL.value)%256;
  96. if (VAL.marker != 0)
  97. error("Entries in byte arrays and strings must be known constants");
  98. /* If the entry is too large for a byte array, issue a warning
  99. and truncate the value */
  100. else
  101. if (VAL.value >= 256)
  102. warning("Entry in '->', 'string' or 'buffer' array not in range 0 to 255");
  103. }
  104. else
  105. { dynamic_array_area[dynamic_array_area_size + 2*i] = (VAL.value)/256;
  106. dynamic_array_area[dynamic_array_area_size + 2*i+1] = (VAL.value)%256;
  107. if (VAL.marker != 0)
  108. backpatch_zmachine(VAL.marker, DYNAMIC_ARRAY_ZA,
  109. dynamic_array_area_size + 2*i);
  110. }
  111. }
  112. else {
  113. /* Array entry i (initial entry has i=0) is set to value j */
  114. if (dynamic_array_area_size+(i+1)*array_entry_size > MAX_STATIC_DATA)
  115. memoryerror("MAX_STATIC_DATA", MAX_STATIC_DATA);
  116. if (array_entry_size==1)
  117. { dynamic_array_area[dynamic_array_area_size+i] = (VAL.value) & 0xFF;
  118. if (VAL.marker != 0)
  119. error("Entries in byte arrays and strings must be known constants");
  120. /* If the entry is too large for a byte array, issue a warning
  121. and truncate the value */
  122. else
  123. if (VAL.value >= 256)
  124. warning("Entry in '->', 'string' or 'buffer' array not in range 0 to 255");
  125. }
  126. else if (array_entry_size==4)
  127. { dynamic_array_area[dynamic_array_area_size + 4*i] = (VAL.value >> 24) & 0xFF;
  128. dynamic_array_area[dynamic_array_area_size + 4*i+1] = (VAL.value >> 16) & 0xFF;
  129. dynamic_array_area[dynamic_array_area_size + 4*i+2] = (VAL.value >> 8) & 0xFF;
  130. dynamic_array_area[dynamic_array_area_size + 4*i+3] = (VAL.value) & 0xFF;
  131. if (VAL.marker != 0)
  132. backpatch_zmachine(VAL.marker, ARRAY_ZA,
  133. dynamic_array_area_size - 4*MAX_GLOBAL_VARIABLES + 4*i);
  134. }
  135. else
  136. {
  137. error("Somehow created an array of shorts");
  138. }
  139. }
  140. }
  141. /* ------------------------------------------------------------------------- */
  142. /* Global and Array directives. */
  143. /* */
  144. /* Global <variablename> | */
  145. /* | = <value> */
  146. /* | <array specification> */
  147. /* */
  148. /* Array <arrayname> <array specification> */
  149. /* */
  150. /* where an array specification is: */
  151. /* */
  152. /* | -> | <number-of-entries> */
  153. /* | --> | <entry-1> ... <entry-n> */
  154. /* | string | [ <entry-1> [,] [;] <entry-2> ... <entry-n> ]; */
  155. /* | table */
  156. /* */
  157. /* ------------------------------------------------------------------------- */
  158. extern void set_variable_value(int i, int32 v)
  159. { global_initial_value[i]=v;
  160. }
  161. /* There are four ways to initialise arrays: */
  162. #define UNSPECIFIED_AI -1
  163. #define NULLS_AI 0
  164. #define DATA_AI 1
  165. #define ASCII_AI 2
  166. #define BRACKET_AI 3
  167. extern void make_global(int array_flag, int name_only)
  168. {
  169. /* array_flag is TRUE for an Array directive, FALSE for a Global;
  170. name_only is only TRUE for parsing an imported variable name, so
  171. array_flag is always FALSE in that case. */
  172. int32 i;
  173. int array_type, data_type;
  174. assembly_operand AO;
  175. int32 global_symbol;
  176. const char *global_name;
  177. debug_location_beginning beginning_debug_location =
  178. get_token_location_beginning();
  179. directive_keywords.enabled = FALSE;
  180. get_next_token();
  181. i = token_value;
  182. global_symbol = i;
  183. global_name = token_text;
  184. if (!glulx_mode) {
  185. if ((token_type==SYMBOL_TT) && (stypes[i]==GLOBAL_VARIABLE_T)
  186. && (svals[i] >= LOWEST_SYSTEM_VAR_NUMBER))
  187. goto RedefinitionOfSystemVar;
  188. }
  189. else {
  190. if ((token_type==SYMBOL_TT) && (stypes[i]==GLOBAL_VARIABLE_T))
  191. goto RedefinitionOfSystemVar;
  192. }
  193. if ((token_type != SYMBOL_TT) || (!(sflags[i] & UNKNOWN_SFLAG)))
  194. { discard_token_location(beginning_debug_location);
  195. if (array_flag)
  196. ebf_error("new array name", token_text);
  197. else ebf_error("new global variable name", token_text);
  198. panic_mode_error_recovery(); return;
  199. }
  200. if ((!array_flag) && (sflags[i] & USED_SFLAG))
  201. error_named("Variable must be defined before use:", token_text);
  202. if (array_flag)
  203. {
  204. if (!glulx_mode)
  205. assign_symbol(i, dynamic_array_area_size, ARRAY_T);
  206. else
  207. assign_symbol(i,
  208. dynamic_array_area_size - 4*MAX_GLOBAL_VARIABLES, ARRAY_T);
  209. if (no_arrays == MAX_ARRAYS)
  210. memoryerror("MAX_ARRAYS", MAX_ARRAYS);
  211. array_symbols[no_arrays] = i;
  212. }
  213. else
  214. { if (!glulx_mode && no_globals==233)
  215. { discard_token_location(beginning_debug_location);
  216. error("All 233 global variables already declared");
  217. panic_mode_error_recovery();
  218. return;
  219. }
  220. if (glulx_mode && no_globals==MAX_GLOBAL_VARIABLES)
  221. { discard_token_location(beginning_debug_location);
  222. memoryerror("MAX_GLOBAL_VARIABLES", MAX_GLOBAL_VARIABLES);
  223. panic_mode_error_recovery();
  224. return;
  225. }
  226. variable_tokens[MAX_LOCAL_VARIABLES+no_globals] = i;
  227. assign_symbol(i, MAX_LOCAL_VARIABLES+no_globals, GLOBAL_VARIABLE_T);
  228. variable_tokens[svals[i]] = i;
  229. if (name_only) import_symbol(i);
  230. else global_initial_value[no_globals++]=0;
  231. }
  232. directive_keywords.enabled = TRUE;
  233. RedefinitionOfSystemVar:
  234. if (name_only)
  235. { discard_token_location(beginning_debug_location);
  236. return;
  237. }
  238. get_next_token();
  239. if ((token_type == SEP_TT) && (token_value == SEMICOLON_SEP))
  240. { if (array_flag)
  241. { discard_token_location(beginning_debug_location);
  242. ebf_error("array definition", token_text);
  243. }
  244. put_token_back();
  245. if (debugfile_switch && !array_flag)
  246. { debug_file_printf("<global-variable>");
  247. debug_file_printf("<identifier>%s</identifier>", global_name);
  248. debug_file_printf("<address>");
  249. write_debug_global_backpatch(svals[global_symbol]);
  250. debug_file_printf("</address>");
  251. write_debug_locations
  252. (get_token_location_end(beginning_debug_location));
  253. debug_file_printf("</global-variable>");
  254. }
  255. return;
  256. }
  257. if (!array_flag)
  258. {
  259. if ((token_type == SEP_TT) && (token_value == SETEQUALS_SEP))
  260. { AO = parse_expression(CONSTANT_CONTEXT);
  261. if (!glulx_mode) {
  262. if (AO.marker != 0)
  263. backpatch_zmachine(AO.marker, DYNAMIC_ARRAY_ZA,
  264. 2*(no_globals-1));
  265. }
  266. else {
  267. if (AO.marker != 0)
  268. backpatch_zmachine(AO.marker, GLOBALVAR_ZA,
  269. 4*(no_globals-1));
  270. }
  271. global_initial_value[no_globals-1] = AO.value;
  272. if (debugfile_switch)
  273. { debug_file_printf("<global-variable>");
  274. debug_file_printf("<identifier>%s</identifier>", global_name);
  275. debug_file_printf("<address>");
  276. write_debug_global_backpatch(svals[global_symbol]);
  277. debug_file_printf("</address>");
  278. write_debug_locations
  279. (get_token_location_end(beginning_debug_location));
  280. debug_file_printf("</global-variable>");
  281. }
  282. return;
  283. }
  284. obsolete_warning("more modern to use 'Array', not 'Global'");
  285. if (!glulx_mode) {
  286. backpatch_zmachine(ARRAY_MV, DYNAMIC_ARRAY_ZA, 2*(no_globals-1));
  287. global_initial_value[no_globals-1]
  288. = dynamic_array_area_size+variables_offset;
  289. }
  290. else {
  291. backpatch_zmachine(ARRAY_MV, GLOBALVAR_ZA, 4*(no_globals-1));
  292. global_initial_value[no_globals-1]
  293. = dynamic_array_area_size - 4*MAX_GLOBAL_VARIABLES;
  294. }
  295. }
  296. array_type = BYTE_ARRAY; data_type = UNSPECIFIED_AI;
  297. if ((!array_flag) &&
  298. ((token_type==DIR_KEYWORD_TT)&&(token_value==DATA_DK)))
  299. data_type=NULLS_AI;
  300. else if ((!array_flag) &&
  301. ((token_type==DIR_KEYWORD_TT)&&(token_value==INITIAL_DK)))
  302. data_type=DATA_AI;
  303. else if ((!array_flag) &&
  304. ((token_type==DIR_KEYWORD_TT)&&(token_value==INITSTR_DK)))
  305. data_type=ASCII_AI;
  306. else if ((token_type==SEP_TT)&&(token_value==ARROW_SEP))
  307. array_type = BYTE_ARRAY;
  308. else if ((token_type==SEP_TT)&&(token_value==DARROW_SEP))
  309. array_type = WORD_ARRAY;
  310. else if ((token_type==DIR_KEYWORD_TT)&&(token_value==STRING_DK))
  311. array_type = STRING_ARRAY;
  312. else if ((token_type==DIR_KEYWORD_TT)&&(token_value==TABLE_DK))
  313. array_type = TABLE_ARRAY;
  314. else if ((token_type==DIR_KEYWORD_TT)&&(token_value==BUFFER_DK))
  315. array_type = BUFFER_ARRAY;
  316. else
  317. { discard_token_location(beginning_debug_location);
  318. if (array_flag)
  319. ebf_error
  320. ("'->', '-->', 'string', 'table' or 'buffer'", token_text);
  321. else
  322. ebf_error
  323. ("'=', '->', '-->', 'string', 'table' or 'buffer'", token_text);
  324. panic_mode_error_recovery();
  325. return;
  326. }
  327. array_entry_size=1;
  328. if ((array_type==WORD_ARRAY) || (array_type==TABLE_ARRAY))
  329. array_entry_size=WORDSIZE;
  330. get_next_token();
  331. if ((token_type == SEP_TT) && (token_value == SEMICOLON_SEP))
  332. { discard_token_location(beginning_debug_location);
  333. error("No array size or initial values given");
  334. put_token_back();
  335. return;
  336. }
  337. switch(data_type)
  338. { case UNSPECIFIED_AI:
  339. if ((token_type == SEP_TT) && (token_value == OPEN_SQUARE_SEP))
  340. data_type = BRACKET_AI;
  341. else
  342. { data_type = NULLS_AI;
  343. if (token_type == DQ_TT) data_type = ASCII_AI;
  344. get_next_token();
  345. if (!((token_type == SEP_TT) && (token_value == SEMICOLON_SEP)))
  346. data_type = DATA_AI;
  347. put_token_back();
  348. put_token_back();
  349. }
  350. break;
  351. case NULLS_AI: obsolete_warning("use '->' instead of 'data'"); break;
  352. case DATA_AI: obsolete_warning("use '->' instead of 'initial'"); break;
  353. case ASCII_AI: obsolete_warning("use '->' instead of 'initstr'"); break;
  354. }
  355. array_base = dynamic_array_area_size;
  356. /* Leave room to write the array size in later, if string/table array */
  357. if ((array_type==STRING_ARRAY) || (array_type==TABLE_ARRAY))
  358. dynamic_array_area_size += array_entry_size;
  359. if (array_type==BUFFER_ARRAY)
  360. dynamic_array_area_size += WORDSIZE;
  361. array_types[no_arrays] = array_type;
  362. switch(data_type)
  363. {
  364. case NULLS_AI:
  365. AO = parse_expression(CONSTANT_CONTEXT);
  366. CalculatedArraySize:
  367. if (module_switch && (AO.marker != 0))
  368. { error("Array sizes must be known now, not externally defined");
  369. break;
  370. }
  371. if (!glulx_mode) {
  372. if ((AO.value <= 0) || (AO.value >= 32768))
  373. { error("An array must have between 1 and 32767 entries");
  374. AO.value = 1;
  375. }
  376. }
  377. else {
  378. if (AO.value <= 0 || (AO.value & 0x80000000))
  379. { error("An array may not have 0 or fewer entries");
  380. AO.value = 1;
  381. }
  382. }
  383. { for (i=0; i<AO.value; i++) array_entry(i, zero_operand);
  384. }
  385. break;
  386. case DATA_AI:
  387. /* In this case the array is initialised to the sequence of
  388. constant values supplied on the same line */
  389. i=0;
  390. do
  391. { get_next_token();
  392. if ((token_type == SEP_TT) && (token_value == SEMICOLON_SEP))
  393. break;
  394. if ((token_type == SEP_TT)
  395. && ((token_value == OPEN_SQUARE_SEP)
  396. || (token_value == CLOSE_SQUARE_SEP)))
  397. { discard_token_location(beginning_debug_location);
  398. error("Missing ';' to end the initial array values "
  399. "before \"[\" or \"]\"");
  400. return;
  401. }
  402. put_token_back();
  403. AO = parse_expression(ARRAY_CONTEXT);
  404. if (i == 0)
  405. { get_next_token();
  406. put_token_back();
  407. if ((token_type == SEP_TT)
  408. && (token_value == SEMICOLON_SEP))
  409. { data_type = NULLS_AI;
  410. goto CalculatedArraySize;
  411. }
  412. }
  413. array_entry(i, AO);
  414. i++;
  415. } while (TRUE);
  416. put_token_back();
  417. break;
  418. case ASCII_AI:
  419. /* In this case the array is initialised to the ASCII values of
  420. the characters of a given "quoted string" */
  421. get_next_token();
  422. if (token_type != DQ_TT)
  423. { ebf_error("literal text in double-quotes", token_text);
  424. token_text = "error";
  425. }
  426. { assembly_operand chars;
  427. int j;
  428. chars.marker = 0;
  429. for (i=0,j=0; token_text[j]!=0; i++,j+=textual_form_length)
  430. {
  431. int32 unicode; int zscii;
  432. unicode = text_to_unicode(token_text+j);
  433. if (glulx_mode)
  434. {
  435. if (unicode < 0 || unicode >= 256)
  436. {
  437. error("Unicode characters beyond Latin-1 are not yet supported in Glulx array literals");
  438. }
  439. else
  440. {
  441. chars.value = unicode;
  442. }
  443. }
  444. else /* Z-code */
  445. {
  446. zscii = unicode_to_zscii(unicode);
  447. if ((zscii != 5) && (zscii < 0x100)) chars.value = zscii;
  448. else
  449. { unicode_char_error("Character can only be used if declared in \
  450. advance as part of 'Zcharacter table':", unicode);
  451. chars.value = '?';
  452. }
  453. }
  454. chars.marker = 0;
  455. set_constant_ot(&chars);
  456. array_entry(i, chars);
  457. }
  458. }
  459. break;
  460. case BRACKET_AI:
  461. /* In this case the array is initialised to the sequence of
  462. constant values given over a whole range of compiler-lines,
  463. between square brackets [ and ] */
  464. i = 0;
  465. while (TRUE)
  466. { get_next_token();
  467. if ((token_type == SEP_TT) && (token_value == SEMICOLON_SEP))
  468. continue;
  469. if ((token_type == SEP_TT) && (token_value == CLOSE_SQUARE_SEP))
  470. break;
  471. if ((token_type == SEP_TT) && (token_value == OPEN_SQUARE_SEP))
  472. { /* Minimal error recovery: we assume that a ] has
  473. been missed, and the programmer is now starting
  474. a new routine */
  475. ebf_error("']'", token_text);
  476. put_token_back(); break;
  477. }
  478. put_token_back();
  479. array_entry(i, parse_expression(ARRAY_CONTEXT));
  480. i++;
  481. }
  482. }
  483. finish_array(i);
  484. if (debugfile_switch)
  485. { debug_file_printf("<array>");
  486. debug_file_printf("<identifier>%s</identifier>", global_name);
  487. debug_file_printf("<value>");
  488. write_debug_array_backpatch(svals[global_symbol]);
  489. debug_file_printf("</value>");
  490. debug_file_printf
  491. ("<byte-count>%d</byte-count>",
  492. dynamic_array_area_size - array_base);
  493. debug_file_printf
  494. ("<bytes-per-element>%d</bytes-per-element>",
  495. array_entry_size);
  496. debug_file_printf
  497. ("<zeroth-element-holds-length>%s</zeroth-element-holds-length>",
  498. (array_type == STRING_ARRAY || array_type == TABLE_ARRAY) ?
  499. "true" : "false");
  500. get_next_token();
  501. write_debug_locations(get_token_location_end(beginning_debug_location));
  502. put_token_back();
  503. debug_file_printf("</array>");
  504. }
  505. if ((array_type==BYTE_ARRAY) || (array_type==WORD_ARRAY)) i--;
  506. if (array_type==BUFFER_ARRAY) i+=WORDSIZE-1;
  507. array_sizes[no_arrays++] = i;
  508. }
  509. extern int32 begin_table_array(void)
  510. {
  511. /* The "box" statement needs to be able to construct (static) table
  512. arrays of strings like this */
  513. array_base = dynamic_array_area_size;
  514. array_entry_size = WORDSIZE;
  515. /* Leave room to write the array size in later */
  516. dynamic_array_area_size += array_entry_size;
  517. if (!glulx_mode)
  518. return array_base;
  519. else
  520. return array_base - WORDSIZE * MAX_GLOBAL_VARIABLES;
  521. }
  522. extern int32 begin_word_array(void)
  523. {
  524. /* The "random(a, b, ...)" function needs to be able to construct
  525. (static) word arrays like this */
  526. array_base = dynamic_array_area_size;
  527. array_entry_size = WORDSIZE;
  528. if (!glulx_mode)
  529. return array_base;
  530. else
  531. return array_base - WORDSIZE * MAX_GLOBAL_VARIABLES;
  532. }
  533. /* ========================================================================= */
  534. /* Data structure management routines */
  535. /* ------------------------------------------------------------------------- */
  536. extern void init_arrays_vars(void)
  537. { dynamic_array_area = NULL;
  538. global_initial_value = NULL;
  539. array_sizes = NULL; array_symbols = NULL; array_types = NULL;
  540. }
  541. extern void arrays_begin_pass(void)
  542. { no_arrays = 0;
  543. if (!glulx_mode)
  544. no_globals=0;
  545. else
  546. no_globals=11;
  547. dynamic_array_area_size = WORDSIZE * MAX_GLOBAL_VARIABLES;
  548. }
  549. extern void arrays_allocate_arrays(void)
  550. { dynamic_array_area = my_calloc(sizeof(int), MAX_STATIC_DATA,
  551. "static data");
  552. array_sizes = my_calloc(sizeof(int), MAX_ARRAYS, "array sizes");
  553. array_types = my_calloc(sizeof(int), MAX_ARRAYS, "array types");
  554. array_symbols = my_calloc(sizeof(int32), MAX_ARRAYS, "array symbols");
  555. global_initial_value = my_calloc(sizeof(int32), MAX_GLOBAL_VARIABLES,
  556. "global values");
  557. }
  558. extern void arrays_free_arrays(void)
  559. { my_free(&dynamic_array_area, "static data");
  560. my_free(&global_initial_value, "global values");
  561. my_free(&array_sizes, "array sizes");
  562. my_free(&array_types, "array sizes");
  563. my_free(&array_symbols, "array sizes");
  564. }
  565. /* ========================================================================= */