home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / misc / ada1110b.lha / AmigaSources / gvars.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-10  |  9.3 KB  |  279 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. #define GEN
  10.  
  11. #include "hdr.h"
  12. #include <stdio.h>
  13.  
  14. /* ada_min_integer; ada_max_integer; are defined in vars.c */
  15.  
  16. /* SETL GENflag is list_code in C */
  17.  int    list_code  =  (0); /* set if GEN option selected */
  18.  
  19. #ifdef TBSN
  20. PREDEF_UNITS; /* predefined units */
  21. #endif
  22.  
  23.  int    debug_flag;
  24. /* set debug_line to line number to cause call to trap_line when
  25.  * starting to generating code for that line 
  26.  * (see maincase.c)        ds 7-19-85
  27.  */
  28.  int    debug_line  =  (0);
  29.  
  30. /* MAINunit identifies the main unit. In SETL this is specified by
  31.  * MAIN program option. In C it will be character string
  32.  */
  33.  char *MAINunit; /* name of main unit (from MAIN opo */
  34.  char *interface_files;
  35.  
  36.  
  37.  int    bind_option; /* bind option */
  38.  int   bind_only_option  =  (0); /* set when binding only, no generation */
  39.  int    line_option  =  (0); /* LINE option use -L to set */
  40.  int    gen_option  =  (1); /* GEN option: set if want to generate code */
  41.  
  42.  
  43.  int ada_line; /* line number for error file (mixed_case) */
  44.  int save_ada_line; /* used to save value of ada_line  */
  45.  
  46.  
  47. #ifdef TBSN
  48. /* STIME and BTIME are used to hold elapsed times in SETL version
  49.  * and are reals there. They are not needed in first C version.
  50.  */
  51. STIME; /* ?? time */
  52. BTIME; /* binding time */
  53. #endif
  54.  
  55.  int     NB_INSTRUCTIONS; /* number of instructions generated */
  56.  int     NB_STATEMENTS; /* number of statements processed?? */
  57.  
  58.  int     ERROR_IN_UNIT; /* boolean set if errors in unit */
  59.  int     STUBS_IN_UNIT; /* boolean set if stubs in unit */
  60.  
  61. /* In SETL, TARGET indicates target machine and is either SETL or IBMPC
  62.  * In C will be integer
  63.  */
  64.  int     TARGET; 
  65.  
  66.  
  67.  Node    FIRST_NODE;         /* first node in a compilation unit */
  68.  
  69.  Tuple     UNIT_FIRST_NODE;     /* map { unit -> FIRST_NODE } */
  70. /* Represent as 'tuple map' in C */
  71.  
  72.  
  73.  Tuple    RENAME_MAP;          
  74. /* map { generic_name -> instance_name } 
  75.  * This is kept as a tuple in C with successive pairs of elements giving
  76.  * domain and range values (tuple as map).
  77.  */
  78.  
  79. #ifdef TBSN
  80. -- this is not referenced        ds 22-feb-85
  81.     Node ROOT_NODE;           /* root node of unit to be expanded */
  82. #endif
  83.  
  84. /* Generated code is built up in CODE_SEGMENT, generated data in
  85.  * DATA_SEGMENT. In SETL these are tuples, and will also be tuples
  86.  * in first C version.
  87.  * DATA_SEGMENT_MAIN is data segment for main code slot, initialized
  88.  * by segment_main_data();
  89.  * Since the type of these (Segment) is not known to all files
  90.  * the variables CODE_SEGMENT, DATA_SEGMENT, DATA_SEGMENT_MAIN
  91.  * VARIANT_TABLE and FIELD_TABLE are defined in init.c and
  92.  * declared as extern's explicitly where needed.
  93.  */
  94.  
  95.  
  96.  Tuple    CODE_SLOTS;          /* map showing code_slots occupation */
  97.                          /*  { procedure_names -> number } */
  98.  
  99.  Tuple    DATA_SLOTS;          /* map showing data_slots occupation */
  100.                          /*  { compilation_unit_names -> number } */
  101.  
  102.  Tuple    EXCEPTION_SLOTS;     /* map showing exception_slots occupation */
  103.                     /*  { exception_names -> number } */
  104.  Tuple    CODE_SEGMENT_MAP;    /* map { number -> [actual code] } */
  105.  Tuple    DATA_SEGMENT_MAP;    /* map { number -> [actual data] } */
  106.  
  107.  
  108.  int    CURRENT_DATA_SEGMENT;   /* number of current data segment */
  109.  int    CURRENT_CODE_SEGMENT;   /* number of current code  segment */
  110. /* UNIT_NAME is variable unit_name declared in vars.c */
  111.     /* name of the current compilation unit */
  112.  
  113. /*
  114.  * GENERATED_OBJECTS is a set of symbols in the SETL version. It is
  115.  * kept as a tuple in the C version. The most common use is in the
  116.  * form
  117.  *    GENERATED_OBJECTS with:= sym;
  118.  * which we will write in C as
  119.  *    generate_object(sym);
  120.  * This will permit option of choosing more efficient data structure
  121.  * later.
  122.  */
  123.  Tuple    GENERATED_OBJECTS;
  124.  
  125. /*  Symbol table and extended symbol table : */
  126.  
  127.  
  128. #ifdef TBSN
  129. /* MISC will be symbol table fields in C version */
  130.     MISC,           /* map used to store miscellanous infos like: */
  131.                     /* for types: */
  132.                     /*   a boolean indicating that they contain tasks */
  133. /* NOTE: Info in MISC is save in library (AXQ files) */
  134.  
  135. #endif
  136.  
  137. /* REFERENCE_MAP and LOCAL_REFERENCE_MAP are used in SETL to give
  138.  * the address assigned to symbols. 
  139.  * LOCAL_REFERENCE_MAP is 'sparse' map from symbols to offsets; note
  140.  * in particular that it is copied.
  141.  * See ghdr.c for description of realization of local_reference_map.
  142.  */
  143.  Tuple LOCAL_REFERENCE_MAP;
  144.  
  145. /* reference_of sets these globals */
  146.  int REFERENCE_SEGMENT;
  147.  int REFERENCE_OFFSET;
  148.  
  149. /* CONSTANT_MAP is a map from constant values to generated symbols. It
  150.  * is referenced only in procedure get_constant_name. The representation
  151.  * in C is still not clear. 
  152.  *
  153.  * Constant map is optimization that is not needed in C 
  154.  * It is referenced ony in get_constant_name to reuse locations having
  155.  * the same value. 
  156.  */
  157. #ifdef TBSN
  158. Tuple    CONSTANT_MAP;
  159. #endif
  160.  
  161.  
  162.  int    LAST_OFFSET;    /* first available offset in current stack frame */
  163.  int    MAX_OFFSET;     /* largest offset in current stack frame */
  164.  int    TASKS_DECLARED; /* flag indicating possible presence of tasks in frame */
  165.  int    SPECS_DECLARED; /* count of # of specs requiring a */
  166.                /* body in a library package. */
  167.  Tuple  SUBPROG_SPECS; /* set of subprograms having an explicit spec in the */
  168.                /* current program unit. */
  169.  
  170.  Tuple    SOURCE;         /* the current list of statements to be processed */
  171.  
  172.  
  173. /* in C, EMAP is maintained by emap_... procedures: */
  174.  Tuple    EMAP;           /* Various temporary storage: */
  175.                     /* Type:     -> list of dependent deferred types */
  176.                     /* Constant: -> Boolean true if a deferred constant */
  177. /* NOTE: info in EMAP is NOT save in libarry (AXQ files) */
  178.  Tuple    EMAP_VALUE; /* value of emap if defined, set by emap_get */
  179.  
  180.  int    CURRENT_LEVEL;  /* used for static depth of blocks */
  181.  
  182.  Tuple    PARAMETER_SET; /* Tuple of symbols for formal parameters */
  183.  
  184. /* RELAY_SET is a tuple of symbols. */
  185. /* Note; need to review if this need be copied */
  186. /* Note: RELAY_SET should be represented more efficiently than just
  187.  * as tuple if possible, as may be 'large'.
  188.  */
  189.  Tuple    RELAY_SET;
  190.  
  191. /* DANGLING_RELAY_SETS is a tuple of relay sets */
  192.  Tuple    DANGLING_RELAY_SETS;
  193.  
  194.  Tuple    SUBPROG_PATCH;
  195.     
  196.  Tuple   CODE_PATCH_SET;
  197.  Tuple    DATA_PATCH_SET;
  198.  
  199. /* Global variables used for record type elaboration */
  200.  
  201.  int    CURRENT_FIELD_NUMBER;
  202.  int    CURRENT_FIELD_OFFSET;
  203.  int    REC_WITH_TASKS; /* boolean */
  204.  int    STATIC_REC; /* boolean */
  205.  Tuple   INTERNAL_ACCESSED_TYPES; /* of symbols */
  206.  
  207. /* Variables used by the binder */
  208.  Tuple  axqfiles_read;        /* set of already read AXQfiles */
  209.  Tuple  call_lib_unit;        /* Accumulates code for idle_task to call library */
  210.                    /* packages. */
  211.  Tuple  PRECEDES_MAP;      /* Map representing relationship between units */
  212.  Tuple  DELAYED_MAP;
  213.  Tuple  compilation_table; /* Table of compilation units giving the order of */
  214.                      /* compilation. */
  215.  Tuple  late_instances;    /* Map from unit unique name to a set of late */
  216.                             /* instances */
  217.  Tuple interfaced_procedures;
  218.                      /* set of the part of codes generated for each
  219.                         intefaced procedures */
  220.  int     interface_counter  =  (256);
  221.                 /* integer associated with each subprogram which */
  222.                 /* has a pragma INTERFACE */
  223.  int    interface_flag;    /* equals 1 if there are interfaced procedures, 
  224.                                       0 otherwise */
  225.  
  226. /* Variables used by the peep-hole optimizer */
  227.  
  228.  int deleted_instructions;
  229. #ifdef TBSN
  230.     optimizable_codes,
  231. #endif
  232.  
  233.  
  234. /* "local" variables (do not use these names elsewhere!) */
  235.  
  236.     Tuple    just_read;
  237.  Node    unit_node;
  238.  
  239. /* TBSL: symbol_constrained_type added 21 jan - needs to be initialized*/
  240.  Symbol symbol_constrained_type;
  241.  Symbol symbol_accept_return  =  ((Symbol)0); /* see gen_accept */
  242. /* TBSL: see if following really needed for 'used' and 'unused':
  243.   Note; "used" and "unused" are just used for loops can use TRUE and FALSE
  244.   There is label generated at startof loop needed only if exit; if exit
  245.   not present, the label is "unused" and some needless code need not
  246.   be generated.
  247.  */
  248.  Symbol symbol_used,symbol_unused;
  249. /* symbol_main_task_type is defined in adasem (vars.c) */
  250. /* define symbol_main_task used for main_task here */
  251.  Symbol symbol_main_task;
  252.  Symbol symbol_type_mark;
  253.  Symbol symbol_task_block;
  254.  Symbol symbol_mulfix; /* expr.c ...*/
  255.  
  256. /* rat_tof() returns its results in the globals:*/
  257. /* make RAT_TOF_1 long for initial C version  ds 6-6-86 */
  258.  long RAT_TOF_1,RAT_TOF_2;
  259.  
  260.  Explicit_ref explicit_ref_0; /* for explicit reference of [0,0] */
  261. /* unit_slots is global tuple maintained by unit_slots_get() and
  262.  * unit_slots_put(). Entries are indexed by unit number. Each entry
  263.  * is tuple of slot numbers; the first three corresponding to OWNED_SLOTS
  264.  * the last two to BORROWED slots.
  265.  */
  266.  Tuple unit_slots   =  ((Tuple) 0);
  267.  int *ivalue_1,*ivalue_10; /* long integer forms of 1 and 10 */
  268.  Const int_const_0; /* Const for integer 0 */
  269.  Rational rat_value_10; /* 10 as rational */
  270. /* global_reference_tupel is used for saving global addresses
  271.  * for trace printout 
  272.  */
  273.  Tuple global_reference_tuple  =  ((Tuple)0);
  274.  
  275.  Const int_const_null_task; /* for NULL_TASK */
  276. #ifdef BINDER_GEN
  277.  int binder_phase   =  (0); /* set non-zero if binder phase */
  278. #endif
  279.