/* Chrysalide - 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 Chrysalide. * * 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 . */ #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; }