From 2f1d6c0b9a00a8535355d1e7b3032c7cc784ded0 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Thu, 6 Jul 2023 17:16:20 -0400 Subject: [PATCH] LibJS/Bytecode: Ensure we do not generate bytecode for super expressions Similar to AST mode, super expressions are handled elsewhere. --- Userland/Libraries/LibJS/AST.h | 1 + Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Userland/Libraries/LibJS/AST.h b/Userland/Libraries/LibJS/AST.h index 43880c6b3b..4f60e8eafe 100644 --- a/Userland/Libraries/LibJS/AST.h +++ b/Userland/Libraries/LibJS/AST.h @@ -1435,6 +1435,7 @@ public: virtual Completion execute(Interpreter&) const override; virtual void dump(int indent) const override; + virtual Bytecode::CodeGenerationErrorOr generate_bytecode(Bytecode::Generator&) const override; virtual bool is_super_expression() const override { return true; } }; diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index 6806721221..fc43a8ff71 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -2348,6 +2348,12 @@ Bytecode::CodeGenerationErrorOr SwitchStatement::generate_labelled_evaluat return {}; } +Bytecode::CodeGenerationErrorOr SuperExpression::generate_bytecode(Bytecode::Generator&) const +{ + // The semantics for SuperExpression are handled in CallExpression and SuperCall. + VERIFY_NOT_REACHED(); +} + Bytecode::CodeGenerationErrorOr ClassDeclaration::generate_bytecode(Bytecode::Generator& generator) const { auto accumulator_backup_reg = generator.allocate_register();