summaryrefslogtreecommitdiff
path: root/js/src/builtin/ModuleObject.h
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-11-28 10:17:43 +0000
committerMoonchild <moonchild@palemoon.org>2020-11-28 10:17:43 +0000
commite6b9d9cbeae7d90a7f368517c67775c0d72c6445 (patch)
treeb10c4075973d3949a47d60becd9db46b8e505fe4 /js/src/builtin/ModuleObject.h
parentb863bd2edc94c16498edc3274531f57fbfc30d3f (diff)
downloaduxp-e6b9d9cbeae7d90a7f368517c67775c0d72c6445.tar.gz
Issue #1624 - Add missing error handling and bail on null specifier.modulefix
Diffstat (limited to 'js/src/builtin/ModuleObject.h')
-rw-r--r--js/src/builtin/ModuleObject.h41
1 files changed, 37 insertions, 4 deletions
diff --git a/js/src/builtin/ModuleObject.h b/js/src/builtin/ModuleObject.h
index dc078e6b28..fde02c6938 100644
--- a/js/src/builtin/ModuleObject.h
+++ b/js/src/builtin/ModuleObject.h
@@ -100,6 +100,32 @@ class ExportEntryObject : public NativeObject
typedef Rooted<ExportEntryObject*> RootedExportEntryObject;
typedef Handle<ExportEntryObject*> HandleExportEntryObject;
+class RequestedModuleObject : public NativeObject
+{
+ public:
+ enum
+ {
+ ModuleSpecifierSlot = 0,
+ LineNumberSlot,
+ ColumnNumberSlot,
+ SlotCount
+ };
+
+ static const Class class_;
+ static JSObject* initClass(JSContext* cx, HandleObject obj);
+ static bool isInstance(HandleValue value);
+ static RequestedModuleObject* create(JSContext* cx,
+ HandleAtom moduleSpecifier,
+ uint32_t lineNumber,
+ uint32_t columnNumber);
+ JSAtom* moduleSpecifier() const;
+ uint32_t lineNumber() const;
+ uint32_t columnNumber() const;
+};
+
+typedef Rooted<RequestedModuleObject*> RootedRequestedModuleObject;
+typedef Handle<RequestedModuleObject*> HandleRequestedModuleObject;
+
class IndirectBindingMap
{
public:
@@ -318,6 +344,8 @@ class MOZ_STACK_CLASS ModuleBuilder
explicit ModuleBuilder(ExclusiveContext* cx, HandleModuleObject module,
const frontend::TokenStream& tokenStream);
+ bool init();
+
bool processImport(frontend::ParseNode* pn);
bool processExport(frontend::ParseNode* pn);
bool processExportFrom(frontend::ParseNode* pn);
@@ -334,15 +362,20 @@ class MOZ_STACK_CLASS ModuleBuilder
private:
using AtomVector = GCVector<JSAtom*>;
- using RootedAtomVector = JS::Rooted<AtomVector>;
using ImportEntryVector = GCVector<ImportEntryObject*>;
+ using RequestedModuleVector = GCVector<RequestedModuleObject*>;
+ using AtomSet = JS::GCHashSet<JSAtom*>;
+ using RootedAtomVector = JS::Rooted<AtomVector>;
using RootedImportEntryVector = JS::Rooted<ImportEntryVector>;
using RootedExportEntryVector = JS::Rooted<ExportEntryVector>;
+ using RootedRequestedModuleVector = JS::Rooted<RequestedModuleVector>;
+ using RootedAtomSet = JS::Rooted<AtomSet>;
ExclusiveContext* cx_;
RootedModuleObject module_;
const frontend::TokenStream& tokenStream_;
- RootedAtomVector requestedModules_;
+ RootedAtomSet requestedModuleSpecifiers_;
+ RootedRequestedModuleVector requestedModules_;
RootedAtomVector importedBoundNames_;
RootedImportEntryVector importEntries_;
RootedExportEntryVector exportEntries_;
@@ -357,10 +390,10 @@ class MOZ_STACK_CLASS ModuleBuilder
bool appendExportFromEntry(HandleAtom exportName, HandleAtom moduleRequest,
HandleAtom importName, frontend::ParseNode* node);
- bool maybeAppendRequestedModule(HandleAtom module);
+ bool maybeAppendRequestedModule(HandleAtom specifier, frontend::ParseNode* node);
template <typename T>
- ArrayObject* createArray(const GCVector<T>& vector);
+ ArrayObject* createArray(const JS::Rooted<GCVector<T>>& vector);
};
} // namespace js