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 {
49 typedef unsigned char namespace_t;
51 typedef enum storage_class_tag_t {
55 STORAGE_CLASS_TYPEDEF,
57 STORAGE_CLASS_REGISTER,
59 STORAGE_CLASS_THREAD_EXTERN,
60 STORAGE_CLASS_THREAD_STATIC,
61 } storage_class_tag_t;
62 typedef unsigned char storage_class_t;
64 typedef enum decl_modifier_t {
65 DM_DLLIMPORT = 1 << 0,
66 DM_DLLEXPORT = 1 << 1,
69 DM_MICROSOFT_INLINE = 1 << 4,
70 DM_FORCEINLINE = 1 << 5,
71 DM_SELECTANY = 1 << 6,
75 DM_NOINLINE = 1 << 10,
76 DM_RESTRICT = 1 << 11,
79 DM_TRANSPARENT_UNION = 1 << 14,
82 DM_CONSTRUCTOR = 1 << 17,
83 DM_DESTRUCTOR = 1 << 18,
87 DM_FASTCALL = 1 << 22,
89 DM_THISCALL = 1 << 24,
90 DM_DEPRECATED = 1 << 25
93 typedef unsigned decl_modifiers_t;
96 * a named entity is something which can be referenced by its name
99 struct entity_base_t {
103 source_position_t source_position;
104 scope_t *parent_scope; /**< The parent scope where this declaration lives. */
106 /** next declaration in a scope */
108 /** next declaration with same symbol */
109 entity_t *symbol_next;
115 decl_modifiers_t modifiers;
117 bool has_flexible_member : 1;
121 bool irtype_complete : 1;
132 struct enum_value_t {
144 bool address_taken : 1;
145 statement_t *statement;
153 decl_modifiers_t modifiers;
158 struct declaration_t {
160 storage_class_t declared_storage_class;
161 storage_class_t storage_class;
162 decl_modifiers_t modifiers;
163 const char *deprecated_string; /**< MS deprecated string if any. */
164 bool used : 1; /**< Set if the declaration is used. */
165 bool implicit : 1; /**< Set for implicit (not found in source code) declarations. */
172 struct compound_member_t {
178 il_size_t offset; /**< The offset of this member inside a compound. */
183 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
185 unsigned char alignment; /**< Alignment of the declaration, 0 for default. */
186 symbol_t *get_property_sym; /**< MS get property. */
187 symbol_t *put_property_sym; /**< MS put property. */
189 initializer_t *initializer;
193 unsigned int value_number;
202 bool need_closure : 1; /**< Inner function needs closure. */
203 bool goto_to_outer : 1; /**< Inner function has goto to outer function. */
206 statement_t *statement;
219 enum_value_t enum_value;
222 declaration_t declaration;
225 compound_member_t compound_member;
228 static inline bool is_declaration(const entity_t *entity)
230 return entity->kind == ENTITY_FUNCTION || entity->kind == ENTITY_VARIABLE
231 || entity->kind == ENTITY_COMPOUND_MEMBER;