mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:57:35 +00:00
LibJS: Implement the NewDeclarativeEnvironment() abstract operation
This commit is contained in:
parent
c6baeca6d7
commit
d8e9a176cd
4 changed files with 16 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
|
* Copyright (c) 2020-2021, Linus Groh <linusg@serenityos.org>
|
||||||
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
@ -8,6 +9,7 @@
|
||||||
#include <AK/Result.h>
|
#include <AK/Result.h>
|
||||||
#include <LibJS/Runtime/AbstractOperations.h>
|
#include <LibJS/Runtime/AbstractOperations.h>
|
||||||
#include <LibJS/Runtime/BoundFunction.h>
|
#include <LibJS/Runtime/BoundFunction.h>
|
||||||
|
#include <LibJS/Runtime/DeclarativeEnvironmentRecord.h>
|
||||||
#include <LibJS/Runtime/ErrorTypes.h>
|
#include <LibJS/Runtime/ErrorTypes.h>
|
||||||
#include <LibJS/Runtime/Function.h>
|
#include <LibJS/Runtime/Function.h>
|
||||||
#include <LibJS/Runtime/GlobalObject.h>
|
#include <LibJS/Runtime/GlobalObject.h>
|
||||||
|
@ -156,4 +158,11 @@ Object* get_prototype_from_constructor(GlobalObject& global_object, Function con
|
||||||
return &prototype.as_object();
|
return &prototype.as_object();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 9.1.2.2 NewDeclarativeEnvironment ( E ), https://tc39.es/ecma262/#sec-newdeclarativeenvironment
|
||||||
|
DeclarativeEnvironmentRecord* new_declarative_environment(EnvironmentRecord& environment_record)
|
||||||
|
{
|
||||||
|
auto& global_object = environment_record.global_object();
|
||||||
|
return global_object.heap().allocate<DeclarativeEnvironmentRecord>(global_object, &environment_record);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
namespace JS {
|
namespace JS {
|
||||||
|
|
||||||
|
DeclarativeEnvironmentRecord* new_declarative_environment(EnvironmentRecord&);
|
||||||
Value require_object_coercible(GlobalObject&, Value);
|
Value require_object_coercible(GlobalObject&, Value);
|
||||||
Function* get_method(GlobalObject& global_object, Value, PropertyName const&);
|
Function* get_method(GlobalObject& global_object, Value, PropertyName const&);
|
||||||
size_t length_of_array_like(GlobalObject&, Object const&);
|
size_t length_of_array_like(GlobalObject&, Object const&);
|
||||||
|
|
|
@ -24,6 +24,11 @@ DeclarativeEnvironmentRecord::DeclarativeEnvironmentRecord(EnvironmentRecordType
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeclarativeEnvironmentRecord::DeclarativeEnvironmentRecord(EnvironmentRecord* parent_scope)
|
||||||
|
: EnvironmentRecord(parent_scope)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
DeclarativeEnvironmentRecord::DeclarativeEnvironmentRecord(HashMap<FlyString, Variable> variables, EnvironmentRecord* parent_scope)
|
DeclarativeEnvironmentRecord::DeclarativeEnvironmentRecord(HashMap<FlyString, Variable> variables, EnvironmentRecord* parent_scope)
|
||||||
: EnvironmentRecord(parent_scope)
|
: EnvironmentRecord(parent_scope)
|
||||||
, m_variables(move(variables))
|
, m_variables(move(variables))
|
||||||
|
|
|
@ -32,6 +32,7 @@ public:
|
||||||
|
|
||||||
DeclarativeEnvironmentRecord();
|
DeclarativeEnvironmentRecord();
|
||||||
DeclarativeEnvironmentRecord(EnvironmentRecordType);
|
DeclarativeEnvironmentRecord(EnvironmentRecordType);
|
||||||
|
explicit DeclarativeEnvironmentRecord(EnvironmentRecord* parent_scope);
|
||||||
DeclarativeEnvironmentRecord(HashMap<FlyString, Variable> variables, EnvironmentRecord* parent_scope);
|
DeclarativeEnvironmentRecord(HashMap<FlyString, Variable> variables, EnvironmentRecord* parent_scope);
|
||||||
DeclarativeEnvironmentRecord(HashMap<FlyString, Variable> variables, EnvironmentRecord* parent_scope, EnvironmentRecordType);
|
DeclarativeEnvironmentRecord(HashMap<FlyString, Variable> variables, EnvironmentRecord* parent_scope, EnvironmentRecordType);
|
||||||
virtual ~DeclarativeEnvironmentRecord() override;
|
virtual ~DeclarativeEnvironmentRecord() override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue