TString TOutputGLSLBase::getTypeName(const TType& type) { TInfoSinkBase out; if (type.isMatrix()) { out << "mat"; out << type.getNominalSize(); } else if (type.isVector()) { switch (type.getBasicType()) { case EbtFloat: out << "vec"; break; case EbtInt: out << "ivec"; break; case EbtBool: out << "bvec"; break; default: UNREACHABLE(); break; } out << type.getNominalSize(); } else { if (type.getBasicType() == EbtStruct) out << hashName(type.getTypeName()); else out << type.getBasicString(); } return TString(out.c_str()); }
TIntermSymbol *TIntermTraverser::createTempSymbol(const TType &type, TQualifier qualifier) { // Each traversal uses at most one temporary variable, so the index stays the same within a single traversal. TInfoSinkBase symbolNameOut; ASSERT(mTemporaryIndex != nullptr); symbolNameOut << "s" << (*mTemporaryIndex); TString symbolName = symbolNameOut.c_str(); TIntermSymbol *node = new TIntermSymbol(0, symbolName, type); node->setInternal(true); node->getTypePointer()->setQualifier(qualifier); return node; }
TIntermSymbol *TIntermTraverser::createTempSymbol(const TType &type, TQualifier qualifier) { // Each traversal uses at most one temporary variable, so the index stays the same within a single traversal. TInfoSinkBase symbolNameOut; ASSERT(mTemporaryIndex != nullptr); symbolNameOut << "s" << (*mTemporaryIndex); TString symbolName = symbolNameOut.c_str(); TIntermSymbol *node = new TIntermSymbol(0, symbolName, type); node->setInternal(true); ASSERT(qualifier == EvqTemporary || qualifier == EvqConst || qualifier == EvqGlobal); node->getTypePointer()->setQualifier(qualifier); // TODO(oetuaho): Might be useful to sanitize layout qualifier etc. on the type of the created // symbol. This might need to be done in other places as well. return node; }