summaryrefslogtreecommitdiff
path: root/src/core/processors.c
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2021-08-12 22:00:35 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2021-08-12 22:00:35 (GMT)
commit0daed1fa6212eb83b65ccd10c9f2c80bf12c6d27 (patch)
tree4b7ba8a882f0bf9c482d7ec64a50e8d4c79a3fc9 /src/core/processors.c
parent35f435585638fdf74377c3a9c7e7c2413995d4a7 (diff)
Connect a factory for operands to all the instructions.
Diffstat (limited to 'src/core/processors.c')
-rw-r--r--src/core/processors.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/src/core/processors.c b/src/core/processors.c
index 3211009..666ddac 100644
--- a/src/core/processors.c
+++ b/src/core/processors.c
@@ -24,6 +24,7 @@
#include "processors.h"
+#include <assert.h>
#include <malloc.h>
#include <pthread.h>
#include <string.h>
@@ -37,6 +38,9 @@
+/* Cache des singletons d'opérandes */
+static GSingletonFactory *__operands_factory = NULL;
+
/* Caractéristiques d'un processeur */
typedef struct _proc_t
{
@@ -85,6 +89,74 @@ void register_arch_gtypes(void)
/******************************************************************************
* *
+* Paramètres : - *
+* *
+* Description : Met en place le fournisseur d'instances uniques d'opérandes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void init_operands_factory(void)
+{
+ assert(__operands_factory == NULL);
+
+ __operands_factory = g_singleton_factory_new();
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Fournit l'usine à opérandes pour toutes les instructions. *
+* *
+* Retour : Producteur d'instances uniques. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GSingletonFactory *get_operands_factory(void)
+{
+ GSingletonFactory *result; /* Usine à renvoyer */
+
+ result = __operands_factory;
+
+ g_object_ref(G_OBJECT(result));
+
+ return result;
+
+}
+
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Supprime le fournisseur d'instances uniques d'opérandes. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+void exit_operands_factory(void)
+{
+ assert(__operands_factory != NULL);
+
+ g_clear_object(&__operands_factory);
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : type = type GLib représentant le type à instancier. *
* *
* Description : Enregistre un processeur pour une architecture donnée. *