diff options
Diffstat (limited to 'src/arch/operands/register.c')
-rw-r--r-- | src/arch/operands/register.c | 158 |
1 files changed, 61 insertions, 97 deletions
diff --git a/src/arch/operands/register.c b/src/arch/operands/register.c index 8cfe39f..4615a99 100644 --- a/src/arch/operands/register.c +++ b/src/arch/operands/register.c @@ -47,30 +47,25 @@ static void g_register_operand_dispose(GRegisterOperand *); /* Procède à la libération totale de la mémoire. */ static void g_register_operand_finalize(GRegisterOperand *); -/* Compare un opérande avec un autre. */ -static int g_register_operand_compare(const GRegisterOperand *, const GRegisterOperand *, bool); -/* Traduit un opérande en version humainement lisible. */ -static void g_register_operand_print(const GRegisterOperand *, GBufferLine *); +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ -/* ------------------------ CONTROLE DU VOLUME DES INSTANCES ------------------------ */ +/* Compare un opérande avec un autre. */ +static int g_register_operand_compare(const GRegisterOperand *, const GRegisterOperand *, bool); +/* Traduit un opérande en version humainement lisible. */ +static void g_register_operand_print(const GRegisterOperand *, GBufferLine *); /* Fournit l'empreinte d'un candidat à une centralisation. */ static guint g_register_operand_hash(const GRegisterOperand *, bool); +/* Charge un contenu depuis une mémoire tampon. */ +static bool g_register_operand_load(GRegisterOperand *, GObjectStorage *, packed_buffer_t *); - -/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */ - - -/* Charge un opérande depuis une mémoire tampon. */ -static bool g_register_operand_unserialize(GRegisterOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *); - -/* Sauvegarde un opérande dans une mémoire tampon. */ -static bool g_register_operand_serialize(const GRegisterOperand *, GAsmStorage *, packed_buffer_t *); +/* Sauvegarde un contenu dans une mémoire tampon. */ +static bool g_register_operand_store(GRegisterOperand *, GObjectStorage *, packed_buffer_t *); @@ -113,8 +108,8 @@ static void g_register_operand_class_init(GRegisterOperandClass *klass) operand->hash = (operand_hash_fc)g_register_operand_hash; - operand->unserialize = (unserialize_operand_fc)g_register_operand_unserialize; - operand->serialize = (serialize_operand_fc)g_register_operand_serialize; + operand->load = (load_operand_fc)g_register_operand_load; + operand->store = (store_operand_fc)g_register_operand_store; } @@ -180,6 +175,37 @@ static void g_register_operand_finalize(GRegisterOperand *operand) /****************************************************************************** * * +* Paramètres : operand = opérande représentant un registre. * +* * +* Description : Fournit le registre associé à l'opérande. * +* * +* Retour : Représentation interne du registre. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GArchRegister *g_register_operand_get_register(const GRegisterOperand *operand) +{ + GArchRegister *result; /* Instance à retourner */ + + result = operand->reg; + + 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. * @@ -232,37 +258,6 @@ static void g_register_operand_print(const GRegisterOperand *operand, GBufferLin /****************************************************************************** * * -* Paramètres : operand = opérande représentant un registre. * -* * -* Description : Fournit le registre associé à l'opérande. * -* * -* Retour : Représentation interne du registre. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GArchRegister *g_register_operand_get_register(const GRegisterOperand *operand) -{ - GArchRegister *result; /* Instance à retourner */ - - result = operand->reg; - - g_object_ref(G_OBJECT(result)); - - return result; - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* CONTROLE DU VOLUME DES INSTANCES */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * * Paramètres : operand = objet dont l'instance se veut unique. * * lock = précise le besoin en verrouillage. * * * @@ -294,20 +289,13 @@ static guint g_register_operand_hash(const GRegisterOperand *operand, bool lock) } - -/* ---------------------------------------------------------------------------------- */ -/* 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. * * * @@ -315,37 +303,24 @@ static guint g_register_operand_hash(const GRegisterOperand *operand, bool lock) * * ******************************************************************************/ -static bool g_register_operand_unserialize(GRegisterOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf) +static bool g_register_operand_load(GRegisterOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf) { bool result; /* Bilan à retourner */ GArchOperandClass *parent; /* Classe parente à consulter */ - off64_t pos; /* Position dans le flux */ - packed_buffer_t reg_pbuf; /* Tampon des données à écrire */ - GArchRegister *reg; /* Registre restauré */ + GSerializableObject *reg; /* Registre manipulé */ parent = G_ARCH_OPERAND_CLASS(g_register_operand_parent_class); - result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf); - - if (result) - result = extract_packed_buffer(pbuf, &pos, sizeof(off64_t), true); + result = parent->load(G_ARCH_OPERAND(operand), storage, pbuf); if (result) { - init_packed_buffer(®_pbuf); + reg = g_object_storage_unpack_object(storage, "registers", pbuf); - result = g_asm_storage_load_register_data(storage, ®_pbuf, pos); + result = (reg != NULL); if (result) - { - reg = NULL;//g_arch_register_load(storage, ®_pbuf); - result = (reg != NULL); - } - - if (result) - operand->reg = reg; - - exit_packed_buffer(®_pbuf); + operand->reg = G_ARCH_REGISTER(reg); } @@ -356,11 +331,11 @@ static bool g_register_operand_unserialize(GRegisterOperand *operand, GAsmStorag /****************************************************************************** * * -* 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. * * * @@ -368,31 +343,20 @@ static bool g_register_operand_unserialize(GRegisterOperand *operand, GAsmStorag * * ******************************************************************************/ -static bool g_register_operand_serialize(const GRegisterOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf) +static bool g_register_operand_store(GRegisterOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf) { bool result; /* Bilan à retourner */ - GArchOperandClass *parent; /* Classe parente à consulter */ - off64_t pos; /* Position dans le flux */ - packed_buffer_t reg_pbuf; /* Tampon des données à écrire */ + GArchOperandClass *parent; /* Classe parente à consulter */ + GSerializableObject *reg; /* Registre manipulé */ parent = G_ARCH_OPERAND_CLASS(g_register_operand_parent_class); - result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf); + result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf); if (result) { - init_packed_buffer(®_pbuf); - - result = false;//g_arch_register_store(operand->reg, storage, ®_pbuf); - - if (result) - result = g_asm_storage_store_register_data(storage, ®_pbuf, &pos); - - if (result) - result = extend_packed_buffer(pbuf, &pos, sizeof(off64_t), true); - - exit_packed_buffer(®_pbuf); - + reg = G_SERIALIZABLE_OBJECT(operand->reg); + result = g_object_storage_pack_object(storage, "registers", reg, pbuf); } return result; |