diff options
author | Andreas Kling <kling@serenityos.org> | 2020-04-17 19:59:32 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-18 10:28:22 +0200 |
commit | f6d57c82f6dbbb5c7e18bffb43d0258956aa0d46 (patch) | |
tree | 1a2a20ded1dccf299926da1f02babf3e30c386b3 /Libraries/LibJS/Runtime/ScriptFunction.cpp | |
parent | 205ac0090da21c593ac7cef7db348412e4f52168 (diff) | |
download | serenity-f6d57c82f6dbbb5c7e18bffb43d0258956aa0d46.zip |
LibJS: Pass prototype to Function constructors
Diffstat (limited to 'Libraries/LibJS/Runtime/ScriptFunction.cpp')
-rw-r--r-- | Libraries/LibJS/Runtime/ScriptFunction.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Libraries/LibJS/Runtime/ScriptFunction.cpp b/Libraries/LibJS/Runtime/ScriptFunction.cpp index 67801181f6..1348eb4d05 100644 --- a/Libraries/LibJS/Runtime/ScriptFunction.cpp +++ b/Libraries/LibJS/Runtime/ScriptFunction.cpp @@ -28,13 +28,21 @@ #include <LibJS/AST.h> #include <LibJS/Interpreter.h> #include <LibJS/Runtime/Error.h> +#include <LibJS/Runtime/GlobalObject.h> #include <LibJS/Runtime/ScriptFunction.h> #include <LibJS/Runtime/Value.h> namespace JS { -ScriptFunction::ScriptFunction(const FlyString& name, const Statement& body, Vector<FlyString> parameters, LexicalEnvironment* parent_environment) - : m_name(name) +ScriptFunction* ScriptFunction::create(GlobalObject& global_object, const FlyString& name, const Statement& body, Vector<FlyString> parameters, LexicalEnvironment* parent_environment) +{ + auto& interpreter = global_object.interpreter(); + return interpreter.heap().allocate<ScriptFunction>(name, body, move(parameters), parent_environment, *interpreter.function_prototype()); +} + +ScriptFunction::ScriptFunction(const FlyString& name, const Statement& body, Vector<FlyString> parameters, LexicalEnvironment* parent_environment, Object& prototype) + : Function(prototype) + , m_name(name) , m_body(body) , m_parameters(move(parameters)) , m_parent_environment(parent_environment) |