prevent rust panic on kill signal

This commit is contained in:
Scott Richmond 2025-07-02 13:44:26 -04:00
parent 9414dc64d9
commit 116a5b2ed9
2 changed files with 20 additions and 19 deletions

View File

@ -1122,28 +1122,28 @@ That leaves the following list:
* [ ] Model after the p5 keyboard input API * [ ] Model after the p5 keyboard input API
* [ ] ludus keyboard API: `key_down?(), key_pressed?(), key_released?()`, key code values (use a dict) * [ ] ludus keyboard API: `key_down?(), key_pressed?(), key_released?()`, key code values (use a dict)
* [a] Escape characters in strings: \n, \t, and \{, \}. * [a] Escape characters in strings: \n, \t, and \{, \}.
* [ ] `doc!` needs to print the patterns of a function. * [a] `doc!` needs to print the patterns of a function.
* [ ] I need to return to the question of whether/how strings are ordered; do we use `at`, or do we want `char_at`? etc. * [a] I need to return to the question of whether/how strings are ordered; do we use `at`, or do we want `char_at`? etc.
- MNL and I decided: yes, stings are indexable - MNL and I decided: yes, stings are indexable
- [ ] implement `slice` and `at` and others for strings - [ ] implement `slice` and `at` and others for strings
* [x] Automate this build process * [x] Automate this build process
* [ ] Start testing against the cases in `ludus-test` * [ ] Start testing against the cases in `ludus-test`
* [ ] Systematically debug prelude * [ ] Systematically debug prelude
* [ ] Bring it in function by function, testing each in turn * [ ] Bring it in function by function, testing each in turn
* [ ] Animation hooked into the web frontend (Spacewar!) * [x] Animation hooked into the web frontend (Spacewar!)
* [ ] Text input (Spacewar!) * [ ] Text input (Spacewar!)
* [ ] ~Makey makey for alternate input?~ * [ ] ~Makey makey for alternate input?~
* [ ] Saving and loading data into Ludus (perceptrons, dissociated press) * [x] Saving and loading data into Ludus (perceptrons, dissociated press)
* [ ] Finding corpuses for Dissociated Press * [ ] Finding corpuses for Dissociated Press
* [ ] improve validator * [a] improve validator
- [ ] Tuples may not be longer than n members - [a] Tuples may not be longer than n members
- [ ] Loops may not have splatterns - [a] Loops may not have splatterns
- [ ] Identify others - [ ] Identify others
- [ ] Splats in functions must be the same arity, and greater than any explicit arity - [a] Splats in functions must be the same arity, and greater than any explicit arity
* [ ] actually good error messages * [a] actually good error messages
- [ ] parsing - [a] parsing
- [ ] my memory is that validator messages are already good? - [ ] my memory is that validator messages are already good?
- [ ] panics, esp. no match panics - [a] panics, esp. no match panics
* [ ] panics should be able to refernce the line number where they fail * [ ] panics should be able to refernce the line number where they fail
* [ ] that suggests that we need a mapping from bytecodes to AST nodes * [ ] that suggests that we need a mapping from bytecodes to AST nodes
* The way I had been planning on doing this is having a vec that moves in lockstep with bytecode that's just references to ast nodes, which are `'static`, so that shouldn't be too bad. But this is per-chunk, which means we need a reference to that vec in the VM. My sense is that what we want is actually a separate data structure that holds the AST nodes--we'll only need them in the sad path, which can be slow. * The way I had been planning on doing this is having a vec that moves in lockstep with bytecode that's just references to ast nodes, which are `'static`, so that shouldn't be too bad. But this is per-chunk, which means we need a reference to that vec in the VM. My sense is that what we want is actually a separate data structure that holds the AST nodes--we'll only need them in the sad path, which can be slow.
@ -1201,10 +1201,10 @@ After that:
* [x] response: js->rust->ludus * [x] response: js->rust->ludus
- [ ] `keyboard` - [ ] `keyboard`
* [ ] still working on how to represent this * [ ] still working on how to represent this
* [ ] hook this up to `web.ludus.dev` * [x] hook this up to `web.ludus.dev`
* [ ] do some integration testing * [x] do some integration testing
- [x] do synchronous programs still work? - [x] do synchronous programs still work?
- [ ] animations? - [x] animations?
- [ ] read inputs? - [x] read inputs?
- [ ] load url text? - [x] load url text?

View File

@ -171,11 +171,12 @@ pub async fn ludus(src: String) -> String {
let mut world = World::new(vm_chunk, prelude.clone(), DEBUG_SCRIPT_RUN); let mut world = World::new(vm_chunk, prelude.clone(), DEBUG_SCRIPT_RUN);
world.run().await; world.run().await;
let result = world.result.clone().unwrap(); let result = world.result.clone();
let output = match result { let output = match result {
Ok(val) => val.show(), Some(Ok(val)) => val.show(),
Err(panic) => format!("Ludus panicked! {panic}") Some(Err(panic)) => format!("Ludus panicked! {panic}"),
None => "Ludus run terminated by user".to_string()
}; };
if DEBUG_SCRIPT_RUN { if DEBUG_SCRIPT_RUN {
// vm.print_stack(); // vm.print_stack();