mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:38:10 +00:00
LibJS: Support LoadRequestedModule AO on SyntheticModule records
This allows test-js to run all the module tests in the new world.
This commit is contained in:
parent
4b1053e327
commit
fc31a0d506
5 changed files with 47 additions and 34 deletions
|
@ -56,6 +56,36 @@ struct ResolvedBinding {
|
|||
}
|
||||
};
|
||||
|
||||
// https://tc39.es/ecma262/#graphloadingstate-record
|
||||
struct GraphLoadingState : public Cell {
|
||||
JS_CELL(GraphLoadingState, Cell);
|
||||
|
||||
public:
|
||||
struct HostDefined : Cell {
|
||||
JS_CELL(HostDefined, Cell);
|
||||
|
||||
public:
|
||||
virtual ~HostDefined() = default;
|
||||
};
|
||||
|
||||
GCPtr<PromiseCapability> promise_capability; // [[PromiseCapability]]
|
||||
bool is_loading { false }; // [[IsLoading]]
|
||||
size_t pending_module_count { 0 }; // [[PendingModulesCount]]
|
||||
HashTable<CyclicModule*> visited; // [[Visited]]
|
||||
GCPtr<HostDefined> host_defined; // [[HostDefined]]
|
||||
|
||||
private:
|
||||
GraphLoadingState(GCPtr<PromiseCapability> promise_capability, bool is_loading, size_t pending_module_count, HashTable<CyclicModule*> visited, GCPtr<HostDefined> host_defined)
|
||||
: promise_capability(move(promise_capability))
|
||||
, is_loading(is_loading)
|
||||
, pending_module_count(pending_module_count)
|
||||
, visited(move(visited))
|
||||
, host_defined(move(host_defined))
|
||||
{
|
||||
}
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
};
|
||||
|
||||
// 16.2.1.4 Abstract Module Records, https://tc39.es/ecma262/#sec-abstract-module-records
|
||||
class Module : public Cell {
|
||||
JS_CELL(Module, Cell);
|
||||
|
@ -84,6 +114,8 @@ public:
|
|||
virtual ThrowCompletionOr<u32> inner_module_linking(VM& vm, Vector<Module*>& stack, u32 index);
|
||||
virtual ThrowCompletionOr<u32> inner_module_evaluation(VM& vm, Vector<Module*>& stack, u32 index);
|
||||
|
||||
virtual PromiseCapability& load_requested_modules(GCPtr<GraphLoadingState::HostDefined>) = 0;
|
||||
|
||||
protected:
|
||||
Module(Realm&, DeprecatedString filename, Script::HostDefined* host_defined = nullptr);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue