2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
26 * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
27 * ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
28 * the full copyright text.
35 static char rcsid[] = "$XConsortium: UilP2Reslv.c /main/11 1995/07/14 09:36:35 drk $"
40 * (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
46 ** User Interface Language Compiler (UIL)
50 ** This module contain the second pass routines for resolving forward
68 ** DEFINE and MACRO DEFINITIONS
76 ** EXTERNAL VARIABLE DECLARATIONS
83 ** GLOBAL VARIABLE DECLARATIONS
91 ** OWN VARIABLE DECLARATIONS
98 ** FUNCTIONAL DESCRIPTION:
100 ** This function processes forward references from the first pass.
102 ** FORMAL PARAMETERS:
108 ** sym_az_forward_ref_chain
109 ** sym_az_val_forward_ref_chain
121 ** error messages may be issued for objects that are still undefined
122 ** or of the wrong type
127 void sem_resolve_forward_refs()
130 sym_forward_ref_entry_type * fwd_entry;
131 sym_forward_ref_entry_type * next_fwd_entry;
132 sym_val_forward_ref_entry_type * fwd_val_entry;
133 sym_val_forward_ref_entry_type * next_fwd_val_entry;
134 sym_widget_entry_type ** target_obj_entry;
135 sym_value_entry_type ** target_val_entry;
136 sym_parent_list_type * parent_node;
137 sym_parent_list_type * parent_ptr;
141 ** Forward references are placed on a chain by the first pass of
142 ** the compiler. This routine walks the chain checking that
143 ** 1) name is now defined
144 ** 2) name points to the correct type of object
147 for (fwd_entry = sym_az_forward_ref_chain;
149 fwd_entry = next_fwd_entry)
151 sym_name_entry_type * name_entry;
152 sym_widget_entry_type * object_entry;
153 unsigned short int object_type;
157 ** Save the pointer to the next forward entry so we can free the current
158 ** entry after it is processed.
160 next_fwd_entry = fwd_entry->az_next_ref;
164 ** Call the Status callback routine to report our progress.
167 Uil_percent_complete = 60;
168 if (Uil_cmd_z_command.status_cb != (Uil_continue_type(*)())NULL)
169 diag_report_status();
172 object_type = fwd_entry->header.b_type;
173 name_entry = fwd_entry->az_name;
174 object_entry = (sym_widget_entry_type *) name_entry->az_object;
176 if (object_entry == NULL)
178 diag_issue_diagnostic
180 _sar_source_pos2 (fwd_entry),
181 diag_object_text( object_type ),
182 name_entry->c_text );
187 ** Make sure object references are to correct type of object.
188 ** A forward reference naming a widget class may be correctly
189 ** resolved by the corresponding gadget class, and vice versa.
191 if ((object_entry->header.b_type!=object_type) &&
192 (uil_gadget_variants[object_entry->header.b_type]!=object_type) &&
193 (uil_gadget_variants[object_type]!=object_entry->header.b_type))
195 diag_issue_diagnostic
197 _sar_source_pos2(fwd_entry),
198 diag_object_text(object_type),
199 diag_object_text(object_entry->header.b_type));
204 (sym_widget_entry_type * *) fwd_entry->a_update_location;
205 *target_obj_entry = object_entry;
208 ** Update objects on forward refernce chain so that their parent_lists point
209 ** to the objects which reference them
211 if (fwd_entry -> parent != NULL)
214 for (parent_ptr = object_entry -> parent_list;
215 ((parent_ptr != NULL) && (found == FALSE));
216 parent_ptr = parent_ptr -> next)
218 if (parent_ptr -> parent == fwd_entry -> parent)
223 parent_node = (sym_parent_list_type *)
224 sem_allocate_node (sym_k_parent_list_entry,
225 sym_k_parent_list_size);
226 parent_node -> next = object_entry -> parent_list;
227 object_entry -> parent_list = parent_node;
228 parent_node -> parent = fwd_entry -> parent;
234 ** Free the Forward reference entry now that it is no longer needed
236 sem_free_node(( sym_entry_type *)fwd_entry);
242 ** Now resolve the forward references to values
246 ** Forward references are placed on a chain by the first pass of
247 ** the compiler. This routine walks the chain checking that
248 ** 1) name is now defined
249 ** 2) name points to the correct type of value
252 for (fwd_val_entry = sym_az_val_forward_ref_chain;
253 fwd_val_entry != NULL;
254 fwd_val_entry = next_fwd_val_entry)
256 sym_name_entry_type * name_entry;
257 sym_value_entry_type * value_entry;
258 sym_obj_entry_type * obj_entry;
262 ** Save the pointer to the next forward entry so we can free the current
263 ** entry after it is processed.
265 next_fwd_val_entry = fwd_val_entry->az_next_ref;
269 ** Call the Status callback routine to report our progress.
272 Uil_percent_complete = 60;
273 if (Uil_cmd_z_command.status_cb != (Uil_continue_type(*)())NULL)
274 diag_report_status();
276 name_entry = fwd_val_entry->az_name;
277 value_entry = (sym_value_entry_type *) name_entry->az_object;
278 obj_entry = (sym_obj_entry_type *) name_entry->az_object;
280 if (value_entry == NULL)
282 diag_issue_diagnostic
284 _sar_source_pos2 (fwd_val_entry),
286 name_entry->c_text );
290 switch (fwd_val_entry->fwd_ref_flags)
292 case (sym_k_patch_add):
293 case (sym_k_patch_list_add):
296 (sym_value_entry_type * *) fwd_val_entry->a_update_location;
297 *target_val_entry = value_entry;
301 _assert(FALSE, "Illegal forward reference");
306 ** Free the Forward reference entry now that it is no longer needed
308 sem_free_node(( sym_entry_type *)fwd_val_entry);