mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:07:45 +00:00
LibJS+LibWeb: Move JS::ModuleRequest to its own header file
This allows us to not include LibJS/AST.h in a couple more places.
This commit is contained in:
parent
38c7fdaac1
commit
3503c658fb
7 changed files with 47 additions and 29 deletions
|
@ -23,6 +23,7 @@
|
|||
#include <LibJS/Runtime/Completion.h>
|
||||
#include <LibJS/Runtime/EnvironmentCoordinate.h>
|
||||
#include <LibJS/Runtime/FunctionKind.h>
|
||||
#include <LibJS/Runtime/ModuleRequest.h>
|
||||
#include <LibJS/Runtime/PropertyKey.h>
|
||||
#include <LibJS/Runtime/Reference.h>
|
||||
#include <LibJS/Runtime/Value.h>
|
||||
|
@ -273,31 +274,6 @@ private:
|
|||
NonnullRefPtrVector<FunctionDeclaration> m_functions_hoistable_with_annexB_extension;
|
||||
};
|
||||
|
||||
// 2.9 ModuleRequest Records, https://tc39.es/proposal-import-assertions/#sec-modulerequest-record
|
||||
struct ModuleRequest {
|
||||
struct Assertion {
|
||||
String key;
|
||||
String value;
|
||||
};
|
||||
|
||||
ModuleRequest() = default;
|
||||
|
||||
explicit ModuleRequest(FlyString specifier)
|
||||
: module_specifier(move(specifier))
|
||||
{
|
||||
}
|
||||
|
||||
ModuleRequest(FlyString module_specifier, Vector<Assertion> assertions);
|
||||
|
||||
void add_assertion(String key, String value)
|
||||
{
|
||||
assertions.empend(move(key), move(value));
|
||||
}
|
||||
|
||||
FlyString module_specifier; // [[Specifier]]
|
||||
Vector<Assertion> assertions; // [[Assertions]]
|
||||
};
|
||||
|
||||
// ImportEntry Record, https://tc39.es/ecma262/#table-importentry-record-fields
|
||||
struct ImportEntry {
|
||||
FlyString import_name; // [[ImportName]] if a String
|
||||
|
|
|
@ -4,8 +4,10 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/AST.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibJS/CyclicModule.h>
|
||||
#include <LibJS/Runtime/ModuleRequest.h>
|
||||
#include <LibJS/Runtime/PromiseCapability.h>
|
||||
#include <LibJS/Runtime/PromiseConstructor.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
|
|
|
@ -181,6 +181,7 @@ class Interpreter;
|
|||
class Intrinsics;
|
||||
class MetaProperty;
|
||||
class Module;
|
||||
struct ModuleRequest;
|
||||
class NativeFunction;
|
||||
class ObjectEnvironment;
|
||||
class Parser;
|
||||
|
|
39
Userland/Libraries/LibJS/Runtime/ModuleRequest.h
Normal file
39
Userland/Libraries/LibJS/Runtime/ModuleRequest.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (c) 2021-2022, David Tuin <davidot@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/FlyString.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
// 2.9 ModuleRequest Records, https://tc39.es/proposal-import-assertions/#sec-modulerequest-record
|
||||
struct ModuleRequest {
|
||||
struct Assertion {
|
||||
String key;
|
||||
String value;
|
||||
};
|
||||
|
||||
ModuleRequest() = default;
|
||||
|
||||
explicit ModuleRequest(FlyString specifier)
|
||||
: module_specifier(move(specifier))
|
||||
{
|
||||
}
|
||||
|
||||
ModuleRequest(FlyString module_specifier, Vector<Assertion> assertions);
|
||||
|
||||
void add_assertion(String key, String value)
|
||||
{
|
||||
assertions.empend(move(key), move(value));
|
||||
}
|
||||
|
||||
FlyString module_specifier; // [[Specifier]]
|
||||
Vector<Assertion> assertions; // [[Assertions]]
|
||||
};
|
||||
|
||||
}
|
|
@ -7,12 +7,12 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/AST.h>
|
||||
#include <LibJS/Heap/DeferGC.h>
|
||||
#include <LibJS/Module.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/Environment.h>
|
||||
#include <LibJS/Runtime/FinalizationRegistry.h>
|
||||
#include <LibJS/Runtime/ModuleRequest.h>
|
||||
#include <LibJS/Runtime/NativeFunction.h>
|
||||
#include <LibJS/Runtime/VM.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/URLParser.h>
|
||||
#include <LibJS/AST.h>
|
||||
#include <LibJS/Runtime/ModuleRequest.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Scripting/Fetching.h>
|
||||
#include <LibWeb/HTML/Scripting/ModuleScript.h>
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/AST.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/ModuleRequest.h>
|
||||
#include <LibWeb/HTML/Scripting/Environments.h>
|
||||
#include <LibWeb/HTML/Scripting/Fetching.h>
|
||||
#include <LibWeb/HTML/Scripting/ModuleScript.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue