本文整理汇总了C++中ModuleGenerator::addMemoryExport方法的典型用法代码示例。如果您正苦于以下问题:C++ ModuleGenerator::addMemoryExport方法的具体用法?C++ ModuleGenerator::addMemoryExport怎么用?C++ ModuleGenerator::addMemoryExport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleGenerator
的用法示例。
在下文中一共展示了ModuleGenerator::addMemoryExport方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Fail
static bool
DecodeMemoryExport(JSContext* cx, Decoder& d, ModuleGenerator& mg, CStringSet* dupSet)
{
if (!mg.usesHeap())
return Fail(cx, d, "cannot export memory with no memory section");
UniqueChars fieldName = DecodeFieldName(cx, d, dupSet);
if (!fieldName)
return false;
return mg.addMemoryExport(Move(fieldName));
}
示例2: Fail
static bool
DecodeMemory(JSContext* cx, Decoder& d, ModuleGenerator& mg, MutableHandle<ArrayBufferObject*> heap)
{
uint32_t sectionStart;
if (!d.startSection(MemoryId, §ionStart))
return Fail(cx, d, "failed to start section");
if (sectionStart == Decoder::NotStarted)
return true;
uint32_t initialSizePages;
if (!d.readVarU32(&initialSizePages))
return Fail(cx, d, "expected initial memory size");
CheckedInt<int32_t> initialSize = initialSizePages;
initialSize *= PageSize;
if (!initialSize.isValid())
return Fail(cx, d, "initial memory size too big");
uint32_t maxSizePages;
if (!d.readVarU32(&maxSizePages))
return Fail(cx, d, "expected initial memory size");
CheckedInt<int32_t> maxSize = maxSizePages;
maxSize *= PageSize;
if (!maxSize.isValid())
return Fail(cx, d, "initial memory size too big");
uint8_t exported;
if (!d.readFixedU8(&exported))
return Fail(cx, d, "expected exported byte");
if (exported) {
UniqueChars fieldName = DuplicateString("memory");
if (!fieldName || !mg.addMemoryExport(Move(fieldName)))
return false;
}
if (!d.finishSection(sectionStart))
return Fail(cx, d, "memory section byte size mismatch");
bool signalsForOOB = CompileArgs(cx).useSignalHandlersForOOB;
heap.set(ArrayBufferObject::createForWasm(cx, initialSize.value(), signalsForOOB));
if (!heap)
return false;
mg.initHeapUsage(HeapUsage::Unshared);
return true;
}