From fb79d2e3dac19aca1aa1b903812638b40141c244 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Thu, 30 Jul 2015 20:17:46 +0000 Subject: Produced a label for bad exit only if needed. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@561 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 7 +++++++ tools/d2c/spec.c | 32 +++++++++++++++++++------------- tools/d2c/syntax.c | 4 +++- tools/d2c/syntax.h | 2 +- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0eda0bf..fa4ced8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 15-07-30 Cyrille Bagard + * tools/d2c/spec.c: + * tools/d2c/syntax.c: + * tools/d2c/syntax.h: + Produce a label for bad exit only if needed. + +15-07-30 Cyrille Bagard + * src/analysis/binary.c: * src/analysis/binary.h: * src/analysis/db/collection.c: diff --git a/tools/d2c/spec.c b/tools/d2c/spec.c index 7d65cab..cf1a066 100644 --- a/tools/d2c/spec.c +++ b/tools/d2c/spec.c @@ -266,7 +266,8 @@ bool write_encoding_spec_disass(const encoding_spec *spec, int fd, const char *a { bool result; /* Bilan à retourner */ char *keyword; /* Mot clef appelable en code */ - bool exit; /* Inclusion de sortie rapide ?*/ + bool quick_exit; /* Inclusion de sortie rapide ?*/ + bool bad_exit; /* Ajout d'une sortie d'échec ?*/ const char *new_ins; /* Nouvelle définition de nom */ result = true; @@ -304,13 +305,13 @@ bool write_encoding_spec_disass(const encoding_spec *spec, int fd, const char *a /* Inclusion des éventuelles règles */ - exit = false; + quick_exit = false; result &= write_decoding_rules(spec->rules, CAT_SEE, - fd, arch, subarch, spec->bits, spec->conversions, pp, &exit); + fd, arch, subarch, spec->bits, spec->conversions, pp, &quick_exit); result &= write_decoding_rules(spec->rules, CAT_UNPREDICTABLE, - fd, arch, subarch, spec->bits, spec->conversions, pp, &exit); + fd, arch, subarch, spec->bits, spec->conversions, pp, &quick_exit); /* Création de l'instruction en elle-même */ @@ -325,18 +326,20 @@ bool write_encoding_spec_disass(const encoding_spec *spec, int fd, const char *a result &= write_hook_functions(spec->hooks, fd); result &= write_decoding_rules(spec->rules, CAT_CHECKED_CALL, - fd, arch, subarch, spec->bits, spec->conversions, pp, &exit); + fd, arch, subarch, spec->bits, spec->conversions, pp, &quick_exit); result &= write_decoding_rules(spec->rules, CAT_CALL, - fd, arch, subarch, spec->bits, spec->conversions, pp, &exit); + fd, arch, subarch, spec->bits, spec->conversions, pp, &quick_exit); /* Création des opérandes */ - result &= define_syntax_items(spec->syntax, fd, arch, spec->bits, spec->conversions, pp); + bad_exit = false; + + result &= define_syntax_items(spec->syntax, fd, arch, spec->bits, spec->conversions, pp, &bad_exit); /* Conclusion de la procédure */ - if (exit) + if (quick_exit) { dprintf(fd, "\t quick_exit:\n"); dprintf(fd, "\n"); @@ -346,14 +349,17 @@ bool write_encoding_spec_disass(const encoding_spec *spec, int fd, const char *a dprintf(fd, "\n"); - dprintf(fd, "\t bad_exit:\n"); + if (bad_exit) + { + dprintf(fd, "\t bad_exit:\n"); + dprintf(fd, "\n"); - dprintf(fd, "\n"); + dprintf(fd, "\t\tg_object_unref(G_OBJECT(instr));\n"); + dprintf(fd, "\t\treturn NULL;\n"); - dprintf(fd, "\t\tg_object_unref(G_OBJECT(instr));\n"); - dprintf(fd, "\t\treturn NULL;\n"); + dprintf(fd, "\n"); - dprintf(fd, "\n"); + } dprintf(fd, "\t}\n"); diff --git a/tools/d2c/syntax.c b/tools/d2c/syntax.c index 14d13d9..2dad772 100644 --- a/tools/d2c/syntax.c +++ b/tools/d2c/syntax.c @@ -301,6 +301,7 @@ const char *get_new_keyword_from_syntax_items(const asm_syntax *syntax) * bits = gestionnaire des bits d'encodage. * * list = liste de l'ensemble des fonctions de conversion. * * pp = pré-processeur pour les échanges de chaînes. * +* exit = exprime le besoin d'une voie de sortie. [OUT] * * * * Description : Définit les variables C associées aux opérandes de syntaxe. * * * @@ -310,7 +311,7 @@ const char *get_new_keyword_from_syntax_items(const asm_syntax *syntax) * * ******************************************************************************/ -bool define_syntax_items(const asm_syntax *syntax, int fd, const char *arch, const coding_bits *bits, const conv_list *list, const pre_processor *pp) +bool define_syntax_items(const asm_syntax *syntax, int fd, const char *arch, const coding_bits *bits, const conv_list *list, const pre_processor *pp, bool *exit) { bool result; /* Bilan à retourner */ size_t i; /* Boucle de parcours */ @@ -370,6 +371,7 @@ bool define_syntax_items(const asm_syntax *syntax, int fd, const char *arch, con } + *exit = true; break; } diff --git a/tools/d2c/syntax.h b/tools/d2c/syntax.h index fc7cc6b..70b3609 100644 --- a/tools/d2c/syntax.h +++ b/tools/d2c/syntax.h @@ -66,7 +66,7 @@ bool declare_syntax_items(const asm_syntax *, int, const coding_bits *, const co const char *get_new_keyword_from_syntax_items(const asm_syntax *); /* Définit les variables C associées aux opérandes de syntaxe. */ -bool define_syntax_items(const asm_syntax *, int, const char *, const coding_bits *, const conv_list *, const pre_processor *); +bool define_syntax_items(const asm_syntax *, int, const char *, const coding_bits *, const conv_list *, const pre_processor *, bool *); -- cgit v0.11.2-87-g4458