From a10f1c65288db36176bcb5c16680698807c758e1 Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Tue, 16 Apr 2019 10:35:59 +0100 Subject: [PATCH] Replace --run option with terser --run-on option. --- HISTORY.md | 4 ++-- README.md | 10 +++++----- bin/sixtypical | 32 +++++++++++++++++++------------- eg/rudiments/README.md | 2 +- 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index f5c452d..ea5938b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -22,8 +22,8 @@ History of SixtyPical * Refactored internal data structures that represent references and types to be immutable `namedtuple`s. * Added `--dump-exit-contexts` option to `sixtypical`. -* Added a new `--run` option to `sixtypical`, which replaces - the old `loadngo.sh` script. +* Added a new `--run-on=` option to `sixtypical`, which + replaces the old `loadngo.sh` script. 0.18 ---- diff --git a/README.md b/README.md index e9bcf59..12d864b 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ SixtyPical _Version 0.19. Work-in-progress, everything is subject to change._ **SixtyPical** is a [low-level](#low-level) programming language -supporting a [sophisticated static analysis](#sophisticated-static-analysis). +supporting a sophisticated [static analysis](#static-analysis). Its reference compiler can generate [efficient code](#efficient-code) for several 6502-based [target platforms](#target-platforms) while catching many common mistakes at compile-time, reducing the time spent in debugging. @@ -18,16 +18,16 @@ executable search path. Then you can run: sixtypical -If you have the [VICE][] emulator installed, you can run +If you have the [VICE][] emulator suite installed, you can run - sixtypical --output-format=c64-basic-prg --run eg/c64/hearts.60p + sixtypical --run-on=x64 eg/c64/hearts.60p and it will compile the [hearts.60p source code](eg/c64/hearts.60p) and automatically start it in the `x64` emulator, and you should see: ![Screenshot of result of running hearts.60p](images/hearts.png?raw=true) -You can try `sixtypical --run` on other sources in the `eg` directory +You can try `sixtypical --run-on` on other sources in the `eg` directory tree, which contains more extensive examples, including an entire game(-like program); see [eg/README.md](eg/README.md) for a listing. @@ -63,7 +63,7 @@ based on common 8-bit machine-language programming idioms, including While a programmer will find these constructs convenient, their inclusion in the language is primarily to make programs easier to analyze. -### Sophisticated static analysis +### Static analysis The language defines an [effect system][], and the reference compiler [abstractly interprets][] the input program to check that diff --git a/bin/sixtypical b/bin/sixtypical index 264c8fe..7767078 100755 --- a/bin/sixtypical +++ b/bin/sixtypical @@ -66,7 +66,7 @@ def process_input_files(filenames, options): compilation_roster = fa.serialize() dump(compilation_roster) - if options.analyze_only or (options.output is None and not options.run): + if options.analyze_only or (options.output is None and not options.run_on): return start_addr = None @@ -76,14 +76,20 @@ def process_input_files(filenames, options): else: start_addr = int(options.origin, 10) - if options.run: + if options.run_on: fh = NamedTemporaryFile(delete=False) output_filename = fh.name + Outputter = outputter_class_for({ + 'x64': 'c64-basic-prg', + 'xvic': 'vic20-basic-prg', + 'stella': 'atari2600-cart', + }.get(options.run_on)) else: fh = open(options.output, 'wb') output_filename = options.output + Outputter = outputter_class_for(options.output_format) - outputter = outputter_class_for(options.output_format)(fh, start_addr=start_addr) + outputter = Outputter(fh, start_addr=start_addr) outputter.write_prelude() compiler = Compiler(symtab, outputter.emitter) compiler.compile_program(program, compilation_roster=compilation_roster) @@ -95,14 +101,14 @@ def process_input_files(filenames, options): fh.close() - if options.run: + if options.run_on: emu = { - 'c64-basic-prg': "x64 -config vicerc", - 'vic20-basic-prg': "xvic -config vicerc", - 'atari2600-cart': "stella" - }.get(options.output_format) + 'x64': "x64 -config vicerc", + 'xvic': "xvic -config vicerc", + 'stella': "stella" + }.get(options.run_on) if not emu: - raise ValueError("No emulator configured for selected --output-format '{}'".format(options.output_format)) + raise ValueError("No emulator configured for selected --run-on '{}'".format(options.output_format)) command = "{} {}".format(emu, output_filename) check_call(command, shell=True) @@ -165,10 +171,10 @@ if __name__ == '__main__': help="Display debugging information when analyzing and compiling." ) argparser.add_argument( - "--run", - action="store_true", - help="Engage 'load-and-go' operation: write the output to a temporary filename, " - "infer an emulator from the given --output-format, and boot the emulator." + "--run-on", type=str, default=None, + help="If given, engage 'load-and-go' operation with the given emulator: write " + "the output to a temporary filename, using an appropriate --output-format " + "and boot the emulator with it. Options are: x64, xvic, stella." ) argparser.add_argument( "--traceback", diff --git a/eg/rudiments/README.md b/eg/rudiments/README.md index 914e2cf..a3b675d 100644 --- a/eg/rudiments/README.md +++ b/eg/rudiments/README.md @@ -11,7 +11,7 @@ points such as `chrout` are defined. In addition, some of these programs use "standard" support modules, so those should be included first too. For example: - sixtypical --output-format=c64-basic-prg --run support/c64.60p support/stdlib.60p vector-table.60p + sixtypical --run-on=x64 support/c64.60p support/stdlib.60p vector-table.60p `chrout` is a routine with outputs the value of the accumulator as an ASCII character, disturbing none of the other registers,