// // Merge the compilation units within the given stage into a single TIntermediate. // // Return true for success. // bool TProgram::linkStage(EShLanguage stage, EShMessages messages) { if (stages[stage].size() == 0) return true; // // Be efficient for the common single compilation unit per stage case, // reusing it's TIntermediate instead of merging into a new one. // if (stages[stage].size() == 1) intermediate[stage] = stages[stage].front()->intermediate; else { intermediate[stage] = new TIntermediate(stage); newedIntermediate[stage] = true; } infoSink->info << "\nLinked " << StageName(stage) << " stage:\n\n"; if (stages[stage].size() > 1) { std::list<TShader*>::const_iterator it; for (it = stages[stage].begin(); it != stages[stage].end(); ++it) intermediate[stage]->merge(*infoSink, *(*it)->intermediate); } intermediate[stage]->finalCheck(*infoSink); if (messages & EShMsgAST) intermediate[stage]->output(*infoSink, true); return intermediate[stage]->getNumErrors() == 0; }
// // Link-time error emitter. // void TIntermediate::error(TInfoSink& infoSink, const char* message) { infoSink.info.prefix(EPrefixError); infoSink.info << "Linking " << StageName(language) << " stage: " << message << "\n"; ++numErrors; }
// // When to use requireStage() // // If only some stages support a feature. // // Operation: If the current stage is not present, give an error message. // void TParseVersions::requireStage(const TSourceLoc& loc, EShLanguageMask languageMask, const char* featureDesc) { if (((1 << language) & languageMask) == 0) error(loc, "not supported in this stage:", featureDesc, StageName(language)); }