本文整理汇总了C++中ASTPrinter::printKeyword方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTPrinter::printKeyword方法的具体用法?C++ ASTPrinter::printKeyword怎么用?C++ ASTPrinter::printKeyword使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTPrinter
的用法示例。
在下文中一共展示了ASTPrinter::printKeyword方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printImpl
void SpecifierTypeRepr::printImpl(ASTPrinter &Printer,
const PrintOptions &Opts) const {
if (getKind() == TypeReprKind::InOut) {
Printer.printKeyword("inout");
} else {
assert((getKind() == TypeReprKind::Shared) && "Unknown kind");
Printer.printKeyword("shared");
}
Printer << " ";
printTypeRepr(Base, Printer, Opts);
}
示例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: 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 << "\"";
//.........这里部分代码省略.........
示例4: 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\"";
//.........这里部分代码省略.........