git @ Cat's Eye Technologies SixtyPical / a10f1c6
Replace --run option with terser --run-on option. Chris Pressey 2 years ago
4 changed file(s) with 28 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
2121 * Refactored internal data structures that represent
2222 references and types to be immutable `namedtuple`s.
2323 * Added `--dump-exit-contexts` option to `sixtypical`.
24 * Added a new `--run` option to `sixtypical`, which replaces
25 the old `loadngo.sh` script.
24 * Added a new `--run-on=<emu>` option to `sixtypical`, which
25 replaces the old `loadngo.sh` script.
2626
2727 0.18
2828 ----
33 _Version 0.19. Work-in-progress, everything is subject to change._
44
55 **SixtyPical** is a [low-level](#low-level) programming language
6 supporting a [sophisticated static analysis](#sophisticated-static-analysis).
6 supporting a sophisticated [static analysis](#static-analysis).
77 Its reference compiler can generate [efficient code](#efficient-code) for
88 several 6502-based [target platforms](#target-platforms) while catching many
99 common mistakes at compile-time, reducing the time spent in debugging.
1717
1818 sixtypical
1919
20 If you have the [VICE][] emulator installed, you can run
20 If you have the [VICE][] emulator suite installed, you can run
2121
22 sixtypical --output-format=c64-basic-prg --run eg/c64/hearts.60p
22 sixtypical --run-on=x64 eg/c64/hearts.60p
2323
2424 and it will compile the [hearts.60p source code](eg/c64/hearts.60p) and
2525 automatically start it in the `x64` emulator, and you should see:
2626
2727 ![Screenshot of result of running hearts.60p](images/hearts.png?raw=true)
2828
29 You can try `sixtypical --run` on other sources in the `eg` directory
29 You can try `sixtypical --run-on` on other sources in the `eg` directory
3030 tree, which contains more extensive examples, including an entire
3131 game(-like program); see [eg/README.md](eg/README.md) for a listing.
3232
6262 While a programmer will find these constructs convenient, their
6363 inclusion in the language is primarily to make programs easier to analyze.
6464
65 ### Sophisticated static analysis
65 ### Static analysis
6666
6767 The language defines an [effect system][], and the reference
6868 compiler [abstractly interprets][] the input program to check that
6565 compilation_roster = fa.serialize()
6666 dump(compilation_roster)
6767
68 if options.analyze_only or (options.output is None and not options.run):
68 if options.analyze_only or (options.output is None and not options.run_on):
6969 return
7070
7171 start_addr = None
7575 else:
7676 start_addr = int(options.origin, 10)
7777
78 if options.run:
78 if options.run_on:
7979 fh = NamedTemporaryFile(delete=False)
8080 output_filename = fh.name
81 Outputter = outputter_class_for({
82 'x64': 'c64-basic-prg',
83 'xvic': 'vic20-basic-prg',
84 'stella': 'atari2600-cart',
85 }.get(options.run_on))
8186 else:
8287 fh = open(options.output, 'wb')
8388 output_filename = options.output
84
85 outputter = outputter_class_for(options.output_format)(fh, start_addr=start_addr)
89 Outputter = outputter_class_for(options.output_format)
90
91 outputter = Outputter(fh, start_addr=start_addr)
8692 outputter.write_prelude()
8793 compiler = Compiler(symtab, outputter.emitter)
8894 compiler.compile_program(program, compilation_roster=compilation_roster)
94100
95101 fh.close()
96102
97 if options.run:
103 if options.run_on:
98104 emu = {
99 'c64-basic-prg': "x64 -config vicerc",
100 'vic20-basic-prg': "xvic -config vicerc",
101 'atari2600-cart': "stella"
102 }.get(options.output_format)
105 'x64': "x64 -config vicerc",
106 'xvic': "xvic -config vicerc",
107 'stella': "stella"
108 }.get(options.run_on)
103109 if not emu:
104 raise ValueError("No emulator configured for selected --output-format '{}'".format(options.output_format))
110 raise ValueError("No emulator configured for selected --run-on '{}'".format(options.output_format))
105111
106112 command = "{} {}".format(emu, output_filename)
107113 check_call(command, shell=True)
164170 help="Display debugging information when analyzing and compiling."
165171 )
166172 argparser.add_argument(
167 "--run",
168 action="store_true",
169 help="Engage 'load-and-go' operation: write the output to a temporary filename, "
170 "infer an emulator from the given --output-format, and boot the emulator."
173 "--run-on", type=str, default=None,
174 help="If given, engage 'load-and-go' operation with the given emulator: write "
175 "the output to a temporary filename, using an appropriate --output-format "
176 "and boot the emulator with it. Options are: x64, xvic, stella."
171177 )
172178 argparser.add_argument(
173179 "--traceback",
1010 programs use "standard" support modules, so those should be included
1111 first too. For example:
1212
13 sixtypical --output-format=c64-basic-prg --run support/c64.60p support/stdlib.60p vector-table.60p
13 sixtypical --run-on=x64 support/c64.60p support/stdlib.60p vector-table.60p
1414
1515 `chrout` is a routine with outputs the value of the accumulator
1616 as an ASCII character, disturbing none of the other registers,