diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2016-12-30 10:38:52 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2016-12-30 10:38:52 (GMT) |
commit | 932ea7c83c07d3982fee605c6dd9895fd2753874 (patch) | |
tree | 766ad53bab9e3e3005334c30e823493de8e84168 /src/arch/raw.c | |
parent | 1b5d39bfbc48c33a0ea0924b60e48448c8b45dd4 (diff) |
Rewritten the line buffers using generators and on-demand building to save memory.
Diffstat (limited to 'src/arch/raw.c')
-rw-r--r-- | src/arch/raw.c | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/src/arch/raw.c b/src/arch/raw.c index 61a37e0..d0348c9 100644 --- a/src/arch/raw.c +++ b/src/arch/raw.c @@ -78,7 +78,7 @@ static const char *g_raw_instruction_get_encoding(const GRawInstruction *); static const char *g_raw_instruction_get_keyword(const GRawInstruction *, AsmSyntax); /* Ajoute à un tampon GLib le contenu de l'instance spécifiée. */ -static GBufferLine *g_raw_instruction_print(GRawInstruction *, GCodeBuffer *, MemoryDataSize, const GBinContent *, AsmSyntax); +static void g_raw_instruction_print(GRawInstruction *, GBufferLine *, size_t, size_t); @@ -444,11 +444,11 @@ static const char *g_raw_instruction_get_keyword(const GRawInstruction *instr, A /****************************************************************************** * * -* Paramètres : instr = instruction d'assemblage à représenter. * -* buffer = espace où placer ledit contenu. * +* Paramètres : instr = instruction d'assemblage à représenter. * +* buffer = espace où placer ledit contenu. * * msize = taille idéale des positions et adresses; * * content = contenu binaire global à venir lire. * -* syntax = type de représentation demandée. * +* syntax = type de représentation demandée. * * * * Description : Ajoute à un tampon GLib le contenu de l'instance spécifiée. * * * @@ -458,9 +458,8 @@ static const char *g_raw_instruction_get_keyword(const GRawInstruction *instr, A * * ******************************************************************************/ -static GBufferLine *g_raw_instruction_print(GRawInstruction *instr, GCodeBuffer *buffer, MemoryDataSize msize, const GBinContent *content, AsmSyntax syntax) +static void g_raw_instruction_print(GRawInstruction *instr, GBufferLine *line, size_t index, size_t repeat) { - GBufferLine *result; /* Ligne de destination */ GArchInstruction *base; /* Autre version de l'instance */ const char *key; /* Mot clef principal */ size_t klen; /* Taille de ce mot clef */ @@ -474,25 +473,21 @@ static GBufferLine *g_raw_instruction_print(GRawInstruction *instr, GCodeBuffer base = G_ARCH_INSTRUCTION(instr); if (!instr->is_padding && !instr->is_string) - result = G_ARCH_INSTRUCTION_CLASS(g_raw_instruction_parent_class)->print(base, buffer, msize, content, syntax); + G_ARCH_INSTRUCTION_CLASS(g_raw_instruction_parent_class)->print(base, line, index, repeat); else { - result = g_code_buffer_prepare_new_line(buffer, &base->range); - - g_buffer_line_add_flag(result, BLF_HAS_CODE); - - g_buffer_line_fill_mrange(result, msize/* TODO ! */, msize); + g_buffer_line_fill_vmpa(line, get_mrange_addr(&base->range), MDS_32_BITS_UNSIGNED, MDS_32_BITS_UNSIGNED); /* Instruction proprement dite */ - key = g_arch_instruction_get_keyword(base, syntax); + key = g_arch_instruction_get_keyword(base, 0/*, syntax*/); klen = strlen(key); - g_buffer_line_append_text(result, BLC_ASSEMBLY_HEAD, key, klen, RTT_INSTRUCTION, NULL); + g_buffer_line_append_text(line, BLC_ASSEMBLY_HEAD, key, klen, RTT_INSTRUCTION, NULL); if (instr->is_padding) - g_buffer_line_append_text(result, BLC_ASSEMBLY, "...", 3, RTT_RAW, NULL); + g_buffer_line_append_text(line, BLC_ASSEMBLY, "...", 3, RTT_RAW, NULL); else /*if (instr->is_string)*/ { @@ -516,15 +511,15 @@ static GBufferLine *g_raw_instruction_print(GRawInstruction *instr, GCodeBuffer { if (!first) { - g_buffer_line_append_text(result, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL); - g_buffer_line_append_text(result, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); + g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL); + g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); } else first = false; string[iter++] = '"'; - g_buffer_line_append_text(result, BLC_ASSEMBLY, string, iter, RTT_STRING, NULL); + g_buffer_line_append_text(line, BLC_ASSEMBLY, string, iter, RTT_STRING, NULL); iter = 1; @@ -534,13 +529,13 @@ static GBufferLine *g_raw_instruction_print(GRawInstruction *instr, GCodeBuffer if (!first) { - g_buffer_line_append_text(result, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL); - g_buffer_line_append_text(result, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); + g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL); + g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); } else first = false; - g_arch_operand_print(base->operands[i], result, syntax); + g_arch_operand_print(base->operands[i], line, 0/*, syntax*/); } @@ -554,15 +549,15 @@ static GBufferLine *g_raw_instruction_print(GRawInstruction *instr, GCodeBuffer { if (!first) { - g_buffer_line_append_text(result, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL); - g_buffer_line_append_text(result, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); + g_buffer_line_append_text(line, BLC_ASSEMBLY, ",", 1, RTT_PUNCT, NULL); + g_buffer_line_append_text(line, BLC_ASSEMBLY, " ", 1, RTT_RAW, NULL); } else first = false; string[iter++] = '"'; - g_buffer_line_append_text(result, BLC_ASSEMBLY, string, iter, RTT_STRING, NULL); + g_buffer_line_append_text(line, BLC_ASSEMBLY, string, iter, RTT_STRING, NULL); } @@ -572,8 +567,6 @@ static GBufferLine *g_raw_instruction_print(GRawInstruction *instr, GCodeBuffer } - return result; - } |