1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-22 01:32:13 +00:00

Explicitly sort the chains by their content, for stable sort.

This commit is contained in:
Chris Pressey 2018-09-06 17:15:10 +01:00
parent 10062fe2fb
commit 8efa73f79d
3 changed files with 17 additions and 17 deletions

View File

@ -7,7 +7,7 @@ History of SixtyPical
* Split TODO off into own file. * Split TODO off into own file.
* `sixtypical` no longer writes the compiled binary to standard * `sixtypical` no longer writes the compiled binary to standard
output. The `--output` command-line argument should be given. output. The `--output` command-line argument should be given.
* Many tests pass when `sixtypical` is run with Python 3. * All tests pass when `sixtypical` is run under Python 3.5.2.
0.16 0.16
---- ----

View File

@ -43,7 +43,7 @@ class FallthruAnalyzer(object):
while pending_routines: while pending_routines:
chains = [self.find_chain(k, pending_routines) for k in pending_routines.keys()] chains = [self.find_chain(k, pending_routines) for k in pending_routines.keys()]
chains.sort(key=len, reverse=True) chains.sort(key=lambda x: (len(x), str(x)), reverse=True)
c = chains[0] c = chains[0]
roster.append(c) roster.append(c)
for k in c: for k in c:

View File

@ -174,8 +174,8 @@ fall through to the other.
= "main" = "main"
= ], = ],
= [ = [
= "bar", = "foo",
= "foo" = "bar"
= ] = ]
= ] = ]
@ -206,10 +206,10 @@ routine.
= "main" = "main"
= ], = ],
= [ = [
= "bar" = "foo"
= ], = ],
= [ = [
= "foo" = "bar"
= ] = ]
= ] = ]
@ -271,10 +271,10 @@ because we don't necessarily know what actual routine the vector contains.
= "main" = "main"
= ], = ],
= [ = [
= "bar" = "foo"
= ], = ],
= [ = [
= "foo" = "bar"
= ] = ]
= ] = ]
@ -416,12 +416,12 @@ in the "true" branch is a `goto`.
| { | {
| } | }
= $080D RTS = $080D RTS
= $080E LDA #$FF = $080E LDA #$00
= $0810 RTS = $0810 BNE $081A
= $0811 LDA #$00 = $0812 LDA #$01
= $0813 BNE $081D = $0814 JMP $081F
= $0815 LDA #$01 = $0817 JMP $081F
= $0817 JMP $080E = $081A LDA #$02
= $081A JMP $0822 = $081C JMP $080D
= $081D LDA #$02 = $081F LDA #$FF
= $081F JMP $080D = $0821 RTS