1: /*
   2:  * External declarations for the linker.
   3:  */
   4: 
   5: #include <stdio.h>
   6: #include "../h/config.h"
   7: 
   8: /*
   9:  * Miscellaneous external declarations.
  10:  */
  11: 
  12: extern FILE *infile;        /* current input file */
  13: extern FILE *outfile;       /* interpreter output file */
  14: extern FILE *dbgfile;       /* debug file */
  15: extern char inname[];       /* input file name */
  16: extern char outname[];      /* output file name */
  17: extern char *pname;     /* this program name (from command line) */
  18: extern int line;        /* source program line number (from ucode) */
  19: extern char *file;      /* source program file name (from ucode) */
  20: extern int statics;     /* total number of statics */
  21: extern int dynoff;      /* stack offset counter for locals */
  22: extern int argoff;      /* stack offset counter for arguments */
  23: extern int static1;     /* first static in procedure */
  24: extern int nlocal;      /* number of locals in local table */
  25: extern int nconst;      /* number of constants in constant table */
  26: extern int nrecords;        /* number of records in program */
  27: extern int trace;       /* initial setting of &trace */
  28: extern int Dflag;       /* debug flag */
  29: extern char ixhdr[];        /* header line for direct execution */
  30: extern char *iconx;     /* location of iconx to put in #! line */
  31: extern int hdrloc;      /* location to place hdr block at */
  32: extern struct lfile *lfiles;    /* list of files to link */
  33: extern struct lfile *getlfile();
  34: 
  35: /*
  36:  * Interpreter code file header - this is written at the start of
  37:  *  an icode file after the start-up program (if any) and the #! line.
  38:  */
  39: struct header {
  40:    int size;            /* size of interpreter code */
  41:    int trace;           /* initial value of &trace */
  42:    int records;         /* location of record blocks */
  43:    int ftab;            /* location of record/field table */
  44:    int globals;         /* location of global variables */
  45:    int gnames;          /* location of names of globals */
  46:    int statics;         /* location of static variables */
  47:    int ident;           /* location of identifier table */
  48:    } hdr;
  49: 
  50: /*
  51:  * Structures for symbol table entries.
  52:  */
  53: 
  54: struct lentry {         /* local table entry */
  55:    char *l_name;        /*   name of variable */
  56:    int l_flag;          /*   variable flags */
  57:    union {          /*   value field */
  58:       int staticid;     /*     unique id for static variables */
  59:       int offset;       /*     stack offset for args and locals */
  60:       struct gentry *global;    /*     global table entry */
  61:       } l_val;
  62:    };
  63: 
  64: struct gentry {         /* global table entry */
  65:    struct gentry *g_blink;  /*   link for bucket chain */
  66:    char *g_name;        /*   name of variable */
  67:    int g_flag;          /*   variable flags */
  68:    int g_nargs;         /*   number of args or fields */
  69:    int g_procid;        /*   procedure or record id */
  70:    int g_pc;            /*   position in icode of object */
  71:    };
  72: 
  73: struct centry {         /* constant table entry */
  74:    int c_flag;          /*   type of literal flag */
  75:    union {          /*   value field */
  76:       long ival;        /*     integer */
  77:       double rval;      /*     real */
  78:       char *sval;       /*     string */
  79:       } c_val;
  80:    int c_length;        /*   length of literal string */
  81:    int c_pc;            /*   position in icode of object */
  82:    };
  83: 
  84: struct ientry {         /* identifier table entry */
  85:    struct ientry *i_blink;  /*   link for bucket chain */
  86:    char *i_name;        /*   pointer to string */
  87:    int i_length;        /*   length of string */
  88:    };
  89: 
  90: struct fentry {         /* field table header entry */
  91:    struct fentry *f_blink;  /*   link for bucket chain */
  92:    char *f_name;        /*   name of field */
  93:    int f_fid;           /*   field id */
  94:    struct rentry *f_rlist;  /*   head of list of records */
  95:    };
  96: 
  97: struct rentry {         /* field table record list entry */
  98:    struct rentry *r_link;   /*   link for list of records */
  99:    int r_recid;         /*   record id */
 100:    int r_fnum;          /*   offset of field within record */
 101:    };
 102: 
 103: /*
 104:  * Structure for linked list of file names to link.
 105:  */
 106: struct lfile {
 107:    struct lfile *lf_link;   /* next file in list */
 108:    char *lf_name;       /* name of file */
 109:    };
 110: 
 111: /*
 112:  * Flag values in symbol tables.
 113:  */
 114: 
 115: #define F_GLOBAL        01  /* variable declared global externally */
 116: #define F_PROC          05  /* procedure (includes GLOBAL) */
 117: #define F_RECORD       011  /* record (includes GLOBAL) */
 118: #define F_DYNAMIC      020  /* variable declared local dynamic */
 119: #define F_STATIC       040  /* variable declared local static */
 120: #define F_BUILTIN     0101  /* identifier refers to built-in procedure */
 121: #define F_IMPERROR        0400  /* procedure has default error */
 122: #define F_ARGUMENT   01000  /* variable is a formal parameter */
 123: #define F_INTLIT     02000  /* literal is an integer */
 124: #define F_REALLIT    04000  /* literal is a real */
 125: #define F_STRLIT    010000  /* literal is a string */
 126: #define F_CSETLIT   020000  /* literal is a cset */
 127: #define F_LONGLIT   040000  /* literal is a long integer */
 128: 
 129: /*
 130:  * Symbol table region pointers.
 131:  */
 132: 
 133: extern struct gentry **ghash;   /* hash area for global table */
 134: extern struct ientry **ihash;   /* hash area for identifier table */
 135: extern struct fentry **fhash;   /* hash area for field table */
 136: 
 137: extern struct lentry *ltable;   /* local table */
 138: extern struct gentry *gtable;   /* global table */
 139: extern struct centry *ctable;   /* constant table */
 140: extern struct ientry *itable;   /* identifier table */
 141: extern struct fentry *ftable;   /* field table headers */
 142: extern struct rentry *rtable;   /* field table record lists */
 143: extern char *strings;       /* string space */
 144: extern int *labels;     /* label table */
 145: extern char *code;      /* generated code space */
 146: 
 147: extern struct gentry *gfree;    /* free pointer for global table */
 148: extern struct ientry *ifree;    /* free pointer for identifier table */
 149: extern struct fentry *ffree;    /* free pointer for field table headers */
 150: extern struct rentry *rfree;    /* free pointer for field table record lists */
 151: extern char *sfree;     /* free pointer for string space */
 152: extern char *codep;     /* free pointer for code space */
 153: 
 154: extern int lsize;       /* size of local table */
 155: extern int gsize;       /* size of global table */
 156: extern int csize;       /* size of constant table */
 157: extern int isize;       /* size of identifier table */
 158: extern int fsize;       /* size of field table headers */
 159: extern int rsize;       /* size of field table record lists */
 160: extern int ssize;       /* size of string space */
 161: extern int ihsize;      /* size of identifier table hash area */
 162: extern int ghsize;      /* size of global table hash area */
 163: extern int fhsize;      /* size of field table hash area */
 164: extern int maxlabels;       /* maximum number of labels per procedure */
 165: extern int maxcode;     /* maximum amount of code per procedure */
 166: 
 167: extern int gmask;       /* mask for global table hash */
 168: extern int imask;       /* mask for identifier table hash */
 169: extern int fmask;       /* mask for field table hash */
 170: 
 171: /*
 172:  * Symbol table parameters.
 173:  */
 174: 
 175: #define LSIZE        100    /* default size of local table */
 176: #define GSIZE        200    /* default size of global table */
 177: #define CSIZE        100    /* default size of constant table */
 178: #define ISIZE        500    /* default size of identifier table */
 179: #define FSIZE        100    /* default size of field table headers */
 180: #define RSIZE        100    /* default size of field table record lists */
 181: #define SSIZE       5000    /* default size of string space */
 182: #define GHSIZE        64    /* default size of global table hash area */
 183: #define IHSIZE       128    /* default size of identifier table hash area */
 184: #define FHSIZE        32    /* default size of field table hash area */
 185: #define MAXLABELS    500    /* default maximum number of labels/proc */
 186: 
 187: /*
 188:  * Hash computation macros.
 189:  */
 190: 
 191: #define ghasher(x)  (((int)x)&gmask)    /* for global table */
 192: #define fhasher(x)  (((int)x)&fmask)    /* for field table */
 193: 
 194: /*
 195:  * Machine-dependent constants.
 196:  */
 197: #ifdef VAX
 198: #define INTSIZE        32   /* # of bits in an int */
 199: #define LOGINTSIZE      5   /* log of INTSIZE */
 200: #define MAXCODE     10000   /* default maximum amount of code/proc */
 201: #define OPSIZE          1   /* # of bytes for opcode */
 202: #define OPNDSIZE        4   /* # of bytes in interpreter operands */
 203: #define WORDSIZE  sizeof(int *) /* # of bytes in a pointer (sizeof(int *)) */
 204: #endif VAX
 205: 
 206: #ifdef PORT
 207: #define INTSIZE      x  /* # of bits in an int */
 208: #define LOGINTSIZE   x  /* log of INTSIZE */
 209: /*#define LONGS			/* longs are different from ints */
 210: /*#define MINSHORT       x	/* smallest short integer */
 211: /*#define MAXSHORT       x	/* largest short integer */
 212: #define MAXCODE          x  /* default maximum amount of code/proc */
 213: #define OPSIZE       1  /* # of bytes for opcode */
 214: #define OPNDSIZE         4  /* # of bytes in interpreter operands */
 215: #define WORDSIZE     4  /* # of bytes in a pointer (sizeof(int *)) */
 216: #endif PORT
 217: 
 218: #ifdef PDP11
 219: #define INTSIZE     16  /* # of bits in an int */
 220: #define LOGINTSIZE   4  /* log of INTSIZE */
 221: #define LONGS           /* longs are different from ints */
 222: #define MINSHORT   0100000  /* smallest short integer */
 223: #define MAXSHORT    077777  /* largest short integer */
 224: #define MAXCODE       2000  /* default maximum amount of code/proc */
 225: #define OPSIZE       1  /* # of bytes for opcode */
 226: #define OPNDSIZE     2  /* # of bytes in interpreter operands */
 227: #define WORDSIZE sizeof(int *)  /* # of bytes in a pointer (sizeof(int *)) */
 228: #endif PDP11
 229: 
 230: #define RKBLKSIZE 9*WORDSIZE    /* size of record constructor block */
 231: #define BITOFFMASK (INTSIZE-1)
 232: #define CSETSIZE (256/INTSIZE)  /* number of ints to hold 256 cset
 233: 				     bits.  Use (256/INTSIZE)+1 if
 234: 				     256 % INTSIZE != 0 */
 235: 
 236: #define MAXHDR      1024    /* size of autoloading header */
 237: #define HDRFILE IconxHdr
 238: 
 239: /*
 240:  * Cset accessing macros.  The definition of setb(b,c) is the total
 241:  *  result of the following definitions.  setb is only used in
 242:  *  code.c/emitcon.
 243:  */
 244: /*
 245:  * Offset in word of cs bit.
 246:  */
 247: #define CSOFF(b)    ((b) & BITOFFMASK)
 248: /*
 249:  * Address of word of cs bit.
 250:  */
 251: #define CSPTR(b,c)  ((c) + (((b)&0377) >> LOGINTSIZE))
 252: /*
 253:  * Set bit b in cset c.
 254:  */
 255: #define setb(b,c)   (*CSPTR(b,c) |= (01 << CSOFF(b)))
 256: /*
 257:  * Test bit b in cset c.
 258:  */
 259: #define tstb(b,c)   ((*CSPTR(b,c) >> CSOFF(b)) & 01)

