3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/linkValidate.cpp
//
// Merge the linker objects from unitLinkerObjects into linkerObjects.
// Duplication is expected and filtered out, but contradictions are an error.
//
Merge the linker objects from unitLinkerObjects into linkerObjects.
Duplication is expected and filtered out, but contradictions are an error.
Merge the linker objects from unitLinkerObjects into linkerObjects . Duplication is expected and filtered out but contradictions are an error .
void TIntermediate::mergeLinkerObjects(TInfoSink& infoSink, TIntermSequence& linkerObjects, const TIntermSequence& unitLinkerObjects)
{
    std::size_t initialNumLinkerObjects = linkerObjects.size();
    for (unsigned int unitLinkObj = 0; unitLinkObj < unitLinkerObjects.size(); ++unitLinkObj) {
        bool merge = true;
        for (std::size_t linkObj = 0; linkObj < initialNumLinkerObjects; ++linkObj) {
            TIntermSymbol* symbol = linkerObjects[linkObj]->getAsSymbolNode();
            TIntermSymbol* unitSymbol = unitLinkerObjects[unitLinkObj]->getAsSymbolNode();
            assert(symbol && unitSymbol);
            if (symbol->getName() == unitSymbol->getName()) {
                merge = false;
                if (symbol->getConstArray().empty() && ! unitSymbol->getConstArray().empty())
                    symbol->setConstArray(unitSymbol->getConstArray());
                if (! symbol->getQualifier().hasBinding() && unitSymbol->getQualifier().hasBinding())
                    symbol->getQualifier().layoutBinding = unitSymbol->getQualifier().layoutBinding;
                mergeImplicitArraySizes(symbol->getWritableType(), unitSymbol->getType());
                mergeErrorCheck(infoSink, *symbol, *unitSymbol, false);
            }
        }
        if (merge)
            linkerObjects.push_back(unitLinkerObjects[unitLinkObj]);
    }
}
void TIntermediate :: mergeLinkerObjects ( TInfoSink & infoSink , TIntermSequence & linkerObjects , const TIntermSequence & unitLinkerObjects ) { std :: size_t initialNumLinkerObjects = linkerObjects . size ( ) ; for ( unsigned int unitLinkObj = 0 ; unitLinkObj < unitLinkerObjects . size ( ) ; ++ unitLinkObj ) { bool merge = true ; for ( std :: size_t linkObj = 0 ; linkObj < initialNumLinkerObjects ; ++ linkObj ) { TIntermSymbol * symbol = linkerObjects [ linkObj ] -> getAsSymbolNode ( ) ; TIntermSymbol * unitSymbol = unitLinkerObjects [ unitLinkObj ] -> getAsSymbolNode ( ) ; assert ( symbol && unitSymbol ) ; if ( symbol -> getName ( ) == unitSymbol -> getName ( ) ) { merge = false ; if ( symbol -> getConstArray ( ) . empty ( ) && ! unitSymbol -> getConstArray ( ) . empty ( ) ) symbol -> setConstArray ( unitSymbol -> getConstArray ( ) ) ; if ( ! symbol -> getQualifier ( ) . hasBinding ( ) && unitSymbol -> getQualifier ( ) . hasBinding ( ) ) symbol -> getQualifier ( ) . layoutBinding = unitSymbol -> getQualifier ( ) . layoutBinding ; mergeImplicitArraySizes ( symbol -> getWritableType ( ) , unitSymbol -> getType ( ) ) ; mergeErrorCheck ( infoSink , * symbol , * unitSymbol , false ) ; } } if ( merge ) linkerObjects . push_back ( unitLinkerObjects [ unitLinkObj ] ) ; } }
Merge the linker objects from unitLinkerObjects into linkerObjects.
Merge the linker objects from unitLinkerObjects into linkerObjects .
// Error check and merge the linker objects (duplicates should not be created) // filter out copy // but if one has an initializer and the other does not, update // the initializer // Similarly for binding // Update implicit array sizes // Check for consistent types/qualification/initializers etc.