diff options
Diffstat (limited to 'src/decomp/expr/immediate.c')
-rw-r--r-- | src/decomp/expr/immediate.c | 150 |
1 files changed, 150 insertions, 0 deletions
diff --git a/src/decomp/expr/immediate.c b/src/decomp/expr/immediate.c new file mode 100644 index 0000000..a97c8bd --- /dev/null +++ b/src/decomp/expr/immediate.c @@ -0,0 +1,150 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * immediate.c - raccord avec les opérandes de valeur immédiate + * + * Copyright (C) 2010 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 "immediate.h" + + +#include "../expression-int.h" + + + +/* Définition d'une expression de valeur immédiate (instance) */ +struct _GImmExpression +{ + GDecExpression parent; /* A laisser en premier */ + + GImmOperand *operand; /* Conteneur d'origine */ + +}; + + +/* Définition d'une expression de valeur immédiate (classe) */ +struct _GImmExpressionClass +{ + GDecExpressionClass parent; /* A laisser en premier */ + +}; + + + +/* Initialise la classe des expressions de valeur immédiate. */ +static void g_imm_expression_class_init(GImmExpressionClass *); + +/* Initialise une instance d'expression de valeur immédiate. */ +static void g_imm_expression_init(GImmExpression *); + +/* Imprime pour l'écran un version humaine d'une expression. */ +static void g_imm_expression_print(const GImmExpression *, GCodeBuffer *, GBufferLine *, GLangOutput *); + + + +/* Indique le type défini pour une expression de valeur immédiate. */ +G_DEFINE_TYPE(GImmExpression, g_imm_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_imm_expression_class_init(GImmExpressionClass *klass) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : expr = instance à initialiser. * +* * +* Description : Initialise une instance d'expression de valeur immédiate. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_imm_expression_init(GImmExpression *expr) +{ + GDecInstruction *instr; /* Autre version de l'objet */ + + instr = G_DEC_INSTRUCTION(expr); + + instr->print = (dec_instr_print_fc)g_imm_expression_print; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = conteneur d'origie de la valeur immédiate. * +* * +* Description : Construit une expression à partir d'une valeur immédiate. * +* * +* Retour : Expression mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GDecInstruction *g_imm_expression_new(GImmOperand *operand) +{ + GImmExpression *result; /* Expression à retourner */ + + result = g_object_new(G_TYPE_IMM_EXPRESSION, NULL); + + result->operand = operand; + + 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_imm_expression_print(const GImmExpression *expr, GCodeBuffer *buffer, GBufferLine *line, GLangOutput *output) +{ + g_arch_operand_print(G_ARCH_OPERAND(expr->operand), line, ASX_COUNT); + +} |