1 /* lab.c -- Implementation File (module.c template V1.0)
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Contributed by James Craig Burley.
5 This file is part of GNU Fortran.
7 GNU Fortran is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
12 GNU Fortran is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GNU Fortran; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
25 Complex data abstraction for Fortran labels. Maintains a single master
26 list for all labels; it is expected initialization and termination of
27 this list will occur on program-unit boundaries.
31 Change ffelab_new for new ffewhere interface.
40 /* Externals defined here. */
43 ffelabNumber ffelab_num_news_
;
45 /* Simple definitions and enumerations. */
48 /* Internal typedefs. */
51 /* Private include files. */
54 /* Internal structure definitions. */
57 /* Static objects accessed by functions in this module. */
60 /* Static functions (internal). */
63 /* Internal macros. */
66 /* ffelab_find -- Find the ffelab object having the desired label value
72 If the desired ffelab object doesn't exist, returns NULL.
74 Straightforward search of list of ffelabs. */
77 ffelab_find (ffelabValue v
)
81 for (l
= ffelab_list_
; (l
!= NULL
) && (ffelab_value (l
) != v
); l
= l
->next
)
87 /* ffelab_finish -- Shut down label management
91 At the end of processing a program unit, call this routine to shut down
94 Kill all the labels on the list. */
102 for (pl
= NULL
, l
= ffelab_list_
; l
!= NULL
; pl
= l
, l
= l
->next
)
104 malloc_kill_ks (ffe_pool_any_unit (), pl
, sizeof (*pl
));
107 malloc_kill_ks (ffe_pool_any_unit (), pl
, sizeof (*pl
));
110 /* ffelab_init_3 -- Initialize label management system
114 Initialize the label management system. Do this before a new program
115 unit is going to be processed. */
121 ffelab_num_news_
= 0;
124 /* ffelab_new -- Create an ffelab object.
130 Create a label having a given value. If the value isn't known, pass
131 FFELAB_valueNONE, and set it later with ffelab_set_value.
133 Allocate, initialize, and stick at top of label list.
136 Change for new ffewhere interface. */
139 ffelab_new (ffelabValue v
)
144 l
= (ffelab
) malloc_new_ks (ffe_pool_any_unit (), "FFELAB label", sizeof (*l
));
145 l
->next
= ffelab_list_
;
146 #ifdef FFECOM_labelHOOK
147 l
->hook
= FFECOM_labelNULL
;
150 l
->firstref_line
= ffewhere_line_unknown ();
151 l
->firstref_col
= ffewhere_column_unknown ();
152 l
->doref_line
= ffewhere_line_unknown ();
153 l
->doref_col
= ffewhere_column_unknown ();
154 l
->definition_line
= ffewhere_line_unknown ();
155 l
->definition_col
= ffewhere_column_unknown ();
156 l
->type
= FFELAB_typeUNKNOWN
;