rewrite the stdio module to be less broken. also add sehbang support

This commit is contained in:
2020-10-10 18:46:32 +02:00
parent 982ba27ed3
commit ace92a6411
21 changed files with 357 additions and 171 deletions
+9 -9
View File
@@ -1,7 +1,6 @@
use std::collections::{HashMap, VecDeque};
use crsn::asm::data::literal::Value;
use crsn::asm::instr::Cond;
use crsn::module::{EvalRes, OpTrait};
use crsn::runtime::fault::Fault;
use crsn::runtime::run_thread::{state::RunState, ThreadInfo};
@@ -10,6 +9,7 @@ use crsn::sexp::{Sexp, atom_qs};
use crsn::utils::A;
use crate::defs::{BufOps, BufValue};
use crsn::asm::instr::cond::Flag;
#[derive(Debug, Default)]
struct ExtData {
@@ -71,10 +71,10 @@ impl OpTrait for BufOps {
let empty = stack.is_empty();
state.write(dst, val)?;
state.update_status(val);
state.set_flag(Cond::Empty, empty);
state.set_flag(Flag::Empty, empty);
} else {
state.set_flag(Cond::Empty, true);
state.set_flag(Cond::Overflow, true);
state.set_flag(Flag::Empty, true);
state.set_flag(Flag::Overflow, true);
}
}
@@ -89,7 +89,7 @@ impl OpTrait for BufOps {
state.update_status(val);
state.write(dst, val)?;
} else {
state.set_flag(Cond::Overflow, true);
state.set_flag(Flag::Overflow, true);
}
}
@@ -115,7 +115,7 @@ impl OpTrait for BufOps {
} else if idx == stack.len() {
stack.push_back(val);
} else {
state.set_flag(Cond::Overflow, true);
state.set_flag(Flag::Overflow, true);
}
}
@@ -131,7 +131,7 @@ impl OpTrait for BufOps {
} else if idx == stack.len() {
stack.push_back(val);
} else {
state.set_flag(Cond::Overflow, true);
state.set_flag(Flag::Overflow, true);
}
}
@@ -146,9 +146,9 @@ impl OpTrait for BufOps {
let empty = stack.is_empty();
state.update_status(val);
state.write(dst, val)?;
state.set_flag(Cond::Empty, empty);
state.set_flag(Flag::Empty, empty);
} else {
state.set_flag(Cond::Overflow, true);
state.set_flag(Flag::Overflow, true);
}
}