home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Icon 8.1 / msm-1 / h.sit / cstructs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-19  |  11.7 KB  |  338 lines  |  [TEXT/MPS ]

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