home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / misc / ada1110b.lha / AmigaSources / vars.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-10  |  8.0 KB  |  286 lines

  1. /*
  2.  * Copyright (C) 1985-1992  New York University
  3.  * 
  4.  * This file is part of the Ada/Ed-C system.  See the Ada/Ed README file for
  5.  * warranty (none) and distribution info and also the GNU General Public
  6.  * License for more details.
  7.  
  8.  */
  9.  
  10. #include "hdr.h"
  11.  
  12. /* vars.ch - global declarations and initializations */
  13.  
  14. /*
  15.  *T+ GLOBAL DECLARATIONS and DEF =  IONS
  16.  *S+ Constants
  17.  */
  18.  
  19.  double    ADA_MIN_REAL  =  ((-79228162514264337593543950336.0));/* - 2.0**96 */
  20.  double    ADA_MAX_REAL  =  (79228162514264337593543950336.0);/* 2.0**96 */
  21.  int    ADA_REAL_DIGITS  =  (6);
  22.  int    cdebug2;
  23.  
  24.  Declaredmap declared_all[4];    /* array of standard declareds */
  25.  int    full_others;  /* a boolean */
  26.  int    fold_context; /* a boolean */
  27.  int    node_count;
  28.  Node current_node;
  29.  Node OPT_NODE;    /*initialized in sem0 */
  30.  
  31. /* Initialized in SEM =   */
  32. /*
  33. ??const qualifiers = {as_qual_range,  as_qual_length,  as_qual_discr,
  34.             as_qual_arange, as_qual_alength, as_qual_adiscr };
  35.  */
  36.  
  37. /*S+ Variables*/
  38.  /* declared map from standard environment */
  39. /*base_declared is array of copies of maps for standard0,standard,
  40. umnentionable0, and ascii. base_declared_symbols is corresponding
  41. array of symbol table pointers */
  42.  Declaredmap base_declared[4];
  43.  Symbol base_declared_symbols[4];
  44.  Tuple scope_st;            /* stack of lexical scopes */
  45.  Tuple has_return_stk;        /* stack to track return statements */
  46.  Tuple newtypes;            /* list of type declaration code to be */
  47.  /* emitted before declaration being processed. */
  48.  Tuple lab_seen;            /* set of labels in procedure . */
  49.  Tuple current_instances;    /* stack for recursive instantiation check */
  50.  
  51.  Symbol scope_name;        /* unique name for each scope */
  52.  char *unit_name;        /* compilation unit information */
  53.  Tuple all_vis;            /* Modules whose visibility is required */
  54.                 /* all_vis used only in ch. 10 */
  55.  
  56.  Tuple open_scopes;        /* nest of currently open scopes, from inner */
  57.  /* to outer.  Outermost is STANDARD. */
  58.  Tuple used_mods;        /* packages appearing in a use clause */
  59.  Tuple vis_mods;    /* list of package names visible in this unit*/
  60.  
  61.  int    noop_error;
  62.  
  63.  /* used by procs init_compunit and compunit. */
  64.  Set non_local_names;        /* To collect non_local references in each subp. */
  65.  
  66.  int    out_context;        /* Signals valid appearance of out parameter.  */
  67.  
  68.  Symbol
  69. symbol_and,
  70. symbol_andthen,
  71. symbol_any,
  72. symbol_any_id,
  73. symbol_array_type,
  74. symbol_ascii,
  75. symbol_assign,
  76. symbol_boolean,
  77. symbol_boolean_type,
  78. symbol_callable,
  79. symbol_character,
  80. symbol_character_type,
  81. symbol_constrained,
  82. symbol_constraint_error,
  83. symbol_daccess,
  84. symbol_dfixed,
  85. symbol_discrete_type,
  86. symbol_divfx,
  87. symbol_duration,
  88. symbol_eq,
  89. symbol_exception,
  90. symbol_float,
  91. symbol_ge,
  92. symbol_gt,
  93. symbol_in,
  94. symbol_incomplete,        /* incomplete, for incp_types */
  95. symbol_integer,
  96. symbol_le,
  97. symbol_left,
  98. symbol_limited,            /* limited for priv_types, incp_types */
  99. symbol_limited_private,        /* cf. symbol_limited */
  100. symbol_long_float,
  101. symbol_long_integer,
  102. symbol_lt,
  103. symbol_main_task_type,
  104. symbol_mulfx,
  105. symbol_natural,
  106. symbol_none,
  107. symbol_not,
  108. symbol_ne,
  109. symbol_notin,
  110. symbol_null,
  111. symbol_numeric,
  112. symbol_numeric_error,
  113. symbol_or,
  114. symbol_order_type,
  115. symbol_orelse,
  116. symbol_overloaded,
  117. symbol_positive,
  118. symbol_private,            /* for priv_types, incp_types */
  119. symbol_program_error,
  120. symbol_right,
  121. symbol_short_integer,
  122. symbol_short_integer_base,
  123. symbol_standard,
  124. symbol_standard0,
  125. symbol_storage_error,
  126. symbol_system_error,
  127. symbol_string,
  128. symbol_string_type,
  129. symbol_system,
  130. symbol_tasking_error,
  131. symbol_undef,
  132. symbol_universal_dfixed,
  133. symbol_universal_fixed,
  134. symbol_universal_integer,
  135. symbol_universal_integer_1,
  136. symbol_universal_real,
  137. symbol_unmentionable,
  138. symbol_xor;
  139.  
  140. /* following used in Chapter 4 mainly for check_type */
  141.  Symbol 
  142. symbol_universal_type,
  143. symbol_integer_type,
  144. symbol_real_type,
  145. symbol_composite_type,
  146. symbol_equal_type;
  147.  
  148.  
  149.  Symbol
  150. symbol_addu,  /* +u */
  151. symbol_subu,  /* -u */
  152. symbol_abs,  /* abs */
  153. symbol_add,  /* + */
  154. symbol_sub,  /* - */
  155. symbol_mul,  /* * */
  156. symbol_div,  /* / */
  157. symbol_mod,  /* mod */
  158. symbol_rem,  /* rem */
  159. symbol_exp,  /* ** */
  160. symbol_cat,  /* & */
  161. /* new symbols for the catenation operations */
  162. symbol_cat_cc, /* &cc */
  163. symbol_cat_ac, /* &ac */
  164. symbol_cat_ca, /* &ca */
  165. symbol_modi,  /* modi */
  166. symbol_remi,  /* remi */
  167. symbol_addui,  /* +ui */
  168. symbol_subui,  /* -ui */
  169. symbol_absi,  /* absi */
  170. symbol_addi,  /* +i */
  171. symbol_subi,  /* -i */
  172. symbol_muli,  /* *i */
  173. symbol_divi,  /* /i */
  174. symbol_addufl,    /* +ufl */
  175. symbol_subufl,    /* -ufl */
  176. symbol_absfl,  /* absfl */
  177. symbol_addfl,  /* +fl */
  178. symbol_subfl,  /* -fl */
  179. symbol_mulfl,  /* *fl */
  180. symbol_divfl,  /* /fl */
  181. symbol_addufx,    /* +ufx */
  182. symbol_subufx,    /* -ufx */
  183. symbol_absfx,  /* absfx */
  184. symbol_addfx,  /* +fx */
  185. symbol_subfx,  /* -fx */
  186. symbol_mulfxi,    /* *fxi */
  187. symbol_mulifx,    /* *ifx */
  188. symbol_divfxi,    /* /fxi */
  189. symbol_mulfli,    /* *fli */
  190. symbol_mulifl,    /* *ifl */
  191. symbol_divfli,    /* /fli */
  192. symbol_expi,  /* **i */
  193. symbol_expfl;  /* **fl */
  194.  
  195.  Tuple unary_sig;
  196.  Tuple binary_sig; /* TBSL: to be initialized in sem0*/
  197.  
  198.  int num_predef_units; /* number of units in predef.ada */
  199.  
  200.  int errors  =  (FALSE); /* flag if errors are present*/
  201.  
  202. /* adaval_overflow is set to indicate overflow from adaval; corresponds
  203.  * to SETL ADAVAL returning 'OVERFLOW'
  204.  */
  205.  int adaval_overflow; 
  206.  char *FILENAME;
  207.  FILE *MSGFILE;
  208. /* added 24 sep 84*/
  209. /* init_nodes is tuple of nodes needed by save_tree (10) */
  210.  Tuple init_nodes;
  211.  Tuple init_symbols; /* tuple of symbols created by sem initialization*/
  212. /* varying length tuple, unit_nodes_n gives current length */
  213.  Tuple unit_nodes;
  214. #ifdef TBSL
  215.  int unit_nodes_n  =  (0);
  216. #endif
  217.  char *PREDEFNAME; /* name of predef file */
  218.  char *AISFILENAME;
  219.  int lib_option  =  (FALSE);
  220.  int new_library  =  (FALSE); /* set if creating library */
  221.  struct unit *pUnits[MAX_UNITS+1];
  222.  Tuple lib_stub;
  223.  Tuple stub_info;
  224.  
  225.  int seq_node_n  =  (0); /* number of nodes allocated */
  226.  Tuple seq_node; /* tuple of allocated nodes*/
  227.  int seq_symbol_n  =  (0);/* number of symbols allocated*/
  228.  Tuple seq_symbol;    /* tuple of allocated symbols */
  229.  
  230. /* added 12 oct 84 to track nodes read from ast */
  231.  int unit_number_now  =  (0);
  232.  int unit_numbers  =  (0);
  233.  int empty_unit_slots  =  (0);
  234.  
  235. /* following variables used to trap references to selected node or symbol.
  236.  * Node specified by trapns and trapnu (giving node sequence and unit),
  237.  * symbol specified by trapss and trapsu (giving symbol sequence and unit).
  238.  * These are meaningful only if either nonzero. When a trapped node referenced,
  239.  * then procedure trap is called.
  240.  * Code to watch for traps is planted at several places, notably sym_new,
  241.  * node_new, zptupsym, zptupnod (these latter two do not call trap).
  242.  */
  243.  int trapns  =  (0),trapnu =(0),trapss =(0),trapsu =(0);
  244.  
  245.  Tuple aisunits_read;
  246.  
  247.  Nodemap node_map;
  248. /* OPT_NAME is used by code_generator but defined here so it can be
  249.  * referenced from libr procedures */
  250.  Symbol OPT_NAME; /* This is to symbols what OPT_NODE is to nodes*/
  251.  
  252. /* I/O trace flags used to get trace prints when reading and writing
  253.  * intermediate files. A trace level is one of the following:
  254.  *    0    no trace
  255.  *    1    brief trace
  256.  *    2    full trace.
  257.  */
  258.  int iot_ifile  =  (0); /* current trace level for ifile */
  259.  int iot_ofile  =  (0); /* current trace level for ofile */
  260.  int iot_ais_r  =  (0); /* trace level for ais files read */
  261.  int iot_ais_w  =  (0); /* trace level for ais files written */
  262.  int iot_tre_r  =  (0); /* trace level for tre files read */
  263.  int iot_tre_w  =  (0); /* trace level for tre files written */
  264.  int iot_lib_r  =  (0); /* trace level for lib files read */
  265.  int iot_lib_w  =  (0);/* set to trace writing lib file */
  266.  char iot_ofile_type;
  267.  char iot_ifile_type;
  268.  
  269. /* compiling predef */
  270.  int    compiling_predef  =  (0); /* set if we are compiling predef */
  271.  
  272. /* the following are used to avoid having string literals in code that
  273.  * might be overlaid on the PC 
  274.  */
  275.  char *string_any_id   =  ("any_id"); 
  276.  char *string_ok   =  ("ok");
  277.  char *string_ds   =  ("$D$");
  278. /* variables to report result from power_of_2(), thus avoiding
  279.  * need to compute a tuple, as is done in SETL version.
  280.  */
  281.  int power_of_2_accuracy; 
  282.  int power_of_2_power;
  283.  Rational power_of_2_small;
  284.  Set stubs_to_write;
  285.  Tuple NOT_CHOSEN;
  286.