diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-05-21 16:48:11 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-05-21 16:48:11 (GMT) |
commit | acd355c4c5ae25fb9cac64b8dc17407a2bcc979b (patch) | |
tree | d5b43201049116cd9734ff554e61ed8a7e0084cc /src/arch/dalvik/operands/register.c | |
parent | 4691a434a34a19317156a761967f719e408b73bb (diff) |
Refined the whole share system for operands.
Diffstat (limited to 'src/arch/dalvik/operands/register.c')
-rw-r--r-- | src/arch/dalvik/operands/register.c | 194 |
1 files changed, 123 insertions, 71 deletions
diff --git a/src/arch/dalvik/operands/register.c b/src/arch/dalvik/operands/register.c index b415d3f..cf29455 100644 --- a/src/arch/dalvik/operands/register.c +++ b/src/arch/dalvik/operands/register.c @@ -65,10 +65,13 @@ static void g_dalvik_register_operand_dispose(GDalvikRegisterOperand *); static void g_dalvik_register_operand_finalize(GDalvikRegisterOperand *); /* Initialise un nouvel objet partagé avec des informations. */ -static bool g_dalvik_register_operand_do_init(GDalvikRegisterOperand *, const GDalvikRegisterOperand *); +static bool g_dalvik_register_operand_apply_template(GDalvikRegisterOperand *, const GDalvikRegisterOperand *); + +/* Réalise une copie minimale d'un contenu partagé. */ +static void g_dalvik_register_operand_define_template(const GDalvikRegisterOperand *, GDalvikRegisterOperand *); /* Compare un opérande avec un autre. */ -static int g_dalvik_register_operand_compare(const GDalvikRegisterOperand * const *, const GDalvikRegisterOperand * const *); +static int g_dalvik_register_operand_compare(const GDalvikRegisterOperand *, const GDalvikRegisterOperand *); /* Traduit un opérande en version humainement lisible. */ static void g_dalvik_register_operand_print(const GDalvikRegisterOperand *, GBufferLine *, AsmSyntax); @@ -82,6 +85,10 @@ static void g_dalvik_register_operand_print(const GDalvikRegisterOperand *, GBuf static GShareManager *_dalvik_register_operand_manager = NULL; +/* Fournit le gestionnaire de partages attribué à un type. */ +static GShareManager *get_dalvik_register_operand_share_manager(void); + + /* ---------------------------------------------------------------------------------- */ /* MANIPULATION D'OPERANDES INDIVIDUELLES */ @@ -116,7 +123,11 @@ static void g_dalvik_register_operand_class_init(GDalvikRegisterOperandClass *kl operand = G_ARCH_OPERAND_CLASS(klass); - operand->init = (operand_do_init_fc)g_dalvik_register_operand_do_init; + operand->get_manager = (get_operand_manager_fc)get_dalvik_register_operand_share_manager; + + operand->apply_template = (apply_operand_template_fc)g_dalvik_register_operand_apply_template; + operand->define_template = (define_operand_template_fc)g_dalvik_register_operand_define_template; + operand->free_template = (free_operand_template_fc)NULL; operand->compare = (operand_compare_fc)g_dalvik_register_operand_compare; operand->print = (operand_print_fc)g_dalvik_register_operand_print; @@ -183,6 +194,95 @@ static void g_dalvik_register_operand_finalize(GDalvikRegisterOperand *operand) /****************************************************************************** * * +* Paramètres : operand = objet partagé à initialiser. * +* template = information à utiliser pour la mise en place. * +* * +* Description : Initialise un nouvel objet partagé avec des informations. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_dalvik_register_operand_apply_template(GDalvikRegisterOperand *operand, const GDalvikRegisterOperand *template) +{ + g_dalvik_register_operand_define_template(template, operand); + + g_object_ref(G_OBJECT(operand->reg)); + + return true; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = objet partagé à consulter. * +* template = informations à retrouver intégralement. * +* * +* Description : Réalise une copie minimale d'un contenu partagé. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_dalvik_register_operand_define_template(const GDalvikRegisterOperand *operand, GDalvikRegisterOperand *template) +{ + template->reg = operand->reg; + +} + + +/****************************************************************************** +* * +* Paramètres : a = premier opérande à consulter. * +* b = second opérande à consulter. * +* * +* Description : Compare un opérande avec un autre. * +* * +* Retour : Bilan de la comparaison. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static int g_dalvik_register_operand_compare(const GDalvikRegisterOperand *a, const GDalvikRegisterOperand *b) +{ + int result; /* Bilan à retourner */ + + result = g_dalvik_register_compare(a->reg, b->reg); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande à traiter. * +* line = ligne tampon où imprimer l'opérande donné. * +* syntax = type de représentation demandée. * +* * +* Description : Traduit un opérande en version humainement lisible. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_dalvik_register_operand_print(const GDalvikRegisterOperand *operand, GBufferLine *line, AsmSyntax syntax) +{ + g_arch_register_print(G_ARCH_REGISTER(operand->reg), line, syntax); + +} + + +/****************************************************************************** +* * * Paramètres : content = flux de données à analyser. * * pos = position courante dans ce flux. [OUT] * * low = position éventuelle des 4 bits visés. [OUT] * @@ -275,53 +375,7 @@ GArchOperand *g_dalvik_register_operand_new_from_existing(GDalvikRegister *reg) fake.reg = reg; - result = G_ARCH_OPERAND(g_share_manager_get(_dalvik_register_operand_manager, (GSharedInstance *)&fake)); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : operand = objet partagé à initialiser. * -* fake = coquille vide contenant les infos à enregistrer. * -* * -* Description : Initialise un nouvel objet partagé avec des informations. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static bool g_dalvik_register_operand_do_init(GDalvikRegisterOperand *operand, const GDalvikRegisterOperand *fake) -{ - operand->reg = fake->reg; - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : a = premier opérande à consulter. * -* b = second opérande à consulter. * -* * -* Description : Compare un opérande avec un autre. * -* * -* Retour : Bilan de la comparaison. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static int g_dalvik_register_operand_compare(const GDalvikRegisterOperand * const *a, const GDalvikRegisterOperand * const *b) -{ - int result; /* Bilan à retourner */ - - result = g_dalvik_register_compare(&(*a)->reg, &(*b)->reg); + result = G_ARCH_OPERAND(g_share_manager_build(_dalvik_register_operand_manager, (GSharedInstance *)&fake)); return result; @@ -330,27 +384,6 @@ static int g_dalvik_register_operand_compare(const GDalvikRegisterOperand * cons /****************************************************************************** * * -* Paramètres : operand = opérande à traiter. * -* line = ligne tampon où imprimer l'opérande donné. * -* syntax = type de représentation demandée. * -* * -* Description : Traduit un opérande en version humainement lisible. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_dalvik_register_operand_print(const GDalvikRegisterOperand *operand, GBufferLine *line, AsmSyntax syntax) -{ - g_arch_register_print(G_ARCH_REGISTER(operand->reg), line, syntax); - -} - - -/****************************************************************************** -* * * Paramètres : operand = opérande représentant un registre. * * * * Description : Fournit le registre Dalvik associé à l'opérande. * @@ -416,6 +449,25 @@ bool g_dalvik_register_operand_is_written(const GDalvikRegisterOperand *operand) * * * Paramètres : - * * * +* Description : Fournit le gestionnaire de partages attribué à un type. * +* * +* Retour : Gestionnaire de partages en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GShareManager *get_dalvik_register_operand_share_manager(void) +{ + return _dalvik_register_operand_manager; + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * * Description : Met en place les mécanismes de partage des opérandes Dalvik. * * * * Retour : Bilan de l'opération. * |