home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v92.tgz / v92.tar / v92 / src / icont / link.h < prev    next >
C/C++ Source or Header  |  1996-03-22  |  5KB  |  147 lines

  1. /*
  2.  * External declarations for the linker.
  3.  */
  4.  
  5. #include "::h:rt.h"
  6.  
  7. /*
  8.  * Miscellaneous external declarations.
  9.  */
  10.  
  11. extern FILE *infile;        /* current input file */
  12. extern FILE *outfile;        /* linker output file */
  13. extern FILE *dbgfile;        /* debug file */
  14. extern char inname[];        /* input file name */
  15. extern int lineno;        /* source program line number (from ucode) */
  16. extern int colmno;        /* source program column number */
  17.  
  18. extern int lstatics;        /* total number of statics */
  19. extern int argoff;        /* stack offset counter for arguments */
  20. extern int dynoff;        /* stack offset counter for locals */
  21. extern int static1;        /* first static in procedure */
  22. extern int nlocal;        /* number of locals in local table */
  23. extern int nconst;        /* number of constants in constant table */
  24. extern int nrecords;        /* number of records in program */
  25. extern int trace;        /* initial setting of &trace */
  26. extern char ixhdr[];        /* header line for direct execution */
  27. extern char *iconx;        /* location of iconx */
  28. extern int hdrloc;        /* location to place hdr block at */
  29. extern struct lfile *llfiles;    /* list of files to link */
  30.  
  31. /*
  32.  * Structures for symbol table entries.
  33.  */
  34.  
  35. struct lentry {            /* local table entry */
  36.    word  l_name;        /*   index into string space of variable name */
  37.    int l_flag;            /*   variable flags */
  38.    union {            /*   value field */
  39.       int staticid;        /*     unique id for static variables */
  40.       word offset;        /*     stack offset for args and locals */
  41.       struct gentry *global;    /*     global table entry */
  42.       } l_val;
  43.    };
  44.  
  45. struct gentry {            /* global table entry */
  46.    struct gentry *g_blink;    /*   link for bucket chain */
  47.    word g_name;            /*   index into string space of variable name */
  48.    int g_flag;            /*   variable flags */
  49.    int g_nargs;            /*   number of args or fields */
  50.    int g_procid;        /*   procedure or record id */
  51.    word g_pc;            /*   position in icode of object */
  52.    int g_index;            /*   "index" in global table */
  53.    struct gentry **g_refs;    /*   other globals referenced, if a proc */
  54.    struct gentry *g_next;    /*   next global in table */
  55.    };
  56.  
  57. struct centry {            /* constant table entry */
  58.    int c_flag;            /*   type of literal flag */
  59.    union xval c_val;        /*   value field */
  60.    int c_length;        /*   length of literal string */
  61.    word c_pc;            /*   position in icode of object */
  62.    };
  63.  
  64. struct ientry {            /* identifier table entry */
  65.    struct ientry *i_blink;    /*   link for bucket chain */
  66.    word i_name;            /*   index into string space of string */
  67.    int i_length;        /*   length of string */
  68.    };
  69.  
  70. struct fentry {            /* field table header entry */
  71.    struct fentry *f_blink;    /*   link for bucket chain */
  72.    word f_name;            /*   index into string space of field name */
  73.    int f_fid;            /*   field id */
  74.    struct rentry *f_rlist;    /*   head of list of records */
  75.    struct fentry *f_nextentry;    /*   next field name in allocation order */
  76.    };
  77.  
  78. struct rentry {            /* field table record list entry */
  79.    struct rentry *r_link;    /*   link for list of records */
  80.    struct gentry *r_gp;        /*   global entry for record */
  81.    int r_fnum;            /*   offset of field within record */
  82.    };
  83.  
  84. #include "lfile.h"
  85.  
  86. /*
  87.  * Flag values in symbol tables.
  88.  */
  89.  
  90. #define F_Global        01    /* variable declared global externally */
  91. #define F_Unref            02    /* procedure is unreferenced */    
  92. #define F_Proc            04    /* procedure */
  93. #define F_Record       010    /* record */
  94. #define F_Dynamic       020    /* variable declared local dynamic */
  95. #define F_Static       040    /* variable declared local static */
  96. #define F_Builtin      0100    /* identifier refers to built-in procedure */
  97. #define F_ImpError      0400    /* procedure has default error */
  98. #define F_Argument     01000    /* variable is a formal parameter */
  99. #define F_IntLit     02000    /* literal is an integer */
  100. #define F_RealLit     04000    /* literal is a real */
  101. #define F_StrLit    010000    /* literal is a string */
  102. #define F_CsetLit    020000    /* literal is a cset */
  103.  
  104. /*
  105.  * Symbol table region pointers.
  106.  */
  107.  
  108. extern struct gentry **lghash;    /* hash area for global table */
  109. extern struct ientry **lihash;    /* hash area for identifier table */
  110. extern struct fentry **lfhash;    /* hash area for field table */
  111.  
  112. extern struct lentry *lltable;    /* local table */
  113. extern struct centry *lctable;    /* constant table */
  114. extern struct ipc_fname *fnmtbl; /* table associating ipc with file name */
  115. extern struct ipc_line *lntable; /* table associating ipc with line number */
  116. extern char *lsspace;        /* string space */
  117. extern word *labels;        /* label table */
  118. extern char *codeb;        /* generated code space */
  119.  
  120. extern struct ipc_fname *fnmfree; /* free pointer for ipc/file name tbl */
  121. extern struct ipc_line *lnfree;    /* free pointer for ipc/line number tbl */
  122. extern word lsfree;        /* free index for string space */
  123. extern char *codep;        /* free pointer for code space */
  124.  
  125. extern struct fentry *lffirst;    /* first field table entry */
  126. extern struct fentry *lflast;    /* last field table entry */
  127. extern struct gentry *lgfirst;    /* first global table entry */
  128. extern struct gentry *lglast;    /* last global table entry */
  129.  
  130.  
  131. /*
  132.  * Hash computation macros.
  133.  */
  134.  
  135. #define ghasher(x)    (((word)x)&gmask)    /* for global table */
  136. #define fhasher(x)    (((word)x)&fmask)    /* for field table */
  137.  
  138. /*
  139.  * Machine-dependent constants.
  140.  */
  141.  
  142. #ifdef MultiThread
  143. #define RkBlkSize(gp) ((10*WordSize)+(gp)->g_nargs * sizeof(struct descrip))
  144. #else                    /* MultiThread */
  145. #define RkBlkSize(gp) ((9*WordSize)+(gp)->g_nargs * sizeof(struct descrip))
  146. #endif                    /* MultiThread */
  147.