diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-07-23 19:07:29 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-07-23 19:07:29 (GMT) |
commit | 8b35a66464636d0c46237af7490a6ca6866ecc4d (patch) | |
tree | 92199b36e3af00eb4c175a80c20b9b14511a6a45 /src/decomp/expr/text.c | |
parent | 8b2189a819c7a761cfdb97d9e3382ea963f225fb (diff) |
Improved decompilation of Dalvik bytecode.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@252 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/decomp/expr/text.c')
-rw-r--r-- | src/decomp/expr/text.c | 157 |
1 files changed, 157 insertions, 0 deletions
diff --git a/src/decomp/expr/text.c b/src/decomp/expr/text.c new file mode 100644 index 0000000..d62e689 --- /dev/null +++ b/src/decomp/expr/text.c @@ -0,0 +1,157 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * text.c - raccord avec les opérandes de chaînes de caractères + * + * Copyright (C) 2012 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 "text.h" + + +#include <string.h> + + +#include "../expression-int.h" + + + +/* Définition d'une expression de valeur immédiate (instance) */ +struct _GStrExpression +{ + GDecExpression parent; /* A laisser en premier */ + + char *value; /* Chaîne représentée */ + size_t len; /* Taille du texte */ + +}; + + +/* Définition d'une expression de valeur immédiate (classe) */ +struct _GStrExpressionClass +{ + GDecExpressionClass parent; /* A laisser en premier */ + +}; + + + +/* Initialise la classe des expressions de valeur immédiate. */ +static void g_str_expression_class_init(GStrExpressionClass *); + +/* Initialise une instance d'expression de valeur immédiate. */ +static void g_str_expression_init(GStrExpression *); + +/* Imprime pour l'écran un version humaine d'une expression. */ +static void g_str_expression_print(const GStrExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *); + + + +/* Indique le type défini pour une expression de valeur immédiate. */ +G_DEFINE_TYPE(GStrExpression, g_str_expression, G_TYPE_DEC_EXPRESSION); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des expressions de valeur immédiate. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_str_expression_class_init(GStrExpressionClass *klass) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : expr = instance à initialiser. * +* * +* Description : Initialise une instance d'expression de valeur immédiate. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_str_expression_init(GStrExpression *expr) +{ + GDecInstruction *instr; /* Autre version de l'objet */ + + instr = G_DEC_INSTRUCTION(expr); + + instr->print = (dec_instr_print_fc)g_str_expression_print; + +} + + +/****************************************************************************** +* * +* Paramètres : value = chaîne de caractères à représenter. * +* * +* Description : Construit une expression à partir d'une valeur immédiate. * +* * +* Retour : Expression mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GDecInstruction *g_str_expression_new(const char *value) +{ + GStrExpression *result; /* Expression à retourner */ + + result = g_object_new(G_TYPE_STR_EXPRESSION, NULL); + + result->value = strdup(value); + result->len = strlen(value); + + return G_DEC_INSTRUCTION(result); + +} + + +/****************************************************************************** +* * +* Paramètres : expr = expression à 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 expression. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_str_expression_print(const GStrExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output) +{ + g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "\"", 1, RTT_STRING); + g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, expr->value, expr->len, RTT_STRING); + g_buffer_line_insert_text(line, BLC_ASSEMBLY_HEAD, "\"", 1, RTT_STRING); + +} |