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[] = "$TOG: UilSymStor.c /main/15 1997/03/12 15:21:44 dbl $"
40 * (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
46 ** User Interface Language Compiler (UIL)
50 ** This module contains the procedures for managing memory for
70 ** DEFINE and MACRO DEFINITIONS
77 ** EXTERNAL VARIABLE DECLARATIONS
84 ** GLOBAL VARIABLE DECLARATIONS
88 externaldef(uil_comp_glbl) sym_name_entry_type
89 *sym_az_hash_table[ sym_k_hash_table_limit];
90 externaldef(uil_comp_glbl) sym_value_entry_type
91 *sym_az_error_value_entry = NULL;
92 externaldef(uil_comp_glbl) sym_external_def_entry_type
93 *sym_az_external_def_chain;
94 externaldef(uil_comp_glbl) sym_forward_ref_entry_type
95 *sym_az_forward_ref_chain;
96 externaldef(uil_comp_glbl) sym_val_forward_ref_entry_type
97 *sym_az_val_forward_ref_chain;
98 externaldef(uil_comp_glbl) sym_module_entry_type
100 externaldef(uil_comp_glbl) sym_root_entry_type
102 externaldef(uil_comp_glbl) sym_section_entry_type
103 *sym_az_current_section_entry;
104 externaldef(uil_comp_glbl) sym_entry_type
105 *sym_az_entry_list_header;
108 * These lists save the allocated and freed symbol table nodes.
110 externaldef(uil_comp_glbl) URMPointerListPtr sym_az_allocated_nodes;
111 externaldef(uil_comp_glbl) URMPointerListPtr sym_az_freed_nodes;
116 ** OWN VARIABLE DECLARATIONS
124 ** FUNCTIONAL DESCRIPTION:
126 ** This routine intializes the compiler's memory allocation system.
128 ** FORMAL PARAMETERS:
138 ** sym_az_last_location ptr to last byte avail for allocation
146 ** first symbol table buffer is allocated
152 sym_initialize_storage(void)
158 * Initialize the name hash table
160 for (i=0; i<sym_k_hash_table_limit; i++)
161 sym_az_hash_table[ i ] = NULL;
164 * Set forward reference, external definition, and symbol table header
167 sym_az_forward_ref_chain = NULL;
168 sym_az_val_forward_ref_chain = NULL;
169 sym_az_external_def_chain = NULL;
170 sym_az_entry_list_header = NULL;
171 sym_az_module_entry = NULL;
174 * Acquire pointer lists to access allocated and freed nodes
176 UrmPlistInit (1000, &sym_az_allocated_nodes);
177 UrmPlistInit (100, &sym_az_freed_nodes);
180 * Allocate a value entry for an error value and give it a name. Giving it
181 * name assures that it is not freed. The name used is one that will not
182 * conflict with a user name.
185 if ( sym_az_error_value_entry == NULL )
186 sym_az_error_value_entry = (sym_value_entry_type *)
187 sem_allocate_node (sym_k_value_entry, sym_k_value_entry_size);
189 sym_az_error_value_entry->b_type = sym_k_error_value;
190 sym_az_error_value_entry->obj_header.b_flags =
191 (sym_m_private | sym_m_builtin);
193 sym_az_error_value_entry->obj_header.az_name =
194 sym_insert_name( 9, "#error...");
201 ** FUNCTIONAL DESCRIPTION:
203 ** This routine cleans up the compiler's memory allocation system, and
204 ** frees all memory used by the symbol table.
206 ** FORMAL PARAMETERS:
208 ** freealloc TRUE if allocated nodes are to be freed.
209 ** Otherwise, free only freed nodes.
213 ** sym_az_entry_list_header ptr to list of symbol entries
217 ** sym_az_entry_list_header ptr to list of symbol entries
225 ** all symbol table memory is freed.
231 Uil_sym_cleanup_storage (boolean freealloc)
234 if ( sym_az_allocated_nodes != NULL )
235 UrmPlistFreeContents (sym_az_allocated_nodes);
237 if ( sym_az_freed_nodes != NULL )
238 UrmPlistFreeContents (sym_az_freed_nodes);
239 if ( sym_az_allocated_nodes != NULL )
240 UrmPlistFree (sym_az_allocated_nodes);
241 if ( sym_az_freed_nodes != NULL )
242 UrmPlistFree (sym_az_freed_nodes);
248 ** FUNCTIONAL DESCRIPTION:
250 ** This routine adds an object to the external definition chain.
252 ** FORMAL PARAMETERS:
254 ** az_name name of object to be placed on the chain
258 ** sym_az_external_def_chain head of the external definition chain
262 ** sym_az_external_def_chain head of the external definition chain
276 sym_make_external_def( XmConst sym_name_entry_type *az_name )
281 sym_external_def_entry_type *external_entry;
283 /* allocate an external definition entry */
285 external_entry = (sym_external_def_entry_type *)
286 sem_allocate_node (sym_k_external_def_entry,
287 sym_k_external_def_entry_size);
289 /* fill in the entry */
291 external_entry->az_name = (sym_name_entry_type *)az_name;
293 /* place on the front of the chain */
295 external_entry->az_next_object = sym_az_external_def_chain;
296 sym_az_external_def_chain = external_entry;
303 ** FUNCTIONAL DESCRIPTION:
305 ** This routine adds a reference to the forward reference chain.
306 ** This routine is used for widget and gadget forward references only.
309 ** FORMAL PARAMETERS:
311 ** az_id_frame parse stack frame for id being referenced
312 ** l_widget_type type of object being referenced
313 ** az_object ptr to the location that needs to be updated
314 ** when the object is resolved
318 ** sym_az_forward_ref_chain head of the forward reference chain
322 ** sym_az_forward_ref_chain head of the forward reference chain
336 sym_make_forward_ref(XmConst yystype *az_id_frame,
337 XmConst int l_widget_type,
338 XmConst char *a_location)
341 sym_forward_ref_entry_type *fwd_ref_entry;
343 _assert( (az_id_frame->b_tag == sar_k_token_frame) &&
344 (az_id_frame->value.az_symbol_entry->header.b_tag ==
345 sym_k_name_entry), "arg1 not an id frame" );
347 /* allocate an external definition entry */
349 fwd_ref_entry = (sym_forward_ref_entry_type *)
350 sem_allocate_node (sym_k_forward_ref_entry,
351 sym_k_forward_ref_entry_size);
353 /* fill in the entry */
355 _sar_save_source_pos (&fwd_ref_entry->header, az_id_frame);
357 fwd_ref_entry->header.b_type = l_widget_type;
358 fwd_ref_entry->az_name =
359 (sym_name_entry_type *) az_id_frame->value.az_symbol_entry;
360 fwd_ref_entry->a_update_location = (char *)a_location;
362 /* place on the front of the chain */
364 fwd_ref_entry->az_next_ref = sym_az_forward_ref_chain;
365 sym_az_forward_ref_chain = fwd_ref_entry;
371 ** FUNCTIONAL DESCRIPTION:
373 ** This routine adds a reference to the values forward reference chain.
374 ** This routine is used for value forward references only.
377 ** FORMAL PARAMETERS:
379 ** az_id_frame parse stack frame for id being referenced
380 ** az_object ptr to the location that needs to be updated
381 ** when the object is resolved
385 ** sym_az_val_forward_ref_chain head of the forward reference chain
389 ** sym_az_val_forward_ref_chain head of the forward reference chain
403 sym_make_value_forward_ref (XmConst yystype *az_value_frame,
404 XmConst char *a_location,
405 XmConst unsigned char fwd_ref_flags )
409 sym_val_forward_ref_entry_type *fwd_ref_entry;
411 /* allocate an external definition entry */
413 fwd_ref_entry = (sym_val_forward_ref_entry_type *)
414 sem_allocate_node (sym_k_val_forward_ref_entry,
415 sym_k_val_forward_ref_entry_size);
417 /* fill in the entry */
419 _sar_save_source_pos (&fwd_ref_entry->header, az_value_frame);
421 switch (fwd_ref_flags)
423 case sym_k_patch_add:
424 fwd_ref_entry->az_name =
425 ((sym_value_entry_type *)
426 az_value_frame->value.az_symbol_entry)->obj_header.az_name;
428 case sym_k_patch_list_add:
429 fwd_ref_entry->az_name =
430 (sym_name_entry_type *)az_value_frame->value.az_symbol_entry;
433 _assert(FALSE, "Illegal forward reference");
436 fwd_ref_entry->a_update_location = (char *)a_location;
437 fwd_ref_entry->fwd_ref_flags = fwd_ref_flags;
439 /* place on the front of the chain */
441 fwd_ref_entry->az_next_ref = sym_az_val_forward_ref_chain;
442 sym_az_val_forward_ref_chain = fwd_ref_entry;
449 ** FUNCTIONAL DESCRIPTION:
451 ** This procedure recursively goes through the symbol table, dumping
452 ** each node accessible from the root node.
454 ** FORMAL PARAMETERS:
471 ** symbol table is dump with the debug output
477 UilDumpSymbolTable ( sym_entry_type *node_entry )
480 sym_value_entry_type *val_node;
481 sym_widget_entry_type *widget_node;
482 sym_module_entry_type *module_node;
483 sym_list_entry_type *list_node;
484 sym_obj_entry_type *list_entry;
485 sym_root_entry_type *root_node;
486 sym_include_file_entry_type *ifile_node;
487 sym_section_entry_type *section_node;
491 * No action on null node. Else dump and processing is based on the kind
492 * of the current node.
494 if ( node_entry == NULL ) return;
495 sym_dump_symbol (node_entry);
496 switch ( node_entry->header.b_tag )
498 case sym_k_value_entry:
499 val_node = (sym_value_entry_type *) node_entry;
500 UilDumpSymbolTable ((sym_entry_type *)val_node->az_charset_value);
501 UilDumpSymbolTable ((sym_entry_type *)val_node->az_first_table_value);
502 UilDumpSymbolTable ((sym_entry_type *)val_node->az_next_table_value);
503 UilDumpSymbolTable ((sym_entry_type *)val_node->az_exp_op1);
504 UilDumpSymbolTable ((sym_entry_type *)val_node->az_exp_op2);
506 case sym_k_widget_entry:
507 case sym_k_gadget_entry:
508 case sym_k_child_entry:
509 widget_node = (sym_widget_entry_type *) node_entry;
510 UilDumpSymbolTable ((sym_entry_type *)widget_node->az_callbacks);
511 UilDumpSymbolTable ((sym_entry_type *)widget_node->az_arguments);
512 UilDumpSymbolTable ((sym_entry_type *)widget_node->az_controls);
513 UilDumpSymbolTable ((sym_entry_type *)widget_node->az_create_proc);
515 case sym_k_module_entry:
516 module_node = (sym_module_entry_type *) node_entry;
517 UilDumpSymbolTable ((sym_entry_type *)module_node->az_version);
518 UilDumpSymbolTable ((sym_entry_type *)module_node->az_character_set);
519 UilDumpSymbolTable ((sym_entry_type *)module_node->az_case_sense);
520 UilDumpSymbolTable ((sym_entry_type *)module_node->az_def_obj);
522 case sym_k_list_entry:
524 * Sublists (nested lists) are not processed recursively to
525 * pick up definitions, since all named lists are picked up
526 * in their list sections. We assume no list of interest to
527 * us can possibly be encountered only in a nested list reference.
529 list_node = (sym_list_entry_type *) node_entry;
530 for (list_entry=(sym_obj_entry_type *)
531 list_node->obj_header.az_next;
533 list_entry=(sym_obj_entry_type *)
534 list_entry->obj_header.az_next)
535 UilDumpSymbolTable ((sym_entry_type *)list_entry);
537 case sym_k_root_entry:
538 root_node = (sym_root_entry_type *) node_entry;
539 UilDumpSymbolTable ((sym_entry_type *)root_node->module_hdr);
540 UilDumpSymbolTable ((sym_entry_type *)root_node->sections);
542 case sym_k_include_file_entry:
543 ifile_node = (sym_include_file_entry_type *) node_entry;
544 UilDumpSymbolTable ((sym_entry_type *)ifile_node->sections);
546 case sym_k_section_entry:
547 section_node = (sym_section_entry_type *) node_entry;
548 switch ( section_node->header.b_type )
550 case sym_k_section_tail:
553 UilDumpSymbolTable ((sym_entry_type *)section_node->next);
554 UilDumpSymbolTable ((sym_entry_type *)section_node->entries);
566 ** FUNCTIONAL DESCRIPTION:
568 ** This procedure dumps the symbol table.
570 ** FORMAL PARAMETERS:
587 ** symbol table is dump with the debug output
593 sym_dump_symbols( void )
597 sym_entry_type *cur_entry;
601 * Loop over all entries which have been allocated. They are in
602 * allocation order (this will include deleted entries).
604 _debug_output( "\nSymbol Table Dump: \n\n" );
605 for ( ndx=0 ; ndx<UrmPlistNum(sym_az_allocated_nodes) ; ndx++ )
607 cur_entry = (sym_entry_type *) UrmPlistPtrN (sym_az_allocated_nodes, ndx);
608 sym_dump_symbol (cur_entry);
610 _debug_output ("\n\n");
617 ** FUNCTIONAL DESCRIPTION:
619 ** This procedure dumps a symbol node.
621 ** FORMAL PARAMETERS:
623 ** az_symbol_entry symbol node to be dumped
638 ** symbol is dumped to the debug output
644 sym_dump_symbol (sym_entry_type *az_symbol_entry)
647 switch (az_symbol_entry->header.b_tag) {
649 case sym_k_name_entry:
650 sym_dump_name((sym_name_entry_type *) az_symbol_entry );
653 case sym_k_module_entry:
654 sym_dump_module((sym_module_entry_type *) az_symbol_entry );
657 case sym_k_value_entry:
658 sym_dump_value((sym_value_entry_type *) az_symbol_entry );
661 case sym_k_widget_entry:
662 case sym_k_gadget_entry:
663 case sym_k_child_entry:
664 sym_dump_widget((sym_widget_entry_type *) az_symbol_entry );
667 case sym_k_forward_ref_entry:
668 sym_dump_forward_ref((sym_forward_ref_entry_type *) az_symbol_entry );
671 case sym_k_external_def_entry:
672 sym_dump_external_def((sym_external_def_entry_type *) az_symbol_entry );
675 case sym_k_proc_def_entry:
676 sym_dump_proc_def((sym_proc_def_entry_type *) az_symbol_entry );
679 case sym_k_proc_ref_entry:
680 sym_dump_proc_ref((sym_proc_ref_entry_type *) az_symbol_entry );
683 case sym_k_control_entry:
684 sym_dump_control((sym_control_entry_type *) az_symbol_entry );
687 case sym_k_argument_entry:
688 sym_dump_argument((sym_argument_entry_type *) az_symbol_entry );
691 case sym_k_callback_entry:
692 sym_dump_callback((sym_callback_entry_type *) az_symbol_entry );
695 case sym_k_list_entry:
696 sym_dump_list((sym_list_entry_type *) az_symbol_entry );
699 case sym_k_color_item_entry:
700 sym_dump_color_item((sym_color_item_entry_type *) az_symbol_entry );
703 case sym_k_parent_list_entry:
704 sym_dump_parent_list_item((sym_parent_list_type *) az_symbol_entry );
707 case sym_k_include_file_entry:
708 sym_dump_include_file ((sym_include_file_entry_type *)az_symbol_entry);
711 case sym_k_section_entry:
712 sym_dump_section ((sym_section_entry_type *)az_symbol_entry);
715 case sym_k_def_obj_entry:
716 sym_dump_object_variant ((sym_def_obj_entry_type *)az_symbol_entry);
719 case sym_k_root_entry:
720 sym_dump_root_entry ((sym_root_entry_type *)az_symbol_entry);
728 _debug_output("%x unknown type: %d size: %d byte: %x\n",
730 az_symbol_entry->header.b_tag,
731 az_symbol_entry->header.w_node_size,
732 az_symbol_entry->header.b_type );
734 l_array = (int *) az_symbol_entry->b_value;
736 for (i=0; i<(int)(az_symbol_entry->header.w_node_size-1); i++)
737 _debug_output( "\t%x", l_array[ i ] );
744 sym_dump_source_info(( sym_entry_header_type *)az_symbol_entry);
752 ** FUNCTIONAL DESCRIPTION:
754 ** This function dumps an object entry in the symbol table
756 ** FORMAL PARAMETERS:
758 ** az_widget_entry pointer to the object
774 ** symbolic representation of the object appears as part of the
781 sym_dump_widget( XmConst sym_widget_entry_type *az_widget_entry )
784 sym_dump_obj_header ((sym_obj_entry_type *)az_widget_entry);
787 " %s %s controls: %x callbacks: %x arguments: %x parent_list: %x\n",
788 diag_object_text( az_widget_entry->header.b_type),
789 diag_tag_text( az_widget_entry->header.b_tag ),
790 az_widget_entry->az_controls,
791 az_widget_entry->az_callbacks,
792 az_widget_entry->az_arguments,
793 az_widget_entry->parent_list);
795 if (az_widget_entry->az_create_proc != NULL) {
796 _debug_output (" create proc: %x\n",
797 az_widget_entry->az_create_proc);
799 /* preserve comments */
800 _debug_output ("\n Comment: %s\n", az_widget_entry->obj_header.az_comment);
807 ** FUNCTIONAL DESCRIPTION:
809 ** This function dumps an argument entry in the symbol table
811 ** FORMAL PARAMETERS:
813 ** az_argument_entry pointer to the argument
829 ** symbolic representation of the name appears as part of the
836 sym_dump_argument( XmConst sym_argument_entry_type *az_argument_entry )
839 sym_dump_obj_header ((sym_obj_entry_type *)az_argument_entry);
841 _debug_output ( " arg name: %x arg value: %x\n",
842 az_argument_entry->az_arg_name,
843 az_argument_entry->az_arg_value );
850 ** FUNCTIONAL DESCRIPTION:
852 ** This function dumps a control entry in the symbol table
854 ** FORMAL PARAMETERS:
856 ** az_control_entry pointer to the control
872 ** symbolic representation of the name appears as part of the
879 sym_dump_control( XmConst sym_control_entry_type *az_control_entry )
882 sym_dump_obj_header ((sym_obj_entry_type *)az_control_entry);
884 /* These are for control objects only. */
886 if (az_control_entry->obj_header.b_flags & sym_m_def_in_progress) {
887 _debug_output (" def in progress");
890 if (az_control_entry->obj_header.b_flags & sym_m_managed) {
891 _debug_output (" managed");
893 _debug_output (" unmanaged");
896 _debug_output ( " obj: %x\n",
897 az_control_entry->az_con_obj );
904 ** FUNCTIONAL DESCRIPTION:
906 ** This function dumps a callback entry in the symbol table
908 ** FORMAL PARAMETERS:
910 ** az_callback_entry pointer to the callback
926 ** symbolic representation of the name appears as part of the
933 sym_dump_callback( XmConst sym_callback_entry_type *az_callback_entry )
936 sym_dump_obj_header ((sym_obj_entry_type *)az_callback_entry);
938 _debug_output ( " reason name: %x proc ref: %x proc ref list: %x\n",
939 az_callback_entry->az_call_reason_name,
940 az_callback_entry->az_call_proc_ref,
941 az_callback_entry->az_call_proc_ref_list );
948 ** FUNCTIONAL DESCRIPTION:
950 ** This function dumps a list entry in the symbol table
952 ** FORMAL PARAMETERS:
954 ** az_list_entry pointer to the list
970 ** symbolic representation of the name appears as part of the
977 sym_dump_list( XmConst sym_list_entry_type *az_list_entry )
980 sym_dump_obj_header ((sym_obj_entry_type *)az_list_entry);
982 _debug_output ( " type: %s count: %d gadget count: %d\n",
983 diag_tag_text( az_list_entry->header.b_type),
984 az_list_entry->w_count,
985 az_list_entry->w_gadget_count );
987 /* preserve comments */
988 _debug_output ("\n Comment: %s\n", az_list_entry->obj_header.az_comment);
995 ** FUNCTIONAL DESCRIPTION:
997 ** This function dumps a name entry in the symbol table
999 ** FORMAL PARAMETERS:
1001 ** az_name_entry pointer to the name
1007 ** IMPLICIT OUTPUTS:
1017 ** symbolic representation of the name appears as part of the
1024 sym_dump_name( XmConst sym_name_entry_type *az_name_entry )
1028 ( "%x name size: %d next name: %x object: %x",
1030 az_name_entry->header.w_node_size,
1031 az_name_entry->az_next_name_entry,
1032 az_name_entry->az_object );
1034 if (az_name_entry->b_flags & sym_m_referenced) {
1035 _debug_output (" referenced");
1039 ( " name: %s \n", az_name_entry->c_text );
1046 ** FUNCTIONAL DESCRIPTION:
1048 ** This function dumps a module entry in the symbol table
1050 ** FORMAL PARAMETERS:
1052 ** az_module_entry pointer to the module
1058 ** IMPLICIT OUTPUTS:
1068 ** symbolic representation of the module appears as part of the
1075 sym_dump_module( XmConst sym_module_entry_type *az_module_entry )
1079 ( "%x module size: %d name: %x version: %x \n",
1081 az_module_entry->header.w_node_size,
1082 az_module_entry->obj_header.az_name,
1083 az_module_entry->az_version );
1085 /* preserve comments */
1086 _debug_output ("\n Comment: %s\n", az_module_entry->obj_header.az_comment);
1093 ** FUNCTIONAL DESCRIPTION:
1095 ** This function dumps a color item entry in the symbol table
1097 ** FORMAL PARAMETERS:
1099 ** az_color_item_entry pointer to the color_item
1105 ** IMPLICIT OUTPUTS:
1115 ** symbolic representation of the color item appears as part of the
1122 sym_dump_color_item( XmConst sym_color_item_entry_type *az_color_item_entry )
1126 ( "%x color_item size: %d letter: %c index: %d color: %x next: %x\n",
1127 az_color_item_entry,
1128 az_color_item_entry->header.w_node_size,
1129 az_color_item_entry->b_letter,
1130 az_color_item_entry->b_index,
1131 az_color_item_entry->az_color,
1132 az_color_item_entry->az_next );
1138 ** FUNCTIONAL DESCRIPTION:
1140 ** This function dumps a parent_list entry in the symbol table
1142 ** FORMAL PARAMETERS:
1144 ** az_parent_list_item pointer to the parent list entry
1150 ** IMPLICIT OUTPUTS:
1166 sym_dump_parent_list_item ( XmConst sym_parent_list_type *az_parent_list_item )
1169 ( "%x parent_list size: %d parent: %x next: %x \n",
1170 az_parent_list_item,
1171 az_parent_list_item->header.w_node_size,
1172 az_parent_list_item->parent,
1173 az_parent_list_item->next);
1179 ** FUNCTIONAL DESCRIPTION:
1181 ** This function dumps an external definition entry in the symbol table
1183 ** FORMAL PARAMETERS:
1185 ** az_external_def_entry pointer to the external definition
1191 ** IMPLICIT OUTPUTS:
1201 ** symbolic representation of the name appears as part of the
1208 sym_dump_external_def(
1209 XmConst sym_external_def_entry_type *az_external_def_entry)
1213 ( "%x external def size: %d next external: %x object: %x \n",
1214 az_external_def_entry,
1215 az_external_def_entry->header.w_node_size,
1216 az_external_def_entry->az_next_object,
1217 az_external_def_entry->az_name );
1224 ** FUNCTIONAL DESCRIPTION:
1226 ** This function dumps a procedure definition entry in the symbol table
1228 ** FORMAL PARAMETERS:
1230 ** az_proc_def_entry pointer to the procedure definition
1236 ** IMPLICIT OUTPUTS:
1246 ** symbolic representation of the procedure definition appears as
1247 ** part of the debug output
1253 sym_dump_proc_def( XmConst sym_proc_def_entry_type *az_proc_def_entry )
1257 char *imported_flag;
1258 char *exported_flag;
1259 char *checking_flag;
1264 checking_flag = " no-check";
1266 if (az_proc_def_entry->v_arg_checking)
1267 checking_flag = " check";
1268 if (az_proc_def_entry->obj_header.b_flags & sym_m_private)
1269 private_flag = " private";
1270 if (az_proc_def_entry->obj_header.b_flags & sym_m_exported)
1271 exported_flag = " exported";
1272 if (az_proc_def_entry->obj_header.b_flags & sym_m_imported)
1273 imported_flag = " imported";
1276 ( "%x proc def size: %d name: %x %s%s%s%s count: %d %s\n",
1278 az_proc_def_entry->header.w_node_size,
1279 az_proc_def_entry->obj_header.az_name,
1284 az_proc_def_entry->b_arg_count,
1285 diag_value_text( az_proc_def_entry->b_arg_type ) );
1287 /* preserve comments */
1288 _debug_output ("\nComment: %s\n",az_proc_def_entry->obj_header.az_comment);
1296 ** FUNCTIONAL DESCRIPTION:
1298 ** This function dumps a procedure reference entry in the symbol table
1300 ** FORMAL PARAMETERS:
1302 ** az_proc_ref_entry pointer to the procedure reference entry
1308 ** IMPLICIT OUTPUTS:
1318 ** symbolic representation of the procedure reference appears as
1319 ** part of the debug output
1325 sym_dump_proc_ref( XmConst sym_proc_ref_entry_type *az_proc_ref_entry )
1328 sym_dump_obj_header ((sym_obj_entry_type *)az_proc_ref_entry);
1331 ( "%x proc ref size: %d proc def: %x value: %x\n",
1333 az_proc_ref_entry->header.w_node_size,
1334 az_proc_ref_entry->az_proc_def,
1335 az_proc_ref_entry->az_arg_value );
1342 ** FUNCTIONAL DESCRIPTION:
1344 ** This function dumps an forward reference entry in the symbol table
1346 ** FORMAL PARAMETERS:
1348 ** az_forward_ref_entry pointer to the forward reference
1354 ** IMPLICIT OUTPUTS:
1364 ** symbolic representation of the name appears as part of the
1371 sym_dump_forward_ref(XmConst sym_forward_ref_entry_type *az_forward_ref_entry)
1375 ( "%x forward ref size: %d next ref: %x location: %x %s parent: %x\n",
1376 az_forward_ref_entry,
1377 az_forward_ref_entry->header.w_node_size,
1378 az_forward_ref_entry->az_next_ref,
1379 az_forward_ref_entry->a_update_location,
1380 diag_object_text( az_forward_ref_entry->header.b_type ),
1381 az_forward_ref_entry->parent );
1385 az_forward_ref_entry->az_name,
1386 az_forward_ref_entry->az_name->c_text );
1393 ** FUNCTIONAL DESCRIPTION:
1395 ** This function dumps a value entry in the symbol table
1397 ** FORMAL PARAMETERS:
1399 ** az_value_entry pointer to the value
1405 ** IMPLICIT OUTPUTS:
1415 ** symbolic representation of the value appears as part of the
1422 sym_dump_value( XmConst sym_value_entry_type *az_value_entry )
1426 char *imported_flag;
1427 char *exported_flag;
1429 char *special_type, *table_type;
1436 if (az_value_entry->obj_header.b_flags & sym_m_builtin)
1437 builtin_flag = " builtin";
1438 if (az_value_entry->obj_header.b_flags & sym_m_private)
1439 private_flag = " private";
1440 if (az_value_entry->obj_header.b_flags & sym_m_exported)
1441 exported_flag = " exported";
1442 if (az_value_entry->obj_header.b_flags & sym_m_imported)
1443 imported_flag = " imported";
1446 ( "%x value size: %d name: %x %s%s%s%s",
1448 az_value_entry->header.w_node_size,
1449 az_value_entry->obj_header.az_name,
1450 builtin_flag, private_flag, exported_flag, imported_flag );
1452 if (az_value_entry->obj_header.b_flags & sym_m_imported)
1454 _debug_output( " %s \n", diag_value_text( az_value_entry->b_type ));
1458 switch (az_value_entry->b_type)
1460 case sym_k_integer_value:
1461 case sym_k_horizontal_integer_value:
1462 case sym_k_vertical_integer_value:
1463 _debug_output(" integer: %d \n",
1464 az_value_entry->value.l_integer );
1467 case sym_k_bool_value:
1468 _debug_output(" boolean: %d \n",
1469 az_value_entry->value.l_integer );
1472 case sym_k_float_value:
1473 case sym_k_horizontal_float_value:
1474 case sym_k_vertical_float_value:
1475 _debug_output(" double: %g \n",
1476 az_value_entry->value.d_real);
1479 case sym_k_color_value:
1483 switch (az_value_entry->b_arg_type)
1485 case sym_k_background_color:
1488 case sym_k_foreground_color:
1491 case sym_k_unspecified_color:
1492 ptr = "unspecified";
1498 _debug_output(" color type: %s", ptr );
1500 output_text( az_value_entry->w_length,
1501 az_value_entry->value.c_value);
1506 case sym_k_reason_value:
1507 special_type = "reason";
1508 goto common_special_type;
1510 case sym_k_argument_value:
1511 special_type = "argument";
1513 common_special_type:
1515 _debug_output(" %s", special_type );
1517 if (az_value_entry->obj_header.b_flags & sym_m_builtin)
1518 _debug_output(" code: %d \n", az_value_entry->value.l_integer );
1520 output_text( az_value_entry->w_length,
1521 az_value_entry->value.c_value);
1525 case sym_k_compound_string_value:
1526 _debug_output(" compound string\n first component: %x\n",
1527 az_value_entry->az_first_table_value );
1529 if ( (az_value_entry->b_aux_flags & sym_m_table_entry) != 0 ) {
1530 _debug_output(" next table entry: %x",
1531 az_value_entry->az_next_table_value);
1537 case sym_k_font_value:
1538 case sym_k_fontset_value:
1539 if (az_value_entry->b_charset != sym_k_userdefined_charset)
1540 _debug_output(" font charset: %s",
1541 diag_charset_text( az_value_entry->b_charset ) );
1543 _debug_output(" font charset: userdefined(%x)",
1544 diag_charset_text( (long)az_value_entry->az_charset_value ) );
1546 goto check_for_table_value;
1549 case sym_k_char_8_value:
1550 case sym_k_localized_string_value:
1551 if (az_value_entry->b_charset != sym_k_userdefined_charset)
1552 switch ( az_value_entry->b_direction )
1554 case XmSTRING_DIRECTION_L_TO_R:
1556 (" string length: %d\n charset: %s L_TO_R",
1557 az_value_entry->w_length,
1559 az_value_entry->b_charset ));
1561 case XmSTRING_DIRECTION_R_TO_L:
1563 (" string length: %d\n charset: %s R_TO_L",
1564 az_value_entry->w_length,
1566 az_value_entry->b_charset ));
1570 switch ( az_value_entry->b_direction )
1572 case XmSTRING_DIRECTION_L_TO_R:
1574 (" string length: %d\n charset: userdefined(%x) L_TO_R",
1575 az_value_entry->w_length,
1576 az_value_entry->az_charset_value);
1578 case XmSTRING_DIRECTION_R_TO_L:
1580 (" string length: %d\n charset: userdefined(%x) R_TO_L",
1581 az_value_entry->w_length,
1582 az_value_entry->az_charset_value);
1586 /* See if this is an entry in a table. */
1587 check_for_table_value:
1589 if ( (az_value_entry->b_aux_flags & sym_m_table_entry) != 0 ) {
1590 _debug_output(" next table entry: %x",
1591 az_value_entry->az_next_table_value);
1595 ( az_value_entry->w_length, az_value_entry->value.c_value );
1599 case sym_k_identifier_value:
1600 _debug_output(" identifier: %s", az_value_entry->value.c_value );
1604 case sym_k_icon_value:
1605 _debug_output(" icon width: %d height: %d colors: %x rows: %x \n",
1606 az_value_entry->value.z_icon->w_width,
1607 az_value_entry->value.z_icon->w_height,
1608 az_value_entry->value.z_icon->az_color_table,
1609 az_value_entry->value.z_icon->az_rows );
1613 case sym_k_string_table_value:
1614 table_type = "string table";
1617 case sym_k_font_table_value:
1618 table_type = "font table";
1621 case sym_k_trans_table_value:
1622 table_type = "translation table";
1626 _debug_output(" %s first table entry: %x\n",
1627 table_type, az_value_entry->az_first_table_value);
1631 case sym_k_color_table_value:
1635 _debug_output(" color_table count: %d max_index: %d \n",
1636 az_value_entry->b_table_count,
1637 az_value_entry->b_max_index );
1639 for (index = 0; index < (int)az_value_entry->b_table_count; index++)
1642 _debug_output( " letter: %c index: %d color: %x\n",
1643 az_value_entry->value.z_color[index].b_letter,
1644 az_value_entry->value.z_color[index].b_index,
1645 az_value_entry->value.z_color[index].az_color );
1651 case sym_k_error_value:
1652 _debug_output(" error \n");
1657 _debug_output(" unknown type: %d \n", az_value_entry->b_type );
1660 /* preserve comments */
1661 _debug_output ("\nComment: %s\n",az_value_entry->obj_header.az_comment);
1669 ** FUNCTIONAL DESCRIPTION:
1671 ** This function will output an arbitrarily long amount of text
1672 ** with the debug output.
1674 ** FORMAL PARAMETERS:
1676 ** length length of the text
1677 ** text pointer to the text
1683 ** IMPLICIT OUTPUTS:
1693 ** text is placed in the debug output
1699 output_text(XmConst int length, XmConst char *text)
1702 char c_buffer[ 71 ];
1703 XmConst char *c_ptr;
1708 _debug_output( "\n" );
1720 last = ( l_length > 70)? 70: l_length;
1722 _move( c_buffer, c_ptr, last );
1724 for (i=0; i<last; i++)
1726 if (iscntrl( c_buffer[ i ] ))
1727 c_buffer[ i ] = '.';
1730 c_buffer[ last ] = 0;
1731 _debug_output( " \"%s\"\n", c_buffer );
1738 ** FUNCTIONAL DESCRIPTION:
1740 ** This procedure dumps the source information in the header of symbol
1743 ** FORMAL PARAMETERS:
1749 ** IMPLICIT OUTPUTS:
1758 sym_dump_source_info (sym_entry_header_type *hdr)
1760 src_source_record_type *src_rec;
1762 src_rec = hdr->az_src_rec;
1764 if (src_rec != NULL)
1765 _debug_output (" Source position: file %d, line %d, columns %d through %d\n",
1766 src_rec->b_file_number,
1767 src_rec->w_line_number,
1771 _debug_output (" Src source record not present.\n");
1778 ** FUNCTIONAL DESCRIPTION:
1780 ** This procedure dumps the common header of "object" entries.
1782 ** FORMAL PARAMETERS:
1788 ** IMPLICIT OUTPUTS:
1798 sym_dump_obj_header (XmConst sym_obj_entry_type *az_obj_entry)
1802 ( "%x %s size: %d \n",
1804 diag_tag_text (az_obj_entry->header.b_tag),
1805 az_obj_entry->header.w_node_size);
1807 if (az_obj_entry->obj_header.az_name != NULL) {
1808 _debug_output (" name: %x", az_obj_entry->obj_header.az_name);
1811 if (az_obj_entry->obj_header.az_reference != NULL) {
1812 _debug_output (" reference: %x",
1813 az_obj_entry->obj_header.az_reference);
1816 if (az_obj_entry->obj_header.az_next != NULL) {
1817 _debug_output (" next: %x", az_obj_entry->obj_header.az_next);
1820 if (az_obj_entry->obj_header.b_flags & sym_m_private) {
1821 _debug_output (" private");
1824 if (az_obj_entry->obj_header.b_flags & sym_m_exported) {
1825 _debug_output (" exported");
1828 if (az_obj_entry->obj_header.b_flags & sym_m_imported) {
1829 _debug_output (" imported");
1832 _debug_output ("\n");
1838 sym_dump_include_file ( sym_include_file_entry_type *az_symbol_entry )
1841 _debug_output ("%x include file file name: %s full file name: %s\n",
1843 az_symbol_entry->file_name, az_symbol_entry->full_file_name);
1850 sym_dump_section ( sym_section_entry_type *az_symbol_entry )
1852 _debug_output ("%x %s section prev section : %x next section: %x entries: %x\n",
1854 sym_section_text(az_symbol_entry->header.b_type),
1855 az_symbol_entry->prev_section, az_symbol_entry->next,
1856 az_symbol_entry->entries);
1863 sym_dump_object_variant ( sym_def_obj_entry_type * az_symbol_entry )
1865 _debug_output ("%x default obj var next: %x object info: %d, variant_info: %d\n",
1867 az_symbol_entry->next, az_symbol_entry->b_object_info,
1868 az_symbol_entry->b_variant_info);
1874 sym_dump_root_entry ( sym_root_entry_type *az_symbol_entry )
1876 _debug_output ( "%x root tag: %d module: %x sections: %x\n module tail: ",
1878 az_symbol_entry->header.b_tag,
1879 az_symbol_entry->module_hdr,
1880 az_symbol_entry->sections);
1886 sym_section_text (int b_type)
1892 case sym_k_list_section:
1894 case sym_k_procedure_section:
1896 case sym_k_value_section:
1898 case sym_k_identifier_section:
1899 return "identifier";
1900 case sym_k_object_section:
1902 case sym_k_include_section:
1904 case sym_k_section_tail: