3rdparty/bgfx/3rdparty/glslang/glslang/MachineIndependent/linkValidate.cpp
//
// Merge the function bodies and global-level initializers from unitGlobals into globals.
// Will error check duplication of function bodies for the same signature.
//
Merge the function bodies and global-level initializers from unitGlobals into globals.
Will error check duplication of function bodies for the same signature.
Merge the function bodies and global - level initializers from unitGlobals into globals . Will error check duplication of function bodies for the same signature .
void TIntermediate::mergeBodies(TInfoSink& infoSink, TIntermSequence& globals, const TIntermSequence& unitGlobals)
{
    for (unsigned int child = 0; child < globals.size() - 1; ++child) {
        for (unsigned int unitChild = 0; unitChild < unitGlobals.size() - 1; ++unitChild) {
            TIntermAggregate* body = globals[child]->getAsAggregate();
            TIntermAggregate* unitBody = unitGlobals[unitChild]->getAsAggregate();
            if (body && unitBody && body->getOp() == EOpFunction && unitBody->getOp() == EOpFunction && body->getName() == unitBody->getName()) {
                error(infoSink, "Multiple function bodies in multiple compilation units for the same signature in the same stage:");
                infoSink.info << "    " << globals[child]->getAsAggregate()->getName() << "\n";
            }
        }
    }
    globals.insert(globals.end() - 1, unitGlobals.begin(), unitGlobals.end() - 1);
}
void TIntermediate :: mergeBodies ( TInfoSink & infoSink , TIntermSequence & globals , const TIntermSequence & unitGlobals ) { for ( unsigned int child = 0 ; child < globals . size ( ) - 1 ; ++ child ) { for ( unsigned int unitChild = 0 ; unitChild < unitGlobals . size ( ) - 1 ; ++ unitChild ) { TIntermAggregate * body = globals [ child ] -> getAsAggregate ( ) ; TIntermAggregate * unitBody = unitGlobals [ unitChild ] -> getAsAggregate ( ) ; if ( body && unitBody && body -> getOp ( ) == EOpFunction && unitBody -> getOp ( ) == EOpFunction && body -> getName ( ) == unitBody -> getName ( ) ) { error ( infoSink , " " ) ; infoSink . info << " " << globals [ child ] -> getAsAggregate ( ) -> getName ( ) << " \n " ; } } } globals . insert ( globals . end ( ) - 1 , unitGlobals . begin ( ) , unitGlobals . end ( ) - 1 ) ; }
Merge the function bodies and global-level initializers from unitGlobals into globals.
Merge the function bodies and global - level initializers from unitGlobals into globals .
// TODO: link-time performance: Processing in alphabetical order will be faster // Error check the global objects, not including the linker objects // Merge the global objects, just in front of the linker objects