Defined variables

hdr defined in line 48; used 19 times

Defined struct's

centry defined in line 73; used 14 times
fentry defined in line 90; used 42 times
gentry defined in line 64; used 57 times
header defined in line 39; used 4 times
ientry defined in line 84; used 34 times
lentry defined in line 54; used 12 times
lfile defined in line 106; used 26 times
rentry defined in line 97; used 29 times

Defined macros

BITOFFMASK defined in line 231; used 1 times
CSETSIZE defined in line 232; used 3 times
CSIZE defined in line 177; used 1 times
CSOFF defined in line 247; used 2 times
CSPTR defined in line 251; used 2 times
FHSIZE defined in line 184; used 1 times
FSIZE defined in line 179; used 1 times
F_ARGUMENT defined in line 122; used 3 times
F_BUILTIN defined in line 120; used 3 times
F_CSETLIT defined in line 126; used 3 times
F_DYNAMIC defined in line 118; used 3 times
F_IMPERROR defined in line 121; used 2 times
F_INTLIT defined in line 123; used 2 times
F_LONGLIT defined in line 127; used 3 times
F_REALLIT defined in line 124; used 3 times
F_RECORD defined in line 117; used 3 times
F_STATIC defined in line 119; used 3 times
F_STRLIT defined in line 125; used 2 times
GHSIZE defined in line 182; used 1 times
GSIZE defined in line 176; used 1 times
HDRFILE defined in line 237; used 2 times
IHSIZE defined in line 183; used 1 times
INTSIZE defined in line 219; used 2 times
ISIZE defined in line 178; used 1 times
LOGINTSIZE defined in line 220; used 1 times
LONGS defined in line 221; used 1 times
LSIZE defined in line 175; used 1 times
MAXCODE defined in line 224; used 1 times
MAXHDR defined in line 236; used 4 times
MAXLABELS defined in line 185; used 1 times
MAXSHORT defined in line 223; used 1 times
MINSHORT defined in line 222; used 1 times
OPNDSIZE defined in line 226; used 8 times
OPSIZE defined in line 225; used 1 times
RKBLKSIZE defined in line 230; used 2 times
RSIZE defined in line 180; used 1 times
SSIZE defined in line 181; used 1 times
WORDSIZE defined in line 227; used 9 times
fhasher defined in line 192; used 2 times
ghasher defined in line 191; used 4 times
setb defined in line 255; used 1 times
tstb defined in line 259; never used

Usage of this include

Last modified: 1984-11-18
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1115
Valid CSS Valid XHTML 1.0 Strict