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,
61 STORAGE_CLASS_THREAD_EXTERN,
62 STORAGE_CLASS_THREAD_STATIC,
63 } storage_class_tag_t;
64 typedef unsigned char storage_class_t;
66 typedef enum decl_modifier_t {
68 DM_DLLIMPORT = 1 << 0,
69 DM_DLLEXPORT = 1 << 1,
72 DM_MICROSOFT_INLINE = 1 << 4,
73 DM_FORCEINLINE = 1 << 5,
74 DM_SELECTANY = 1 << 6,
78 DM_NOINLINE = 1 << 10,
79 DM_RESTRICT = 1 << 11,
82 DM_TRANSPARENT_UNION = 1 << 14,
85 DM_CONSTRUCTOR = 1 << 17,
86 DM_DESTRUCTOR = 1 << 18,
90 DM_FASTCALL = 1 << 22,
92 DM_THISCALL = 1 << 24,
93 DM_DEPRECATED = 1 << 25
96 typedef unsigned decl_modifiers_t;
99 * A scope containing entities.
103 entity_t *last_entity;
104 scope_t *parent; /**< points to the parent scope. */
105 unsigned depth; /**< while parsing, the depth of this scope in the
110 * a named entity is something which can be referenced by its name
113 struct entity_base_t {
115 entity_namespace_t namespc;
117 source_position_t source_position;
118 scope_t *parent_scope; /**< The parent scope where this declaration lives. */
120 /** next declaration in a scope */
122 /** next declaration with same symbol */
123 entity_t *symbol_next;
128 entity_t *alias; /* used for name mangling of anonymous types */
130 decl_modifiers_t modifiers;
132 bool has_flexible_member : 1;
136 bool irtype_complete : 1;
141 entity_t *alias; /* used for name mangling of anonymous types */
148 struct enum_value_t {
160 bool address_taken : 1;
161 statement_t *statement;
174 decl_modifiers_t modifiers;
179 struct declaration_t {
181 storage_class_t declared_storage_class;
182 storage_class_t storage_class;
183 decl_modifiers_t modifiers;
184 const char *deprecated_string; /**< MS deprecated string if any. */
185 bool used : 1; /**< Set if the declaration is used. */
186 bool implicit : 1; /**< Set for implicit (not found in source code) declarations. */
193 struct compound_member_t {
199 il_size_t offset; /**< The offset of this member inside a compound. */
204 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
206 unsigned char alignment; /**< Alignment of the declaration, 0 for default. */
207 symbol_t *get_property_sym; /**< MS get property. */
208 symbol_t *put_property_sym; /**< MS put property. */
210 initializer_t *initializer;
214 unsigned int value_number;
223 bool need_closure : 1; /**< Inner function needs closure. */
224 bool goto_to_outer : 1; /**< Inner function has goto to outer function. */
227 statement_t *statement;
240 enum_value_t enum_value;
242 namespace_t namespacee;
244 declaration_t declaration;
247 compound_member_t compound_member;
250 static inline bool is_declaration(const entity_t *entity)
252 return entity->kind == ENTITY_FUNCTION || entity->kind == ENTITY_VARIABLE
253 || entity->kind == ENTITY_COMPOUND_MEMBER;