summaryrefslogtreecommitdiff
path: root/src/arch/operand.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/operand.c')
-rw-r--r--src/arch/operand.c138
1 files changed, 88 insertions, 50 deletions
diff --git a/src/arch/operand.c b/src/arch/operand.c
index 944c34e..e95f24e 100644
--- a/src/arch/operand.c
+++ b/src/arch/operand.c
@@ -31,6 +31,7 @@
#include "operand-int.h"
#include "storage.h"
+#include "../analysis/storage/serialize-int.h"
#include "../common/fnv1a.h"
#include "../common/sort.h"
#include "../core/logs.h"
@@ -48,7 +49,10 @@ static void g_arch_operand_class_init(GArchOperandClass *);
static void g_arch_operand_init(GArchOperand *);
/* Procède à l'initialisation de l'interface de singleton. */
-static void g_arch_operand_singleton_interface_init(GSingletonCandidateInterface *);
+static void g_arch_operand_singleton_init(GSingletonCandidateInterface *);
+
+/* Procède à l'initialisation de l'interface de sérialisation. */
+static void g_arch_operand_serializable_init(GSerializableObjectInterface *);
/* Supprime toutes les références externes. */
static void g_arch_operand_dispose(GArchOperand *);
@@ -87,14 +91,20 @@ static bool g_arch_operand_is_read_only(GArchOperand *);
-/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */
+/* -------------------- CONSERVATION ET RECHARGEMENT DES DONNEES -------------------- */
+
+
+/* Charge un contenu depuis une mémoire tampon. */
+static bool _g_arch_operand_load(GArchOperand *, GObjectStorage *, packed_buffer_t *);
+/* Charge un contenu depuis une mémoire tampon. */
+static bool g_arch_operand_load(GArchOperand *, GObjectStorage *, packed_buffer_t *);
-/* Charge un opérande depuis une mémoire tampon. */
-static bool g_arch_operand_unserialize(GArchOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *);
+/* Sauvegarde un contenu dans une mémoire tampon. */
+static bool _g_arch_operand_store(GArchOperand *, GObjectStorage *, packed_buffer_t *);
-/* Sauvegarde un opérande dans une mémoire tampon. */
-static bool g_arch_operand_serialize(const GArchOperand *, GAsmStorage *, packed_buffer_t *);
+/* Sauvegarde un contenu dans une mémoire tampon. */
+static bool g_arch_operand_store(GArchOperand *, GObjectStorage *, packed_buffer_t *);
@@ -105,7 +115,8 @@ static bool g_arch_operand_serialize(const GArchOperand *, GAsmStorage *, packed
/* Indique le type défini pour un opérande d'architecture. */
G_DEFINE_TYPE_WITH_CODE(GArchOperand, g_arch_operand, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE(G_TYPE_SINGLETON_CANDIDATE, g_arch_operand_singleton_interface_init));
+ G_IMPLEMENT_INTERFACE(G_TYPE_SINGLETON_CANDIDATE, g_arch_operand_singleton_init)
+ G_IMPLEMENT_INTERFACE(G_TYPE_SERIALIZABLE_OBJECT, g_arch_operand_serializable_init));
/******************************************************************************
@@ -136,8 +147,8 @@ static void g_arch_operand_class_init(GArchOperandClass *klass)
operand->hash = _g_arch_operand_hash;
- operand->unserialize = (unserialize_operand_fc)g_arch_operand_unserialize;
- operand->serialize = (serialize_operand_fc)g_arch_operand_serialize;
+ operand->load = (load_operand_fc)_g_arch_operand_load;
+ operand->store = (store_operand_fc)_g_arch_operand_store;
}
@@ -177,7 +188,7 @@ static void g_arch_operand_init(GArchOperand *operand)
* *
******************************************************************************/
-static void g_arch_operand_singleton_interface_init(GSingletonCandidateInterface *iface)
+static void g_arch_operand_singleton_init(GSingletonCandidateInterface *iface)
{
iface->list_inner = (list_inner_instances_fc)g_arch_operand_list_inner_instances;
iface->update_inner = (update_inner_instances_fc)g_arch_operand_update_inner_instances;
@@ -193,6 +204,26 @@ static void g_arch_operand_singleton_interface_init(GSingletonCandidateInterface
/******************************************************************************
* *
+* Paramètres : iface = interface GLib à initialiser. *
+* *
+* Description : Procède à l'initialisation de l'interface de sérialisation. *
+* *
+* Retour : - *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static void g_arch_operand_serializable_init(GSerializableObjectInterface *iface)
+{
+ iface->load = (load_serializable_object_cb)g_arch_operand_load;
+ iface->store = (store_serializable_object_cb)g_arch_operand_store;
+
+}
+
+
+/******************************************************************************
+* *
* Paramètres : operand = instance d'objet GLib à traiter. *
* *
* Description : Supprime toutes les références externes. *
@@ -746,18 +777,17 @@ static bool g_arch_operand_is_read_only(GArchOperand *operand)
/* ---------------------------------------------------------------------------------- */
-/* TRANSPOSITIONS VIA CACHE DES OPERANDES */
+/* CONSERVATION ET RECHARGEMENT DES DONNEES */
/* ---------------------------------------------------------------------------------- */
/******************************************************************************
* *
-* Paramètres : operand = opérande d'assemblage à constituer. *
-* storage = mécanisme de sauvegarde à manipuler. *
-* format = format binaire chargé associé à l'architecture. *
-* pbuf = zone tampon à remplir. *
+* Paramètres : operand = élément GLib à constuire. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à lire. *
* *
-* Description : Charge un opérande depuis une mémoire tampon. *
+* Description : Charge un contenu depuis une mémoire tampon. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -765,11 +795,22 @@ static bool g_arch_operand_is_read_only(GArchOperand *operand)
* *
******************************************************************************/
-static bool g_arch_operand_unserialize(GArchOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf)
+static bool _g_arch_operand_load(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
+ operand_extra_data_t *extra; /* Données insérées à consulter*/
+ uleb128_t value; /* Valeur ULEB128 à charger */
+
+ extra = GET_ARCH_OP_EXTRA(operand);
- result = true;
+ LOCK_GOBJECT_EXTRA(extra);
+
+ result = unpack_uleb128(&value, pbuf);
+
+ if (result)
+ extra->flags = value;
+
+ UNLOCK_GOBJECT_EXTRA(extra);
return result;
@@ -778,36 +819,26 @@ static bool g_arch_operand_unserialize(GArchOperand *operand, GAsmStorage *stora
/******************************************************************************
* *
-* Paramètres : storage = mécanisme de sauvegarde à manipuler. *
-* format = format binaire chargé associé à l'architecture. *
-* pbuf = zone tampon à remplir. *
+* Paramètres : operand = élément GLib à constuire. *
+* storage = conservateur de données à manipuler ou NULL. *
+* pbuf = zone tampon à lire. *
* *
-* Description : Charge un opérande depuis une mémoire tampon. *
+* Description : Charge un contenu depuis une mémoire tampon. *
* *
-* Retour : Opérande d'assemblage constitué ou NULL en cas d'échec. *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-GArchOperand *g_arch_operand_load(GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf)
+static bool g_arch_operand_load(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
- GArchOperand *result; /* Instance à retourner */
- bool status; /* Bilan du chargement */
-
- result = G_ARCH_OPERAND(g_asm_storage_create_object(storage, pbuf));
-
- if (result != NULL)
- {
- status = G_ARCH_OPERAND_GET_CLASS(result)->unserialize(result, storage, format, pbuf);
+ bool result; /* Bilan à retourner */
+ GArchOperandClass *class; /* Classe à activer */
- if (!status)
- {
- g_object_unref(G_OBJECT(result));
- result = NULL;
- }
+ class = G_ARCH_OPERAND_GET_CLASS(operand);
- }
+ result = class->load(operand, storage, pbuf);
return result;
@@ -816,11 +847,11 @@ GArchOperand *g_arch_operand_load(GAsmStorage *storage, GBinFormat *format, pack
/******************************************************************************
* *
-* Paramètres : operand = opérande d'assemblage à consulter. *
-* storage = mécanisme de sauvegarde à manipuler. *
+* Paramètres : operand = élément GLib à consulter. *
+* storage = conservateur de données à manipuler ou NULL. *
* pbuf = zone tampon à remplir. *
* *
-* Description : Sauvegarde un opérande dans une mémoire tampon. *
+* Description : Sauvegarde un contenu dans une mémoire tampon. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -828,11 +859,18 @@ GArchOperand *g_arch_operand_load(GAsmStorage *storage, GBinFormat *format, pack
* *
******************************************************************************/
-static bool g_arch_operand_serialize(const GArchOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf)
+static bool _g_arch_operand_store(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
+ operand_extra_data_t *extra; /* Données insérées à consulter*/
- result = true;
+ extra = GET_ARCH_OP_EXTRA(operand);
+
+ LOCK_GOBJECT_EXTRA(extra);
+
+ result = pack_uleb128((uleb128_t []){ extra->flags }, pbuf);
+
+ UNLOCK_GOBJECT_EXTRA(extra);
return result;
@@ -841,11 +879,11 @@ static bool g_arch_operand_serialize(const GArchOperand *operand, GAsmStorage *s
/******************************************************************************
* *
-* Paramètres : operand = instruction d'assemblage à consulter. *
-* storage = mécanisme de sauvegarde à manipuler. *
+* Paramètres : operand = élément GLib à consulter. *
+* storage = conservateur de données à manipuler ou NULL. *
* pbuf = zone tampon à remplir. *
* *
-* Description : Sauvegarde un opérande dans une mémoire tampon. *
+* Description : Sauvegarde un contenu dans une mémoire tampon. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -853,14 +891,14 @@ static bool g_arch_operand_serialize(const GArchOperand *operand, GAsmStorage *s
* *
******************************************************************************/
-bool g_arch_operand_store(const GArchOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf)
+static bool g_arch_operand_store(GArchOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
+ GArchOperandClass *class; /* Classe à activer */
- result = g_asm_storage_store_object_gtype(storage, G_OBJECT(operand), pbuf);
+ class = G_ARCH_OPERAND_GET_CLASS(operand);
- if (result)
- result = G_ARCH_OPERAND_GET_CLASS(operand)->serialize(operand, storage, pbuf);
+ result = class->store(operand, storage, pbuf);
return result;