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()); }
static void ReportInfo(TInfoSinkBase& sink, TPrefixType type, TSourceLoc loc, const char* reason, const char* token, const char* extraInfo) { /* VC++ format: file(linenum) : error #: 'token' : extrainfo */ sink.prefix(type); sink.location(loc); sink << "'" << token << "' : " << reason << " " << extraInfo << "\n"; }
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; }
void OutputTreeText(TInfoSinkBase& sink, TIntermNode* node, const int depth) { int i; sink.location(node->getLine()); for (i = 0; i < depth; ++i) sink << " "; }
std::string StructureHLSL::structsHeader() const { TInfoSinkBase out; for (size_t structIndex = 0; structIndex < mStructDeclarations.size(); structIndex++) { out << mStructDeclarations[structIndex]; } for (Constructors::const_iterator constructor = mConstructors.begin(); constructor != mConstructors.end(); constructor++) { out << *constructor; } return out.str(); }