From b66cda8ef8be6d9929683ab5a1b22bdfe4b22849 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Thu, 30 May 2019 12:49:12 +0200
Subject: Determined if an iterator is at its ending position.

---
 src/arch/instriter.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 src/arch/instriter.h |  3 +++
 2 files changed, 59 insertions(+)

diff --git a/src/arch/instriter.c b/src/arch/instriter.c
index a603383..3319fb7 100644
--- a/src/arch/instriter.c
+++ b/src/arch/instriter.c
@@ -332,3 +332,59 @@ GArchInstruction *get_instruction_iterator_next(instr_iter_t *iter)
     return result;
 
 }
+
+
+/******************************************************************************
+*                                                                             *
+*  Paramètres  : iter = itérateur à consulter.                                *
+*                                                                             *
+*  Description : Détermine s'il reste une instruction dans l'itération.       *
+*                                                                             *
+*  Retour      : Bilan de la consultation.                                    *
+*                                                                             *
+*  Remarques   : -                                                            *
+*                                                                             *
+******************************************************************************/
+
+bool has_instruction_iterator_next(const instr_iter_t *iter)
+{
+    bool result;                            /* Bilan à retourner           */
+    GArchInstruction *instr;                /* Prochaine instruction       */
+    const mrange_t *irange;                 /* Emplacement d'instruction   */
+
+    g_arch_processor_lock(iter->proc);
+
+    if (iter->stamp != g_arch_processor_get_stamp(iter->proc))
+        result = false;
+
+    else
+    {
+        if ((iter->index + 1) < g_arch_processor_count_instructions(iter->proc))
+        {
+            instr = g_arch_processor_get_instruction(iter->proc, iter->index + 1);
+
+            /* L'instruction sort-elle des clous ? */
+            if (iter->is_restricted)
+            {
+                irange = g_arch_instruction_get_range(instr);
+
+                result = mrange_contains_mrange(&iter->restriction, irange);
+
+            }
+
+            else
+                result = true;
+
+            g_object_unref(G_OBJECT(instr));
+
+        }
+        else
+            result = false;
+    }
+
+    g_arch_processor_unlock(iter->proc);
+
+    return result;
+
+
+}
diff --git a/src/arch/instriter.h b/src/arch/instriter.h
index 68db9cb..9a58005 100644
--- a/src/arch/instriter.h
+++ b/src/arch/instriter.h
@@ -57,6 +57,9 @@ GArchInstruction *get_instruction_iterator_prev(instr_iter_t *);
 /* Fournit l'instruction qui en suit une autre. */
 GArchInstruction *get_instruction_iterator_next(instr_iter_t *);
 
+/* Détermine s'il reste une instruction dans l'itération. */
+bool has_instruction_iterator_next(const instr_iter_t *);
+
 
 
 #endif  /* _ARCH_INSTRITER_H */
-- 
cgit v0.11.2-87-g4458