Skip to content

Commit 9dea165

Browse files
committed
added list comparison
1 parent d19e819 commit 9dea165

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/execution.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,36 @@ impl Object {
640640
}
641641
_ => return Ok(false),
642642
},
643+
GCRefData::SLICE(s) => match other {
644+
Object::GC_REF(other_gc_ref) => {
645+
let other_res = shared_execution_context.heap.deref(&other_gc_ref);
646+
if other_res.is_err() {
647+
return Err(other_res.err().unwrap());
648+
}
649+
match other_res.unwrap() {
650+
GCRefData::SLICE(other_s) => {
651+
if s.s.len() != other_s.s.len() {
652+
return Ok(false);
653+
}
654+
let mut i = 0;
655+
for item in s.s {
656+
let eq_res = item
657+
.equals(shared_execution_context, other_s.s[i].clone());
658+
if eq_res.is_err() {
659+
return Err(eq_res.err().unwrap());
660+
}
661+
if eq_res.unwrap() {
662+
return Ok(false);
663+
}
664+
i += 1;
665+
}
666+
return Ok(true);
667+
}
668+
_ => return Ok(false),
669+
}
670+
}
671+
_ => return Ok(false),
672+
},
643673
_ => todo!(),
644674
}
645675
Ok(true)

0 commit comments

Comments
 (0)