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
30 ENTITY_COMPOUND_MEMBER,
41 typedef unsigned char entity_kind_t;
43 typedef enum namespace_tag_t {
51 typedef unsigned char entity_namespace_t;
53 typedef enum storage_class_tag_t {
57 STORAGE_CLASS_TYPEDEF,
59 STORAGE_CLASS_REGISTER,
60 } storage_class_tag_t;
61 typedef unsigned char storage_class_t;
63 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 scope containing entities.
100 entity_t *last_entity;
101 scope_t *parent; /**< points to the parent scope. */
102 unsigned depth; /**< while parsing, the depth of this scope in the
107 * a named entity is something which can be referenced by its name
110 struct entity_base_t {
112 entity_namespace_t namespc;
114 source_position_t source_position;
115 scope_t *parent_scope; /**< The parent scope where this declaration lives. */
117 /** next declaration in a scope */
119 /** next declaration with same symbol */
120 entity_t *symbol_next;
125 entity_t *alias; /* used for name mangling of anonymous types */
127 decl_modifiers_t modifiers;
129 bool has_flexible_member : 1;
133 bool irtype_complete : 1;
138 entity_t *alias; /* used for name mangling of anonymous types */
145 struct enum_value_t {
157 bool address_taken : 1;
158 statement_t *statement;
171 decl_modifiers_t modifiers;
176 struct declaration_t {
178 storage_class_t declared_storage_class;
179 storage_class_t storage_class;
180 decl_modifiers_t modifiers;
181 const char *deprecated_string; /**< MS deprecated string if any. */
182 bool used : 1; /**< Set if the declaration is used. */
183 bool implicit : 1; /**< Set for implicit (not found in source code) declarations. */
190 struct compound_member_t {
196 il_size_t offset; /**< The offset of this member inside a compound. */
201 bool thread_local : 1; /**< GCC __thread */
202 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
204 unsigned char alignment; /**< Alignment of the declaration, 0 for default. */
205 symbol_t *get_property_sym; /**< MS get property. */
206 symbol_t *put_property_sym; /**< MS put property. */
208 initializer_t *initializer;
212 unsigned int value_number;
221 bool need_closure : 1; /**< Inner function needs closure. */
222 bool goto_to_outer : 1; /**< Inner function has goto to outer function. */
225 statement_t *statement;
238 enum_value_t enum_value;
240 namespace_t namespacee;
242 declaration_t declaration;
245 compound_member_t compound_member;
248 static inline bool is_declaration(const entity_t *entity)
250 return entity->kind == ENTITY_FUNCTION || entity->kind == ENTITY_VARIABLE
251 || entity->kind == ENTITY_COMPOUND_MEMBER;