implement iseq, tests
Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
parent
5ce0a8e8b2
commit
cb83fa5655
6 changed files with 134 additions and 25 deletions
|
|
@ -49,7 +49,7 @@ pub enum Type {
|
|||
* I was going to call it Cell and then I learned about
|
||||
* how important RefCells were in Rust
|
||||
*/
|
||||
#[derive(Debug, Default)]
|
||||
#[derive(Debug, Default, PartialEq)]
|
||||
pub struct Seg {
|
||||
/* "Contents of Address Register"
|
||||
* Historical way of referring to the first value in a cell.
|
||||
|
|
@ -251,6 +251,23 @@ impl fmt::Display for Ctr {
|
|||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Ctr {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match (self, other) {
|
||||
(Ctr::Symbol(r), Ctr::Symbol(l)) => *r == *l,
|
||||
(Ctr::String(r), Ctr::String(l)) => *r == *l,
|
||||
(Ctr::Bool(r), Ctr::Bool(l)) => *r == *l,
|
||||
(Ctr::Seg(r), Ctr::Seg(l)) => *r == *l,
|
||||
(Ctr::None, Ctr::None) => true,
|
||||
(Ctr::Integer(r), Ctr::Integer(l)) => *r == *l,
|
||||
(Ctr::Float(r), Ctr::Float(l)) => *r == *l,
|
||||
(Ctr::Integer(r), Ctr::Float(l)) => *r < f64::MAX as i128 && *r as f64 == *l,
|
||||
(Ctr::Float(r), Ctr::Integer(l)) => *l < f64::MAX as i128 && *r == *l as f64,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Seg {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{}", seg_to_string(self, true))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue