summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke <luke.wilde@live.co.uk>2021-06-08 10:13:37 +0100
committerAndreas Kling <kling@serenityos.org>2021-06-08 11:20:10 +0200
commit1dc31842cb1ac27e7ee180db1aa08e98e46527c6 (patch)
tree333de2d7e78236c9c68e68936766e951029d15cf
parentcac94b1c16b8c8063dfad6bf07d3e333c774d2cc (diff)
downloadserenity-1dc31842cb1ac27e7ee180db1aa08e98e46527c6.zip
LibJS: Add sequence expression bytecode generation
-rw-r--r--Userland/Libraries/LibJS/AST.h1
-rw-r--r--Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp10
2 files changed, 11 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/AST.h b/Userland/Libraries/LibJS/AST.h
index 582a083f01..dd2395e810 100644
--- a/Userland/Libraries/LibJS/AST.h
+++ b/Userland/Libraries/LibJS/AST.h
@@ -604,6 +604,7 @@ public:
virtual void dump(int indent) const override;
virtual Value execute(Interpreter&, GlobalObject&) const override;
+ virtual Optional<Bytecode::Register> generate_bytecode(Bytecode::Generator&) const override;
private:
NonnullRefPtrVector<Expression> m_expressions;
diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp
index 53adfbc530..db7763d0a7 100644
--- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp
+++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp
@@ -449,4 +449,14 @@ Optional<Bytecode::Register> ConditionalExpression::generate_bytecode(Bytecode::
return result_reg;
}
+Optional<Bytecode::Register> SequenceExpression::generate_bytecode(Bytecode::Generator& generator) const
+{
+ Optional<Bytecode::Register> last_reg;
+
+ for (auto& expression : m_expressions)
+ last_reg = expression.generate_bytecode(generator);
+
+ return last_reg;
+}
+
}