本文整理汇总了C++中ASTPrinter::callPrintStructurePre方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTPrinter::callPrintStructurePre方法的具体用法?C++ ASTPrinter::callPrintStructurePre怎么用?C++ ASTPrinter::callPrintStructurePre使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTPrinter
的用法示例。
在下文中一共展示了ASTPrinter::callPrintStructurePre方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printImpl
void TupleTypeRepr::printImpl(ASTPrinter &Printer,
const PrintOptions &Opts) const {
Printer.callPrintStructurePre(PrintStructureKind::TupleType);
SWIFT_DEFER { Printer.printStructurePost(PrintStructureKind::TupleType); };
Printer << "(";
for (unsigned i = 0, e = Bits.TupleTypeRepr.NumElements; i != e; ++i) {
if (i) Printer << ", ";
Printer.callPrintStructurePre(PrintStructureKind::TupleElement);
auto name = getElementName(i);
if (isNamedParameter(i)) {
// Printing empty Identifier is same as printing '_'.
Printer.printName(Identifier(),
PrintNameContext::FunctionParameterExternal);
if (!name.empty()) {
Printer << " ";
Printer.printName(name, PrintNameContext::FunctionParameterLocal);
}
Printer << ": ";
} else {
if (!name.empty()) {
Printer.printName(name, PrintNameContext::TupleElement);
Printer << ": ";
}
}
printTypeRepr(getElementType(i), Printer, Opts);
Printer.printStructurePost(PrintStructureKind::TupleElement);
if (hasEllipsis() && getEllipsisIndex() == i)
Printer << "...";
}
Printer << ")";
}
示例2: printImpl
void FunctionTypeRepr::printImpl(ASTPrinter &Printer,
const PrintOptions &Opts) const {
Printer.callPrintStructurePre(PrintStructureKind::FunctionType);
printTypeRepr(ArgsTy, Printer, Opts);
if (throws()) {
Printer << " ";
Printer.printKeyword("throws");
}
Printer << " -> ";
Printer.callPrintStructurePre(PrintStructureKind::FunctionReturnType);
printTypeRepr(RetTy, Printer, Opts);
Printer.printStructurePost(PrintStructureKind::FunctionReturnType);
Printer.printStructurePost(PrintStructureKind::FunctionType);
}
示例3: printAttrs
void AttributedTypeRepr::printAttrs(ASTPrinter &Printer,
const PrintOptions &Options) const {
const TypeAttributes &Attrs = getAttrs();
auto hasAttr = [&](TypeAttrKind K) -> bool {
if (Options.excludeAttrKind(K))
return false;
return Attrs.has(K);
};
if (hasAttr(TAK_autoclosure))
Printer.printSimpleAttr("@autoclosure") << " ";
if (hasAttr(TAK_escaping))
Printer.printSimpleAttr("@escaping") << " ";
if (hasAttr(TAK_thin))
Printer.printSimpleAttr("@thin") << " ";
if (hasAttr(TAK_thick))
Printer.printSimpleAttr("@thick") << " ";
if (hasAttr(TAK_convention) && Attrs.convention.hasValue()) {
Printer.callPrintStructurePre(PrintStructureKind::BuiltinAttribute);
Printer.printAttrName("@convention");
Printer << "(" << Attrs.convention.getValue() << ")";
Printer.printStructurePost(PrintStructureKind::BuiltinAttribute);
Printer << " ";
}
}
示例4: printImpl
bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
const Decl *D) const {
// Handle any attributes that are not printed at all before we make printer
// callbacks.
switch (getKind()) {
case DAK_ObjC:
if (Options.PrintForSIL && isImplicit())
return false;
break;
case DAK_RawDocComment:
case DAK_ObjCBridged:
case DAK_SynthesizedProtocol:
case DAK_ShowInInterface:
case DAK_Rethrows:
case DAK_Infix:
return false;
default:
break;
}
// Handle any decl-modifiers.
// FIXME: Ideally we would handle decl modifiers as a special kind of
// attribute, but for now it's simpler to treat them as a keyword in the
// printer.
switch (getKind()) {
// Handle all of the SIMPLE_DECL_ATTRs.
#define SIMPLE_DECL_ATTR(X, CLASS, ...) case DAK_##CLASS:
#include "swift/AST/Attr.def"
case DAK_Inline:
case DAK_AccessControl:
case DAK_ReferenceOwnership:
case DAK_Effects:
case DAK_Optimize:
if (DeclAttribute::isDeclModifier(getKind())) {
Printer.printKeyword(getAttrName());
} else {
Printer.printSimpleAttr(getAttrName(), /*needAt=*/true);
}
return true;
case DAK_SetterAccess:
Printer.printKeyword(getAttrName());
Printer << "(set)";
return true;
default:
break;
}
Printer.callPrintStructurePre(PrintStructureKind::BuiltinAttribute);
SWIFT_DEFER {
Printer.printStructurePost(PrintStructureKind::BuiltinAttribute);
};
switch (getKind()) {
case DAK_Semantics:
Printer.printAttrName("@_semantics");
Printer << "(\"" << cast<SemanticsAttr>(this)->Value << "\")";
break;
case DAK_Alignment:
Printer.printAttrName("@_alignment");
Printer << "(" << cast<AlignmentAttr>(this)->getValue() << ")";
break;
case DAK_SILGenName:
Printer.printAttrName("@_silgen_name");
Printer << "(\"" << cast<SILGenNameAttr>(this)->Name << "\")";
break;
case DAK_Available: {
Printer.printAttrName("@available");
Printer << "(";
auto Attr = cast<AvailableAttr>(this);
if (Attr->isLanguageVersionSpecific())
Printer << "swift";
else
Printer << Attr->platformString();
if (Attr->isUnconditionallyUnavailable())
Printer << ", unavailable";
else if (Attr->isUnconditionallyDeprecated())
Printer << ", deprecated";
if (Attr->Introduced)
Printer << ", introduced: " << Attr->Introduced.getValue().getAsString();
if (Attr->Deprecated)
Printer << ", deprecated: " << Attr->Deprecated.getValue().getAsString();
if (Attr->Obsoleted)
Printer << ", obsoleted: " << Attr->Obsoleted.getValue().getAsString();
if (!Attr->Rename.empty())
Printer << ", renamed: \"" << Attr->Rename << "\"";
// If there's no message, but this is specifically an imported
// "unavailable in Swift" attribute, synthesize a message to look good in
// the generated interface.
if (!Attr->Message.empty())
Printer << ", message: \"" << Attr->Message << "\"";
//.........这里部分代码省略.........
示例5: printImpl
bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options) const {
// Handle any attributes that are not printed at all before we make printer
// callbacks.
switch (getKind()) {
case DAK_ObjC:
if (Options.PrintForSIL && isImplicit())
return false;
break;
case DAK_RawDocComment:
case DAK_ObjCBridged:
case DAK_SynthesizedProtocol:
case DAK_ShowInInterface:
case DAK_Rethrows:
return false;
default:
break;
}
// Handle any decl-modifiers.
// FIXME: Ideally we would handle decl modifiers as a special kind of
// attribute, but for now it's simpler to treat them as a keyword in the
// printer.
switch (getKind()) {
// Handle all of the SIMPLE_DECL_ATTRs.
#define SIMPLE_DECL_ATTR(X, CLASS, ...) case DAK_##CLASS:
#include "swift/AST/Attr.def"
case DAK_Inline:
case DAK_Accessibility:
case DAK_Ownership:
case DAK_Effects:
if (DeclAttribute::isDeclModifier(getKind())) {
Printer.printKeyword(getAttrName());
} else {
Printer.callPrintStructurePre(PrintStructureKind::BuiltinAttribute);
Printer.printAttrName(getAttrName(), /*needAt=*/true);
Printer.printStructurePost(PrintStructureKind::BuiltinAttribute);
}
return true;
case DAK_SetterAccessibility:
Printer.printKeyword(getAttrName());
Printer << "(set)";
return true;
default:
break;
}
Printer.callPrintStructurePre(PrintStructureKind::BuiltinAttribute);
SWIFT_DEFER {
Printer.printStructurePost(PrintStructureKind::BuiltinAttribute);
};
switch (getKind()) {
case DAK_Semantics:
Printer.printAttrName("@_semantics");
Printer << "(\"" << cast<SemanticsAttr>(this)->Value << "\")";
break;
case DAK_Alignment:
Printer.printAttrName("@_alignment");
Printer << "(" << cast<AlignmentAttr>(this)->Value << ")";
break;
case DAK_SILGenName:
Printer.printAttrName("@_silgen_name");
Printer << "(\"" << cast<SILGenNameAttr>(this)->Name << "\")";
break;
case DAK_Available: {
Printer.printAttrName("@available");
Printer << "(";
auto Attr = cast<AvailableAttr>(this);
Printer << Attr->platformString();
if (Attr->isUnconditionallyUnavailable())
Printer << ", unavailable";
else if (Attr->isUnconditionallyDeprecated())
Printer << ", deprecated";
if (Attr->Introduced)
Printer << ", introduced: " << Attr->Introduced.getValue().getAsString();
if (Attr->Deprecated)
Printer << ", deprecated: " << Attr->Deprecated.getValue().getAsString();
if (Attr->Obsoleted)
Printer << ", obsoleted: " << Attr->Obsoleted.getValue().getAsString();
if (!Attr->Rename.empty())
Printer << ", renamed: \"" << Attr->Rename << "\"";
// If there's no message, but this is specifically an imported
// "unavailable in Swift" attribute, synthesize a message to look good in
// the generated interface.
if (!Attr->Message.empty())
Printer << ", message: \"" << Attr->Message << "\"";
else if (Attr->getUnconditionalAvailability()
== UnconditionalAvailabilityKind::UnavailableInSwift)
Printer << ", message: \"Not available in Swift\"";
//.........这里部分代码省略.........