summaryrefslogtreecommitdiffstats
path: root/js/src/builtin/ModuleObject.h
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/builtin/ModuleObject.h')
-rw-r--r--js/src/builtin/ModuleObject.h56
1 files changed, 41 insertions, 15 deletions
diff --git a/js/src/builtin/ModuleObject.h b/js/src/builtin/ModuleObject.h
index 22db762ac..be0315215 100644
--- a/js/src/builtin/ModuleObject.h
+++ b/js/src/builtin/ModuleObject.h
@@ -24,6 +24,7 @@ class ModuleObject;
namespace frontend {
class ParseNode;
+class TokenStream;
} /* namespace frontend */
typedef Rooted<ModuleObject*> RootedModuleObject;
@@ -39,6 +40,8 @@ class ImportEntryObject : public NativeObject
ModuleRequestSlot = 0,
ImportNameSlot,
LocalNameSlot,
+ LineNumberSlot,
+ ColumnNumberSlot,
SlotCount
};
@@ -48,10 +51,14 @@ class ImportEntryObject : public NativeObject
static ImportEntryObject* create(ExclusiveContext* cx,
HandleAtom moduleRequest,
HandleAtom importName,
- HandleAtom localName);
+ HandleAtom localName,
+ uint32_t lineNumber,
+ uint32_t columnNumber);
JSAtom* moduleRequest() const;
JSAtom* importName() const;
JSAtom* localName() const;
+ uint32_t lineNumber() const;
+ uint32_t columnNumber() const;
};
typedef Rooted<ImportEntryObject*> RootedImportEntryObject;
@@ -66,6 +73,8 @@ class ExportEntryObject : public NativeObject
ModuleRequestSlot,
ImportNameSlot,
LocalNameSlot,
+ LineNumberSlot,
+ ColumnNumberSlot,
SlotCount
};
@@ -76,11 +85,15 @@ class ExportEntryObject : public NativeObject
HandleAtom maybeExportName,
HandleAtom maybeModuleRequest,
HandleAtom maybeImportName,
- HandleAtom maybeLocalName);
+ HandleAtom maybeLocalName,
+ uint32_t lineNumber,
+ uint32_t columnNumber);
JSAtom* exportName() const;
JSAtom* moduleRequest() const;
JSAtom* importName() const;
JSAtom* localName() const;
+ uint32_t lineNumber() const;
+ uint32_t columnNumber() const;
};
typedef Rooted<ExportEntryObject*> RootedExportEntryObject;
@@ -192,8 +205,8 @@ struct FunctionDeclaration
using FunctionDeclarationVector = GCVector<FunctionDeclaration, 0, ZoneAllocPolicy>;
-// Possible values for ModuleState are defined in SelfHostingDefines.h.
-using ModuleState = int32_t;
+// Possible values for ModuleStatus are defined in SelfHostingDefines.h.
+using ModuleStatus = int32_t;
class ModuleObject : public NativeObject
{
@@ -204,7 +217,8 @@ class ModuleObject : public NativeObject
InitialEnvironmentSlot,
EnvironmentSlot,
NamespaceSlot,
- StateSlot,
+ StatusSlot,
+ ErrorSlot,
HostDefinedSlot,
RequestedModulesSlot,
ImportEntriesSlot,
@@ -215,11 +229,21 @@ class ModuleObject : public NativeObject
NamespaceExportsSlot,
NamespaceBindingsSlot,
FunctionDeclarationsSlot,
+ DFSIndexSlot,
+ DFSAncestorIndexSlot,
SlotCount
};
static_assert(EnvironmentSlot == MODULE_OBJECT_ENVIRONMENT_SLOT,
"EnvironmentSlot must match self-hosting define");
+ static_assert(StatusSlot == MODULE_OBJECT_STATUS_SLOT,
+ "StatusSlot must match self-hosting define");
+ static_assert(ErrorSlot == MODULE_OBJECT_ERROR_SLOT,
+ "ErrorSlot must match self-hosting define");
+ static_assert(DFSIndexSlot == MODULE_OBJECT_DFS_INDEX_SLOT,
+ "DFSIndexSlot must match self-hosting define");
+ static_assert(DFSAncestorIndexSlot == MODULE_OBJECT_DFS_ANCESTOR_INDEX_SLOT,
+ "DFSAncestorIndexSlot must match self-hosting define");
static const Class class_;
@@ -244,7 +268,8 @@ class ModuleObject : public NativeObject
ModuleEnvironmentObject& initialEnvironment() const;
ModuleEnvironmentObject* environment() const;
ModuleNamespaceObject* namespace_();
- ModuleState state() const;
+ ModuleStatus status() const;
+ Value error() const;
Value hostDefinedField() const;
ArrayObject& requestedModules() const;
ArrayObject& importEntries() const;
@@ -255,8 +280,8 @@ class ModuleObject : public NativeObject
JSObject* namespaceExports();
IndirectBindingMap* namespaceBindings();
- static bool DeclarationInstantiation(JSContext* cx, HandleModuleObject self);
- static bool Evaluation(JSContext* cx, HandleModuleObject self);
+ static bool Instantiate(JSContext* cx, HandleModuleObject self);
+ static bool Evaluate(JSContext* cx, HandleModuleObject self);
void setHostDefinedField(const JS::Value& value);
@@ -269,10 +294,8 @@ class ModuleObject : public NativeObject
// For intrinsic_InstantiateModuleFunctionDeclarations.
static bool instantiateFunctionDeclarations(JSContext* cx, HandleModuleObject self);
- void setState(ModuleState newState);
-
- // For intrinsic_EvaluateModule.
- static bool evaluate(JSContext* cx, HandleModuleObject self, MutableHandleValue rval);
+ // For intrinsic_ExecuteModule.
+ static bool execute(JSContext* cx, HandleModuleObject self, MutableHandleValue rval);
// For intrinsic_NewModuleNamespace.
static ModuleNamespaceObject* createNamespace(JSContext* cx, HandleModuleObject self,
@@ -294,7 +317,8 @@ class ModuleObject : public NativeObject
class MOZ_STACK_CLASS ModuleBuilder
{
public:
- explicit ModuleBuilder(ExclusiveContext* cx, HandleModuleObject module);
+ explicit ModuleBuilder(ExclusiveContext* cx, HandleModuleObject module,
+ const frontend::TokenStream& tokenStream);
bool processImport(frontend::ParseNode* pn);
bool processExport(frontend::ParseNode* pn);
@@ -319,6 +343,7 @@ class MOZ_STACK_CLASS ModuleBuilder
ExclusiveContext* cx_;
RootedModuleObject module_;
+ const frontend::TokenStream& tokenStream_;
RootedAtomVector requestedModules_;
RootedAtomVector importedBoundNames_;
RootedImportEntryVector importEntries_;
@@ -329,9 +354,10 @@ class MOZ_STACK_CLASS ModuleBuilder
ImportEntryObject* importEntryFor(JSAtom* localName) const;
- bool appendExportEntry(HandleAtom exportName, HandleAtom localName);
+ bool appendExportEntry(HandleAtom exportName, HandleAtom localName,
+ frontend::ParseNode* node = nullptr);
bool appendExportFromEntry(HandleAtom exportName, HandleAtom moduleRequest,
- HandleAtom importName);
+ HandleAtom importName, frontend::ParseNode* node);
bool maybeAppendRequestedModule(HandleAtom module);