Implement more things according to newer ECMAScript spec

* Fix parser error related with async arrow function
* CodeBlock may have diffrent source code start position data(from `function` keyword)
  - new ECMAScript spec says we should make function source string from `function` keyword
* Apply new spec on builtin Function constructor
* AsyncFunctions must have correct initial properties

Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
This commit is contained in:
Seonghyun Kim 2020-01-17 15:17:08 +09:00 committed by Hyukwoo Park
commit ae35a576f5
25 changed files with 178 additions and 204 deletions

View file

@ -38,14 +38,16 @@
namespace Escargot {
ScriptFunctionObject::ScriptFunctionObject(ExecutionState& state, CodeBlock* codeBlock, LexicalEnvironment* outerEnv, bool isConstructor, bool isGenerator)
ScriptFunctionObject::ScriptFunctionObject(ExecutionState& state, CodeBlock* codeBlock, LexicalEnvironment* outerEnv, bool isConstructor, bool isGenerator, bool isAsync)
: ScriptFunctionObject(state, codeBlock, outerEnv,
((isConstructor || isGenerator) ? (ESCARGOT_OBJECT_BUILTIN_PROPERTY_NUMBER + 3) : (ESCARGOT_OBJECT_BUILTIN_PROPERTY_NUMBER + 2)) + (codeBlock->isStrict() ? 2 : 0))
{
initStructureAndValues(state, isConstructor, isGenerator);
initStructureAndValues(state, isConstructor, isGenerator, isAsync);
if (isGenerator) {
Object::setPrototypeForIntrinsicObjectCreation(state, state.context()->globalObject()->generator());
} else if (isAsync) {
Object::setPrototypeForIntrinsicObjectCreation(state, state.context()->globalObject()->asyncFunctionPrototype());
} else {
Object::setPrototypeForIntrinsicObjectCreation(state, state.context()->globalObject()->functionPrototype());
}