summaryrefslogtreecommitdiff
path: root/src/arch/operands/proxy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/operands/proxy.c')
-rw-r--r--src/arch/operands/proxy.c161
1 files changed, 120 insertions, 41 deletions
diff --git a/src/arch/operands/proxy.c b/src/arch/operands/proxy.c
index bf26a4f..c71f96f 100644
--- a/src/arch/operands/proxy.c
+++ b/src/arch/operands/proxy.c
@@ -43,22 +43,25 @@ static void g_proxy_operand_dispose(GProxyOperand *);
/* Procède à la libération totale de la mémoire. */
static void g_proxy_operand_finalize(GProxyOperand *);
-/* Compare un opérande avec un autre. */
-static int g_proxy_operand_compare(const GProxyOperand *, const GProxyOperand *);
-/* Traduit un opérande en version humainement lisible. */
-static void g_proxy_operand_print(const GProxyOperand *, GBufferLine *);
+
+/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */
+/* Compare un opérande avec un autre. */
+static int g_proxy_operand_compare(const GProxyOperand *, const GProxyOperand *, bool);
-/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */
+/* Traduit un opérande en version humainement lisible. */
+static void g_proxy_operand_print(const GProxyOperand *, GBufferLine *);
+/* Fournit l'empreinte d'un candidat à une centralisation. */
+static guint g_proxy_operand_hash(const GProxyOperand *, bool);
-/* Charge un opérande depuis une mémoire tampon. */
-static bool g_proxy_operand_unserialize(GProxyOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *);
+/* Charge un contenu depuis une mémoire tampon. */
+static bool g_proxy_operand_load(GProxyOperand *, GObjectStorage *, packed_buffer_t *);
-/* Sauvegarde un opérande dans une mémoire tampon. */
-static bool g_proxy_operand_serialize(const GProxyOperand *, GAsmStorage *, packed_buffer_t *);
+/* Sauvegarde un contenu dans une mémoire tampon. */
+static bool g_proxy_operand_store(GProxyOperand *, GObjectStorage *, packed_buffer_t *);
@@ -98,8 +101,10 @@ static void g_proxy_operand_class_init(GProxyOperandClass *klass)
operand->compare = (operand_compare_fc)g_proxy_operand_compare;
operand->print = (operand_print_fc)g_proxy_operand_print;
- operand->unserialize = (unserialize_operand_fc)g_proxy_operand_unserialize;
- operand->serialize = (serialize_operand_fc)g_proxy_operand_serialize;
+ operand->hash = (operand_hash_fc)g_proxy_operand_hash;
+
+ operand->load = (load_operand_fc)g_proxy_operand_load;
+ operand->store = (store_operand_fc)g_proxy_operand_store;
}
@@ -190,8 +195,40 @@ GArchOperand *g_proxy_operand_new(GProxyFeeder *feeder)
/******************************************************************************
* *
-* Paramètres : a = premier opérande à consulter. *
-* b = second opérande à consulter. *
+* Paramètres : operand = opérande à consulter. *
+* *
+* Description : Fournit le fournisseur représenté par l'opérande. *
+* *
+* Retour : Fournisseur associé à l'opérande. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+GProxyFeeder *g_proxy_operand_get_feeder(const GProxyOperand *operand)
+{
+ GProxyFeeder *result; /* Instance à retourner */
+
+ result = operand->feeder;
+
+ g_object_ref(G_OBJECT(result));
+
+ return result;
+
+}
+
+
+
+/* ---------------------------------------------------------------------------------- */
+/* IMPLEMENTATION DES FONCTIONS DE CLASSE */
+/* ---------------------------------------------------------------------------------- */
+
+
+/******************************************************************************
+* *
+* Paramètres : a = premier opérande à consulter. *
+* b = second opérande à consulter. *
+* lock = précise le besoin en verrouillage. *
* *
* Description : Compare un opérande avec un autre. *
* *
@@ -201,12 +238,36 @@ GArchOperand *g_proxy_operand_new(GProxyFeeder *feeder)
* *
******************************************************************************/
-static int g_proxy_operand_compare(const GProxyOperand *a, const GProxyOperand *b)
+static int g_proxy_operand_compare(const GProxyOperand *a, const GProxyOperand *b, bool lock)
{
int result; /* Bilan à retourner */
+ operand_extra_data_t *ea; /* Données insérées à consulter*/
+ operand_extra_data_t *eb; /* Données insérées à consulter*/
+ GArchOperandClass *class; /* Classe parente normalisée */
+
+ ea = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(a));
+ eb = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(b));
+
+ if (lock)
+ {
+ LOCK_GOBJECT_EXTRA(ea);
+ LOCK_GOBJECT_EXTRA(eb);
+ }
result = g_proxy_feeder_compare(a->feeder, b->feeder);
+ if (result == 0)
+ {
+ class = G_ARCH_OPERAND_CLASS(g_proxy_operand_parent_class);
+ result = class->compare(G_ARCH_OPERAND(a), G_ARCH_OPERAND(b), false);
+ }
+
+ if (lock)
+ {
+ UNLOCK_GOBJECT_EXTRA(eb);
+ UNLOCK_GOBJECT_EXTRA(ea);
+ }
+
return result;
}
@@ -234,43 +295,48 @@ static void g_proxy_operand_print(const GProxyOperand *operand, GBufferLine *lin
/******************************************************************************
* *
-* Paramètres : operand = opérande à consulter. *
+* Paramètres : operand = objet dont l'instance se veut unique. *
+* lock = précise le besoin en verrouillage. *
* *
-* Description : Fournit le fournisseur représenté par l'opérande. *
+* Description : Fournit l'empreinte d'un candidat à une centralisation. *
* *
-* Retour : Fournisseur associé à l'opérande. *
+* Retour : Empreinte de l'élément représenté. *
* *
* Remarques : - *
* *
******************************************************************************/
-GProxyFeeder *g_proxy_operand_get_feeder(const GProxyOperand *operand)
+static guint g_proxy_operand_hash(const GProxyOperand *operand, bool lock)
{
- GProxyFeeder *result; /* Instance à retourner */
+ guint result; /* Valeur à retourner */
+ operand_extra_data_t *extra; /* Données insérées à consulter*/
+ GArchOperandClass *class; /* Classe parente normalisée */
- result = operand->feeder;
+ extra = GET_ARCH_OP_EXTRA(G_ARCH_OPERAND(operand));
- g_object_ref(G_OBJECT(result));
+ if (lock)
+ LOCK_GOBJECT_EXTRA(extra);
- return result;
+ class = G_ARCH_OPERAND_CLASS(g_proxy_operand_parent_class);
+ result = class->hash(G_ARCH_OPERAND(operand), false);
-}
+ result ^= g_direct_hash(operand->feeder);
+ if (lock)
+ UNLOCK_GOBJECT_EXTRA(extra);
+ return result;
-/* ---------------------------------------------------------------------------------- */
-/* TRANSPOSITIONS VIA CACHE DES OPERANDES */
-/* ---------------------------------------------------------------------------------- */
+}
/******************************************************************************
* *
-* 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. *
* *
@@ -278,17 +344,26 @@ GProxyFeeder *g_proxy_operand_get_feeder(const GProxyOperand *operand)
* *
******************************************************************************/
-static bool g_proxy_operand_unserialize(GProxyOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf)
+static bool g_proxy_operand_load(GProxyOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
GArchOperandClass *parent; /* Classe parente à consulter */
+ GSerializableObject *feeder; /* Fournisseur manipulé */
parent = G_ARCH_OPERAND_CLASS(g_proxy_operand_parent_class);
- result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf);
+ result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf);
if (result)
- result = g_proxy_feeder_unserialize(operand->feeder, format, pbuf);
+ {
+ feeder = g_object_storage_unpack_object(storage, "operands", pbuf);
+
+ result = (feeder != NULL);
+
+ if (result)
+ operand->feeder = G_PROXY_FEEDER(feeder);
+
+ }
return result;
@@ -297,11 +372,11 @@ static bool g_proxy_operand_unserialize(GProxyOperand *operand, GAsmStorage *sto
/******************************************************************************
* *
-* 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. *
* *
@@ -309,17 +384,21 @@ static bool g_proxy_operand_unserialize(GProxyOperand *operand, GAsmStorage *sto
* *
******************************************************************************/
-static bool g_proxy_operand_serialize(const GProxyOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf)
+static bool g_proxy_operand_store(GProxyOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
- GArchOperandClass *parent; /* Classe parente à consulter */
+ GArchOperandClass *parent; /* Classe parente à consulter */
+ GSerializableObject *feeder; /* Fournisseur manipulé */
parent = G_ARCH_OPERAND_CLASS(g_proxy_operand_parent_class);
- result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf);
+ result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf);
if (result)
- result = g_proxy_feeder_serialize(operand->feeder, pbuf);
+ {
+ feeder = G_SERIALIZABLE_OBJECT(operand->feeder);
+ result = g_object_storage_pack_object(storage, "operands", feeder, pbuf);
+ }
return result;