2 * This file is part of cparser.
3 * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 ENTITY_COMPOUND_MEMBER,
38 typedef unsigned char entity_kind_t;
40 typedef enum namespace_tag_t {
48 typedef unsigned char namespace_t;
50 typedef enum storage_class_tag_t {
54 STORAGE_CLASS_TYPEDEF,
56 STORAGE_CLASS_REGISTER,
58 STORAGE_CLASS_THREAD_EXTERN,
59 STORAGE_CLASS_THREAD_STATIC,
60 } storage_class_tag_t;
61 typedef unsigned char storage_class_t;
63 typedef enum decl_modifier_t {
64 DM_DLLIMPORT = 1 << 0,
65 DM_DLLEXPORT = 1 << 1,
68 DM_MICROSOFT_INLINE = 1 << 4,
69 DM_FORCEINLINE = 1 << 5,
70 DM_SELECTANY = 1 << 6,
74 DM_NOINLINE = 1 << 10,
75 DM_RESTRICT = 1 << 11,
78 DM_TRANSPARENT_UNION = 1 << 14,
81 DM_CONSTRUCTOR = 1 << 17,
82 DM_DESTRUCTOR = 1 << 18,
86 DM_FASTCALL = 1 << 22,
88 DM_THISCALL = 1 << 24,
89 DM_DEPRECATED = 1 << 25
92 typedef unsigned decl_modifiers_t;
95 * a named entity is something which can be referenced by its name
98 struct entity_base_t {
102 source_position_t source_position;
103 scope_t *parent_scope; /**< The parent scope where this declaration lives. */
105 /** next declaration in a scope */
107 /** next declaration with same symbol */
108 entity_t *symbol_next;
114 decl_modifiers_t modifiers;
116 bool has_flexible_member : 1;
120 bool irtype_complete : 1;
131 struct enum_value_t {
143 bool address_taken : 1;
144 statement_t *statement;
152 decl_modifiers_t modifiers;
157 struct declaration_t {
159 storage_class_t declared_storage_class;
160 storage_class_t storage_class;
161 decl_modifiers_t modifiers;
162 const char *deprecated_string; /**< MS deprecated string if any. */
163 bool used : 1; /**< Set if the declaration is used. */
164 bool implicit : 1; /**< Set for implicit (not found in source code) declarations. */
171 struct compound_member_t {
177 il_size_t offset; /**< The offset of this member inside a compound. */
182 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
184 unsigned char alignment; /**< Alignment of the declaration, 0 for default. */
185 symbol_t *get_property_sym; /**< MS get property. */
186 symbol_t *put_property_sym; /**< MS put property. */
188 initializer_t *initializer;
192 unsigned int value_number;
201 bool need_closure : 1; /**< Inner function needs closure. */
202 bool goto_to_outer : 1; /**< Inner function has goto to outer function. */
205 statement_t *statement;
218 enum_value_t enum_value;
221 declaration_t declaration;
224 compound_member_t compound_member;
227 static inline bool is_declaration(const entity_t *entity)
229 return entity->kind == ENTITY_FUNCTION || entity->kind == ENTITY_VARIABLE
230 || entity->kind == ENTITY_COMPOUND_MEMBER;