mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibJS: Add bytecode ops for >, >= and <=
This commit is contained in:
parent
73b8acf432
commit
4be3374b24
Notes:
sideshowbarker
2024-07-18 12:41:15 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/4be3374b24d Pull-request: https://github.com/SerenityOS/serenity/pull/7884
4 changed files with 99 additions and 0 deletions
|
@ -61,9 +61,18 @@ Optional<Bytecode::Register> BinaryExpression::generate_bytecode(Bytecode::Gener
|
|||
case BinaryOp::Exponentiation:
|
||||
generator.emit<Bytecode::Op::Exp>(dst_reg, *lhs_reg, *rhs_reg);
|
||||
return dst_reg;
|
||||
case BinaryOp::GreaterThan:
|
||||
generator.emit<Bytecode::Op::GreaterThan>(dst_reg, *lhs_reg, *rhs_reg);
|
||||
return dst_reg;
|
||||
case BinaryOp::GreaterThanEquals:
|
||||
generator.emit<Bytecode::Op::GreaterThanEquals>(dst_reg, *lhs_reg, *rhs_reg);
|
||||
return dst_reg;
|
||||
case BinaryOp::LessThan:
|
||||
generator.emit<Bytecode::Op::LessThan>(dst_reg, *lhs_reg, *rhs_reg);
|
||||
return dst_reg;
|
||||
case BinaryOp::LessThanEquals:
|
||||
generator.emit<Bytecode::Op::LessThanEquals>(dst_reg, *lhs_reg, *rhs_reg);
|
||||
return dst_reg;
|
||||
case BinaryOp::AbstractInequals:
|
||||
generator.emit<Bytecode::Op::AbstractInequals>(dst_reg, *lhs_reg, *rhs_reg);
|
||||
return dst_reg;
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
O(Div) \
|
||||
O(Mod) \
|
||||
O(Exp) \
|
||||
O(GreaterThan) \
|
||||
O(GreaterThanEquals) \
|
||||
O(LessThan) \
|
||||
O(LessThanEquals) \
|
||||
O(AbstractInequals) \
|
||||
O(AbstractEquals) \
|
||||
O(NewString) \
|
||||
|
|
|
@ -82,11 +82,26 @@ void Exp::execute(Bytecode::Interpreter& interpreter) const
|
|||
interpreter.reg(m_dst) = exp(interpreter.global_object(), interpreter.reg(m_src1), interpreter.reg(m_src2));
|
||||
}
|
||||
|
||||
void GreaterThan::execute(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.reg(m_dst) = greater_than(interpreter.global_object(), interpreter.reg(m_src1), interpreter.reg(m_src2));
|
||||
}
|
||||
|
||||
void GreaterThanEquals::execute(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.reg(m_dst) = greater_than_equals(interpreter.global_object(), interpreter.reg(m_src1), interpreter.reg(m_src2));
|
||||
}
|
||||
|
||||
void LessThan::execute(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.reg(m_dst) = less_than(interpreter.global_object(), interpreter.reg(m_src1), interpreter.reg(m_src2));
|
||||
}
|
||||
|
||||
void LessThanEquals::execute(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.reg(m_dst) = less_than_equals(interpreter.global_object(), interpreter.reg(m_src1), interpreter.reg(m_src2));
|
||||
}
|
||||
|
||||
void AbstractInequals::execute(Bytecode::Interpreter& interpreter) const
|
||||
{
|
||||
interpreter.reg(m_dst) = Value(!abstract_eq(interpreter.global_object(), interpreter.reg(m_src1), interpreter.reg(m_src2)));
|
||||
|
@ -233,11 +248,26 @@ String Exp::to_string() const
|
|||
return String::formatted("Exp dst:{}, src1:{}, src2:{}", m_dst, m_src1, m_src2);
|
||||
}
|
||||
|
||||
String GreaterThan::to_string() const
|
||||
{
|
||||
return String::formatted("GreaterThan dst:{}, src1:{}, src2:{}", m_dst, m_src1, m_src2);
|
||||
}
|
||||
|
||||
String GreaterThanEquals::to_string() const
|
||||
{
|
||||
return String::formatted("GreaterThanEquals dst:{}, src1:{}, src2:{}", m_dst, m_src1, m_src2);
|
||||
}
|
||||
|
||||
String LessThan::to_string() const
|
||||
{
|
||||
return String::formatted("LessThan dst:{}, src1:{}, src2:{}", m_dst, m_src1, m_src2);
|
||||
}
|
||||
|
||||
String LessThanEquals::to_string() const
|
||||
{
|
||||
return String::formatted("LessThanEquals dst:{}, src1:{}, src2:{}", m_dst, m_src1, m_src2);
|
||||
}
|
||||
|
||||
String AbstractInequals::to_string() const
|
||||
{
|
||||
return String::formatted("AbstractInequals dst:{}, src1:{}, src2:{}", m_dst, m_src1, m_src2);
|
||||
|
|
|
@ -146,6 +146,44 @@ private:
|
|||
Register m_src2;
|
||||
};
|
||||
|
||||
class GreaterThan final : public Instruction {
|
||||
public:
|
||||
GreaterThan(Register dst, Register src1, Register src2)
|
||||
: Instruction(Type::GreaterThan)
|
||||
, m_dst(dst)
|
||||
, m_src1(src1)
|
||||
, m_src2(src2)
|
||||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string() const;
|
||||
|
||||
private:
|
||||
Register m_dst;
|
||||
Register m_src1;
|
||||
Register m_src2;
|
||||
};
|
||||
|
||||
class GreaterThanEquals final : public Instruction {
|
||||
public:
|
||||
GreaterThanEquals(Register dst, Register src1, Register src2)
|
||||
: Instruction(Type::GreaterThanEquals)
|
||||
, m_dst(dst)
|
||||
, m_src1(src1)
|
||||
, m_src2(src2)
|
||||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string() const;
|
||||
|
||||
private:
|
||||
Register m_dst;
|
||||
Register m_src1;
|
||||
Register m_src2;
|
||||
};
|
||||
|
||||
class LessThan final : public Instruction {
|
||||
public:
|
||||
LessThan(Register dst, Register src1, Register src2)
|
||||
|
@ -165,6 +203,25 @@ private:
|
|||
Register m_src2;
|
||||
};
|
||||
|
||||
class LessThanEquals final : public Instruction {
|
||||
public:
|
||||
LessThanEquals(Register dst, Register src1, Register src2)
|
||||
: Instruction(Type::LessThanEquals)
|
||||
, m_dst(dst)
|
||||
, m_src1(src1)
|
||||
, m_src2(src2)
|
||||
{
|
||||
}
|
||||
|
||||
void execute(Bytecode::Interpreter&) const;
|
||||
String to_string() const;
|
||||
|
||||
private:
|
||||
Register m_dst;
|
||||
Register m_src1;
|
||||
Register m_src2;
|
||||
};
|
||||
|
||||
class AbstractInequals final : public Instruction {
|
||||
public:
|
||||
AbstractInequals(Register dst, Register src1, Register src2)
|
||||
|
|
Loading…
Reference in a new issue