1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-06-07 06:29:32 +00:00

Replace --run option with terser --run-on option.

This commit is contained in:
Chris Pressey 2019-04-16 10:35:59 +01:00
parent 4d82e2352e
commit a10f1c6528
4 changed files with 27 additions and 21 deletions

View File

@ -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=<emu>` option to `sixtypical`, which
replaces the old `loadngo.sh` script.
0.18
----

View File

@ -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

View File

@ -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",

View File

@ -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,