get rid of special words understood by outer interpreter

This commit is contained in:
psf 2022-03-26 21:11:55 -07:00
parent a6e611ad2f
commit 75304a0c82

View file

@ -1,6 +1,5 @@
use std::cmp;
use std::io;
use std::process;
//use std::process;
use std::convert::TryInto;
//const CORE_SIZE: usize = 65408
@ -40,7 +39,6 @@ fn truncate_name(name: &str) -> ShortName {
let n = std::cmp::min(3, out.length) as usize;
out.bytes[0..n].copy_from_slice(&name_bytes[0..n]);
return out;
}
struct TableEntry {
@ -49,11 +47,12 @@ struct TableEntry {
immediate: bool
}
const PRIMITIVES: [TableEntry; 13] = [
const PRIMITIVES: [TableEntry; 14] = [
TableEntry {f: ret , name: None, immediate: false},
TableEntry {f: lit , name: None, immediate: false},
TableEntry {f: call , name: Some(ShortName {bytes: *b"cal", length: 4}), immediate: false},
TableEntry {f: dot , name: Some(ShortName {bytes: *b". ", length: 1}), immediate: false},
TableEntry {f: dump , name: Some(ShortName {bytes: *b"dum", length: 4}), immediate: false},
TableEntry {f: comma_ , name: Some(ShortName {bytes: *b", ", length: 1}), immediate: false},
TableEntry {f: store , name: Some(ShortName {bytes: *b"! ", length: 1}), immediate: false},
TableEntry {f: load , name: Some(ShortName {bytes: *b"@ ", length: 1}), immediate: false},
@ -181,9 +180,6 @@ fn call(c: &mut Core) {
// note: this is an inline primitive, not a dict entry
fn ret(c: &mut Core) {
if c.trs == 0 {
}
c.ip = from_r(c);
}
@ -228,6 +224,10 @@ fn dot(c: &mut Core) {
print!("{} ", pop(c));
}
fn dump(c: &mut Core) {
println!("{:?}", c);
}
// note: this is an inline primitive, not a dict entry
fn lit(c: &mut Core) {
let ip = c.ip as usize;
@ -273,11 +273,6 @@ fn outer(c: &mut Core, s: &str) {
let ss = s.trim();
let tokens = ss.split(" ");
for t in tokens {
match t {
"dmp" => {
println!("{:?}", c);
},
_ => {
match find(c, truncate_name(t)) {
Some(addr) => {
if c.state == State::Interpreting || is_immediate(c, addr) {
@ -304,8 +299,6 @@ fn outer(c: &mut Core, s: &str) {
}
}
}
}
}
}
fn main() {