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


C++ MutableHandle::init方法代码示例

本文整理汇总了C++中MutableHandle::init方法的典型用法代码示例。如果您正苦于以下问题:C++ MutableHandle::init方法的具体用法?C++ MutableHandle::init怎么用?C++ MutableHandle::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MutableHandle的用法示例。


在下文中一共展示了MutableHandle::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: d

static bool
DecodeModule(JSContext* cx, UniqueChars filename, const uint8_t* bytes, uint32_t length,
             ImportNameVector* importNames, ExportMap* exportMap,
             MutableHandle<WasmModuleObject*> moduleObj)
{
    Decoder d(bytes, bytes + length);

    uint32_t u32;
    if (!d.readU32(&u32) || u32 != MagicNumber)
        return Fail(cx, d, "failed to match magic number");

    if (!d.readU32(&u32) || u32 != EncodingVersion)
        return Fail(cx, d, "failed to match binary version");

    UniqueModuleGeneratorData init = MakeUnique<ModuleGeneratorData>();
    if (!init)
        return false;

    if (!DecodeSignatureSection(cx, d, init.get()))
        return false;

    if (!DecodeDeclarationSection(cx, d, init.get()))
        return false;

    if (!DecodeImportSection(cx, d, init.get(), importNames))
        return false;

    ModuleGenerator mg(cx);
    if (!mg.init(Move(init)))
        return false;

    if (!DecodeExportsSection(cx, d, mg, exportMap))
        return false;

    HeapUsage heapUsage = HeapUsage::None;

    if (!DecodeCodeSection(cx, d, mg))
        return false;

    CacheableCharsVector funcNames;

    while (!d.readCStringIf(EndSection)) {
        if (!DecodeUnknownSection(cx, d))
            return false;
    }

    if (!d.done())
        return Fail(cx, d, "failed to consume all bytes of module");

    UniqueModuleData module;
    UniqueStaticLinkData link;
    SlowFunctionVector slowFuncs(cx);
    if (!mg.finish(heapUsage, Move(filename), Move(funcNames), &module, &link, &slowFuncs))
        return false;

    moduleObj.set(WasmModuleObject::create(cx));
    if (!moduleObj)
        return false;

    if (!moduleObj->init(cx->new_<Module>(Move(module))))
        return false;

    return moduleObj->module().staticallyLink(cx, *link);
}
开发者ID:ajkerrigan,项目名称:gecko-dev,代码行数:64,代码来源:Wasm.cpp

示例2: d

static bool
DecodeModule(JSContext* cx, UniqueChars file, const uint8_t* bytes, uint32_t length,
             ImportNameVector* importNames, UniqueExportMap* exportMap,
             MutableHandle<ArrayBufferObject*> heap, MutableHandle<WasmModuleObject*> moduleObj)
{
    Decoder d(bytes, bytes + length);

    uint32_t u32;
    if (!d.readFixedU32(&u32) || u32 != MagicNumber)
        return Fail(cx, d, "failed to match magic number");

    if (!d.readFixedU32(&u32) || u32 != EncodingVersion)
        return Fail(cx, d, "failed to match binary version");

    UniqueModuleGeneratorData init = js::MakeUnique<ModuleGeneratorData>(cx);
    if (!init)
        return false;

    if (!DecodeSignatures(cx, d, init.get()))
        return false;

    if (!DecodeImportTable(cx, d, init.get(), importNames))
        return false;

    if (!DecodeFunctionSignatures(cx, d, init.get()))
        return false;

    if (!DecodeFunctionTable(cx, d, init.get()))
        return false;

    ModuleGenerator mg(cx);
    if (!mg.init(Move(init), Move(file)))
        return false;

    if (!DecodeMemory(cx, d, mg, heap))
        return false;

    if (!DecodeExportTable(cx, d, mg))
        return false;

    if (!DecodeFunctionBodies(cx, d, mg))
        return false;

    if (!DecodeDataSegments(cx, d, heap))
        return false;

    CacheableCharsVector funcNames;

    while (!d.done()) {
        if (!d.skipSection())
            return Fail(cx, d, "failed to skip unknown section at end");
    }

    UniqueModuleData module;
    UniqueStaticLinkData staticLink;
    SlowFunctionVector slowFuncs(cx);
    if (!mg.finish(Move(funcNames), &module, &staticLink, exportMap, &slowFuncs))
        return false;

    moduleObj.set(WasmModuleObject::create(cx));
    if (!moduleObj)
        return false;

    if (!moduleObj->init(cx->new_<Module>(Move(module))))
        return false;

    return moduleObj->module().staticallyLink(cx, *staticLink);
}
开发者ID:cbradley857,项目名称:gecko-dev,代码行数:68,代码来源:Wasm.cpp


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