diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2020-02-02 20:38:58 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2020-02-02 20:38:58 (GMT) |
commit | 296b4ed15fd074f80266e1d22ef4ade7ee11905e (patch) | |
tree | 9ec0dc238f42c5f3b7f12e96dd1c631685c539b3 /src/arch/raw.c | |
parent | 62f178cc3dcc889d56ba6d94f6fc8bba7b503c1a (diff) |
Relied on flags for raw instructions.
Diffstat (limited to 'src/arch/raw.c')
-rw-r--r-- | src/arch/raw.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/src/arch/raw.c b/src/arch/raw.c index 9d597fa..243752d 100644 --- a/src/arch/raw.c +++ b/src/arch/raw.c @@ -46,9 +46,6 @@ struct _GRawInstruction { GArchInstruction parent; /* A laisser en premier */ - bool is_padding; /* Bourrage à représenter ? */ - bool is_string; /* Chaîne de caractères ? */ - }; /* Définition générique d'une instruction brute d'architecture (classe) */ @@ -450,7 +447,7 @@ static const char *g_raw_instruction_get_encoding(const GRawInstruction *instr) { const char *result; /* Description à retourner */ - if (instr->is_string) + if (g_raw_instruction_is_string(instr)) result = _("String"); else result = _("Raw"); @@ -529,7 +526,7 @@ static bool g_raw_instruction_unserialize(GRawInstruction *instr, GAsmStorage *s result = extract_packed_buffer(pbuf, &boolean, sizeof(uint8_t), false); if (result) - instr->is_padding = (boolean == 1 ? true : false); + g_raw_instruction_mark_as_padding(instr, (boolean == 1)); } @@ -538,7 +535,7 @@ static bool g_raw_instruction_unserialize(GRawInstruction *instr, GAsmStorage *s result = extract_packed_buffer(pbuf, &boolean, sizeof(uint8_t), false); if (result) - instr->is_string = (boolean == 1 ? true : false); + g_raw_instruction_mark_as_string(instr, (boolean == 1)); } @@ -573,13 +570,13 @@ static bool g_raw_instruction_serialize(GRawInstruction *instr, GAsmStorage *sto if (result) { - boolean = (instr->is_padding ? 1 : 0); + boolean = (g_raw_instruction_is_padding(instr) ? 1 : 0); result = extend_packed_buffer(pbuf, &boolean, sizeof(uint8_t), false); } if (result) { - boolean = (instr->is_string ? 1 : 0); + boolean = (g_raw_instruction_is_string(instr) ? 1 : 0); result = extend_packed_buffer(pbuf, &boolean, sizeof(uint8_t), false); } @@ -636,10 +633,10 @@ static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, s /* Contenu */ - if (instr->is_padding) + if (g_raw_instruction_is_padding(instr)) max_displayed_len = 0; - else if (instr->is_string) + else if (g_raw_instruction_is_string(instr)) max_displayed_len = 1; else @@ -657,7 +654,7 @@ static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, s g_buffer_line_append_text(line, BLC_ASSEMBLY_HEAD, key, klen, RTT_INSTRUCTION, NULL); - if (instr->is_padding) + if (g_raw_instruction_is_padding(instr)) g_buffer_line_append_text(line, BLC_ASSEMBLY, "...", 3, RTT_RAW, NULL); else @@ -683,7 +680,7 @@ static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, s if (g_imm_operand_get_size(imm) != MDS_8_BITS) goto grip_fallback; - if (!instr->is_string && g_imm_operand_get_display(imm) != IOD_CHAR) + if (!g_raw_instruction_is_string(instr) && g_imm_operand_get_display(imm) != IOD_CHAR) goto grip_fallback; #ifndef NDEBUG @@ -794,7 +791,10 @@ static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, s void g_raw_instruction_mark_as_padding(GRawInstruction *instr, bool is_padding) { - instr->is_padding = is_padding; + if (is_padding) + g_arch_instruction_set_flag(G_ARCH_INSTRUCTION(instr), RIF_PADDING); + else + g_arch_instruction_unset_flag(G_ARCH_INSTRUCTION(instr), RIF_PADDING); } @@ -814,7 +814,11 @@ void g_raw_instruction_mark_as_padding(GRawInstruction *instr, bool is_padding) bool g_raw_instruction_is_padding(const GRawInstruction *instr) { - return instr->is_padding; + bool result; /* Indication à retourner */ + + result = g_arch_instruction_has_flag(G_ARCH_INSTRUCTION(instr), RIF_PADDING); + + return result; } @@ -834,7 +838,10 @@ bool g_raw_instruction_is_padding(const GRawInstruction *instr) void g_raw_instruction_mark_as_string(GRawInstruction *instr, bool is_string) { - instr->is_string = is_string; + if (is_string) + g_arch_instruction_set_flag(G_ARCH_INSTRUCTION(instr), RIF_STRING); + else + g_arch_instruction_unset_flag(G_ARCH_INSTRUCTION(instr), RIF_STRING); } @@ -854,6 +861,10 @@ void g_raw_instruction_mark_as_string(GRawInstruction *instr, bool is_string) bool g_raw_instruction_is_string(const GRawInstruction *instr) { - return instr->is_string; + bool result; /* Indication à retourner */ + + result = g_arch_instruction_has_flag(G_ARCH_INSTRUCTION(instr), RIF_STRING); + + return result; } |