+/*
+ * This file is part of cparser.
+ * Copyright (C) 2007-2008 Matthias Braun <matze@braunis.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
#ifndef AST_T_H
#define AST_T_H
EXPR_INVALID,
EXPR_REFERENCE,
EXPR_CONST,
+ EXPR_CHARACTER_CONSTANT,
+ EXPR_WIDE_CHARACTER_CONSTANT,
EXPR_STRING_LITERAL,
EXPR_WIDE_STRING_LITERAL,
+ EXPR_COMPOUND_LITERAL,
EXPR_CALL,
EXPR_CONDITIONAL,
EXPR_SELECT,
case EXPR_UNARY_ASSUME: \
case EXPR_UNARY_BITFIELD_EXTRACT:
+/**
+ * A scope containing declarations.
+ */
struct scope_t {
- declaration_t *declarations; /**< List of declarations in this scope. */
+ declaration_t *declarations; /**< List of declarations in this scope. */
+ declaration_t *last_declaration; /**< last declaration in this scope. */
};
struct expression_base_t {
struct const_expression_t {
expression_base_t base;
union {
- long long int_value;
- long double float_value;
+ long long int_value;
+ long double float_value;
+ string_t character;
+ wide_string_t wide_character;
} v;
};
wide_string_t value;
};
+struct compound_literal_expression_t {
+ expression_base_t base;
+ type_t *type;
+ initializer_t *initializer;
+};
+
struct builtin_symbol_expression_t {
expression_base_t base;
symbol_t *symbol;
};
struct designator_t {
- symbol_t *symbol;
- expression_t *array_access;
- designator_t *next;
+ source_position_t source_position;
+ symbol_t *symbol;
+ expression_t *array_index;
+ designator_t *next;
};
struct offsetof_expression_t {
const_expression_t conste;
string_literal_expression_t string;
wide_string_literal_expression_t wide_string;
+ compound_literal_expression_t compound_literal;
builtin_symbol_expression_t builtin_symbol;
builtin_constant_expression_t builtin_constant;
builtin_prefetch_expression_t builtin_prefetch;
typedef enum {
STORAGE_CLASS_NONE,
- STORAGE_CLASS_TYPEDEF,
STORAGE_CLASS_EXTERN,
STORAGE_CLASS_STATIC,
+ STORAGE_CLASS_TYPEDEF,
STORAGE_CLASS_AUTO,
STORAGE_CLASS_REGISTER,
STORAGE_CLASS_ENUM_ENTRY,
STORAGE_CLASS_THREAD,
STORAGE_CLASS_THREAD_EXTERN,
- STORAGE_CLASS_THREAD_STATIC
+ STORAGE_CLASS_THREAD_STATIC,
} storage_class_tag_t;
typedef enum {
INITIALIZER_VALUE,
INITIALIZER_LIST,
INITIALIZER_STRING,
- INITIALIZER_WIDE_STRING
+ INITIALIZER_WIDE_STRING,
+ INITIALIZER_DESIGNATOR
} initializer_kind_t;
struct initializer_base_t {
};
struct initializer_value_t {
- initializer_base_t initializer;
+ initializer_base_t base;
expression_t *value;
};
struct initializer_list_t {
- initializer_base_t initializer;
+ initializer_base_t base;
size_t len;
initializer_t *initializers[];
};
struct initializer_string_t {
- initializer_base_t initializer;
+ initializer_base_t base;
string_t string;
};
struct initializer_wide_string_t {
- initializer_base_t initializer;
+ initializer_base_t base;
wide_string_t string;
};
+struct initializer_designator_t {
+ initializer_base_t base;
+ designator_t *designator;
+};
+
union initializer_t {
initializer_kind_t kind;
initializer_base_t base;
initializer_list_t list;
initializer_string_t string;
initializer_wide_string_t wide_string;
+ initializer_designator_t designator;
};
+/**
+ * Extended microsoft modifier.
+ */
typedef enum {
- DM_DLLIMPORT = (1 << 0),
- DM_DLLEXPORT = (1 << 1),
- DM_THREAD = (1 << 2),
- DM_NAKED = (1 << 3),
- DM_FORCEINLINE = (1 << 4),
- DM_NOTHROW = (1 << 5),
- DM_NORETURN = (1 << 6),
- DM_NOINLINE = (1 << 7)
+ DM_DLLIMPORT = (1 << 0),
+ DM_DLLEXPORT = (1 << 1),
+ DM_THREAD = (1 << 2),
+ DM_NAKED = (1 << 3),
+ DM_MICROSOFT_INLINE = (1 << 4),
+ DM_FORCEINLINE = (1 << 5),
+ DM_SELECTANY = (1 << 6),
+ DM_NOTHROW = (1 << 7),
+ DM_NOVTABLE = (1 << 8),
+ DM_NORETURN = (1 << 9),
+ DM_NOINLINE = (1 << 10),
+ DM_DEPRECATED = (1 << 11),
+ DM_RESTRICT = (1 << 12),
+ DM_NOALIAS = (1 << 13)
} decl_modifier_t;
typedef unsigned short decl_modifiers_t;
struct declaration_t {
unsigned char namespc;
+ unsigned char declared_storage_class;
unsigned char storage_class;
- decl_modifiers_t modifiers;
+ unsigned char alignment; /**< Alignmnet of the declaration, 0 for default. */
+ decl_modifiers_t modifiers; /**< MS __declspec modifiers. */
+ const char *deprecated_string; /**< MS deprecated string if any. */
+ symbol_t *get_property_sym; /**< MS get property. */
+ symbol_t *put_property_sym; /**< MS put property. */
unsigned int address_taken : 1;
unsigned int is_inline : 1;
unsigned int used : 1; /**< Set if the declaration is used. */
initializer_t *initializer;
expression_t *enum_value;
} init;
- scope_t scope;
- scope_t *parent_scope;
+ scope_t scope; /**< The scope that this declaration opens. */
+ scope_t *parent_scope; /**< The parant scope where this declaration lives. */
/** next declaration in a scope */
declaration_t *next;
/* the following fields are used in ast2firm module */
unsigned char declaration_kind;
union {
- unsigned int value_number;
- ir_entity *entity;
- ir_node *block;
- tarval *enum_val;
- ir_type *irtype;
+ unsigned int value_number;
+ ir_entity *entity;
+ ir_node *block;
+ ir_node *vla_base;
+ tarval *enum_val;
+ ir_type *irtype;
} v;
};
typedef enum {
STATEMENT_INVALID,
+ STATEMENT_EMPTY,
STATEMENT_COMPOUND,
STATEMENT_RETURN,
STATEMENT_DECLARATION,
source_position_t source_position;
};
+struct invalid_statement_t {
+ statement_base_t base;
+};
+
+struct empty_statement_t {
+ statement_base_t base;
+};
+
struct return_statement_t {
statement_base_t base;
expression_t *value;
return obstack_alloc(&ast_obstack, size);
}
+static inline
+bool is_invalid_expression(expression_t *expression)
+{
+ return expression->base.kind == EXPR_INVALID;
+}
+
+static inline
+bool is_invalid_statement(statement_t *statement)
+{
+ return statement->base.kind == STATEMENT_INVALID;
+}
+
+
#define allocate_ast(size) _allocate_ast(size)
#endif