示例#1
0
bool
ModuleGenerator::declareExport(UniqueChars fieldName, uint32_t funcIndex, uint32_t* exportIndex)
{
    if (!exportMap_->fieldNames.append(Move(fieldName)))
        return false;

    FuncIndexMap::AddPtr p = funcIndexToExport_.lookupForAdd(funcIndex);
    if (p) {
        if (exportIndex)
            *exportIndex = p->value();
        return exportMap_->fieldsToExports.append(p->value());
    }

    uint32_t newExportIndex = module_->exports.length();
    MOZ_ASSERT(newExportIndex < MaxExports);

    if (exportIndex)
        *exportIndex = newExportIndex;

    Sig copy;
    if (!copy.clone(funcSig(funcIndex)))
        return false;

    return module_->exports.append(Move(copy)) &&
           funcIndexToExport_.add(p, funcIndex, newExportIndex) &&
           exportMap_->fieldsToExports.append(newExportIndex) &&
           exportMap_->exportFuncIndices.append(funcIndex);
}
示例#2
0
bool
ModuleGenerator::declareExport(uint32_t funcIndex, uint32_t* exportIndex)
{
    FuncIndexMap::AddPtr p = funcIndexToExport_.lookupForAdd(funcIndex);
    if (p) {
        *exportIndex = p->value();
        return true;
    }

    Sig copy;
    if (!copy.clone(funcSig(funcIndex)))
        return false;

    *exportIndex = module_->exports.length();
    return funcIndexToExport_.add(p, funcIndex, *exportIndex) &&
           module_->exports.append(Move(copy)) &&
           exportFuncIndices_.append(funcIndex);
}