Skip to content

Commit

Permalink
js: Implement LessThan bytecode instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwuelker committed Jul 6, 2024
1 parent 9bcc65f commit d969131
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion crates/js/src/bytecode/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::{
};
use crate::{
value::{
evaluate_string_or_numeric_binary_expression, StringOrNumericBinaryOperator,
evaluate_string_or_numeric_binary_expression, LeftFirst, StringOrNumericBinaryOperator,
ValueOrReference,
},
Value,
Expand Down Expand Up @@ -265,6 +265,21 @@ impl Vm {
)?;
self.set_register(*dst, Value::from(result).into());
},
Instruction::LessThan { lhs, rhs, dst } => {
let r = Value::is_less_than(
&self.register(*lhs).get_value()?,
&self.register(*rhs).get_value()?,
LeftFirst::Yes,
)?;

let result = if r.is_undefined() {
Value::from(false)
} else {
r
};

self.set_register(*dst, result.into());
},
Instruction::Throw { value } => {
let value = self.register(*value).clone().get_value()?;
return Err(Exception::new(value));
Expand Down

0 comments on commit d969131

Please sign in to comment.