本文整理汇总了C++中ModuleGenerator::numFuncSigs方法的典型用法代码示例。如果您正苦于以下问题:C++ ModuleGenerator::numFuncSigs方法的具体用法?C++ ModuleGenerator::numFuncSigs怎么用?C++ ModuleGenerator::numFuncSigs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleGenerator
的用法示例。
在下文中一共展示了ModuleGenerator::numFuncSigs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Fail
static bool
DecodeFunctionBodies(JSContext* cx, Decoder& d, ModuleGenerator& mg)
{
if (!mg.startFuncDefs())
return false;
uint32_t sectionStart;
if (!d.startSection(FunctionBodiesId, §ionStart))
return Fail(cx, d, "failed to start section");
if (sectionStart == Decoder::NotStarted) {
if (mg.numFuncSigs() != 0)
return Fail(cx, d, "expected function bodies");
return mg.finishFuncDefs();
}
uint32_t numFuncBodies;
if (!d.readVarU32(&numFuncBodies))
return Fail(cx, d, "expected function body count");
if (numFuncBodies != mg.numFuncSigs())
return Fail(cx, d, "function body count does not match function signature count");
for (uint32_t funcIndex = 0; funcIndex < numFuncBodies; funcIndex++) {
if (!DecodeFunctionBody(cx, d, mg, funcIndex))
return false;
}
if (!d.finishSection(sectionStart))
return Fail(cx, d, "function section byte size mismatch");
return mg.finishFuncDefs();
}
示例2: Fail
static bool
DecodeExport(JSContext* cx, Decoder& d, ModuleGenerator& mg, ExportMap* exportMap)
{
if (!d.readCStringIf(FuncSubsection))
return Fail(cx, d, "expected 'func' tag");
uint32_t funcIndex;
if (!d.readVarU32(&funcIndex))
return Fail(cx, d, "expected export internal index");
if (funcIndex >= mg.numFuncSigs())
return Fail(cx, d, "export function index out of range");
uint32_t exportIndex;
if (!mg.declareExport(funcIndex, &exportIndex))
return false;
MOZ_ASSERT(exportIndex <= exportMap->exportNames.length());
if (exportIndex == exportMap->exportNames.length()) {
UniqueChars funcName(JS_smprintf("%u", unsigned(funcIndex)));
if (!funcName || !exportMap->exportNames.emplaceBack(Move(funcName)))
return false;
}
if (!exportMap->fieldsToExports.append(exportIndex))
return false;
const char* chars;
if (!d.readCString(&chars))
return Fail(cx, d, "expected export external name string");
return exportMap->fieldNames.emplaceBack(DuplicateString(chars));
}
示例3: Fail
static bool
DecodeFunctionSections(JSContext* cx, Decoder& d, ModuleGenerator& mg)
{
if (!mg.startFuncDefs())
return false;
uint32_t funcIndex = 0;
for (; d.readCStringIf(FuncLabel); funcIndex++) {
if (funcIndex >= mg.numFuncSigs())
return Fail(cx, d, "more function definitions than declarations");
if (!DecodeFunctionSection(cx, d, mg, funcIndex))
return false;
}
if (funcIndex < mg.numFuncSigs())
return Fail(cx, d, "fewer function definitions than declarations");
if (!mg.finishFuncDefs())
return false;
return true;
}