From ea788264f7bf4921b5ffc34489eb0a8a8a4bec74 Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Tue, 22 Oct 2019 10:18:56 +0100 Subject: [PATCH] Make test as intended. It fails atm. Simplify driver code. --- bin/sixtypical | 11 ++--------- tests/SixtyPical Fallthru.md | 18 ++++++------------ 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/bin/sixtypical b/bin/sixtypical index afa4f02..c22f0b0 100755 --- a/bin/sixtypical +++ b/bin/sixtypical @@ -61,18 +61,11 @@ def process_input_files(filenames, options): if options.optimize_fallthru: from sixtypical.fallthru import FallthruAnalyzer - def dump(data, label=None): - if not options.dump_fallthru_info: - return - if label: - sys.stdout.write("*** {}:\n".format(label)) - sys.stdout.write(json.dumps(data, indent=4, sort_keys=True, separators=(',', ': '))) - sys.stdout.write("\n") - fa = FallthruAnalyzer(symtab, debug=options.debug) fa.analyze_program(program) compilation_roster = fa.serialize() - dump(compilation_roster) + if options.dump_fallthru_info: + sys.stdout.write(json.dumps(compilation_roster, indent=4, sort_keys=True, separators=(',', ': '))) if options.analyze_only or (options.output is None and not options.run_on): return diff --git a/tests/SixtyPical Fallthru.md b/tests/SixtyPical Fallthru.md index 7f95573..22c5376 100644 --- a/tests/SixtyPical Fallthru.md +++ b/tests/SixtyPical Fallthru.md @@ -384,11 +384,6 @@ It can optimize out one of the `goto`s if they are the same. It cannot optimize out the `goto`s if they are different. -Note, this currently produces unfortunately unoptimized code, -because generating code for the "true" branch of an `if` always -generates a jump out of the `if`, even if the last instruction -in the "true" branch is a `goto`. - | define foo routine trashes a, z, n | { | ld a, 0 @@ -411,11 +406,10 @@ in the "true" branch is a `goto`. | } = $080D RTS = $080E LDA #$00 - = $0810 BNE $081A + = $0810 BNE $0817 = $0812 LDA #$01 - = $0814 JMP $081F - = $0817 JMP $081F - = $081A LDA #$02 - = $081C JMP $080D - = $081F LDA #$FF - = $0821 RTS + = $0814 JMP $081C + = $0817 LDA #$02 + = $0819 JMP $080D + = $081C LDA #$FF + = $081E RTS