本文整理汇总了C++中TypeAnnotationPtr类的典型用法代码示例。如果您正苦于以下问题:C++ TypeAnnotationPtr类的具体用法?C++ TypeAnnotationPtr怎么用?C++ TypeAnnotationPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TypeAnnotationPtr类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: accessTypeName
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;
}
}
示例2: tupleTypeName
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, ")");
}
示例3: genericTypeName
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 += ">";
}
示例4: tupleTypeName
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 += ")";
}
示例5: functionTypeName
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);
}
示例6: Expression
ParameterExpression::ParameterExpression(
EXPRESSION_CONSTRUCTOR_PARAMETERS,
TypeAnnotationPtr type,
bool hhType,
const std::string &name,
bool ref,
TokenID modifier,
ExpressionPtr defaultValue,
ExpressionPtr attributeList,
bool variadic)
: Expression(EXPRESSION_CONSTRUCTOR_PARAMETER_VALUES(ParameterExpression))
, m_originalType(type)
, m_name(name)
, m_hhType(hhType)
, m_ref(ref)
, m_modifier(modifier)
, m_defaultValue(defaultValue)
, m_attributeList(attributeList)
, m_variadic(variadic)
{
m_type = toLower(type ? type->vanillaName() : "");
if (m_defaultValue) {
m_defaultValue->setContext(InParameterExpression);
}
}
示例7: outputCodeModel
void TypeAnnotation::outputCodeModel(CodeGenerator& cg) {
TypeAnnotationPtr typeArgsElem = m_typeArgs;
auto numTypeArgs = 0;
while (typeArgsElem != nullptr) {
numTypeArgs++;
typeArgsElem = typeArgsElem->m_typeList;
}
typeArgsElem = m_typeArgs;
auto numProps = 1;
if (m_nullable) numProps++;
if (m_soft) numProps++;
if (m_function) numProps++;
if (numTypeArgs > 0) numProps++;
cg.printObjectHeader("TypeExpression", numProps);
cg.printPropertyHeader("name");
cg.printValue(m_tuple ? "tuple" : m_name);
if (m_nullable) {
cg.printPropertyHeader("isNullable");
cg.printBool(true);
}
if (m_soft) {
cg.printPropertyHeader("isSoft");
cg.printBool(true);
}
if (m_function) {
cg.printPropertyHeader("returnType");
typeArgsElem->outputCodeModel(cg);
typeArgsElem = typeArgsElem->m_typeList;
numTypeArgs--;
}
if (numTypeArgs > 0) {
cg.printPropertyHeader("typeArguments");
cg.printf("V:9:\"HH\\Vector\":%d:{", numTypeArgs);
while (typeArgsElem != nullptr) {
typeArgsElem->outputCodeModel(cg);
typeArgsElem = typeArgsElem->m_typeList;
}
cg.printf("}");
}
cg.printObjectFooter();
}
示例8: functionTypeName
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 += ")";
}
示例9: shapeTypeName
void TypeAnnotation::shapeTypeName(std::string& name) const {
name += "HH\\shape(";
TypeAnnotationPtr shapeField = m_typeArgs;
auto sep = "";
while (shapeField) {
name += sep;
if (shapeField->isClsCnsShapeField()) {
folly::toAppend(shapeField->m_name, &name);
} else {
folly::toAppend("'", shapeField->m_name, "'", &name);
}
auto fieldValue = shapeField->m_typeArgs;
assert(fieldValue);
folly::toAppend("=>", fieldValue->fullName(), &name);
sep = ", ";
shapeField = shapeField->m_typeList;
}
name += ")";
}