Beispiel #1
0
void TypeAnnotation::functionTypeName(std::string &name) const {
  name += "(function (";
  // return value of function types is the first element of type list
  TypeAnnotationPtr retType = m_typeArgs;
  TypeAnnotationPtr typeEl = m_typeArgs->m_typeList;
  auto sep = "";
  while (typeEl) {
    folly::toAppend(sep, typeEl->fullName(), &name);
    typeEl = typeEl->m_typeList;
    sep = ", ";
  }
  // add function return value
  folly::toAppend("): ", retType->fullName(), ")", &name);
}
Beispiel #2
0
void TypeAnnotation::accessTypeName(std::string &name) const {
  name += m_name;
  TypeAnnotationPtr typeEl = m_typeArgs;
  while (typeEl) {
    folly::toAppend("::", typeEl->fullName(), &name);
    typeEl = typeEl->m_typeList;
  }
}
void TypeAnnotation::tupleTypeName(std::string &name) const {
  name += "(";
  TypeAnnotationPtr typeEl = m_typeArgs;
  while (typeEl) {
    name += typeEl->fullName();
    typeEl = typeEl->m_typeList;
    name += ", ";
  }
  // replace the trailing ", " with ")"
  name.replace(name.size() - 2, 2, ")");
}
Beispiel #4
0
void TypeAnnotation::genericTypeName(std::string &name) const {
  folly::toAppend(m_name, "<", &name);
  TypeAnnotationPtr typeEl = m_typeArgs;
  auto sep = "";
  while (typeEl) {
    folly::toAppend(sep, typeEl->fullName(), &name);
    typeEl = typeEl->m_typeList;
    sep = ", ";
  }
  name += ">";
}
Beispiel #5
0
void TypeAnnotation::tupleTypeName(std::string &name) const {
  name += "(";
  TypeAnnotationPtr typeEl = m_typeArgs;
  auto sep = "";
  while (typeEl) {
    folly::toAppend(sep, typeEl->fullName(), &name);
    typeEl = typeEl->m_typeList;
    sep = ", ";
  }
  name += ")";
}
void TypeAnnotation::functionTypeName(std::string &name) const {
  name += "(function (";
  // return value of function types is the first element of type list
  TypeAnnotationPtr retType = m_typeArgs;
  TypeAnnotationPtr typeEl = m_typeArgs->m_typeList;
  bool hasArgs = (typeEl != nullptr);
  while (typeEl) {
    name += typeEl->fullName();
    typeEl = typeEl->m_typeList;
    name += ", ";
  }
  // replace the trailing ", " (if any) with "): "
  if (hasArgs) {
    name.replace(name.size() - 2, 2, "): ");
  } else {
    name += "): ";
  }
  // add function return value
  name += retType->fullName();
  name += ")";
}