home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / misc / ada1110b.lha / AmigaSources / ivars.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-10  |  9.2 KB  |  223 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.       |                                                   |
  11.       |      I N T E R P R E T E R   V A R I A B L E S    |
  12.       |                                                   |
  13.       |                    (C Version)                    |
  14.       |                                                   |
  15.       |   Adapted From Low Level SETL version written by  |
  16.       |                                                   |
  17.       |                    Monte Zweben                   |
  18.       |                 Philippe Kruchten                 |
  19.       |                 Jean-Pierre Rosen                 |
  20.       |                                                   |
  21.       |    Original High Level SETL version written by    |
  22.       |                                                   |
  23.       |                     Clint Goss                    |
  24.       |                  Tracey M. Siesser                |
  25.       |                  Bernard D. Banner                |
  26.       |                  Stephen C. Bryant                |
  27.       |                    Gerry Fisher                   |
  28.       |                                                   |
  29.       |                 C version written by              |
  30.       |                                                   |
  31.       |                  Robert B. K. Dewar               |
  32.       |                                                   |
  33.       +---------------------------------------------------+     */
  34.  
  35.  
  36. /* Revision History
  37.   19 Jun 1985, 10:11 (RBKD)
  38.   First complete version, from low level version 10-23-1984
  39.  */
  40. #include <stdlib.h>
  41. #include "config.h"
  42. #include "int.h"
  43. /*  This module contains variables used in all parts of the interpretor */
  44.  
  45. /*
  46.  *  Memory lay-out
  47.  *  --------------
  48.  */
  49.  
  50.  int *stack_segments [MAX_TASKS]; /* one stack segment for each task */
  51.  int task_stackptr [MAX_TASKS];   /* stack pointers for task stacks */
  52.  unsigned int data_segments_dim;  /* dimension of data_segments */
  53.  int **data_segments;             /* one data segment for each cunit */
  54.  int *data_seglen;                /* length of data segments */
  55.  unsigned int code_segments_dim;  /* dimension of code_segments */
  56.  char **code_segments;            /* segments containing code */
  57.  int *code_seglen;                /* length of code segments */
  58.  int *cur_stack;                  /* current stack segment */
  59.  int cur_stackptr;                /* stack ptr for cur_stack */
  60.  char *cur_code;                  /* current code segment */
  61.  int num_cunits;                  /* number of compilation units */
  62.  
  63. /*
  64.  *  Context of a task
  65.  *  -----------------
  66.  */
  67.  
  68.  int cs;       /* index of current code_segment in code_segments */
  69.  int ip;       /* instruction pointer in cur_code */
  70.  int sp;       /* stack pointer */
  71.  int sfp;      /* stack frame pointer */
  72.  int bfp;      /* block frame pointer */
  73.  int exr;      /* exception register */
  74.  int lin;      /* line number for tracing */
  75.  
  76. /*
  77.  *  Global context (not preserved by context switch)
  78.  *  ------------------------------------------------
  79.  */
  80.  
  81.  int tp;                /* index of current task in stack_segments */
  82.  int *heap_next;        /* top of heap for allocation */
  83.  int heap_base;         /* segment number of heap */
  84.  int *heap_addr;        /* address of beginning of heap */
  85.  long next_clock;        /* next time to call clock_interrupts */
  86.  long time_offset;       /* cumulative skipped time for simulated time */
  87.  int next_clock_flag;   /* request to check the clock (task waiting) */
  88.  int simul_time_flag;   /* run with simulated time (versus real time) */
  89.  int time_slicing_flag; /* time slicing (vs schedule at system call) */
  90.  long time_slice;        /* length of time slice (500 ms default) */
  91.  int tasking_trace;     /* TRUE to trace tasking */
  92.  int rendezvous_trace;  /* TRUE to trace rendezvous */
  93.  int signal_trace;      /* TRUE to trace signalling */
  94.  int debug_trace;       /* TRUE for general debugging trace */
  95.  int exception_trace;   /* TRUE to trace exceptions */
  96.  int call_trace;        /* TRUE to trace calls */
  97.  int line_trace;        /* TRUE to trace line numbers */
  98.  int instruction_trace; /* TRUE to trace instructions */
  99.  
  100. /* Number of slots */
  101.  
  102.  unsigned int data_slots_dim;      /* dimension of data_slots */
  103.  char **data_slots;
  104.  unsigned int code_slots_dim;      /* dimension of code_slots */
  105.  char **code_slots;
  106.  unsigned int exception_slots_dim; /* dimension of exception_slots */
  107.  char **exception_slots;
  108.  
  109. /* Global Variables (for main interpreter) */
  110.  
  111.  int max_mem;                      /* size of a heap segment */
  112.  int w;                            /* used by GET_WORD */
  113.  struct tt_fx_range *temp_template;/* fixed point work template */
  114.  
  115.  int bse,bas1,bas2,bas3,bas4;      /* address base values */
  116.  int off,off1,off2,off3,off4;      /* address offset values */
  117.  int *ptr,*ptr1,*ptr2,*ptr3,*ptr4; /* memory addresses */
  118.  int value,val1,val2;              /* operands for int operations */
  119.  int length1,length2;              /* for array operations */
  120.  long lvalue,lval1,lval2;          /* operands for long operations */
  121.  long fval1,fval2,fvalue;          /* operands for fixed operations */
  122.  float rvalue,rval1,rval2;         /* operands for float operations */
  123.  int val_high,val_low;             /* low/high of INT range */
  124.  int result,delta;                 /* used in fixed point */
  125.  int size;                         /* size of object */
  126.  int attribute;                    /* attribute code */
  127.  int slot;                         /* for create structure */
  128.  int component_size;               /* size of array component */
  129.  long now_time;                     /* current time */
  130.  int to_type;                      /* type from template */
  131.  int discr_list[MAX_DISCR];        /* accumulate list of discriminants */
  132.  int nb,i;                         /* loop counters etc */
  133.  int overflow;                     /* overflow flag from arith routines */
  134.  int nb_discr;                     /* number of discriminants */
  135.  int nb_dim;                       /* dimension of array */
  136.  int ratio,power;                  /* used in attribute processing */
  137.  int d,n;                          /* temporaries */
  138.  int old_cs;                       /* old value of cs */
  139.  int jump;                         /* jump address */
  140.  int lim;                          /* limit in for loop */
  141.  struct bf *bfptr;                 /* pointer to block frame */
  142.  int *tfptr1,*tfptr2;              /* pointers to task frames */
  143.  int cur_col;                      /* temporary for predef */
  144.  
  145. /*
  146.  * I/O trace flags used to get trace prints when reading and writing
  147.  * intermediate files. A trace level is one of the following:
  148.  *               0           no trace
  149.  *               1           brief trace
  150.  *               2           full trace
  151.  */
  152.  int iot_ifile  =  (0); /* current trace level for ifile */
  153.  int iot_ais_r  =  (0); /* trace level for ais files read */
  154.  int iot_lib_r  =  (0); /* trace level for lib files read */
  155.  char iot_ifile_type;
  156.  
  157.  int break_point;       /* next break point */  
  158.  
  159.  int fix_val1[20];      /* fixed point intermediate values */
  160.  int fix_val2[20];     
  161.  int fix_resu[20];     
  162.  int fix_temp[20];     
  163.  int mul_fact[20];     
  164.  int div_fact[20];     
  165.  
  166.  int arith_overflow;
  167.  int sgn;
  168.  int last_task;
  169.  int *free_list  =  ((int *)0);
  170.  int raise_cs;
  171.  int raise_lin;
  172.  char *raise_reason;
  173.  
  174. /*
  175.  *                             P R E D E F
  176.  */
  177.  
  178. /* Define maximum number of files and AFCB vector to match */
  179.  
  180. /*
  181.  * Note that file numbers are 1's origin subscripts into this vector, so that
  182.  * the file number value of 1 corresponds to the first entry, i.e. afcbs[0]
  183.  */
  184.  
  185. #define MAXFILES 20
  186.  struct afcb *(afcbs[MAXFILES]);
  187.  
  188. /* Variables for predef */
  189.  
  190.  int operation;         /* operation for predef. set in the main loop */
  191.  int data_exception;    /* exception to raise on data error */
  192.  int filenum;           /* number of current file */
  193.  int standard_in_file;  /* index of standard input file */
  194.  int standard_out_file; /* index of standard output file */
  195.  int current_in_file;   /* index of current default input file */
  196.  int current_out_file;  /* index of current default output file */
  197.  int current_in_file_saved;   
  198.      /* duplicate index of current default input file */
  199.  int current_out_file_saved;  
  200.      /* duplicate index of current default output file */
  201.  int file_offset;       /* Offset due to file argument in the stack */
  202.                          /* 2 if explicit file, 0 if default file */
  203.  struct tfile *tfiles;  /* linked list of temporary files */
  204.  
  205. /*
  206.  * The area work_string is used to hold an ASCIIZ string. It is a strictly
  207.  * temporary area which can be destroyed by almost any function. Anyone
  208.  * who needs to keep this string value must copy it using make_string.
  209.  *
  210.  * Note that the maximum length of strings in the Ada system is 4K bytes.
  211. */
  212.  
  213.  char work_string[4096];
  214.  
  215. /* The task stack size for created tasks is given by new_task_size,
  216.  * and the size of the main task is given by main_task_size.
  217.  * These are initialized in imain.c; and can be set by program options
  218.  * -s and -p, respectively.
  219.  */
  220.  
  221.  int main_task_size;
  222.  int new_task_size;
  223.