diff options
author | Andreas Kling <kling@serenityos.org> | 2021-06-05 15:53:36 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-07 18:11:59 +0200 |
commit | 80b1604b0a90b85f1fbdfecfcffcbf73e5b485bc (patch) | |
tree | 9f5a39f3b47842905c62bc3eb3096f04582937c2 /Userland/Libraries/LibJS/AST.h | |
parent | b609fc6d516f0215a2df92f17c6137afde513c72 (diff) | |
download | serenity-80b1604b0a90b85f1fbdfecfcffcbf73e5b485bc.zip |
LibJS: Compile ScriptFunctions into bytecode and run them that way :^)
If there's a current Bytecode::Interpreter in action, ScriptFunction
will now compile itself into bytecode and execute in that context.
This patch also adds the Return bytecode instruction so that we can
actually return values from called functions. :^)
Return values are propagated from callee to caller via the caller's
$0 register. Bytecode::Interpreter now keeps a stack of register
"windows". These are not very efficient, but it should be pretty
straightforward to convert them to e.g a sliding register window
architecture later on.
This is pretty dang cool! :^)
Diffstat (limited to 'Userland/Libraries/LibJS/AST.h')
-rw-r--r-- | Userland/Libraries/LibJS/AST.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/AST.h b/Userland/Libraries/LibJS/AST.h index d6ff389251..4e156ef655 100644 --- a/Userland/Libraries/LibJS/AST.h +++ b/Userland/Libraries/LibJS/AST.h @@ -329,6 +329,7 @@ public: virtual Value execute(Interpreter&, GlobalObject&) const override; virtual void dump(int indent) const override; + virtual Optional<Bytecode::Register> generate_bytecode(Bytecode::Generator&) const override; private: RefPtr<Expression> m_argument; |