diff options
Diffstat (limited to 'src/arch/immediate.c')
-rw-r--r-- | src/arch/immediate.c | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/src/arch/immediate.c b/src/arch/immediate.c index bf4a36a..1c084ea 100644 --- a/src/arch/immediate.c +++ b/src/arch/immediate.c @@ -109,6 +109,17 @@ static char *g_imm_operand_build_tooltip(const GImmOperand *, const GLoadedBinar +/* --------------------- TRANSPOSITIONS VIA CACHE DES OPERANDES --------------------- */ + + +/* Charge un opérande depuis une mémoire tampon. */ +static bool g_imm_operand_unserialize(GImmOperand *, GAsmStorage *, GBinFormat *, packed_buffer *); + +/* Sauvegarde un opérande dans une mémoire tampon. */ +static bool g_imm_operand_serialize(const GImmOperand *, GAsmStorage *, packed_buffer *); + + + /* Indique le type défini pour un opérande de valeur numérique. */ G_DEFINE_TYPE(GImmOperand, g_imm_operand, G_TYPE_ARCH_OPERAND); @@ -141,6 +152,9 @@ static void g_imm_operand_class_init(GImmOperandClass *klass) operand->print = (operand_print_fc)g_imm_operand_print; operand->build_tooltip = (operand_build_tooltip_fc)g_imm_operand_build_tooltip; + operand->unserialize = (unserialize_operand_fc)g_imm_operand_unserialize; + operand->serialize = (serialize_operand_fc)g_imm_operand_serialize; + } @@ -1357,3 +1371,96 @@ bool g_imm_operand_to_off_t(const GImmOperand *operand, off_t *value, bool *nega return false; } + + + +/* ---------------------------------------------------------------------------------- */ +/* 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. * +* * +* Description : Charge un opérande depuis une mémoire tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_imm_operand_unserialize(GImmOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer *pbuf) +{ + bool result; /* Bilan à retourner */ + GArchOperandClass *parent; /* Classe parente à consulter */ + + parent = G_ARCH_OPERAND_CLASS(g_imm_operand_parent_class); + + result = parent->unserialize(G_ARCH_OPERAND(operand), storage, format, pbuf); + + if (result) + result = extract_packed_buffer(pbuf, &operand->raw, sizeof(uint64_t), true); + + if (result) + result = extract_packed_buffer(pbuf, &operand->size, sizeof(MemoryDataSize), true); + + if (result) + result = extract_packed_buffer(pbuf, &operand->def_display, sizeof(ImmOperandDisplay), true); + + if (result) + result = extract_packed_buffer(pbuf, &operand->display, sizeof(ImmOperandDisplay), true); + + if (result) + result = extract_packed_buffer(pbuf, &operand->misc, sizeof(uint8_t), false); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : operand = opérande d'assemblage à consulter. * +* storage = mécanisme de sauvegarde à manipuler. * +* pbuf = zone tampon à remplir. * +* * +* Description : Sauvegarde un opérande dans une mémoire tampon. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool g_imm_operand_serialize(const GImmOperand *operand, GAsmStorage *storage, packed_buffer *pbuf) +{ + bool result; /* Bilan à retourner */ + GArchOperandClass *parent; /* Classe parente à consulter */ + + parent = G_ARCH_OPERAND_CLASS(g_imm_operand_parent_class); + + result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf); + + if (result) + result = extend_packed_buffer(pbuf, &operand->raw, sizeof(uint64_t), true); + + if (result) + result = extend_packed_buffer(pbuf, &operand->size, sizeof(MemoryDataSize), true); + + if (result) + result = extend_packed_buffer(pbuf, &operand->def_display, sizeof(ImmOperandDisplay), true); + + if (result) + result = extend_packed_buffer(pbuf, &operand->display, sizeof(ImmOperandDisplay), true); + + if (result) + result = extend_packed_buffer(pbuf, &operand->misc, sizeof(uint8_t), false); + + return result; + +} |