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 / h / cstructs.h < prev    next >
C/C++ Source or Header  |  1996-03-22  |  12KB  |  343 lines

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