diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2018-06-09 23:19:01 +0200 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2018-06-10 14:59:14 +0200 |
| commit | 924237fea92f689172330b9bb203b3faf263b929 (patch) | |
| tree | bd61c254ce94c30b2f3685970e6d2191c3a65db0 /miasm2/core/asmblock.py | |
| parent | 990060f21e515ff1a25246f8fdf0936a97ac698f (diff) | |
| download | miasm-924237fea92f689172330b9bb203b3faf263b929.tar.gz miasm-924237fea92f689172330b9bb203b3faf263b929.zip | |
Jitter: label to_string
Diffstat (limited to 'miasm2/core/asmblock.py')
| -rw-r--r-- | miasm2/core/asmblock.py | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/miasm2/core/asmblock.py b/miasm2/core/asmblock.py index 1f54a7e4..082dc344 100644 --- a/miasm2/core/asmblock.py +++ b/miasm2/core/asmblock.py @@ -67,8 +67,17 @@ class AsmConstraint(object): label = property(get_label, set_label) + def to_string(self, symbol_pool=None): + if symbol_pool is None: + return "%s:%s" % (self.c_t, self.loc_key) + else: + return "%s:%s" % ( + self.c_t, + symbol_pool.str_loc_key(self.loc_key) + ) + def __str__(self): - return "%s:%s" % (str(self.c_t), str(self.loc_key)) + return self.to_string() class asm_constraint(AsmConstraint): @@ -127,22 +136,29 @@ class AsmBlock(object): label = property(get_label) - def __str__(self): + def to_string(self, symbol_pool=None): out = [] - out.append(str(self.loc_key)) - for l in self.lines: - out.append(str(l)) + if symbol_pool is None: + out.append(str(self.loc_key)) + else: + out.append(symbol_pool.str_loc_key(self.loc_key)) + + for instr in self.lines: + out.append(instr.to_string(symbol_pool)) if self.bto: lbls = ["->"] - for l in self.bto: - if l is None: + for dst in self.bto: + if dst is None: lbls.append("Unknown? ") else: - lbls.append(str(l) + " ") + lbls.append(dst.to_string(symbol_pool) + " ") lbls = '\t'.join(lbls) out.append(lbls) return '\n'.join(out) + def __str__(self): + return self.to_string() + def addline(self, l): self.lines.append(l) |