1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:18:12 +00:00

LibJS: Add bytecode instructions for a bunch of unary operators

~, !, +, -, typeof, and void.
This commit is contained in:
Linus Groh 2021-06-07 19:53:47 +01:00
parent 54fc7079c6
commit fa9bad912e
5 changed files with 175 additions and 1 deletions

View file

@ -317,6 +317,91 @@ private:
Register m_src2;
};
class BitwiseNot final : public Instruction {
public:
BitwiseNot(Register dst, Register src)
: Instruction(Type::BitwiseNot)
, m_dst(dst)
, m_src(src)
{
}
void execute(Bytecode::Interpreter&) const;
String to_string() const;
private:
Register m_dst;
Register m_src;
};
class Not final : public Instruction {
public:
Not(Register dst, Register src)
: Instruction(Type::Not)
, m_dst(dst)
, m_src(src)
{
}
void execute(Bytecode::Interpreter&) const;
String to_string() const;
private:
Register m_dst;
Register m_src;
};
class UnaryPlus final : public Instruction {
public:
UnaryPlus(Register dst, Register src)
: Instruction(Type::UnaryPlus)
, m_dst(dst)
, m_src(src)
{
}
void execute(Bytecode::Interpreter&) const;
String to_string() const;
private:
Register m_dst;
Register m_src;
};
class UnaryMinus final : public Instruction {
public:
UnaryMinus(Register dst, Register src)
: Instruction(Type::UnaryMinus)
, m_dst(dst)
, m_src(src)
{
}
void execute(Bytecode::Interpreter&) const;
String to_string() const;
private:
Register m_dst;
Register m_src;
};
class Typeof final : public Instruction {
public:
Typeof(Register dst, Register src)
: Instruction(Type::Typeof)
, m_dst(dst)
, m_src(src)
{
}
void execute(Bytecode::Interpreter&) const;
String to_string() const;
private:
Register m_dst;
Register m_src;
};
class NewString final : public Instruction {
public:
NewString(Register dst, String string)