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