summaryrefslogtreecommitdiff
path: root/src/decomp
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2013-02-02 18:51:02 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2013-02-02 18:51:02 (GMT)
commit5b89c8369d2a26089f22be7c482e8254244ebc8c (patch)
treefdd7a23a256a0841f0d0d32a0ce33ceeb54e671e /src/decomp
parent0936f64aac6a4fa9ebc08962bc9cac663f210c00 (diff)
Closed some switch cases with a 'break' keyword.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@336 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/decomp')
-rw-r--r--src/decomp/instr/Makefile.am1
-rw-r--r--src/decomp/instr/keyword.c162
-rw-r--r--src/decomp/instr/keyword.h68
-rw-r--r--src/decomp/instr/switch.c11
4 files changed, 237 insertions, 5 deletions
diff --git a/src/decomp/instr/Makefile.am b/src/decomp/instr/Makefile.am
index 6120cac..d299cd2 100644
--- a/src/decomp/instr/Makefile.am
+++ b/src/decomp/instr/Makefile.am
@@ -3,6 +3,7 @@ noinst_LTLIBRARIES = libdecompinstr.la
libdecompinstr_la_SOURCES = \
ite.h ite.c \
+ keyword.h keyword.c \
switch.h switch.c
libdecompinstr_la_LDFLAGS =
diff --git a/src/decomp/instr/keyword.c b/src/decomp/instr/keyword.c
new file mode 100644
index 0000000..eca1530
--- /dev/null
+++ b/src/decomp/instr/keyword.c
@@ -0,0 +1,162 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * keyword.c - insertions de mots clefs de haut niveau
+ *
+ * Copyright (C) 2013 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA 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.
+ *
+ * OpenIDA 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/>.
+ */
+
+
+#include "keyword.h"
+
+
+#include "../instruction-int.h"
+
+
+
+/* Définition d'un mot clef de haut niveau (instance) */
+struct _GKeywordInstruction
+{
+ GDecInstruction parent; /* A laisser en premier */
+
+ DecompiledKeyWord keyword; /* Mot clef représenté */
+
+};
+
+
+/* Indique le type défini pour un mot clef de haut niveau. */
+struct _GKeywordInstructionClass
+{
+ GDecInstructionClass parent; /* A laisser en premier */
+
+};
+
+
+
+/* Initialise la classe des mots clefs de haut niveau. */
+static void g_keyword_instruction_class_init(GKeywordInstructionClass *);
+
+/* Initialise une instance de mot clef de haut niveau. */
+static void g_keyword_instruction_init(GKeywordInstruction *);
+
+/* Imprime pour l'écran un version humaine d'une instruction. */
+static GBufferLine *g_keyword_instruction_print(const GKeywordInstruction *, GCodeBuffer *, GBufferLine *, GLangOutput *);
+
+
+
+/* Indique le type défini pour un mot clef de haut niveau. */
+G_DEFINE_TYPE(GKeywordInstruction, g_keyword_instruction, G_TYPE_DEC_INSTRUCTION);
+
+
+/******************************************************************************
+* *
+* Paramètres : klass = classe à initialiser. *
+* *
+* Description : Initialise la classe des mots clefs de haut niveau. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_keyword_instruction_class_init(GKeywordInstructionClass *klass)
+{
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instance à initialiser. *
+* *
+* Description : Initialise une instance de mot clef de haut niveau. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_keyword_instruction_init(GKeywordInstruction *instr)
+{
+ GDecInstruction *base; /* Autre version de l'objet */
+
+ base = G_DEC_INSTRUCTION(instr);
+
+ base->print = (dec_instr_print_fc)g_keyword_instruction_print;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : keyword = mot clef à représenter. *
+* *
+* Description : Crée un mot clef de haut niveau. *
+* *
+* Retour : Instruction mise en place. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GDecInstruction *g_keyword_instruction_new(DecompiledKeyWord keyword)
+{
+ GKeywordInstruction *result; /* Expression à retourner */
+
+ result = g_object_new(G_TYPE_KEYWORD_INSTRUCTION, NULL);
+
+ result->keyword = keyword;
+
+ return G_DEC_INSTRUCTION(result);
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : instr = instruction à transcrire en version humaine. *
+* buffer = tampon où doit se réaliser l'insertion. *
+* line = ligne d'impression prête à emploi ou NULL. *
+* output = langage de programmation de sortie. *
+* *
+* Description : Imprime pour l'écran un version humaine d'une instruction. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static GBufferLine *g_keyword_instruction_print(const GKeywordInstruction *instr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output)
+{
+ switch (instr->keyword)
+ {
+ case DKW_BREAK:
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "break", 5, RTT_KEY_WORD);
+ break;
+
+ case DKW_CONTINUE:
+ g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "continue", 8, RTT_KEY_WORD);
+ break;
+
+ }
+
+ return line;
+
+}
diff --git a/src/decomp/instr/keyword.h b/src/decomp/instr/keyword.h
new file mode 100644
index 0000000..69d6901
--- /dev/null
+++ b/src/decomp/instr/keyword.h
@@ -0,0 +1,68 @@
+
+/* OpenIDA - Outil d'analyse de fichiers binaires
+ * keyword.h - prototypes pour les insertions de mots clefs de haut niveau
+ *
+ * Copyright (C) 2013 Cyrille Bagard
+ *
+ * This file is part of OpenIDA.
+ *
+ * OpenIDA 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.
+ *
+ * OpenIDA 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 _DECOMP_INSTR_KEYWORD_H
+#define _DECOMP_INSTR_KEYWORD_H
+
+
+#include <glib-object.h>
+
+
+#include "../instruction.h"
+
+
+
+#define G_TYPE_KEYWORD_INSTRUCTION g_keyword_instruction_get_type()
+#define G_KEYWORD_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_keyword_instruction_get_type(), GKeywordInstruction))
+#define G_IS_KEYWORD_INSTRUCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_keyword_instruction_get_type()))
+#define G_KEYWORD_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_KEYWORD_INSTRUCTION, GKeywordInstructionClass))
+#define G_IS_KEYWORD_INSTRUCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_KEYWORD_INSTRUCTION))
+#define G_KEYWORD_INSTRUCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_KEYWORD_INSTRUCTION, GKeywordInstructionClass))
+
+
+
+/* Type de mots clefs pris en charge */
+typedef enum _DecompiledKeyWord
+{
+ DKW_BREAK, /* 'break' */
+ DKW_CONTINUE, /* 'continue' */
+
+} DecompiledKeyWord;
+
+
+/* Définition d'un mot clef de haut niveau (instance) */
+typedef struct _GKeywordInstruction GKeywordInstruction;
+
+/* Définition d'un mot clef de haut niveau (classe) */
+typedef struct _GKeywordInstructionClass GKeywordInstructionClass;
+
+
+/* Indique le type défini pour un mot clef de haut niveau. */
+GType g_keyword_instruction_get_type(void);
+
+/* Crée un mot clef de haut niveau. */
+GDecInstruction *g_keyword_instruction_new(DecompiledKeyWord);
+
+
+
+#endif /* _DECOMP_INSTR_KEYWORD_H */
diff --git a/src/decomp/instr/switch.c b/src/decomp/instr/switch.c
index 3c204a0..4b1662b 100644
--- a/src/decomp/instr/switch.c
+++ b/src/decomp/instr/switch.c
@@ -31,15 +31,16 @@
#include "../instruction-int.h"
+
/* Détails d'un cas */
typedef struct _case_info
{
- vmpa_t addr; /* Adresse des blocs associés */
+ vmpa_t addr; /* Adresse des blocs associés */
- GDecExpression **values; /* Valeur d'embranchement */
- size_t values_count; /* Quantité de cas rassemblés */
+ GDecExpression **values; /* Valeur d'embranchement */
+ size_t values_count; /* Quantité de cas rassemblés */
- GDecInstruction *instrs; /* Instructions du cas */
+ GDecInstruction *instrs; /* Instructions du cas */
} case_info;
@@ -138,7 +139,7 @@ static void g_switch_instruction_init(GSwitchInstruction *instr)
* *
* Description : Exprime un aiguillage multiple du flux selon une valeur. *
* *
-* Retour : Expression mise en place. *
+* Retour : Instruction mise en place. *
* *
* Remarques : - *
* *