summaryrefslogtreecommitdiff
path: root/tools/d2c/coder.h
blob: 70a886da6041b64f313d0fe537215e4d057875ea (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147

/* Chrysalide - Outil d'analyse de fichiers binaires
 * coder.h - prototypes pour la lecture automatisée des spécifications d'architecture
 *
 * Copyright (C) 2014 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 _TOOLS_D2C_CODER_H
#define _TOOLS_D2C_CODER_H


#include <stdbool.h>


#include "pproc.h"
#include "spec.h"



/* Suivi des constructions */
typedef struct _rented_coder rented_coder;



/* -------------------------- CONSTRUCTION SELON COMMANDES -------------------------- */


/* Type d'entrée/sortie attendues */
typedef enum _InputOutputType
{
    IOT_UNDEFINED,                          /* Type non défini             */
    IOT_RAW,                                /* Lecture de contenu brut     */
    IOT_FORMAT                              /* Définition d'opérandes      */

} InputOutputType;


/* Débute la définition d'une fonction de désassemblage. */
rented_coder *create_coder(void);

/* Supprime le codeur de la mémoire. */
void delete_coder(rented_coder *);

/* Détermine si les propriétés de base d'un codeur sont là. */
bool do_basic_checks_with_coder(const rented_coder *);

/* Indique le fichier de définition considéré en entrée. */
const char *get_coder_input_file(const rented_coder *);

/* Spécifie le fichier de définition à prendre en entrée. */
void set_coder_input_file(rented_coder *, const char *);

/* Spécifie le type de format à prendre en compte (E/S). */
void set_coder_input_type(rented_coder *, InputOutputType);

/* Spécifie le répertoire de base pour les sorties de code. */
void set_coder_output_directory(rented_coder *, const char *);

/* Détermine l'architecture visée par les traitements. */
void set_coder_arch(rented_coder *, const char *);

/* Définit la base des protections des fichiers d'en-tête. */
void set_coder_header_base(rented_coder *, const char *);

/* Définit le préfixe pour les opérandes chargées par format. */
void set_coder_const_prefix(rented_coder *, const char *);

/* Fournit le pré-processeur du compilateur. */
pre_processor *get_coder_pre_proc(const rented_coder *);

/* Enregistre les contours d'une instruction d'assemblage. */
void save_notes_for_coder(rented_coder *, char *, char *, char, const char *);



/* --------------------------- REPRESENTATION D'ENCODAGES --------------------------- */


/* Fournit un lien vers les spécifications courantes. */
encoding_spec *get_current_encoding_spec(const rented_coder *);

/* Enregistre une définition supplémentaire. */
void push_encoding_spec(rented_coder *, char *, unsigned int);



/* --------------------------- GESTION DES CHAMPS DE BITS --------------------------- */


/* Note la présence d'un champ remarquable dans une définition. */
void register_named_field_in_coder(rented_coder *, char *, unsigned int);

/* Note la présence d'un bit invariable dans une définition. */
void register_bit_in_coder(rented_coder *, int);

/* Indique le nombre de bits traités. */
//unsigned int count_coder_bits(const rented_coder *);



/* ---------------------------- SYNTAXE DES INSTRUCTIONS ---------------------------- */


/* Enregistre la présence d'un nouvel opérande. */
void register_syntax_item_in_coder(rented_coder *, char *, bool);



/* ---------------------------- CONVERSION DES ARGUMENTS ---------------------------- */


/* Enregistre la function de conversion du brut à l'utile. */
void register_conversion_in_coder(rented_coder *, conv_func *);



/* --------------------------- CONDITIONS ET CONSEQUENCES --------------------------- */





/* --------------------------- GENERATIONS DE CODE SOURCE --------------------------- */


/* Débute la définition des fonctions issues des spécifications. */
bool dump_all_routines_using_coder(const rented_coder *);



#endif  /* _TOOLS_D2C_CODER_H */