summaryrefslogtreecommitdiff
path: root/src/decomp/context.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2012-07-29 21:41:52 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2012-07-29 21:41:52 (GMT)
commit8e1f2335773a9025cd46d45a33261725707af3ba (patch)
tree6001a1095985514bbde3c8ec49b4dd5d32182fc8 /src/decomp/context.c
parent8b35a66464636d0c46237af7490a6ca6866ecc4d (diff)
Updated all decompiled instructions using right pseudo registers.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@253 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/decomp/context.c')
-rw-r--r--src/decomp/context.c54
1 files changed, 5 insertions, 49 deletions
diff --git a/src/decomp/context.c b/src/decomp/context.c
index 15215eb..9db0bca 100644
--- a/src/decomp/context.c
+++ b/src/decomp/context.c
@@ -27,39 +27,13 @@
#include <malloc.h>
+#include "context-int.h"
#include "instruction-int.h"
-#include "expr/pseudo.h"
#include "../arch/operand.h"
-#include "../glibext/gnhash.h"
+#include "../format/dex/method.h"
-/* Définition d'une context décompilée (instance) */
-struct _GDecContext
-{
- GObject parent; /* A laisser en premier */
-
- vmpa_t max; /* Première adresse à écarter */
-
- GDecInstruction *list; /* Chaîne décompilée */
-
- GHashTable *machine; /* Correspondance reg./pseudo */
- GHashTable *ssa; /* Remplacement des pseudos */
-
- GDecInstruction **pseudos; /* Liste des pseudos-registre */
- size_t count; /* Taille de cette liste */
-
-};
-
-
-/* Définition d'une context décompilée (classe) */
-struct _GDecContextClass
-{
- GObjectClass parent; /* A laisser en premier */
-
-};
-
-
/* Initialise la classe des contextes de décompilation. */
static void g_dec_context_class_init(GDecContextClass *);
@@ -216,6 +190,7 @@ void g_dec_context_set_decomp_instrs(GDecContext *ctx, GDecInstruction *instr)
* *
* Paramètres : ctx = instance à consulter, voire mettre à jour. *
* operand = opérande représentant un registre quelconque. *
+* assign = précise le sort prochain du registre. *
* *
* Description : Convertit un registre machine en un pseudo-registre. *
* *
@@ -225,27 +200,8 @@ void g_dec_context_set_decomp_instrs(GDecContext *ctx, GDecInstruction *instr)
* *
******************************************************************************/
-GDecInstruction *g_dec_context_convert_register(GDecContext *ctx, gpointer operand)
+GDecInstruction *g_dec_context_convert_register(GDecContext *ctx, gpointer operand, bool assign)
{
- GDecInstruction *result; /* Instance à retourner */
- gpointer *found; /* Pseudo-registre trouvé */
-
- found = g_hash_table_lookup(ctx->machine, operand);
-
- if (found != NULL) result = G_DEC_INSTRUCTION(found);
- else
- {
- result = g_pseudo_register_new();
- g_pseudo_register_set_index(G_PSEUDO_REGISTER(result), ctx->count);
-
- g_hash_table_insert(ctx->machine, operand, result);
-
- ctx->pseudos = (GDecInstruction **)realloc(ctx->pseudos,
- ++ctx->count * sizeof(GDecInstruction *));
- ctx->pseudos[ctx->count - 1] = result;
-
- }
-
- return result;
+ return ctx->convert_reg(ctx, operand, assign);
}