diff options
author | Moonchild <moonchild@palemoon.org> | 2020-11-27 15:47:49 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-11-27 15:47:49 +0000 |
commit | 15914ec5780e7867ab508a48a83311c56950f8a9 (patch) | |
tree | 80562c8ff9e25d119fde8725fa89d171ef20bb42 /js/src/builtin | |
parent | b863bd2edc94c16498edc3274531f57fbfc30d3f (diff) | |
download | UXP-15914ec5780e7867ab508a48a83311c56950f8a9.tar UXP-15914ec5780e7867ab508a48a83311c56950f8a9.tar.gz UXP-15914ec5780e7867ab508a48a83311c56950f8a9.tar.lz UXP-15914ec5780e7867ab508a48a83311c56950f8a9.tar.xz UXP-15914ec5780e7867ab508a48a83311c56950f8a9.zip |
Issue #1691 - Part 1: Provide a way of associating a private value with a script
or module.
This is a prerequisite for dynamic import
Diffstat (limited to 'js/src/builtin')
-rw-r--r-- | js/src/builtin/ModuleObject.cpp | 20 | ||||
-rw-r--r-- | js/src/builtin/ModuleObject.h | 6 |
2 files changed, 10 insertions, 16 deletions
diff --git a/js/src/builtin/ModuleObject.cpp b/js/src/builtin/ModuleObject.cpp index 2790b1c44..ae966c89a 100644 --- a/js/src/builtin/ModuleObject.cpp +++ b/js/src/builtin/ModuleObject.cpp @@ -725,6 +725,12 @@ ModuleObject::namespace_() return &value.toObject().as<ModuleNamespaceObject>(); } +ScriptSourceObject* +ModuleObject::scriptSourceObject() const +{ + return &getReservedSlot(ScriptSourceObjectSlot).toObject().as<ScriptSourceObject>(); +} + FunctionDeclarationVector* ModuleObject::functionDeclarations() { @@ -738,8 +744,10 @@ ModuleObject::functionDeclarations() void ModuleObject::init(HandleScript script) { + MOZ_ASSERT(script); initReservedSlot(ScriptSlot, PrivateValue(script)); initReservedSlot(StatusSlot, Int32Value(MODULE_STATUS_UNINSTANTIATED)); + initReservedSlot(ScriptSourceObjectSlot, ObjectValue(script->scriptSourceUnwrap())); } void @@ -868,18 +876,6 @@ ModuleObject::evaluationError() const return getReservedSlot(EvaluationErrorSlot); } -Value -ModuleObject::hostDefinedField() const -{ - return getReservedSlot(HostDefinedSlot); -} - -void -ModuleObject::setHostDefinedField(const JS::Value& value) -{ - setReservedSlot(HostDefinedSlot, value); -} - Scope* ModuleObject::enclosingScope() const { diff --git a/js/src/builtin/ModuleObject.h b/js/src/builtin/ModuleObject.h index dc078e6b2..c2514e876 100644 --- a/js/src/builtin/ModuleObject.h +++ b/js/src/builtin/ModuleObject.h @@ -219,7 +219,7 @@ class ModuleObject : public NativeObject NamespaceSlot, StatusSlot, EvaluationErrorSlot, - HostDefinedSlot, + ScriptSourceObjectSlot, RequestedModulesSlot, ImportEntriesSlot, LocalExportEntriesSlot, @@ -271,7 +271,7 @@ class ModuleObject : public NativeObject ModuleStatus status() const; bool hadEvaluationError() const; Value evaluationError() const; - Value hostDefinedField() const; + ScriptSourceObject* scriptSourceObject() const; ArrayObject& requestedModules() const; ArrayObject& importEntries() const; ArrayObject& localExportEntries() const; @@ -284,8 +284,6 @@ class ModuleObject : public NativeObject static bool Instantiate(JSContext* cx, HandleModuleObject self); static bool Evaluate(JSContext* cx, HandleModuleObject self); - void setHostDefinedField(const JS::Value& value); - // For BytecodeEmitter. bool noteFunctionDeclaration(ExclusiveContext* cx, HandleAtom name, HandleFunction fun); |