diff options
| author | Cyrille Bagard <nocbos@gmail.com> | 2016-02-10 12:09:38 (GMT) | 
|---|---|---|
| committer | Cyrille Bagard <nocbos@gmail.com> | 2016-02-10 12:09:38 (GMT) | 
| commit | dbd5e7fdfd43fba609fce3fafdcd38d704554d99 (patch) | |
| tree | 5811a602d34993598eeea5ea56b1efc3b93f9c63 /tools/d2c/format/manager.c | |
| parent | 465488d5b231c2552116a305c48b5fcccea55a09 (diff) | |
Included indications to load the proper pool constants in Dalvik operands.
Diffstat (limited to 'tools/d2c/format/manager.c')
| -rw-r--r-- | tools/d2c/format/manager.c | 37 | 
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");  | 
