Pristine Ack-5.5
[Ack-5.5.git] / lang / cem / cemcom / l_state.str
1 /*
2  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
3  * See the copyright notice in the ACK home directory, in the file "Copyright".
4  */
5 /* $Id: l_state.str,v 3.4 1994/06/24 12:04:56 ceriel Exp $ */
6 /*      Lint state stack        */
7
8 /* These datastructures are used to implement a stack on which the
9  * state of automatic variables (including register variables) is
10  * kept.
11  * In this way it is possible to account for the flow of
12  * control of the program.
13  */
14
15 #define TEST_VAR        0               /* not a constant */
16 #define TEST_TRUE       1               /* always true */
17 #define TEST_FALSE      2               /* always false */
18
19 struct loop_state {                     /* used in lint_end_state only */
20         int lps_test;                   /* is the test a constant? */
21         struct state *lps_body;
22         struct state *lps_loop;
23 };
24
25 struct switch_state {                   /* used in lint_end_state only */
26         struct state *sws_case;
27         struct state *sws_break;
28         int sws_default_met;
29 };
30
31 /*      This union describes the (possibly incomplete) state at the end of the
32         mentioned construct.
33 */
34 union lint_end_state {                  /* used in lint_stack_entry only */
35         struct state *ule_if;
36         struct loop_state ule_loop;
37         struct switch_state ule_switch;
38 };
39
40 struct lint_stack_entry {
41         struct lint_stack_entry *next;
42         struct lint_stack_entry *ls_previous;
43         int ls_level;
44         struct state *ls_current;       /* used by all classes */
45         short ls_class;                 /* IF, WHILE, DO, FOR, SWITCH, CASE */
46         union lint_end_state ls_end;
47 };
48
49 /* ALLOCDEF "lint_stack_entry" 10 */
50
51 /* macros to access the union */
52 #define LS_IF           ls_end.ule_if
53 #define LS_TEST         ls_end.ule_loop.lps_test
54 #define LS_BODY         ls_end.ule_loop.lps_body
55 #define LS_LOOP         ls_end.ule_loop.lps_loop
56 #define LS_CASE         ls_end.ule_switch.sws_case
57 #define LS_BREAK        ls_end.ule_switch.sws_break
58 #define LS_DEFAULT_MET  ls_end.ule_switch.sws_default_met
59
60 /* describes a branch in the program, with its local idfs */
61 struct state {
62         struct state *next;             /* only used by memory allocator */
63         struct auto_def *st_auto_list;
64         int st_notreached;              /* set if not reached */
65         int st_warned;                  /* set if warning issued */
66 };
67
68 /* ALLOCDEF "state" 15 */
69
70 /* describes the state of a local idf in a given branch of the program */
71 struct auto_def {
72         struct auto_def *next;
73         struct idf *ad_idf;
74         struct def *ad_def;
75         int ad_used;
76         int ad_set;
77         int ad_maybe_set;
78 };
79
80 /* ALLOCDEF "auto_def" 20 */
81
82 /* describes the state of an idf during expression evaluation */
83 struct expr_state {                     /*actually concerns idfs only */
84         struct expr_state *next;
85         struct idf *es_idf;             /* the idf with its offset */
86         arith es_offset;
87         int es_used;                    /* value has been used */
88         int es_referred;                /* address has been taken */
89         int es_set;                     /* has been assigned to */
90 };
91
92 /* ALLOCDEF "expr_state" 20 */
93