本文整理汇总了C++中JSGlobalObject::moduleNamespaceObjectStructure方法的典型用法代码示例。如果您正苦于以下问题:C++ JSGlobalObject::moduleNamespaceObjectStructure方法的具体用法?C++ JSGlobalObject::moduleNamespaceObjectStructure怎么用?C++ JSGlobalObject::moduleNamespaceObjectStructure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSGlobalObject
的用法示例。
在下文中一共展示了JSGlobalObject::moduleNamespaceObjectStructure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getModuleNamespace
JSModuleNamespaceObject* AbstractModuleRecord::getModuleNamespace(ExecState* exec)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
// http://www.ecma-international.org/ecma-262/6.0/#sec-getmodulenamespace
if (m_moduleNamespaceObject)
return m_moduleNamespaceObject.get();
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
IdentifierSet exportedNames;
getExportedNames(exec, this, exportedNames);
RETURN_IF_EXCEPTION(scope, nullptr);
Vector<std::pair<Identifier, Resolution>> resolutions;
for (auto& name : exportedNames) {
Identifier ident = Identifier::fromUid(exec, name.get());
const Resolution resolution = resolveExport(exec, ident);
RETURN_IF_EXCEPTION(scope, nullptr);
switch (resolution.type) {
case Resolution::Type::NotFound:
throwSyntaxError(exec, scope, makeString("Exported binding name '", String(name.get()), "' is not found."));
return nullptr;
case Resolution::Type::Error:
throwSyntaxError(exec, scope, makeString("Exported binding name 'default' cannot be resolved by star export entries."));
return nullptr;
case Resolution::Type::Ambiguous:
break;
case Resolution::Type::Resolved:
resolutions.append({ WTFMove(ident), resolution });
break;
}
}
auto* moduleNamespaceObject = JSModuleNamespaceObject::create(exec, globalObject, globalObject->moduleNamespaceObjectStructure(), this, WTFMove(resolutions));
RETURN_IF_EXCEPTION(scope, nullptr);
m_moduleNamespaceObject.set(vm, this, moduleNamespaceObject);
return moduleNamespaceObject;
}