summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Bytecode/Op.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-06-11 00:35:25 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-11 00:36:18 +0200
commit9ee5029bc5ab24d614525acd3229300063aa1d68 (patch)
tree20e96f3ea5836d1765acc31ab09093a38379987e /Userland/Libraries/LibJS/Bytecode/Op.h
parentb47246ec70e8243639772cc1cc280ed42a6c4ff5 (diff)
downloadserenity-9ee5029bc5ab24d614525acd3229300063aa1d68.zip
LibJS: Basic bytecode support for computed member expressions
Expressions like foo[1 + 2] now work, and you can assign to them as well! :^)
Diffstat (limited to 'Userland/Libraries/LibJS/Bytecode/Op.h')
-rw-r--r--Userland/Libraries/LibJS/Bytecode/Op.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h
index f5961b87e0..79212526ea 100644
--- a/Userland/Libraries/LibJS/Bytecode/Op.h
+++ b/Userland/Libraries/LibJS/Bytecode/Op.h
@@ -266,6 +266,38 @@ private:
StringTableIndex m_property;
};
+class GetByValue final : public Instruction {
+public:
+ explicit GetByValue(Register base)
+ : Instruction(Type::GetByValue)
+ , m_base(base)
+ {
+ }
+
+ void execute(Bytecode::Interpreter&) const;
+ String to_string(Bytecode::Executable const&) const;
+
+private:
+ Register m_base;
+};
+
+class PutByValue final : public Instruction {
+public:
+ PutByValue(Register base, Register property)
+ : Instruction(Type::PutByValue)
+ , m_base(base)
+ , m_property(property)
+ {
+ }
+
+ void execute(Bytecode::Interpreter&) const;
+ String to_string(Bytecode::Executable const&) const;
+
+private:
+ Register m_base;
+ Register m_property;
+};
+
class Jump : public Instruction {
public:
constexpr static bool IsTerminator = true;