当前位置: 首页>>代码示例>>C++>>正文


C++ ASTPrinter::printNewline方法代码示例

本文整理汇总了C++中ASTPrinter::printNewline方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTPrinter::printNewline方法的具体用法?C++ ASTPrinter::printNewline怎么用?C++ ASTPrinter::printNewline使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ASTPrinter的用法示例。


在下文中一共展示了ASTPrinter::printNewline方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: print

void DeclAttribute::print(ASTPrinter &Printer, const PrintOptions &Options,
                          const Decl *D) const {

  if (!printImpl(Printer, Options, D))
    return; // Nothing printed.

  if (isLongAttribute() && Options.PrintLongAttrsOnSeparateLines)
    Printer.printNewline();
  else
    Printer << " ";
}
开发者ID:aisobe,项目名称:swift,代码行数:11,代码来源:Attr.cpp

示例2: printShortFormAvailable

/// Print the short-form @available() attribute for an array of long-form
/// AvailableAttrs that can be represented in the short form.
/// For example, for:
///   @available(OSX, introduced=10.10)
///   @available(iOS, introduced=8.0)
/// this will print:
///   @available(OSX 10.10, iOS 8.0, *)
static void printShortFormAvailable(ArrayRef<const DeclAttribute *> Attrs,
                                    ASTPrinter &Printer,
                                    const PrintOptions &Options) {
  assert(!Attrs.empty());

  Printer << "@available(";
  for (auto *DA : Attrs) {
    auto *AvailAttr = cast<AvailableAttr>(DA);
    assert(AvailAttr->Introduced.hasValue());

    Printer << platformString(AvailAttr->Platform) << " "
            << AvailAttr->Introduced.getValue().getAsString() << ", ";
  }

  Printer << "*)";
  Printer.printNewline();
}
开发者ID:asdfeng,项目名称:swift,代码行数:24,代码来源:Attr.cpp

示例3: printShortFormAvailable

/// Print the short-form @available() attribute for an array of long-form
/// AvailableAttrs that can be represented in the short form.
/// For example, for:
///   @available(OSX, introduced: 10.10)
///   @available(iOS, introduced: 8.0)
/// this will print:
///   @available(OSX 10.10, iOS 8.0, *)
static void printShortFormAvailable(ArrayRef<const DeclAttribute *> Attrs,
                                    ASTPrinter &Printer,
                                    const PrintOptions &Options) {
  assert(!Attrs.empty());

  Printer << "@available(";
  auto FirstAvail = cast<AvailableAttr>(Attrs.front());
  if (Attrs.size() == 1 &&
      FirstAvail->isLanguageVersionSpecific()) {
    assert(FirstAvail->Introduced.hasValue());
    Printer << "swift "
            << FirstAvail->Introduced.getValue().getAsString()
            << ")";
  } else {
    for (auto *DA : Attrs) {
      auto *AvailAttr = cast<AvailableAttr>(DA);
      assert(AvailAttr->Introduced.hasValue());
      Printer << platformString(AvailAttr->Platform) << " "
              << AvailAttr->Introduced.getValue().getAsString() << ", ";
    }
    Printer << "*)";
  }
  Printer.printNewline();
}
开发者ID:aisobe,项目名称:swift,代码行数:31,代码来源:Attr.cpp

示例4: print


//.........这里部分代码省略.........

  case DAK_Available: {
    Printer << "@available(";
    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 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\"";

    Printer << ")";
    break;
  }
  case DAK_AutoClosure:
    Printer << "@autoclosure";
    if (cast<AutoClosureAttr>(this)->isEscaping())
      Printer << "(escaping)";
    break;
  case DAK_ObjC: {
    if (Options.PrintForSIL && isImplicit())
      break;
    Printer << "@objc";
    llvm::SmallString<32> scratch;
    if (auto Name = cast<ObjCAttr>(this)->getName()) {
      if (!cast<ObjCAttr>(this)->isNameImplicit())
        Printer << "(" << Name->getString(scratch) << ")";
    }
    break;
  }

  case DAK_SetterAccessibility:
    Printer << getAttrName() << "(set)";
    break;
    
  case DAK_SwiftNativeObjCRuntimeBase: {
    auto *attr = cast<SwiftNativeObjCRuntimeBaseAttr>(this);
    Printer << "@_swift_native_objc_runtime_base("
            << attr->BaseClassName.str() << ")";
    break;
  }

  case DAK_RawDocComment:
    // Not printed.
    return;

  case DAK_ObjCBridged:
    // Not printed.
    return;

  case DAK_SynthesizedProtocol:
    // Not printed.
    return;

  case DAK_WarnUnusedResult: {
    Printer << "@warn_unused_result";
    auto *attr = cast<WarnUnusedResultAttr>(this);
    bool printedParens = false;
    if (!attr->getMessage().empty()) {
      Printer << "(message=\"" << attr->getMessage() << "\"";
      printedParens = true;
    }
    if (!attr->getMutableVariant().empty()) {
      if (printedParens)
        Printer << ", ";
      else
        Printer << "(";
      Printer << "mutable_variant=\"" << attr->getMutableVariant() << "\"";
      printedParens = true;
    }
    if (printedParens)
      Printer << ")";
    break;
  }

  case DAK_Count:
    llvm_unreachable("exceed declaration attribute kinds");
  }

  if (isLongAttribute() && Options.PrintLongAttrsOnSeparateLines)
    Printer.printNewline();
  else
    Printer << " ";
}
开发者ID:asdfeng,项目名称:swift,代码行数:101,代码来源:Attr.cpp


注:本文中的ASTPrinter::printNewline方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。