summaryrefslogtreecommitdiff
path: root/src/analysis/type.h
blob: f7fba36a3ea05770fdd9898e7ff7535a7d5ce7f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

/* Chrysalide - Outil d'analyse de fichiers binaires
 * type.h - prototypes pour la manipulation des types en tout genre
 *
 * Copyright (C) 2010-2013 Cyrille Bagard
 *
 *  This file is part of Chrysalide.
 *
 *  Chrysalide 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 3 of the License, or
 *  (at your option) any later version.
 *
 *  Chrysalide 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef _ANALYSIS_TYPE_H
#define _ANALYSIS_TYPE_H


#include <glib.h>
#include <glib-object.h>
#include <stdbool.h>


#include "../arch/archbase.h"
#include "../decomp/output.h"
#include "../glibext/gbufferline.h"



/* ------------------------ REPRESENTATION INTERNE DES TYPES ------------------------ */


#define G_TYPE_DATA_TYPE               g_data_type_get_type()
#define G_DATA_TYPE(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), g_data_type_get_type(), GDataType))
#define G_IS_DATA_TYPE(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_data_type_get_type()))
#define G_DATA_TYPE_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_DATA_TYPE, GDataTypeClass))
#define G_IS_DATA_TYPE_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_DATA_TYPE))
#define G_DATA_TYPE_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_DATA_TYPE, GDataTypeClass))


/* Description de type quelconque (instance) */
typedef struct _GDataType GDataType;

/* Description de type quelconque (classe) */
typedef struct _GDataTypeClass GDataTypeClass;


/* Qualificatifs de variables */
typedef enum _TypeQualifier
{
    TQF_NONE        = (0 << 0),             /* Néant                       */
    TQF_RESTRICT    = (1 << 0),             /* restrict (C99)              */
    TQF_VOLATILE    = (1 << 1),             /* volatile                    */
    TQF_CONST       = (1 << 2)              /* const                       */

} TypeQualifier;


/* Indique le type défini pour un type quelconque. */
GType g_data_type_get_type(void);

/* Crée un copie d'un type existant. */
GDataType *g_data_type_dup(const GDataType *);

/* Définit le groupe d'appartenance d'un type donné. */
void g_data_type_set_namespace(GDataType *, GDataType *);

/* Décrit le type fourni sous forme de caractères. */
char *_g_data_type_to_string(const GDataType *, bool);

#define g_data_type_to_string(t) _g_data_type_to_string((t), true)

/* Ajoute un qualificatif à une instance de type. */
void g_data_type_add_qualifier(GDataType *, TypeQualifier);

/* Indique la terminaison de la représentation du type. */
bool g_data_type_is_pointer(const GDataType *, bool);

/* Procède à l'impression de la description d'un type. */
void g_data_type_output(const GDataType *, GLangOutput *, GBufferLine *, bool, bool);



/* -------------------------- COLLECTE ET GESTION DE TYPES -------------------------- */


#define G_TYPE_TYPES_MANAGER               g_types_manager_get_type()
#define G_TYPES_MANAGER(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), g_types_manager_get_type(), GTypesManager))
#define G_IS_TYPES_MANAGER(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_types_manager_get_type()))
#define G_TYPES_MANAGER_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_TYPES_MANAGER, GTypesManagerClass))
#define G_IS_TYPES_MANAGER_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_TYPES_MANAGER))
#define G_TYPES_MANAGER_GET_CLASS(obj)     (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_TYPES_MANAGER, GTypesManagerClass))


/* Description d'un gestionnaire de types (instance) */
typedef struct _GTypesManager GTypesManager;

/* Description d'un gestionnaire de types (classe) */
typedef struct _GTypesManagerClass GTypesManagerClass;


/* Indique le type défini pour un gestionnaire de types. */
GType g_types_manager_get_type(void);





#endif  /* _ANALYSIS_TYPE_H */