flush
[m6w6/ext-psi] / src / types / decl_type.h
1 /*******************************************************************************
2 Copyright (c) 2016, Michael Wallner <mike@php.net>.
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13
14 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
18 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
20 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
21 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *******************************************************************************/
25
26 #ifndef PSI_TYPES_DECL_TYPE_H
27 #define PSI_TYPES_DECL_TYPE_H
28
29 #include "token.h"
30
31 typedef struct decl_type {
32 struct psi_token *token;
33 char *name;
34 token_t type;
35 union {
36 struct decl_arg *def;
37 struct decl_struct *strct;
38 struct decl_union *unn;
39 struct decl_enum *enm;
40 struct decl *func;
41 } real;
42 } decl_type;
43
44 #include <string.h>
45 #define is_anon_type(name, type) !strncmp(name, type "@", sizeof(type))
46
47 decl_type *init_decl_type(token_t type, const char *name);
48 void free_decl_type(decl_type *type);
49 void dump_decl_type(int fd, decl_type *t, unsigned level);
50
51 struct decl_args *extract_decl_type_args(decl_type *dtyp, decl_type** real_typ_ptr);
52 size_t extract_decl_type_size(decl_type *dtyp, decl_type **real_typ_ptr);
53
54 int weak_decl_type(decl_type *type);
55 decl_type *real_decl_type(decl_type *type);
56
57 struct decl_typedefs;
58 struct decl_structs;
59 struct decl_unions;
60 struct decl_enums;
61 struct decls;
62
63 int locate_decl_type_alias(struct decl_typedefs *defs, decl_type *type);
64 int locate_decl_type_struct(struct decl_structs *structs, decl_type *type);
65 int locate_decl_type_union(struct decl_unions *unions, decl_type *type);
66 int locate_decl_type_enum(struct decl_enums *enums, decl_type *type);
67 int locate_decl_type_decl(struct decls *decls, decl_type *type);
68
69 struct psi_data;
70
71 int validate_decl_type(struct psi_data *data, decl_type *type, struct decl_arg *def);
72
73 size_t alignof_decl_type(decl_type *t);
74
75 #endif