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)); }
static bool DecodeFunctionExport(JSContext* cx, Decoder& d, ModuleGenerator& mg, CStringSet* dupSet) { 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"); UniqueChars fieldName = DecodeFieldName(cx, d, dupSet); if (!fieldName) return false; return mg.declareExport(Move(fieldName), funcIndex); }