summaryrefslogtreecommitdiff
path: root/src/arch/operands/known.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/arch/operands/known.c')
-rw-r--r--src/arch/operands/known.c73
1 files changed, 33 insertions, 40 deletions
diff --git a/src/arch/operands/known.c b/src/arch/operands/known.c
index bf16674..a4b3844 100644
--- a/src/arch/operands/known.c
+++ b/src/arch/operands/known.c
@@ -31,6 +31,7 @@
#include "immediate-int.h"
#include "rename-int.h"
+#include "../../analysis/db/misc/rlestr.h"
#include "../../core/logs.h"
#include "../../gtkext/gtkblockdisplay.h"
@@ -85,11 +86,11 @@ static void g_known_imm_operand_print(const GKnownImmOperand *, GBufferLine *);
/* Fournit l'empreinte d'un candidat à une centralisation. */
static guint g_known_imm_operand_hash(const GKnownImmOperand *, bool);
-/* Charge un opérande depuis une mémoire tampon. */
-static bool g_known_imm_operand_unserialize(GKnownImmOperand *, GAsmStorage *, GBinFormat *, packed_buffer_t *);
+/* Charge un contenu depuis une mémoire tampon. */
+static bool g_known_imm_operand_load(GKnownImmOperand *, GObjectStorage *, packed_buffer_t *);
-/* Sauvegarde un opérande dans une mémoire tampon. */
-static bool g_known_imm_operand_serialize(const GKnownImmOperand *, GAsmStorage *, packed_buffer_t *);
+/* Sauvegarde un contenu dans une mémoire tampon. */
+static bool g_known_imm_operand_store(GKnownImmOperand *, GObjectStorage *, packed_buffer_t *);
@@ -139,8 +140,8 @@ static void g_known_imm_operand_class_init(GKnownImmOperandClass *klass)
operand->hash = (operand_hash_fc)g_known_imm_operand_hash;
- operand->unserialize = (unserialize_operand_fc)g_known_imm_operand_unserialize;
- operand->serialize = (serialize_operand_fc)g_known_imm_operand_serialize;
+ operand->load = (load_operand_fc)g_known_imm_operand_load;
+ operand->store = (store_operand_fc)g_known_imm_operand_store;
}
@@ -386,12 +387,11 @@ static guint g_known_imm_operand_hash(const GKnownImmOperand *operand, bool lock
/******************************************************************************
* *
-* 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. *
* *
@@ -399,27 +399,30 @@ static guint g_known_imm_operand_hash(const GKnownImmOperand *operand, bool lock
* *
******************************************************************************/
-static bool g_known_imm_operand_unserialize(GKnownImmOperand *operand, GAsmStorage *storage, GBinFormat *format, packed_buffer_t *pbuf)
+static bool g_known_imm_operand_load(GKnownImmOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
GArchOperandClass *parent; /* Classe parente à consulter */
- unsigned short len; /* Taille du contenu alternatif*/
+ rle_string str; /* Chaîne à charger */
parent = G_ARCH_OPERAND_CLASS(g_known_imm_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 = extract_packed_buffer(pbuf, &len, sizeof(unsigned short), true);
+ {
+ setup_empty_rle_string(&str);
- if (result)
- result = (len > 0);
+ result = unpack_rle_string(&str, pbuf);
- if (result)
- {
- operand->alt_text = malloc(len);
+ if (result)
+ {
+ if (get_rle_string(&str) != NULL)
+ operand->alt_text = strdup(get_rle_string(&str));
- result = extract_packed_buffer(pbuf, operand->alt_text, len, false);
+ exit_rle_string(&str);
+
+ }
}
@@ -430,11 +433,11 @@ static bool g_known_imm_operand_unserialize(GKnownImmOperand *operand, GAsmStora
/******************************************************************************
* *
-* 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. *
* *
@@ -442,33 +445,23 @@ static bool g_known_imm_operand_unserialize(GKnownImmOperand *operand, GAsmStora
* *
******************************************************************************/
-static bool g_known_imm_operand_serialize(const GKnownImmOperand *operand, GAsmStorage *storage, packed_buffer_t *pbuf)
+static bool g_known_imm_operand_store(GKnownImmOperand *operand, GObjectStorage *storage, packed_buffer_t *pbuf)
{
bool result; /* Bilan à retourner */
GArchOperandClass *parent; /* Classe parente à consulter */
- size_t len; /* Taille du contenu alternatif*/
+ rle_string str; /* Chaîne à conserver */
parent = G_ARCH_OPERAND_CLASS(g_known_imm_operand_parent_class);
- result = parent->serialize(G_ARCH_OPERAND(operand), storage, pbuf);
+ result = parent->store(G_ARCH_OPERAND(operand), storage, pbuf);
if (result)
{
- len = strlen(operand->alt_text) + 1;
- assert(len > 1);
-
- if (len > (2 << (sizeof(unsigned short) * 8 - 1)))
- {
- log_variadic_message(LMT_ERROR, "Alternative text too long: '%s' (%zu bytes)",
- operand->alt_text, len);
- result = false;
- }
+ init_static_rle_string(&str, operand->alt_text);
- else
- result = extend_packed_buffer(pbuf, (unsigned short []) { len }, sizeof(unsigned short), true);
+ result = pack_rle_string(&str, pbuf);
- if (result)
- result = extend_packed_buffer(pbuf, operand->alt_text, len, false);
+ exit_rle_string(&str);
}