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 / h / cstructs.h < prev    next >
C/C++ Source or Header  |  2002-01-18  |  12KB  |  321 lines

  1. /*
  2.  * cstructs.h - structures and accompanying manifest constants for functions
  3.  *  in the common subdirectory.
  4.  */
  5.  
  6. /*
  7.  * fileparts holds a file name broken down into parts.
  8.  */
  9. struct fileparts {            /* struct of file name parts */
  10.    char *dir;                /* directory */
  11.    char *name;                /* name */
  12.    char *ext;                /* extension */
  13.    #if VMS
  14.       char *version;
  15.    #endif                    /* VMS */
  16.    };
  17.  
  18. /*
  19.  * xval - holds references to literal constants
  20.  */
  21. union xval {
  22.    long ival;        /* integer */
  23.    double rval;        /*  real */
  24.    word sval;        /*  offset into string space of string */
  25.    };
  26.  
  27. /*
  28.  * str_buf references a string buffer. Strings are built a character
  29.  *  at a time. When a buffer "fragment" is filled, another is allocated
  30.  *  and the the current string copied to it.
  31.  */
  32. struct str_buf_frag {
  33.    struct str_buf_frag *next;     /* next buffer fragment */
  34.    char s[1];                     /* variable size buffer, really > 1 */
  35.    };
  36.  
  37. struct str_buf {
  38.    unsigned int size;             /* total size of current buffer */
  39.    char *strtimage;               /* start of string currently being built */
  40.    char *endimage;                /* next free character in buffer */
  41.    char *end;                     /* end of current buffer */
  42.    struct str_buf_frag *frag_lst; /* list of buffer fragments */
  43.    struct str_buf *next;          /* buffers can be put on free list */
  44.    };
  45.  
  46. #define AppChar(sbuf, c) do {\
  47.    if ((sbuf).endimage >= (sbuf).end)\
  48.       new_sbuf(&(sbuf));\
  49.    *((sbuf).endimage)++ = (c);\
  50.    } while (0)
  51.  
  52. /*
  53.  * implement contains information about the implementation of an operation.
  54.  */
  55. #define NoRsltSeq  -1L         /* no result sequence: {} */
  56. #define UnbndSeq   -2L       /* unbounded result sequence: {*} */
  57.  
  58. #define DoesRet    01         /* operation (or "body" function) returns */
  59. #define DoesFail   02         /* operation (or "body" function) fails */
  60. #define DoesSusp   04         /* operation (or "body" function) suspends */
  61. #define DoesEFail 010        /* fails through error conversion */
  62. #define DoesFThru 020         /* only "body" functions can "fall through" */
  63.  
  64. struct implement {
  65.    struct implement *blink;   /* link for bucket chain in hash tables */
  66.    char oper_typ;             /* 'K'=keyword, 'F'=function, 'O'=operator */
  67.    char prefix[2];          /* prefix to make start of name unique */
  68.    char *name;              /* function/operator/keyword name */
  69.    char *op;              /* operator symbol (operators only) */
  70.    int nargs;              /* number of arguments operation requires */
  71.    int *arg_flgs;             /* array of arg flags: deref/underef, var len*/
  72.    long min_result;          /* minimum result sequence length */
  73.    long max_result;          /* maiximum result sequence length */
  74.    int resume;              /* flag - resumption after last result */
  75.    int ret_flag;          /* DoesRet, DoesFail, DoesSusp */
  76.    int use_rslt;              /* flag - explicitly uses result location */
  77.    char *comment;          /* description of operation */
  78.    int ntnds;              /* size of tnds array */
  79.    struct tend_var *tnds;     /* pointer to array of info about tended vars */
  80.    int nvars;                 /* size of vars array */
  81.    struct ord_var  *vars;     /* pointer to array of info about ordinary vars */
  82.    struct il_code *in_line;    /* inline version of the operation */
  83.    int iconc_flgs;          /* flags for internal use by the compiler */
  84.    };
  85.  
  86. /*
  87.  * These codes are shared between the data base and rtt. They are defined
  88.  *  here, though not all are used by the data base.
  89.  */
  90. #define TndDesc   1  /* a tended descriptor */
  91. #define TndStr    2  /* a tended character pointer */
  92. #define TndBlk    3  /* a tended block pointer */
  93. #define OtherDcl  4  /* a declaration that is not special */
  94. #define IsTypedef 5  /* a typedef */
  95. #define VArgLen   6  /* identifier for length of variable parm list */
  96. #define RsltLoc   7  /* the special result location of an operation */
  97. #define Label     8  /* label */
  98. #define RtParm   16  /* undereferenced parameter of run-time routine */
  99. #define DrfPrm   32  /* dereferenced parameter of run-time routine */
  100. #define VarPrm   64  /* variable part of parm list (with RtParm or DrfPrm) */
  101. #define PrmMark 128  /* flag - used while recognizing params of body fnc */
  102. #define ByRef   256  /* flag - parameter to body function passed by reference */
  103.  
  104. /*
  105.  * Flags to indicate what types are returned from the function implementing
  106.  *  a body. These are unsed in determining the calling conventions
  107.  *  of the function.
  108.  */
  109. #define RetInt   1  /* body/function returns a C_integer */
  110. #define RetDbl   2  /* body/function returns a C_double */
  111. #define RetOther 4  /* body (not function itself) returns something else */
  112. #define RetNoVal 8  /* function returns no value */
  113. #define RetSig  16  /* function returns a signal */
  114.  
  115. /*
  116.  * tend_var contains information about a tended variable in the "declare {...}"
  117.  *  action of an operation.
  118.  */
  119. struct tend_var {
  120.    int var_type;           /* TndDesc, TndStr, or TndBlk */
  121.    struct il_c *init;      /* initial value from declaration */
  122.    char *blk_name;         /* TndBlk: struct name of block */
  123.    };
  124.  
  125. /*
  126.  * ord_var contains information about an ordinary variable in the
  127.  *  "declare {...}" action of an operation.
  128.  */
  129. struct ord_var {
  130.    char *name;        /* name of variable */
  131.    struct il_c *dcl;  /* declaration of variable (includes name) */
  132.    };
  133.  
  134. /*
  135.  * il_code has information about an action in an operation.
  136.  */
  137. #define IL_If1     1
  138. #define IL_If2     2
  139. #define IL_Tcase1  3
  140. #define IL_Tcase2  4
  141. #define IL_Lcase   5
  142. #define IL_Err1    6
  143. #define IL_Err2    7
  144. #define IL_Lst     8
  145. #define IL_Const   9
  146. #define IL_Bang   10
  147. #define IL_And    11
  148. #define IL_Cnv1   12
  149. #define IL_Cnv2   13
  150. #define IL_Def1   14
  151. #define IL_Def2   15
  152. #define IL_Is     16
  153. #define IL_Var    17
  154. #define IL_Subscr 18
  155. #define IL_Block  19
  156. #define IL_Call   20
  157. #define IL_Abstr  21
  158. #define IL_VarTyp 22
  159. #define IL_Store  23
  160. #define IL_Compnt 24
  161. #define IL_TpAsgn 25
  162. #define IL_Union  26
  163. #define IL_Inter  27
  164. #define IL_New    28
  165. #define IL_IcnTyp 29
  166. #define IL_Acase  30
  167.  
  168. #define CM_Fields -1
  169.  
  170. union il_fld {
  171.    struct il_code *fld;
  172.    struct il_c *c_cd;
  173.    int *vect;
  174.    char *s;
  175.    word n;
  176.    };
  177.  
  178. struct il_code {
  179.    int il_type;
  180.    union il_fld u[1];   /* actual number of fields varies with type */
  181.    };
  182.  
  183. /*
  184.  * The following manifest constants are used to describe types, conversions,
  185.  *   and returned values. Non-negative numbers are reserved for types described
  186.  *   in the type specification system.
  187.  */
  188. #define TypAny    -1
  189. #define TypEmpty  -2
  190. #define TypVar    -3
  191. #define TypCInt   -4
  192. #define TypCDbl   -5
  193. #define TypCStr   -6
  194. #define TypEInt   -7
  195. #define TypECInt  -8
  196. #define TypTStr   -9
  197. #define TypTCset -10
  198. #define RetDesc  -11
  199. #define RetNVar  -12
  200. #define RetSVar  -13
  201. #define RetNone  -14
  202.  
  203. /*
  204.  * il_c describes a piece of C code.
  205.  */
  206. #define ILC_Ref    1   /* nonmodifying reference to var. in sym. tab. */
  207. #define ILC_Mod    2   /* modifying reference to var. in sym. tab */
  208. #define ILC_Tend   3   /* tended var. local to inline block */
  209. #define ILC_SBuf   4   /* string buffer */
  210. #define ILC_CBuf   5   /* cset buffer */
  211. #define ILC_Ret    6   /* return statement */
  212. #define ILC_Susp   7   /* suspend statement */
  213. #define ILC_Fail   8   /* fail statement */
  214. #define ILC_Goto   9   /* goto */
  215. #define ILC_CGto  10   /* conditional goto */
  216. #define ILC_Lbl   11   /* label */
  217. #define ILC_LBrc  12   /* '{' */
  218. #define ILC_RBrc  13   /* '}' */
  219. #define ILC_Str   14   /* arbitrary string of code */
  220. #define ILC_EFail 15   /* errorfail statement */
  221.  
  222. #define RsltIndx -1   /* symbol table index for "result" */
  223.  
  224. struct il_c {
  225.    int il_c_type;
  226.    struct il_c *code[3];
  227.    word n;
  228.    char *s;
  229.    struct il_c *next;
  230.    };
  231.  
  232. /*
  233.  * The parameter value of a run-time operation may be in one of several
  234.  *  different locations depending on what conversions have been done to it.
  235.  *  These codes are shared by rtt and iconc.
  236.  */
  237. #define PrmTend    1   /* in tended location */
  238. #define PrmCStr    3   /* converted to C string: tended location */
  239. #define PrmInt     4   /* converted to C int: non-tended location */
  240. #define PrmDbl     8   /* converted to C double: non-tended location */
  241.  
  242. /*
  243.  * Kind of RLT return statement supported.
  244.  */
  245. #define TRetNone  0   /* does not support an RTL return statement */
  246. #define TRetBlkP  1   /* block pointer */
  247. #define TRetDescP 2   /* descriptor pointer */
  248. #define TRetCharP 3   /* character pointer */
  249. #define TRetCInt  4   /* C integer */
  250. #define TRetSpcl  5   /* RLT return statement has special form & semenatics */
  251.  
  252. /*
  253.  * Codes for dereferencing needs.
  254.  */
  255. #define DrfNone  0  /* not a variable type */
  256. #define DrfGlbl  1  /* treat as a global variable */
  257. #define DrfCnst  2  /* type of values in variable doesn't change */
  258. #define DrfSpcl  3  /* special dereferencing: trapped variable */
  259.  
  260. /*
  261.  * Information about an Icon type.
  262.  */
  263. struct icon_type {
  264.    char *id;        /* name of type */
  265.    int support_new;    /* supports RTL "new" construct */
  266.    int deref;        /* dereferencing needs */
  267.    int rtl_ret;        /* kind of RTL return supported if any */
  268.    char *typ;        /* for variable: initial type */
  269.    int num_comps;    /* for aggregate: number of type components */
  270.    int compnts;        /* for aggregate: index of first component */
  271.    char *abrv;        /* abreviation used for type tracing */
  272.    char *cap_id;    /* name of type with first character capitalized */
  273.    };
  274.  
  275. /*
  276.  * Information about a component of an aggregate type.
  277.  */
  278. struct typ_compnt {
  279.    char *id;        /* name of component */
  280.    int n;        /* position of component within type aggragate */
  281.    int var;        /* flag: this component is an Icon-level variable */
  282.    int aggregate;    /* index of type that owns the component */
  283.    char *abrv;        /* abreviation used for type tracing */
  284.    };
  285.  
  286. extern int num_typs;                 /* number of types in table */
  287. extern struct icon_type icontypes[]; /* table of icon types */
  288.  
  289. /*
  290.  * Type inference needs to know where most of the standard types
  291.  *  reside. Some have special uses outside operations written in
  292.  *  RTL code, such as the null type for initializing variables, and
  293.  *  others have special semantics, such as trapped variables.
  294.  */
  295. extern int str_typ;                  /* index of string type */
  296. extern int int_typ;                  /* index of integer type */
  297. extern int rec_typ;                  /* index of record type */
  298. extern int proc_typ;                 /* index of procedure type */
  299. extern int coexp_typ;                /* index of co-expression type */
  300. extern int stv_typ;                  /* index of sub-string trapped var type */
  301. extern int ttv_typ;                  /* index of table-elem trapped var type */
  302. extern int null_typ;                 /* index of null type */
  303. extern int cset_typ;                 /* index of cset type */
  304. extern int real_typ;                 /* index of real type */
  305. extern int list_typ;                 /* index of list type */
  306. extern int tbl_typ;                  /* index of table type */
  307.  
  308. extern int num_cmpnts;                 /* number of aggregate components */
  309. extern struct typ_compnt typecompnt[]; /* table of aggregate components */
  310. extern int str_var;                    /* index of trapped string variable */
  311. extern int trpd_tbl;                   /* index of trapped table */
  312. extern int lst_elem;                   /* index of list element */
  313. extern int tbl_val;                    /* index of table element value */
  314. extern int tbl_dflt;                   /* index of table default */
  315.  
  316. /*
  317.  * minimum number of unsigned ints needed to hold the bits of a cset - only
  318.  *  used in translators, not in the run-time system.
  319.  */
  320. #define BVectSize 16
  321.