Pristine Ack-5.5
[Ack-5.5.git] / lang / occam / comp / expr.h
1 /* $Id: expr.h,v 1.7 1994/06/24 12:26:58 ceriel Exp $ */
2 /*
3  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4  * See the copyright notice in the ACK home directory, in the file "Copyright".
5  */
6 #define E_NODE  0
7 #define E_VAR   1       /* Variable *or* channel */
8 #define E_CONST 2
9 #define E_TABLE 3
10 #define E_BTAB  4
11 #define E_NOW   5
12 #define E_IO    6
13 #define E_CALL  7
14
15 struct table {
16         struct table    *next;
17         long    val;
18 };
19
20 struct expr;
21
22 struct expr_list {
23         struct expr_list        *next;
24         struct expr *arg;
25 };
26
27 struct expr {
28         short kind;
29         short type;
30         int arr_siz;
31         union {
32                 struct {
33                         int op;
34                         struct expr *left, *right;
35                 } node;
36
37                 struct symbol *var;
38
39                 long cst;
40
41                 int tab;
42
43                 struct {
44                         int out;
45                         struct expr *chan;
46                         struct expr_list *args;
47                 } io;
48
49                 struct {
50                         struct expr *c_proc;
51                         struct expr_list *c_args;
52                 } call;
53         } u;
54 };
55
56 struct expr *new_node(), *new_var(), *new_const(), *new_table(), *new_now();
57 struct expr *new_io(), *new_call(), *copy_const();
58 void table_add(), expr_list_add();
59 void check_param(), check_io(), check_wait();
60 void destroy(), used();
61
62 #define valueless(e)            (((e)->type&T_TYPE)==T_VOID)
63 #define valued(e)               (((e)->type&T_TYPE)==T_VALUE)
64 #define input_process(e)        ((e)->kind==E_IO && !(e)->u.io.out)
65 #define constant(e)             ((e)->kind==E_CONST)
66 #define arr_constant(e)         ((e)->kind==E_TABLE || (e)->kind==E_BTAB)