git @ Cat's Eye Technologies SixtyPical / ea78826
Make test as intended. It fails atm. Simplify driver code. Chris Pressey 2 years ago
2 changed file(s) with 8 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
6060 if options.optimize_fallthru:
6161 from sixtypical.fallthru import FallthruAnalyzer
6262
63 def dump(data, label=None):
64 if not options.dump_fallthru_info:
65 return
66 if label:
67 sys.stdout.write("*** {}:\n".format(label))
68 sys.stdout.write(json.dumps(data, indent=4, sort_keys=True, separators=(',', ': ')))
69 sys.stdout.write("\n")
70
7163 fa = FallthruAnalyzer(symtab, debug=options.debug)
7264 fa.analyze_program(program)
7365 compilation_roster = fa.serialize()
74 dump(compilation_roster)
66 if options.dump_fallthru_info:
67 sys.stdout.write(json.dumps(compilation_roster, indent=4, sort_keys=True, separators=(',', ': ')))
7568
7669 if options.analyze_only or (options.output is None and not options.run_on):
7770 return
383383
384384 It cannot optimize out the `goto`s if they are different.
385385
386 Note, this currently produces unfortunately unoptimized code,
387 because generating code for the "true" branch of an `if` always
388 generates a jump out of the `if`, even if the last instruction
389 in the "true" branch is a `goto`.
390
391386 | define foo routine trashes a, z, n
392387 | {
393388 | ld a, 0
410405 | }
411406 = $080D RTS
412407 = $080E LDA #$00
413 = $0810 BNE $081A
408 = $0810 BNE $0817
414409 = $0812 LDA #$01
415 = $0814 JMP $081F
416 = $0817 JMP $081F
417 = $081A LDA #$02
418 = $081C JMP $080D
419 = $081F LDA #$FF
420 = $0821 RTS
410 = $0814 JMP $081C
411 = $0817 LDA #$02
412 = $0819 JMP $080D
413 = $081C LDA #$FF
414 = $081E RTS