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
26 #include <libfirm/firm_types.h>
31 ENTITY_COMPOUND_MEMBER,
43 typedef unsigned char entity_kind_t;
45 typedef enum namespace_tag_t {
53 typedef unsigned char entity_namespace_t;
55 typedef enum storage_class_tag_t {
59 STORAGE_CLASS_TYPEDEF,
61 STORAGE_CLASS_REGISTER,
62 } storage_class_tag_t;
63 typedef unsigned char storage_class_t;
65 typedef enum decl_modifier_t {
67 DM_DLLIMPORT = 1 << 0,
68 DM_DLLEXPORT = 1 << 1,
71 DM_MICROSOFT_INLINE = 1 << 4,
72 DM_FORCEINLINE = 1 << 5,
73 DM_SELECTANY = 1 << 6,
77 DM_NOINLINE = 1 << 10,
78 DM_RESTRICT = 1 << 11,
81 DM_TRANSPARENT_UNION = 1 << 14,
84 DM_CONSTRUCTOR = 1 << 17,
85 DM_DESTRUCTOR = 1 << 18,
89 DM_FASTCALL = 1 << 22,
91 DM_THISCALL = 1 << 24,
92 DM_DEPRECATED = 1 << 25,
93 DM_RETURNS_TWICE = 1 << 26,
96 typedef unsigned decl_modifiers_t;
99 * A scope containing entities.
103 entity_t *last_entity;
104 unsigned depth; /**< while parsing, the depth of this scope in the
109 * a named entity is something which can be referenced by its name
112 struct entity_base_t {
114 entity_namespace_t namespc;
116 source_position_t source_position;
117 scope_t *parent_scope; /**< The scope where this entity
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 {
195 unsigned char alignment;
197 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
201 il_size_t offset; /**< The offset of this member inside a compound. */
206 bool thread_local : 1; /**< GCC __thread */
207 bool address_taken : 1; /**< Set if the address of this declaration was taken. */
209 unsigned char alignment;
210 symbol_t *get_property_sym; /**< MS get property. */
211 symbol_t *put_property_sym; /**< MS put property. */
213 initializer_t *initializer;
217 unsigned int value_number;
225 bool address_taken : 1;
230 unsigned int value_number;
238 bool need_closure : 1; /**< Inner function needs closure. */
239 bool goto_to_outer : 1; /**< Inner function has goto to outer function. */
242 statement_t *statement;
255 enum_value_t enum_value;
257 namespace_t namespacee;
259 declaration_t declaration;
261 parameter_t parameter;
263 compound_member_t compound_member;
266 static inline bool is_declaration(const entity_t *entity)
268 return entity->kind == ENTITY_FUNCTION || entity->kind == ENTITY_VARIABLE
269 || entity->kind == ENTITY_PARAMETER
270 || entity->kind == ENTITY_COMPOUND_MEMBER;
274 const char *get_entity_kind_name(entity_kind_t kind);