Pristine Ack-5.5
[Ack-5.5.git] / lang / m2 / comp / scope.h
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  * Author: Ceriel J.H. Jacobs
6  */
7
8 /* S C O P E   M E C H A N I S M */
9
10 /* $Id: scope.h,v 1.22 1994/06/24 12:42:37 ceriel Exp $ */
11
12 #define OPENSCOPE       0       /* Indicating an open scope */
13 #define CLOSEDSCOPE     1       /* Indicating a closed scope (module) */
14
15 #define SC_CHKFORW      1       /* Check for forward definitions when closing
16                                    a scope
17                                 */
18 #define SC_CHKPROC      2       /* Check for forward procedure definitions
19                                    when closing a scope
20                                 */
21 #define SC_REVERSE      4       /* Reverse list of definitions, to get it
22                                    back into original order
23                                 */
24
25 struct scope {
26         /* struct scope *next; */
27         char *sc_name;          /* name of this scope */
28         struct def *sc_def;     /* list of definitions in this scope */
29         arith sc_off;           /* offsets of variables in this scope */
30         char sc_scopeclosed;    /* flag indicating closed or open scope */
31         char sc_defmodule;      /* flag set is this scope is from a separate
32                                    definition module
33                                 */
34         int sc_level;           /* level of this scope */
35         struct def *sc_definedby; /* The def structure defining this scope */
36         struct node *sc_end;    /* node to remember line number of end of scope */
37 };
38
39 struct scopelist {
40         struct scopelist *sc_next;
41         struct scope *sc_scope;
42         struct scopelist *sc_encl;
43         int sc_count;
44 };
45
46 typedef struct scope t_scope;
47 typedef struct scopelist t_scopelist;
48
49 extern t_scope
50         *PervasiveScope;
51
52 extern t_scopelist
53         *CurrVis, *GlobalVis;
54
55 #define CurrentScope    (CurrVis->sc_scope)
56 #define GlobalScope     (GlobalVis->sc_scope)
57 #define enclosing(x)    ((x)->sc_encl)
58 #define scopeclosed(x)  ((x)->sc_scopeclosed)
59 #define nextvisible(x)  ((x)->sc_next)          /* use with scopelists */
60
61 t_scope *open_and_close_scope();