ret with nothing on the return stack should exit

This commit is contained in:
psf 2022-03-25 23:30:18 -07:00
parent c90591b864
commit b1a477ea99

View file

@ -1,6 +1,6 @@
use std::cmp;
use std::io;
//use std::convert::TryFrom;
use std::process;
use std::convert::TryInto;
//const CORE_SIZE: usize = 65280
@ -48,7 +48,7 @@ struct TableEntry {
// NOTE: lazy_static or SyncLazy would allow nicer init
const PRIMITIVES: [TableEntry; 8] = [
TableEntry {f: ret , name: ShortName {bytes: ['r' as u8, 'e' as u8, 't' as u8], length: 1}},
TableEntry {f: ret , name: ShortName {bytes: ['r' as u8, 'e' as u8, 't' as u8], length: 3}},
TableEntry {f: dot , name: ShortName {bytes: ['.' as u8, 32, 32], length: 1}},
TableEntry {f: store, name: ShortName {bytes: ['!' as u8, 32, 32], length: 1}},
TableEntry {f: load , name: ShortName {bytes: ['@' as u8, 32, 32], length: 1}},
@ -148,6 +148,9 @@ fn inner(c: &mut Core) {
}
fn ret(c: &mut Core) {
if c.trs == 0 {
std::process::exit(0);
}
c.ip = from_r(c);
}