summaryrefslogtreecommitdiff
path: root/tools/d2c/format/manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/d2c/format/manager.c')
-rw-r--r--tools/d2c/format/manager.c37
1 files changed, 27 insertions, 10 deletions
diff --git a/tools/d2c/format/manager.c b/tools/d2c/format/manager.c
index 070b70c..a799af9 100644
--- a/tools/d2c/format/manager.c
+++ b/tools/d2c/format/manager.c
@@ -34,7 +34,8 @@
/* Mémorisation de la définition d'opérandes */
struct _operands_format
{
- char *type; /* Définitions des opérandes */
+ char **types; /* Définitions des opérandes */
+ size_t count; /* Quantité de définitions */
};
@@ -77,8 +78,13 @@ operands_format *create_operands_format(void)
void delete_operands_format(operands_format *format)
{
- if (format->type != NULL)
- free(format->type);
+ size_t i; /* Boucle de parcours */
+
+ for (i = 0; i < format->count; i++)
+ free(format->types[i]);
+
+ if (format->types != NULL)
+ free(format->types);
free(format);
@@ -98,12 +104,11 @@ void delete_operands_format(operands_format *format)
* *
******************************************************************************/
-void set_operands_format_type(operands_format *format, char *type)
+void add_operands_format_type(operands_format *format, char *type)
{
- if (format->type != NULL)
- free(format->type);
+ format->types = (char **)realloc(format->types, ++format->count * sizeof(char *));
- format->type = make_string_upper(type);
+ format->types[format->count - 1] = make_string_upper(type);
}
@@ -126,7 +131,9 @@ void set_operands_format_type(operands_format *format, char *type)
bool define_operands_loading(const operands_format *format, int fd, const char *arch, const char *prefix, bool *exit)
{
- if (format->type == NULL)
+ size_t i; /* Boucle de parcours */
+
+ if (format->count == 0)
{
fprintf(stderr, "Error: no type defined for operands.\n");
return false;
@@ -134,8 +141,18 @@ bool define_operands_loading(const operands_format *format, int fd, const char *
*exit = true;
- dprintf(fd, "\tif (!%s_read_operands(result, format, content, pos, endian, %s%s))\n",
- arch, prefix, format->type);
+ dprintf(fd, "\tif (!%s_read_operands(result, format, content, pos, endian, ", arch);
+
+ for (i = 0; i < format->count; i++)
+ {
+ if (i > 0)
+ dprintf(fd, " | ");
+
+ dprintf(fd, "%s%s", prefix, format->types[i]);
+
+ }
+
+ dprintf(fd, "))\n");
dprintf(fd, "\t\tgoto bad_exit;\n");
dprintf(fd, "\n");