Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 #ifndef __CIF_C_H 00037 #define __CIF_C_H 00038 #ifdef __cplusplus 00039 extern "C" { 00040 #endif 00041 00042 00043 00044 /* 00045 * Type used for all fields of CIF records 00046 */ 00047 typedef unsigned int CIF_field; 00048 00049 #ifndef __inttypes_INCLUDED 00050 typedef unsigned int uint32_t; 00051 #endif /* __inttypes_INCLUDED */ 00052 00053 00054 /* 00055 * Identification for a Mongoose-generated CIF file 00056 */ 00057 #define CIF_MAGIC_STRING "CIF" 00058 00059 00060 /* 00061 * Version number for Mongoose-generated CIF for C/C++ 00062 */ 00063 #define CIF_C_VERSION 1U 00064 00065 00066 /* 00067 * Langugages supported in Mongoose-generated CIF 00068 */ 00069 #define CIF_LANGUAGE_c 1U 00070 #define CIF_LANGUAGE_cplusplus 2U 00071 00072 00073 /* 00074 * CIF record tags for C/C++ 00075 */ 00076 #define CIF_TAG_pu_def 1U 00077 #define CIF_TAG_object 2U 00078 #define CIF_TAG_basic_type 3U 00079 #define CIF_TAG_one_kid_type 4U 00080 #define CIF_TAG_two_kids_type 5U 00081 #define CIF_TAG_n_kids_type 6U 00082 #define CIF_TAG_enum_constant 7U 00083 #define CIF_TAG_source_file 8U 00084 #define CIF_TAG_macro 9U 00085 #define CIF_TAG_namespace 10U 00086 #define CIF_TAG_function 11U 00087 00088 00089 /* 00090 * CIF object kinds 00091 */ 00092 #define CIF_OBJECT_variable 1U 00093 #define CIF_OBJECT_parameter 2U 00094 #define CIF_OBJECT_data_member 3U 00095 00096 00097 /* 00098 * CIF access kinds 00099 */ 00100 #define CIF_ACCESS_public 1U 00101 #define CIF_ACCESS_private 2U 00102 #define CIF_ACCESS_protected 3U 00103 00104 00105 /* 00106 * Basic type kinds 00107 */ 00108 #define CIF_BASIC_TYPE_void 1U 00109 #define CIF_BASIC_TYPE_bool 2U 00110 #define CIF_BASIC_TYPE_wchar_t 3U 00111 #define CIF_BASIC_TYPE_char 4U 00112 #define CIF_BASIC_TYPE_int 5U 00113 #define CIF_BASIC_TYPE_float 6U 00114 #define CIF_BASIC_TYPE_double 7U 00115 00116 00117 /* 00118 * One-kid type kinds 00119 */ 00120 #define CIF_ONE_KID_TYPE_pointer 1U 00121 #define CIF_ONE_KID_TYPE_reference 2U 00122 #define CIF_ONE_KID_TYPE_qualified 3U 00123 00124 00125 /* 00126 * Two-kid type kinds 00127 */ 00128 #define CIF_TWO_KIDS_TYPE_array 1U 00129 #define CIF_TWO_KIDS_TYPE_ptr_to_mbr 2U 00130 #define CIF_TWO_KIDS_TYPE_typedef 3U 00131 00132 00133 /* 00134 * N-kid type kinds 00135 */ 00136 #define CIF_N_KIDS_TYPE_class 1U 00137 #define CIF_N_KIDS_TYPE_struct 2U 00138 #define CIF_N_KIDS_TYPE_union 3U 00139 #define CIF_N_KIDS_TYPE_enum 4U 00140 #define CIF_N_KIDS_TYPE_function 5U 00141 00142 00143 /* 00144 * CIF kid kinds 00145 */ 00146 #define CIF_KID_base_class 1U 00147 #define CIF_KID_member_variable 2U 00148 #define CIF_KID_member_function 3U 00149 #define CIF_KID_member_type 4U 00150 #define CIF_KID_friend_class 5U 00151 #define CIF_KID_friend_function 6U 00152 #define CIF_KID_enum_constant 7U 00153 #define CIF_KID_nested_namespace 8U 00154 #define CIF_KID_return_type 9U 00155 #define CIF_KID_parameter_type 10U 00156 #define CIF_KID_exception_type 11U 00157 00158 00159 /* 00160 * CIF usage codes 00161 * Extreme caution should be exercised when changing these; 00162 * they depend on symbol reference kinds generated in the front end. 00163 */ 00164 #define CIF_USAGE_CODE_declaration 0x1U 00165 #define CIF_USAGE_CODE_definition 0x2U 00166 #define CIF_USAGE_CODE_reference 0x4U 00167 #define CIF_USAGE_CODE_use 0x8U 00168 #define CIF_USAGE_CODE_modification 0x10U 00169 #define CIF_USAGE_CODE_address_taken 0x20U 00170 #define CIF_USAGE_CODE_error 0x40U 00171 #define CIF_USAGE_CODE_implicit 0x80U 00172 00173 00174 /* 00175 * CIF_file_header is always the first record in a CIF file 00176 */ 00177 typedef struct CIF_file_header { 00178 00179 CIF_field magic_number; /* magic number for identifying CIFs */ 00180 CIF_field cif_version; /* version number for CIF format */ 00181 CIF_field language; /* language in the primary source file */ 00182 CIF_field cif_level; /* level of detail in CIF information */ 00183 00184 CIF_field comp_dir_offset; /* directory where compilation was done */ 00185 CIF_field cmd_line_offset; /* command line used to compile */ 00186 00187 CIF_field num_pu_defs; /* number of function definitions */ 00188 CIF_field pu_def_offset; /* offset of the first func. def. scope */ 00189 00190 CIF_field num_src_files; /* number of source files */ 00191 CIF_field src_file_list; /* offset of the source file list */ 00192 00193 CIF_field num_macros; /* number of macro records */ 00194 CIF_field macro_offset; /* offset of the first macro record */ 00195 00196 CIF_field num_namespaces; /* number of namespace records */ 00197 CIF_field namespace_offset; /* offset of the first namespace */ 00198 00199 CIF_field num_nonlocal_vars; /* number of non-local variables */ 00200 CIF_field nonlocal_var_offset; /* offset of the first non-local var */ 00201 00202 CIF_field num_nonlocal_types; /* number of non-local types */ 00203 CIF_field nonlocal_type_offset;/* offset of the first non-local type */ 00204 00205 CIF_field num_unnamed_types; /* number of unnamed types */ 00206 CIF_field unnamed_type_offset; /* offset of the first unnamed type */ 00207 00208 CIF_field num_functions; /* number of function records */ 00209 CIF_field function_offset; /* offset of the first function */ 00210 00211 CIF_field hash_table_size; 00212 CIF_field hash_table_offset; 00213 00214 CIF_field hash_chain_size; 00215 CIF_field hash_chain_offset; 00216 00217 CIF_field id_map_size; /* size of the CIF_index_entry array */ 00218 CIF_field id_map_offset; /* offset of the CIF_index_entry array */ 00219 00220 CIF_field string_table_size; 00221 CIF_field string_table_offset; 00222 00223 } CIF_file_header; 00224 00225 00226 00227 /* 00228 * CIF record used for function definitions 00229 */ 00230 typedef struct CIF_pu_def { 00231 CIF_field cif_tag:8; /* record tag = CIF_TAG_pu_def */ 00232 CIF_field cif_id:24; /* CIF id for the program unit */ 00233 CIF_field start_file_index:16; /* */ 00234 CIF_field start_column:16; /* First source position */ 00235 CIF_field start_line_num:32; /* */ 00236 CIF_field end_file_index:16; /* */ 00237 CIF_field end_column:16; /* Last source position */ 00238 CIF_field end_line_num:32; /* */ 00239 CIF_field num_callees:32; /* number of callees */ 00240 } CIF_pu_def; 00241 00242 00243 /* 00244 * CIF record used for variables, parameters, and data members (fields) 00245 */ 00246 typedef struct CIF_object { 00247 CIF_field cif_tag:8; /* record tag = CIF_TAG_object */ 00248 CIF_field cif_id:24; /* CIF ID for this var/param/field */ 00249 CIF_field parent_id:24; /* CIF ID of the parent */ 00250 CIF_field object_kind:2; /* variable, parameter, data_member*/ 00251 CIF_field access_kind:2; /* public, private, protected */ 00252 CIF_field is_extern:1; 00253 CIF_field is_static:1; 00254 CIF_field is_auto:1; 00255 CIF_field is_bitfield:1; /* can be set only for fields */ 00256 CIF_field type_id:32; 00257 CIF_field num_usages:32; 00258 } CIF_object; 00259 00260 00261 /* 00262 * CIF record used for representing basic types. 00263 */ 00264 typedef struct CIF_basic_type { 00265 CIF_field cif_tag:8; /* record tag = CIF_TAG_basic_type */ 00266 CIF_field cif_id:24; /* CIF ID for the type */ 00267 CIF_field size:16; /* size in bytes for this type */ 00268 CIF_field type_kind:8; /* what kind of type is this */ 00269 CIF_field is_short:1; 00270 CIF_field is_long:1; 00271 CIF_field is_longlong:1; 00272 CIF_field is_signed:1; /* explicitly */ 00273 CIF_field is_unsigned:1; /* explicitly */ 00274 CIF_field align_dummy:3; 00275 } CIF_basic_type; 00276 00277 00278 /* 00279 * CIF record for types that have one child type 00280 */ 00281 typedef struct CIF_one_kid_type { 00282 CIF_field cif_tag:8; /* record tag = CIF_TAG_one_kid_type */ 00283 CIF_field cif_id:24; /* CIF ID for the type */ 00284 CIF_field size:32; /* size of the type in bytes */ 00285 CIF_field base_type:24; /* CIF IF of the base type */ 00286 CIF_field type_kind:2; /* pointer/reference/qualified */ 00287 CIF_field is_const:1; 00288 CIF_field is_volatile:1; 00289 CIF_field is_restrict:1; 00290 CIF_field align_dummy:3; 00291 } CIF_one_kid_type; 00292 00293 00294 /* 00295 * CIF record for types that have two children 00296 */ 00297 typedef struct CIF_two_kids_type { 00298 CIF_field cif_tag:8; /* record tag = CIF_TAG_two_kids_type */ 00299 CIF_field cif_id:24; /* CIF ID for the type */ 00300 CIF_field size:32; /* size of the type in bytes */ 00301 CIF_field base_type:24; /* CIF ID of the base type */ 00302 CIF_field type_kind:8; /* array/ptr_to_member/typedef */ 00303 union { 00304 CIF_field num_elems:32; /* array: number of elements */ 00305 CIF_field class_id:32; /* ptr_to_mbr: class cif_id */ 00306 CIF_field parent_id:32; /* typedef: parent cif_id */ 00307 } other_kid; 00308 CIF_field num_usages:32; /* number of uses for this type */ 00309 } CIF_two_kids_type; 00310 00311 00312 /* 00313 * CIF record for aggregate types with variable number of children 00314 */ 00315 typedef struct CIF_n_kids_type { 00316 CIF_field cif_tag:8; /* record tag = CIF_TAG_n_kids_type */ 00317 CIF_field cif_id:24; /* CIF ID for the type */ 00318 CIF_field parent_id:24; /* CIF ID for the parent entity */ 00319 CIF_field type_kind:8; /* class/struct/union/enum/func */ 00320 CIF_field size:32; /* size in bytes for this type */ 00321 CIF_field num_kids:32; /* number of kids for the type */ 00322 CIF_field num_usages:32; /* number of uses for this type */ 00323 } CIF_n_kids_type; 00324 00325 00326 /* 00327 * CIF record for enumerator constants 00328 */ 00329 typedef struct CIF_enum_constant { 00330 CIF_field cif_tag:8; /* record tag = CIF_TAG_enum_constant */ 00331 CIF_field cif_id:24; /* CIF ID for this enumerator */ 00332 CIF_field parent_id:32; /* CIF ID for the enum type */ 00333 CIF_field value:32; /* integer value of the constant */ 00334 CIF_field num_usages:32; /* number of usages for this enum */ 00335 } CIF_enum_constant; 00336 00337 00338 /* 00339 * CIF record for representing source files 00340 */ 00341 typedef struct CIF_source_file { 00342 CIF_field cif_tag:8; /* record tag = CIF_TAG_source_file */ 00343 CIF_field cif_id:24; /* CIF ID for the source file */ 00344 CIF_field parent_index:30; /* parent file ID (0 if none) */ 00345 CIF_field is_include:1; /* is it an included file */ 00346 CIF_field is_sys_include:1; /* included by <file.h> notation */ 00347 CIF_field include_line:32; /* #include location (0 if none) */ 00348 CIF_field name_offset:32; /* StrTable offset of file name */ 00349 } CIF_source_file; 00350 00351 00352 /* 00353 * CIF record for representing macros 00354 */ 00355 typedef struct CIF_macro { 00356 CIF_field cif_tag:8; /* record tag = CIF_TAG_macro */ 00357 CIF_field cif_id:24; /* CIF ID of this macro */ 00358 CIF_field num_usages:32; /* number of uses for this macro */ 00359 } CIF_macro; 00360 00361 00362 /* 00363 * CIF record for representing namespaces 00364 */ 00365 typedef struct CIF_namespace { 00366 CIF_field cif_tag:8; /* record tag = CIF_TAG_namespace */ 00367 CIF_field cif_id:24; /* CIF ID of this namespace */ 00368 CIF_field parent_id:24; /* CIF ID of the parent */ 00369 CIF_field is_alias:8; /* is this a namespace alias */ 00370 union { /* if is_alias */ 00371 CIF_field alias_of:32; /* CIF ID of assoc_namespace */ 00372 CIF_field num_kids:32; /* else */ 00373 } extra_info; /* number of kids */ 00374 CIF_field num_usages:32; /* number of uses for namespace */ 00375 } CIF_namespace; 00376 00377 00378 /* 00379 * CIF record for representing functions (defined and/or declared) 00380 */ 00381 typedef struct CIF_function { 00382 CIF_field cif_tag:8; /* record tag = CIF_TAG_function */ 00383 CIF_field cif_id:24; /* CIF ID for this function */ 00384 CIF_field parent_id:24; /* CIF ID of the parent */ 00385 CIF_field access_kind:2; /* public, private, protected */ 00386 CIF_field func_flags:6; /* Flags to be filled later */ 00387 CIF_field type_id:24; /* CIF ID for function type */ 00388 CIF_field is_defined:1; 00389 CIF_field is_extern:1; 00390 CIF_field is_static:1; 00391 CIF_field is_inline:1; 00392 CIF_field is_virtual:1; 00393 CIF_field is_operator:1; 00394 CIF_field is_constructor:1; 00395 CIF_field is_destructor:1; 00396 CIF_field pu_def_offset:32; /* Offset of CIF_pu_def record */ 00397 CIF_field num_usages:32; /* Number of func_usages */ 00398 } CIF_function; 00399 00400 00401 /* 00402 * CIF record for representing a generic child of another CIF record 00403 */ 00404 typedef struct CIF_kid { 00405 CIF_field kid_kind:4; 00406 CIF_field access_kind:2; 00407 CIF_field is_virtual:1; 00408 CIF_field is_static:1; 00409 CIF_field cif_id:24; 00410 } CIF_kid; 00411 00412 00413 /* 00414 * CIF record for representing usage information (except for functions) 00415 */ 00416 typedef struct CIF_usage { 00417 CIF_field file_index:16; 00418 CIF_field column_number:16; 00419 CIF_field line_number:24; 00420 CIF_field usage_code:8; 00421 } CIF_usage; 00422 00423 00424 /* 00425 * CIF record for representing function usage information 00426 */ 00427 typedef struct CIF_func_usage { 00428 CIF_field caller_id; 00429 CIF_field file_index:16; 00430 CIF_field column_number:16; 00431 CIF_field line_number:24; 00432 CIF_field usage_code:8; 00433 } CIF_func_usage; 00434 00435 00436 /* 00437 * An entry in the ID map, which for each CIF ID contains 00438 * the file offset of the corresponding record and 00439 * the string table offset of the corresponding name 00440 */ 00441 typedef struct CIF_index_entry { 00442 CIF_field cif_tag:5; /* Tag for identifying CIF record */ 00443 CIF_field name_offset:27; /* String table offset of the name */ 00444 CIF_field record_offset:32; /* File offset of the CIF record */ 00445 } CIF_index_entry; 00446 00447 00448 /* 00449 * Each entry in the hash table contains the CIF ID of a 00450 * syntactic element, the string table offset for its name, 00451 * and a link to the next entry in the same hash chain. 00452 * Currently, cif_tag is not set! 00453 */ 00454 typedef struct CIF_hash_entry { 00455 CIF_field cif_tag:8; /* Tag for identifying CIF record */ 00456 CIF_field cif_id:24; /* Index into Cif_Id_Map */ 00457 CIF_field next_in_chain:32; /* Index of the next hash-table */ 00458 /* entry in the same chain */ 00459 } CIF_hash_entry; 00460 00461 00462 /* 00463 * Generic CIF record that is a subset of all other records 00464 */ 00465 typedef struct CIF_generic { 00466 CIF_field cif_tag:8; 00467 CIF_field cif_id:24; 00468 } CIF_generic; 00469 00470 00471 typedef CIF_field CIF_id; /* Wrapper type for CIF IDs */ 00472 typedef CIF_field CIF_tag; /* Wrapper type for CIF tags */ 00473 typedef CIF_field CIF_offset; /* Wrapper type for CIF offsets */ 00474 typedef CIF_field CIF_kid_kind; /* Wrapper type for kid kind */ 00475 typedef CIF_field CIF_type_kind; /* Wrapper type for type kind */ 00476 typedef CIF_field CIF_object_kind; /* Wrapper type for object kind */ 00477 typedef CIF_field CIF_access_kind; /* Wrapper type for access kind */ 00478 typedef CIF_field CIF_usage_code; /* Wrapper type for usage codes */ 00479 00480 00481 /*************************************************** 00482 * Macros for accessing fields of CIF records * 00483 ***************************************************/ 00484 00485 /* CIF_file_header*/ 00486 #define CIF_LANGUAGE(hdr) ((hdr)->language) 00487 00488 #define CIF_NUM_PU_DEFS(hdr) ((hdr)->num_pu_defs) 00489 #define CIF_PU_DEF_LIST(hdr) ((hdr)->pu_def_offset) 00490 00491 #define CIF_NUM_SRC_FILES(hdr) ((hdr)->num_src_files) 00492 #define CIF_SRC_FILE_LIST(hdr) ((hdr)->src_file_list) 00493 00494 #define CIF_NUM_MACROS(hdr) ((hdr)->num_macros) 00495 #define CIF_MACRO_LIST(hdr) ((hdr)->macro_offset) 00496 00497 #define CIF_NUM_NAMESPACES(hdr) ((hdr)->num_namespaces) 00498 #define CIF_NAMESPACE_LIST(hdr) ((hdr)->namespace_offset) 00499 00500 #define CIF_NUM_NONLOCAL_VARS(hdr) ((hdr)->num_nonlocal_vars) 00501 #define CIF_NONLOCAL_VAR_LIST(hdr) ((hdr)->nonlocal_var_offset) 00502 00503 #define CIF_NUM_NONLOCAL_TYPES(hdr) ((hdr)->num_nonlocal_types) 00504 #define CIF_NONLOCAL_TYPE_LIST(hdr) ((hdr)->nonlocal_type_offset) 00505 00506 #define CIF_NUM_UNNAMED_TYPES(hdr) ((hdr)->num_unnamed_types) 00507 #define CIF_UNNAMED_TYPE_LIST(hdr) ((hdr)->unnamed_type_offset) 00508 00509 #define CIF_NUM_FUNCTIONS(hdr) ((hdr)->num_functions) 00510 #define CIF_FUNCTION_LIST(hdr) ((hdr)->function_offset) 00511 00512 #define CIF_HASH_TABLE_SIZE(hdr) ((hdr)->hash_table_size) 00513 #define CIF_HASH_TABLE_OFFSET(hdr) ((hdr)->hash_table_offset) 00514 00515 #define CIF_HASH_CHAIN_SIZE(hdr) ((hdr)->hash_chain_size) 00516 #define CIF_HASH_CHAIN_OFFSET(hdr) ((hdr)->hash_chain_offset) 00517 00518 #define CIF_ID_MAP_SIZE(hdr) ((hdr)->id_map_size) 00519 #define CIF_ID_MAP_OFFSET(hdr) ((hdr)->id_map_offset) 00520 00521 #define CIF_STR_TABLE_SIZE(hdr) ((hdr)->string_table_size) 00522 #define CIF_STR_TABLE_OFFSET(hdr) ((hdr)->string_table_offset) 00523 00524 #define CIF_STRING_TABLE(hdr) ((char*)(hdr) + CIF_STR_TABLE_OFFSET(hdr)) 00525 00526 00527 /* For a given CIF ID get its CIF_index_entry */ 00528 #define CIF_INDEX_ENTRY(hdr,id) \ 00529 ((CIF_index_entry*)(((char*)(hdr)) + CIF_ID_MAP_OFFSET(hdr)) + id) 00530 00531 /* For a given hash table index get its CIF_hash_entry */ 00532 #define CIF_HASH_TABLE_ENTRY(hdr,index) \ 00533 ((CIF_hash_entry*)(((char*)(hdr)) + CIF_HASH_TABLE_OFFSET(hdr)) + index) 00534 00535 /* For a given hash chain index get its CIF_hash_entry */ 00536 #define CIF_HASH_CHAIN_ENTRY(hdr,index) \ 00537 ((CIF_hash_entry*)(((char*)(hdr)) + CIF_HASH_CHAIN_OFFSET(hdr)) + index) 00538 00539 /* Get the CIF_source_file record with a given index (index is not CIF ID) */ 00540 /* It is safer to use the functional interface via cif_src_file */ 00541 #define CIF_SRC_FILE(hdr,index) \ 00542 ((CIF_source_file*)((char*)(hdr) + CIF_SRC_FILE_LIST(hdr)) + index) 00543 00544 00545 /* Fields common to various CIF records */ 00546 #define CIF_ID(record) ((record)->cif_id) 00547 #define CIF_TAG(record) ((record)->cif_tag) 00548 #define CIF_TYPE(record) ((record)->type_id) 00549 #define CIF_PARENT(record) ((record)->parent_id) 00550 #define CIF_NUM_USAGES(record) ((record)->num_usages) 00551 #define CIF_ACCESS_KIND(record) ((record)->access_kind) 00552 #define CIF_NAME_OFFSET(record) ((record)->name_offset) 00553 00554 00555 /* CIF_index_entry */ 00556 #define CIF_RECORD_OFFSET(entry) ((entry)->record_offset) 00557 00558 00559 /* CIF_hash_entry */ 00560 #define CIF_NEXT_IN_CHAIN(entry) ((entry)->next_in_chain) 00561 00562 00563 /* CIF_pu_def 00564 * start and end file indexes are not CIF IDs 00565 */ 00566 #define CIF_PU_DEF_START_FILE(pu) ((pu)->start_file_index) 00567 #define CIF_PU_DEF_START_LINE(pu) ((pu)->start_line_num) 00568 #define CIF_PU_DEF_START_COL(pu) ((pu)->start_column) 00569 #define CIF_PU_DEF_END_FILE(pu) ((pu)->end_file_index) 00570 #define CIF_PU_DEF_END_LINE(pu) ((pu)->end_line_num) 00571 #define CIF_PU_DEF_END_COL(pu) ((pu)->end_column) 00572 #define CIF_PU_DEF_NUM_CALLEES(pu) ((pu)->num_callees) 00573 #define CIF_PU_DEF_CALLEES(pu) ((CIF_id*)((pu)+1)) 00574 #define CIF_PU_DEF_START_FILE_ID(hdr,pu) \ 00575 CIF_ID(CIF_SRC_FILE((hdr), CIF_PU_DEF_START_FILE(pu))) 00576 #define CIF_PU_DEF_END_FILE_ID(hdr,pu) \ 00577 CIF_ID(CIF_SRC_FILE((hdr), CIF_PU_DEF_END_FILE(pu))) 00578 00579 00580 /* CIF_object */ 00581 #define CIF_OBJECT_KIND(obj) ((obj)->object_kind) 00582 #define CIF_MEMBER_STATIC(obj) ((obj)->is_static) 00583 00584 00585 /* Various CIF type records */ 00586 #define CIF_TYPE_KIND(type) ((type)->type_kind) 00587 #define CIF_TYPE_SIZE(type) ((type)->size) 00588 #define CIF_TYPE_SHORT(type) ((type)->is_short) 00589 #define CIF_TYPE_LONG(type) ((type)->is_long) 00590 #define CIF_TYPE_LONGLONG(type) ((type)->is_longlong) 00591 #define CIF_TYPE_SIGNED(type) ((type)->is_signed) 00592 #define CIF_TYPE_UNSIGNED(type) ((type)->is_unsigned) 00593 #define CIF_TYPE_CONST(type) ((type)->is_const) 00594 #define CIF_TYPE_VOLATILE(type) ((type)->is_volatile) 00595 #define CIF_TYPE_RESTRICT(type) ((type)->is_restrict) 00596 #define CIF_TYPE_BASE(type) ((type)->base_type) 00597 #define CIF_TYPE_NUM_KIDS(type) ((type)->num_kids) 00598 00599 #define CIF_ARRAY_NUM_ELEMS(array) ((array)->other_kid.num_elems) 00600 #define CIF_PTR_TO_MBR_CLASS(ptr) ((ptr)->other_kid.class_id) 00601 #define CIF_TYPEDEF_PARENT(type) ((type)->other_kid.parent_id) 00602 00603 00604 /* CIF_enum_constant */ 00605 #define CIF_ENUM_VALUE(constant) ((constant)->value) 00606 00607 00608 /* CIF_source_file 00609 * parent_index is not the same as the parent's CIF ID 00610 */ 00611 #define CIF_SRC_FILE_PARENT_INDEX(file) ((file)->parent_index) 00612 #define CIF_SRC_FILE_IS_INCLUDE(file) ((file)->is_include) 00613 #define CIF_SRC_FILE_SYS_INCLUDE(file) ((file)->is_sys_include) 00614 #define CIF_SRC_FILE_INCLUDE_LINE(file) ((file)->include_line) 00615 00616 /* It is safer to use the functional interface via 00617 * cif_src_file_parent_id and cif_src_file_full_name 00618 */ 00619 #define CIF_SRC_FILE_PARENT_ID(hdr,file) \ 00620 CIF_ID(CIF_SRC_FILE((hdr), CIF_SRC_FILE_PARENT_INDEX(file))) 00621 #define CIF_SRC_FILE_FULL_NAME(hdr,file) \ 00622 (CIF_STRING_TABLE(hdr) + CIF_NAME_OFFSET(file)) 00623 00624 00625 /* CIF_namespace */ 00626 #define CIF_NSP_IS_ALIAS(nsp) ((nsp)->is_alias) 00627 #define CIF_NSP_ALIAS_OF(nsp) ((nsp)->extra_info.alias_of) 00628 #define CIF_NSP_NUM_KIDS(nsp) ((nsp)->extra_info.num_kids) 00629 00630 00631 /* CIF_function */ 00632 #define CIF_FUNC_DEF_OFFSET(func) ((func)->pu_def_offset) 00633 #define CIF_FUNC_VIRTUAL(func) ((func)->is_virtual) 00634 #define CIF_FUNC_INLINE(func) ((func)->is_inline) 00635 #define CIF_FUNC_CTOR(func) ((func)->is_constructor) 00636 #define CIF_FUNC_DTOR(func) ((func)->is_destructor) 00637 #define CIF_FUNC_OPERATOR(func) ((func)->is_operator) 00638 #define CIF_FUNC_DEFINED(func) ((func)->is_defined) 00639 #define CIF_FUNC_USAGES(func) ((CIF_func_usage*)((func)+1)) 00640 00641 /* It is safer to use the functional interface via cif_func_def */ 00642 #define CIF_FUNC_PU_DEF(hdr,func) \ 00643 ((CIF_pu_def*)((char*)((hdr)) + CIF_FUNC_DEF_OFFSET(func))) 00644 00645 00646 /* CIF_kid records */ 00647 #define CIF_KID_ID(kid) ((kid)->cif_id) 00648 #define CIF_KID_KIND(kid) ((kid)->kid_kind) 00649 #define CIF_KID_VIRTUAL(kid) ((kid)->is_virtual) 00650 #define CIF_KID_STATIC(kid) ((kid)->is_static) 00651 00652 00653 /* CIF_usage records 00654 * file_index is not the same as CIF ID 00655 */ 00656 #define CIF_USAGE_CALLER(usage) ((usage)->caller_id) 00657 #define CIF_USAGE_FILE_INDEX(usage) ((usage)->file_index) 00658 #define CIF_USAGE_LINE(usage) ((usage)->line_number) 00659 #define CIF_USAGE_COLUMN(usage) ((usage)->column_number) 00660 #define CIF_USAGE_CODE(usage) ((usage)->usage_code) 00661 #define CIF_USAGE_FILE_ID(hdr,usage) \ 00662 CIF_ID(CIF_SRC_FILE((hdr), CIF_USAGE_FILE_INDEX(usage))) 00663 00664 00665 /* Get the name associated with a CIF_index_entry */ 00666 #define CIF_INDEX_ENTRY_NAME(hdr,entry) \ 00667 (CIF_STRING_TABLE(hdr) + CIF_NAME_OFFSET(entry)) 00668 00669 /* Get the name associated with a CIF_hash_entry */ 00670 #define CIF_HASH_ENTRY_NAME(hdr,entry) \ 00671 CIF_INDEX_ENTRY_NAME(hdr, CIF_INDEX_ENTRY(hdr, CIF_ID(entry))) 00672 00673 00674 #define CIF_ERROR 0 00675 00676 00677 /* 00678 * Hash function used for hashing named CIF records 00679 */ 00680 #if defined(__CIF_C_CONSUMER__) || defined(__CIF_C_PRODUCER__) 00681 #ifndef __STRING_H__ 00682 #include <string.h> 00683 #endif /* __STRING_H__ */ 00684 #ifdef __cplusplus 00685 inline 00686 #else 00687 static 00688 #endif /* __cplusplus */ 00689 CIF_field 00690 cif_hash (const char* name) 00691 { 00692 #define CIF_HASH_FACTOR ((CIF_field) 73) 00693 CIF_field hash_value = 0; 00694 const char* ptr = name; 00695 size_t length = strlen(name); 00696 00697 if (length > 9) { 00698 hash_value = (CIF_field)*ptr++; 00699 hash_value = (hash_value * CIF_HASH_FACTOR) + (CIF_field)*ptr++; 00700 hash_value = (hash_value * CIF_HASH_FACTOR) + (CIF_field)*ptr; 00701 ptr = name + (length >> 1) - 1; 00702 hash_value = (hash_value * CIF_HASH_FACTOR) + (CIF_field)*ptr++; 00703 hash_value = (hash_value * CIF_HASH_FACTOR) + (CIF_field)*ptr++; 00704 hash_value = (hash_value * CIF_HASH_FACTOR) + (CIF_field)*ptr; 00705 ptr = name + length - 3; 00706 hash_value = (hash_value * CIF_HASH_FACTOR) + (CIF_field)*ptr++; 00707 hash_value = (hash_value * CIF_HASH_FACTOR) + (CIF_field)*ptr++; 00708 hash_value = (hash_value * CIF_HASH_FACTOR) + (CIF_field)*ptr; 00709 } 00710 else { 00711 size_t i; 00712 for (i = 0; i < length; ++i) { 00713 hash_value = (hash_value * CIF_HASH_FACTOR) + (CIF_field)*ptr++; 00714 } 00715 } 00716 00717 return hash_value; 00718 } 00719 #endif /* __CIF_C_PRODUCER__ || __CIF_C_PRODUCER__ */ 00720 00721 00722 #ifdef __cplusplus 00723 } 00724 #endif 00725 #endif /* __CIF_C_H */