Exemplo n.º 1
0
int CodeGenerator::checkLiteralString(const std::string &str, int &index,
                                      AnalysisResultPtr ar, BlockScopePtr bs,
                                      bool scalarVariant /* = false */) {
  always_assert(getContext() != CodeGenerator::CppConstantsDecl &&
         getContext() != CodeGenerator::CppClassConstantsImpl);
  int stringId = ar->getLiteralStringId(str, index);
  if (m_literalScope) {
    bs = m_literalScope;
  }
  if (bs && bs != ar) {
    FileScopePtr fs = bs->getContainingFile();
    if (fs) {
      fs->addUsedLiteralString(str);
      if (scalarVariant) fs->addUsedLitVarString(str);
      if (isFileOrClassHeader()) {
        ClassScopePtr cs = bs->getContainingClass();
        if (cs) {
          cs->addUsedLiteralStringHeader(str);
          if (scalarVariant) cs->addUsedLitVarStringHeader(str);
        } else {
          fs->addUsedLiteralStringHeader(str);
          if (scalarVariant) fs->addUsedLitVarStringHeader(str);
        }
      }
    }
  }

  return stringId;
}
Exemplo n.º 2
0
int CodeGenerator::checkLiteralString(const std::string &str,
                                      AnalysisResultPtr ar) {
  if (Option::PrecomputeLiteralStrings &&
      getOutput() != CodeGenerator::SystemCPP &&
      getContext() != CodeGenerator::CppConstantsDecl &&
      getContext() != CodeGenerator::CppClassConstantsImpl &&
      ar->getLiteralStringCount() > 0) {
    int stringId = ar->getLiteralStringId(str);
    if (stringId >= 0) return stringId;
  }
  return -1;
}
Exemplo n.º 3
0
int CodeGenerator::checkLiteralString(const std::string &str, int &index,
                                      AnalysisResultPtr ar) {
  if (Option::PrecomputeLiteralStrings &&
      (getOutput() != CodeGenerator::SystemCPP ||
       Option::UseNamedLiteralString) &&
      getContext() != CodeGenerator::CppConstantsDecl &&
      getContext() != CodeGenerator::CppClassConstantsImpl) {
    int stringId = ar->getLiteralStringId(str, index);
    if (stringId >= 0) return stringId;
  }
  index = -1;
  return -1;
}