From 4934d16397877028fc3a126e3630b7b853a762f4 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 4 Jun 2021 11:38:17 +0200 Subject: [PATCH] LibJS: Make Bytecode::Generator::emit() return the created instruction This will be useful for instructions that need to be modified later on during code generation, e.g jumps. :^) --- Userland/Libraries/LibJS/Bytecode/Generator.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Bytecode/Generator.h b/Userland/Libraries/LibJS/Bytecode/Generator.h index ed4fa05818..f5dcee15d3 100644 --- a/Userland/Libraries/LibJS/Bytecode/Generator.h +++ b/Userland/Libraries/LibJS/Bytecode/Generator.h @@ -18,10 +18,12 @@ public: Register allocate_register(); template - void emit(Args&&... args) + OpType& emit(Args&&... args) { auto instruction = make(forward(args)...); + auto* ptr = instruction.ptr(); append(move(instruction)); + return *ptr; } private: