diff options
| author | Ajax <commial@gmail.com> | 2016-10-04 10:26:10 +0200 |
|---|---|---|
| committer | Ajax <commial@gmail.com> | 2016-10-04 14:04:30 +0200 |
| commit | 5813b4c45c296aa3ef16f17c282624d3c8ca31bd (patch) | |
| tree | e02930f4a7ad1fe53a9914f9a1129f53bf2dcc9e | |
| parent | cc27435675802a5967df638b05fe87bd5d9fdd64 (diff) | |
| download | miasm-5813b4c45c296aa3ef16f17c282624d3c8ca31bd.tar.gz miasm-5813b4c45c296aa3ef16f17c282624d3c8ca31bd.zip | |
Avoid duplicate -1 case
| -rw-r--r-- | miasm2/jitter/codegen.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/miasm2/jitter/codegen.py b/miasm2/jitter/codegen.py index 540509bf..1ce7ba6d 100644 --- a/miasm2/jitter/codegen.py +++ b/miasm2/jitter/codegen.py @@ -370,14 +370,23 @@ class CGen(object): @attrib: an Attributs instance @instr_offsets: list of instructions offsets - @dst2index: link from dstination to index + @dst2index: link from destination to index """ if not dst2index: return [] out = [] out.append('switch(DST_case) {') + + stopcase = False for dst, index in sorted(dst2index.iteritems(), key=lambda lblindex: lblindex[1]): + if index == -1: + # Handle '-1' case only once + if not stopcase: + stopcase = True + else: + continue + out.append('\tcase %d:' % index) out += self.gen_goto_code(attrib, instr_offsets, dst) out.append('\t\tbreak;') |