1/* 2 * Copyright (c) 2010 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of Apple Inc. ("Apple") nor the names of its 16 * contributors may be used to endorse or promote products derived from 17 * this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 * 30 * Portions of this software have been released under the following terms: 31 * 32 * (c) Copyright 1989-1993 OPEN SOFTWARE FOUNDATION, INC. 33 * (c) Copyright 1989-1993 HEWLETT-PACKARD COMPANY 34 * (c) Copyright 1989-1993 DIGITAL EQUIPMENT CORPORATION 35 * 36 * To anyone who acknowledges that this file is provided "AS IS" 37 * without any express or implied warranty: 38 * permission to use, copy, modify, and distribute this file for any 39 * purpose is hereby granted without fee, provided that the above 40 * copyright notices and this notice appears in all source code copies, 41 * and that none of the names of Open Software Foundation, Inc., Hewlett- 42 * Packard Company or Digital Equipment Corporation be used 43 * in advertising or publicity pertaining to distribution of the software 44 * without specific, written prior permission. Neither Open Software 45 * Foundation, Inc., Hewlett-Packard Company nor Digital 46 * Equipment Corporation makes any representations about the suitability 47 * of this software for any purpose. 48 * 49 * Copyright (c) 2007, Novell, Inc. All rights reserved. 50 * Redistribution and use in source and binary forms, with or without 51 * modification, are permitted provided that the following conditions 52 * are met: 53 * 54 * 1. Redistributions of source code must retain the above copyright 55 * notice, this list of conditions and the following disclaimer. 56 * 2. Redistributions in binary form must reproduce the above copyright 57 * notice, this list of conditions and the following disclaimer in the 58 * documentation and/or other materials provided with the distribution. 59 * 3. Neither the name of Novell Inc. nor the names of its contributors 60 * may be used to endorse or promote products derived from this 61 * this software without specific prior written permission. 62 * 63 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 64 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 65 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 66 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY 67 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 68 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 69 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 70 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 71 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 72 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 73 * 74 * @APPLE_LICENSE_HEADER_END@ 75 */ 76 77/* 78** 79** NAME: 80** 81** fe_pvt.h 82** 83** FACILITY: 84** 85** Interface Definition Language (IDL) Compiler 86** 87** ABSTRACT: 88** 89** Header file containing defining front-end private data structures 90** for data that is kept in the fe_info_t field of the AST nodes. 91** 92** VERSION: DCE 1.0 93** 94*/ 95 96#ifndef fe_pvth_incl 97#define fe_pvth_incl 98 99#include <nametbl.h> 100 101/* 102 * The frontend structure describes information private to 103 * the frontend portion of the compiler. 104 */ 105 106typedef enum 107{ 108 fe_bitset_info, 109 fe_const_info, 110 fe_source_only, 111 fe_tag_fwd_ref, 112 fe_clone_info, 113 fe_if_info, 114 fe_ptr_info 115} fe_type_k_t; 116 117typedef enum /* Integer constant kinds */ 118{ 119 fe_int_const_k, 120 fe_bitset_const_k, 121 fe_enum_const_k 122} fe_const_k_t; 123 124typedef enum /* AST node kinds */ 125{ 126 fe_interface_n_k, 127 fe_type_p_n_k, 128 fe_import_n_k, 129 fe_export_n_k, 130 fe_cpp_quote_n_k, 131 fe_constant_n_k, 132 fe_type_n_k, 133 fe_rep_as_n_k, 134 fe_array_n_k, 135 fe_array_index_n_k, 136 fe_bitset_n_k, 137 fe_disc_union_n_k, 138 fe_arm_n_k, 139 fe_case_label_n_k, 140 fe_enumeration_n_k, 141 fe_pipe_n_k, 142 fe_pointer_n_k, 143 fe_structure_n_k, 144 fe_field_n_k, 145 fe_field_attr_n_k, 146 fe_field_ref_n_k, 147 fe_parameter_n_k, 148 fe_operation_n_k, 149 fe_include_n_k, 150 fe_exception_n_k, 151 fe_cs_char_n_k, 152 fe_expression_n_k 153} fe_node_k_t; 154 155/* 156 * Bit names contained in fe_info flags word 157 */ 158 159#define FE_SELF_POINTING 0x00000001 /* True if this type node */ 160 /* is on the sp_types list. */ 161 /* Needed because non self- */ 162 /* pointing types can be on */ 163 /* the list also */ 164 165#define FE_POINTED_AT 0x00000002 /* True if this type node */ 166 /* is on the pa_types list */ 167 168#define FE_HAS_PTR_ARRAY 0x00000004 /* True if type contains a */ 169 /* [ptr] array used as other*/ 170 /* than a top-level param */ 171 172#define FE_INCOMPLETE 0x00000008 /* True if this */ 173 /* struct/union is not yet */ 174 /* complete due to a */ 175 /* forward reference */ 176 177#define FE_HAS_UNIQUE_PTR 0x00000010 /* True if this type or any */ 178 /* types it pts to have any */ 179 /* [unique] ptrs */ 180 181#define FE_HAS_PTR 0x00000020 /* True if this type or any */ 182 /* contained types are ptrs */ 183 184#define FE_HAS_CFMT_ARR 0x00000040 /* True if this param */ 185 /* contains a non-top-level */ 186 /* conformant array that is */ 187 /* not under a full pointer */ 188 189#define FE_PROP_TYPE_DONE 0x00000080 /* True if this item has */ 190 /* had type propagation */ 191 /* completed */ 192 193#define FE_HAS_REF_PTR 0x00000100 /* True if this type or any */ 194 /* types it pts to have any */ 195 /* [ref] ptrs */ 196 197#define FE_PROP_IN_PARAM_DONE 0x00000200 /* True if this item has */ 198 /* had [in] param */ 199 /* propagation completed */ 200 201#define FE_HAS_REP_AS 0x00000400 /* True if this item has */ 202 /* or contains a type with */ 203 /* [represent_as] on it */ 204 205#define FE_OOL 0x00000800 /* True if this item has */ 206 /* been put on the ool list */ 207 208#define FE_HAS_VAL_FLOAT 0x00001000 /* True if operation has */ 209 /* float passed by value */ 210 211#define FE_HAS_V1_ATTR 0x00002000 /* True if type has or cts. */ 212 /* a V1-specific attribute */ 213 214#define FE_HAS_V2_ATTR 0x00004000 /* True if type has or cts. */ 215 /* a V2-specific attribute */ 216 217#define FE_PROP_OUT_PARAM_DONE 0x00008000 /* True if this item has */ 218 /* had [out] param */ 219 /* propagation completed */ 220 221#define FE_HAS_FULL_PTR 0x00010000 /* True if this type or any */ 222 /* types it pts to have any */ 223 /* [ref] ptrs */ 224 225#define FE_HAS_XMIT_AS 0x00020000 /* True if this item has */ 226 /* or contains a type with */ 227 /* [transmit_as] on it */ 228 229#define FE_HAS_CHAR 0x00040000 /* True if this item is or */ 230 /* contains a char type */ 231 232#define FE_HAS_FLOAT 0x00080000 /* True if this item is or */ 233 /* contains a floating type */ 234 235#define FE_HAS_INT 0x00100000 /* True if this item is or */ 236 /* contains an integer type */ 237 238#define FE_MAYBE_WIRE_ALIGNED 0x00200000 /* True if this item's memory */ 239 /* alignment might match NDR */ 240 241#define FE_HAS_IN_FULL_PTR 0x00400000 /* True if this operation has */ 242 /* any [ptr] pointers in [in] */ 243 /* or [in,out] parameters */ 244 245#define FE_USED_AS_CS_FLD_ATTR 0x00800000 /* True if this instance is */ 246 /* used as the target of a */ 247 /* [size_is] or [length_is] */ 248 /* for array of [cs_char] type*/ 249 250#define FE_HAS_NF_CS_ARRAY 0x01000000 /* On a type, True if the type*/ 251 /* contains a non-fixed array */ 252 /* of [cs_char] type */ 253#define FE_FIRST_IN_NF_CS_ARR 0x01000000 /* On a param, True if it is */ 254 /* the first [in] param in an */ 255 /* operation containing non- */ 256 /* fixed array of [cs_char] */ 257 258#define FE_CT_CS_CHAR 0x02000000 /* On a type, True if the type*/ 259 /* contains, not merely is, a */ 260 /* [cs_char] type */ 261#define FE_LAST_IN_NF_CS_ARR 0x02000000 /* On a param, True if it is */ 262 /* the last [in] param in an */ 263 /* operation containing non- */ 264 /* fixed array of [cs_char] */ 265 266#define FE_USED_IN_TRANSMITTED 0x04000000 /* On a type, True if it is */ 267 /* used within a transmitted */ 268 /* type specified in a */ 269 /* [transmit_as] attribute */ 270#define FE_FIRST_OUT_NF_CS_ARR 0x04000000 /* On a param, True if it is */ 271 /* the first [out] param in an*/ 272 /* operation containing non- */ 273 /* fixed array of [cs_char] */ 274 275#define FE_LAST_OUT_NF_CS_ARR 0x08000000 /* On a param, True if it is */ 276 /* the last [out] param in an */ 277 /* operation containing non- */ 278 /* fixed array of [cs_char] */ 279 280#define FE_USED_AS_REG_FLD_ATTR 0x10000000 /* True if this instance is */ 281 /* used as the target of a */ 282 /* field attribute for array */ 283 /* of non-[cs_char] type */ 284 285/* 286 * Macros to set, clear, and test fe_info flags word 287 */ 288#define FE_SET(word,bit) ((word) |= (bit)) 289#define FE_TEST(word,bit) (((word) & (bit)) != 0) 290#define FE_CLEAR(word,bit) ((word) &= ~(bit)) 291 292/* 293 * Info in the AST used only by the frontend. 294 */ 295typedef struct fe_info_t 296{ 297 struct fe_info_t *next; 298 struct fe_info_t *last; 299 fe_node_k_t node_kind; /* AST node kind */ 300 STRTAB_str_t file; 301 int source_line; 302 STRTAB_str_t acf_file; /* ACF file for this node or NIL */ 303 int acf_source_line; /* ACF line number or 0 if none */ 304 fe_type_k_t fe_type_id; 305 union 306 { 307 int cardinal; /* For bitsets and enumerations */ 308 fe_const_k_t const_kind; /* fe_type_id == fe_const_info */ 309 struct AST_type_p_n_t *clone; /* fe_type_id == fe_clone_info */ 310 int if_flags; /* fe_type_id == fe_if_info */ 311 struct AST_type_n_t *pointer_type; /* fe_type_id == fe_ptr_info */ 312 } type_specific; 313 314 struct AST_type_n_t *tag_ptr; /* Type node for the tag from which */ 315 /* this type was derived. */ 316 NAMETABLE_id_t tag_name; /* Tag name from which this type is */ 317 /* derived. */ 318 unsigned long int gen_index; /* Index used in gen'd names */ 319 short int pointer_count; /* The number of pointers on a */ 320 /* array bound reference. */ 321 unsigned short int ref_count; /* Reference count. On a parameter, */ 322 /* used to count occurences of 'used*/ 323 /* as field attribute reference for */ 324 /* an array of [cs_char] */ 325 unsigned short int ref_count_a; /* Reference count. On a parameter, */ 326 /* used to count occurences of 'used*/ 327 /* as [in] [size_is] reference for */ 328 /* an [out]-only conformant array */ 329 /* of [cs_char]' */ 330 unsigned long int flags; /* A bitvector of flags */ 331 332 struct AST_type_n_t *original; /* Type node for a type with */ 333 /* DEF_AS_TAG set */ 334} fe_info_t; 335 336#endif 337