当前位置: 首页>>代码示例>>C++>>正文


C++ ModuleGenerator::addMemoryExport方法代码示例

本文整理汇总了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));
}
开发者ID:kitcambridge,项目名称:gecko-dev,代码行数:12,代码来源:Wasm.cpp

示例2: Fail

static bool
DecodeMemory(JSContext* cx, Decoder& d, ModuleGenerator& mg, MutableHandle<ArrayBufferObject*> heap)
{
    uint32_t sectionStart;
    if (!d.startSection(MemoryId, &sectionStart))
        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;
}
开发者ID:cbradley857,项目名称:gecko-dev,代码行数:48,代码来源:Wasm.cpp


注:本文中的ModuleGenerator::addMemoryExport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。