mirror of
https://gitlab.cs.washington.edu/fidelp/frustration.git
synced 2024-12-26 21:58:20 +01:00
get rid of special words understood by outer interpreter
This commit is contained in:
parent
a6e611ad2f
commit
75304a0c82
1 changed files with 26 additions and 33 deletions
|
@ -1,6 +1,5 @@
|
||||||
use std::cmp;
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::process;
|
//use std::process;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
|
||||||
//const CORE_SIZE: usize = 65408
|
//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;
|
let n = std::cmp::min(3, out.length) as usize;
|
||||||
out.bytes[0..n].copy_from_slice(&name_bytes[0..n]);
|
out.bytes[0..n].copy_from_slice(&name_bytes[0..n]);
|
||||||
return out;
|
return out;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct TableEntry {
|
struct TableEntry {
|
||||||
|
@ -49,11 +47,12 @@ struct TableEntry {
|
||||||
immediate: bool
|
immediate: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
const PRIMITIVES: [TableEntry; 13] = [
|
const PRIMITIVES: [TableEntry; 14] = [
|
||||||
TableEntry {f: ret , name: None, immediate: false},
|
TableEntry {f: ret , name: None, immediate: false},
|
||||||
TableEntry {f: lit , 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: 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: 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: comma_ , name: Some(ShortName {bytes: *b", ", length: 1}), immediate: false},
|
||||||
TableEntry {f: store , 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},
|
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
|
// note: this is an inline primitive, not a dict entry
|
||||||
fn ret(c: &mut Core) {
|
fn ret(c: &mut Core) {
|
||||||
if c.trs == 0 {
|
|
||||||
|
|
||||||
}
|
|
||||||
c.ip = from_r(c);
|
c.ip = from_r(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +224,10 @@ fn dot(c: &mut Core) {
|
||||||
print!("{} ", pop(c));
|
print!("{} ", pop(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn dump(c: &mut Core) {
|
||||||
|
println!("{:?}", c);
|
||||||
|
}
|
||||||
|
|
||||||
// note: this is an inline primitive, not a dict entry
|
// note: this is an inline primitive, not a dict entry
|
||||||
fn lit(c: &mut Core) {
|
fn lit(c: &mut Core) {
|
||||||
let ip = c.ip as usize;
|
let ip = c.ip as usize;
|
||||||
|
@ -273,11 +273,6 @@ fn outer(c: &mut Core, s: &str) {
|
||||||
let ss = s.trim();
|
let ss = s.trim();
|
||||||
let tokens = ss.split(" ");
|
let tokens = ss.split(" ");
|
||||||
for t in tokens {
|
for t in tokens {
|
||||||
match t {
|
|
||||||
"dmp" => {
|
|
||||||
println!("{:?}", c);
|
|
||||||
},
|
|
||||||
_ => {
|
|
||||||
match find(c, truncate_name(t)) {
|
match find(c, truncate_name(t)) {
|
||||||
Some(addr) => {
|
Some(addr) => {
|
||||||
if c.state == State::Interpreting || is_immediate(c, addr) {
|
if c.state == State::Interpreting || is_immediate(c, addr) {
|
||||||
|
@ -304,8 +299,6 @@ fn outer(c: &mut Core, s: &str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
Loading…
Reference in a new issue