summaryrefslogtreecommitdiff
path: root/src/decomp/expr
diff options
context:
space:
mode:
Diffstat (limited to 'src/decomp/expr')
-rw-r--r--src/decomp/expr/access.c6
-rw-r--r--src/decomp/expr/arithm.c6
-rw-r--r--src/decomp/expr/array.c6
-rw-r--r--src/decomp/expr/assign.c10
-rw-r--r--src/decomp/expr/assign.h4
-rw-r--r--src/decomp/expr/block.c41
-rw-r--r--src/decomp/expr/block.h3
-rw-r--r--src/decomp/expr/call.c3
-rw-r--r--src/decomp/expr/cond.c6
-rw-r--r--src/decomp/expr/pseudo.c27
-rw-r--r--src/decomp/expr/pseudo.h16
-rw-r--r--src/decomp/expr/return.c3
12 files changed, 111 insertions, 20 deletions
diff --git a/src/decomp/expr/access.c b/src/decomp/expr/access.c
index f06c47b..8afe635 100644
--- a/src/decomp/expr/access.c
+++ b/src/decomp/expr/access.c
@@ -158,10 +158,12 @@ static bool g_access_expression_visit(GAccessExpression *expr, dec_instr_visitor
{
bool result; /* Bilan à retourner */
- result = g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->owner), callback, flags, data);
+ result = _g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->owner), G_DEC_INSTRUCTION(expr),
+ callback, flags, data);
if (result)
- result = g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->target), callback, flags, data);
+ result = _g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->target), G_DEC_INSTRUCTION(expr),
+ callback, flags, data);
return result;
diff --git a/src/decomp/expr/arithm.c b/src/decomp/expr/arithm.c
index 3811cf4..e8a4c30 100644
--- a/src/decomp/expr/arithm.c
+++ b/src/decomp/expr/arithm.c
@@ -163,10 +163,12 @@ static bool g_arithm_expression_visit(GArithmExpression *expr, dec_instr_visitor
{
bool result; /* Bilan à retourner */
- result = g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->op1), callback, flags, data);
+ result = _g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->op1), G_DEC_INSTRUCTION(expr),
+ callback, flags, data);
if (result)
- result = g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->op2), callback, flags, data);
+ result = _g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->op2), G_DEC_INSTRUCTION(expr),
+ callback, flags, data);
return result;
diff --git a/src/decomp/expr/array.c b/src/decomp/expr/array.c
index 4053169..b2bb2f1 100644
--- a/src/decomp/expr/array.c
+++ b/src/decomp/expr/array.c
@@ -158,10 +158,12 @@ static bool g_array_access_visit(GArrayAccess *expr, dec_instr_visitor_cb callba
{
bool result; /* Bilan à retourner */
- result = g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->array), callback, flags, data);
+ result = _g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->array), G_DEC_INSTRUCTION(expr),
+ callback, flags, data);
if (result)
- result = g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->index), callback, flags, data);
+ result = _g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->index), G_DEC_INSTRUCTION(expr),
+ callback, flags, data);
return result;
diff --git a/src/decomp/expr/assign.c b/src/decomp/expr/assign.c
index 26d31f6..939407d 100644
--- a/src/decomp/expr/assign.c
+++ b/src/decomp/expr/assign.c
@@ -158,10 +158,12 @@ static bool g_assign_expression_visit(GAssignExpression *expr, dec_instr_visitor
{
bool result; /* Bilan à retourner */
- result = g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->dest), callback, flags, data);
+ result = _g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->dest), G_DEC_INSTRUCTION(expr),
+ callback, flags, data);
if (result)
- result = g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->src), callback, flags, data);
+ result = _g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->src), G_DEC_INSTRUCTION(expr),
+ callback, flags, data);
return result;
@@ -259,7 +261,7 @@ static GBufferLine *g_assign_expression_print(const GAssignExpression *expr, GCo
* *
******************************************************************************/
-GDecInstruction *g_assign_expression_get_dest(const GAssignExpression *assign)
+GDecExpression *g_assign_expression_get_dest(const GAssignExpression *assign)
{
return assign->dest;
@@ -278,7 +280,7 @@ GDecInstruction *g_assign_expression_get_dest(const GAssignExpression *assign)
* *
******************************************************************************/
-GDecInstruction *g_assign_expression_get_src(const GAssignExpression *assign)
+GDecExpression *g_assign_expression_get_src(const GAssignExpression *assign)
{
return assign->src;
diff --git a/src/decomp/expr/assign.h b/src/decomp/expr/assign.h
index ce441f6..b55853e 100644
--- a/src/decomp/expr/assign.h
+++ b/src/decomp/expr/assign.h
@@ -56,10 +56,10 @@ GType g_assign_expression_get_type(void);
GDecInstruction *g_assign_expression_new(GDecExpression *, GDecExpression *);
/* Indique la destination d'une assignation. */
-GDecInstruction *g_assign_expression_get_dest(const GAssignExpression *);
+GDecExpression *g_assign_expression_get_dest(const GAssignExpression *);
/* Indique la source d'une assignation. */
-GDecInstruction *g_assign_expression_get_src(const GAssignExpression *);
+GDecExpression *g_assign_expression_get_src(const GAssignExpression *);
diff --git a/src/decomp/expr/block.c b/src/decomp/expr/block.c
index 3c56ef6..b58972d 100644
--- a/src/decomp/expr/block.c
+++ b/src/decomp/expr/block.c
@@ -25,6 +25,7 @@
#include <malloc.h>
+#include <string.h>
#include "../expression-int.h"
@@ -163,7 +164,8 @@ static bool g_expr_block_visit(GExprBlock *block, dec_instr_visitor_cb callback,
result = true;
for (i = 0; i < block->count && result; i++)
- result = g_dec_instruction_visit(block->list[i], callback, flags, data);
+ result = _g_dec_instruction_visit(block->list[i], G_DEC_INSTRUCTION(block),
+ callback, flags, data);
return result;
@@ -270,3 +272,40 @@ void g_expr_block_add_item(GExprBlock *block, GDecInstruction *item)
block->list[block->count - 1] = item;
}
+
+
+/******************************************************************************
+* *
+* Paramètres : block = ensemble à faire évoluer. *
+* item = nouvel élément à retirer de l'ensemble. *
+* *
+* Description : Supprime une instruction décompilée du conteneur existant. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void g_expr_block_delete_item(GExprBlock *block, GDecInstruction *item)
+{
+ size_t i; /* Boucle de parcours */
+
+ for (i = 0; i < block->count; i++)
+ if (block->list[i] == item)
+ break;
+
+ if (i < block->count)
+ {
+ if ((i + 1) < block->count)
+ memmove(&block->list[i], &block->list[i + 1],
+ (block->count - i - 1) * sizeof(GDecInstruction *));
+
+ block->list = (GDecInstruction **)realloc(block->list,
+ --block->count * sizeof(GDecInstruction *));
+
+ g_object_unref(G_OBJECT(item));
+
+ }
+
+}
diff --git a/src/decomp/expr/block.h b/src/decomp/expr/block.h
index 4ae4ff1..b0c2baa 100644
--- a/src/decomp/expr/block.h
+++ b/src/decomp/expr/block.h
@@ -57,6 +57,9 @@ GDecInstruction *g_expr_block_new(GDecInstruction *);
/* Ajoute une instruction décompilée au conteneur existant. */
void g_expr_block_add_item(GExprBlock *, GDecInstruction *);
+/* Supprime une instruction décompilée du conteneur existant. */
+void g_expr_block_delete_item(GExprBlock *, GDecInstruction *);
+
#endif /* _DECOMP_EXPR_BLOCK_H */
diff --git a/src/decomp/expr/call.c b/src/decomp/expr/call.c
index ed1c43a..9aad9c0 100644
--- a/src/decomp/expr/call.c
+++ b/src/decomp/expr/call.c
@@ -166,7 +166,8 @@ static bool g_routine_call_visit(GRoutineCall *call, dec_instr_visitor_cb callba
result = true;
for (i = 0; i < call->count && result; i++)
- result = g_dec_instruction_visit(call->args[i], callback, flags, data);
+ result = _g_dec_instruction_visit(call->args[i], G_DEC_INSTRUCTION(call),
+ callback, flags, data);
return result;
diff --git a/src/decomp/expr/cond.c b/src/decomp/expr/cond.c
index d96f483..fab2c17 100644
--- a/src/decomp/expr/cond.c
+++ b/src/decomp/expr/cond.c
@@ -161,10 +161,12 @@ static bool g_cond_expression_visit(GCondExpression *expr, dec_instr_visitor_cb
{
bool result; /* Bilan à retourner */
- result = g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->a), callback, flags, data);
+ result = _g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->a), G_DEC_INSTRUCTION(expr),
+ callback, flags, data);
if (result)
- result = g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->b), callback, flags, data);
+ result = _g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->b), G_DEC_INSTRUCTION(expr),
+ callback, flags, data);
return result;
diff --git a/src/decomp/expr/pseudo.c b/src/decomp/expr/pseudo.c
index 9da76e7..7c7ba71 100644
--- a/src/decomp/expr/pseudo.c
+++ b/src/decomp/expr/pseudo.c
@@ -38,6 +38,8 @@ struct _GPseudoRegister
{
GDecExpression parent; /* A laisser en premier */
+ PseudoRegUsage usage; /* Type d'utilisation attendue */
+
char *name; /* Désignation générale */
size_t index; /* Position dans l'ensemble */
GBinVariable *var; /* Variable plus précise */
@@ -112,7 +114,7 @@ static void g_pseudo_register_init(GPseudoRegister *reg)
/******************************************************************************
* *
-* Paramètres : - *
+* Paramètres : usage = précision quant à l'usage du pseudo-registre à créer.*
* *
* Description : Assigne le contenu d'une expression dans une autre. *
* *
@@ -122,12 +124,14 @@ static void g_pseudo_register_init(GPseudoRegister *reg)
* *
******************************************************************************/
-GDecInstruction *g_pseudo_register_new(void)
+GDecInstruction *g_pseudo_register_new(PseudoRegUsage usage)
{
GPseudoRegister *result; /* Pseudo-registre à renvoyer */
result = g_object_new(G_TYPE_PSEUDO_REGISTER, NULL);
+ result->usage = usage;
+
return G_DEC_INSTRUCTION(result);
}
@@ -135,6 +139,25 @@ GDecInstruction *g_pseudo_register_new(void)
/******************************************************************************
* *
+* Paramètres : reg = pseudo-registre à venir consulter. *
+* *
+* Description : Indique l'usage attendu du pseudo-registre consulté. *
+* *
+* Retour : Utilité du pseudo-registre en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PseudoRegUsage g_pseudo_register_get_usage(const GPseudoRegister *reg)
+{
+ return reg->usage;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : reg = expression à transcrire en version humaine. *
* buffer = tampon où doit se réaliser l'insertion. *
* line = ligne d'impression prête à emploi ou NULL. *
diff --git a/src/decomp/expr/pseudo.h b/src/decomp/expr/pseudo.h
index a465b41..e7f3b00 100644
--- a/src/decomp/expr/pseudo.h
+++ b/src/decomp/expr/pseudo.h
@@ -42,6 +42,17 @@
+/* Types de pseudo-registre */
+typedef enum _PseudoRegUsage
+{
+ PRU_THIS, /* "this" pour les objets */
+ PRU_ARG, /* Argument de fonction */
+ PRU_LOCAL, /* Variable locale */
+ PRU_FIXED /* Variable type champ */
+
+} PseudoRegUsage;
+
+
/* Définition d'un pseudo-registre (instance) */
typedef struct _GPseudoRegister GPseudoRegister;
@@ -53,7 +64,10 @@ typedef struct _GPseudoRegisterClass GPseudoRegisterClass;
GType g_pseudo_register_get_type(void);
/* Assigne le contenu d'une expression dans une autre. */
-GDecInstruction *g_pseudo_register_new(void);
+GDecInstruction *g_pseudo_register_new(PseudoRegUsage);
+
+/* Indique l'usage attendu du pseudo-registre consulté. */
+PseudoRegUsage g_pseudo_register_get_usage(const GPseudoRegister *);
/* Définit un nom général pour un pseudo-registre donné. */
void g_pseudo_register_set_basename(GPseudoRegister *, const char *);
diff --git a/src/decomp/expr/return.c b/src/decomp/expr/return.c
index d012893..65fd641 100644
--- a/src/decomp/expr/return.c
+++ b/src/decomp/expr/return.c
@@ -156,7 +156,8 @@ static bool g_return_expression_visit(GReturnExpression *expr, dec_instr_visitor
bool result; /* Bilan à retourner */
if (expr->payload)
- result = g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->payload), callback, flags, data);
+ result = _g_dec_instruction_visit(G_DEC_INSTRUCTION(expr->payload), G_DEC_INSTRUCTION(expr),
+ callback, flags, data);
else
result = false;