mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:47:34 +00:00
LibJS: Implement create_dynamic_function() according to the spec
The three major changes are: - Parsing parameters, the function body, and then the full assembled function source all separately. This is required by the spec, as function parameters and body must be valid each on their own, which cannot be guaranteed if we only ever parse the full function. - Returning an ECMAScriptFunctionObject instead of a FunctionExpression that needs to be evaluated separately. This vastly simplifies the {Async,AsyncGenerator,Generator,}Function constructor implementations. Drop '_node' from the function name accordingly. - The prototype is now determined via GetPrototypeFromConstructor and passed to OrdinaryFunctionCreate.
This commit is contained in:
parent
13fe4e8c64
commit
e8519156bc
9 changed files with 299 additions and 87 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <AK/StringBuilder.h>
|
||||
#include <LibJS/AST.h>
|
||||
#include <LibJS/Lexer.h>
|
||||
#include <LibJS/Runtime/FunctionConstructor.h>
|
||||
#include <LibJS/SourceRange.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -173,6 +174,9 @@ public:
|
|||
bool try_parse_arrow_function_expression_failed;
|
||||
};
|
||||
|
||||
// Needs to mess with m_state, and we're not going to expose a non-const getter for that :^)
|
||||
friend ThrowCompletionOr<ECMAScriptFunctionObject*> FunctionConstructor::create_dynamic_function(GlobalObject&, FunctionObject&, FunctionObject*, FunctionKind, MarkedValueList const&);
|
||||
|
||||
private:
|
||||
friend class ScopePusher;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue