[AST] Introduce the ASTPrinter class, and have its callbacks invoked during AST printing.

This provides useful extension points during AST printing.

Swift SVN r11338
This commit is contained in:
Argyrios Kyrtzidis
2013-12-16 01:26:36 +00:00
parent 04b98c7d67
commit 93c15bed50
15 changed files with 588 additions and 382 deletions

View File

@@ -15,6 +15,7 @@
//===----------------------------------------------------------------------===//
#include "swift/AST/AST.h"
#include "swift/AST/ASTPrinter.h"
#include "swift/AST/ASTVisitor.h"
#include "swift/Basic/STLExtras.h"
#include "llvm/ADT/APFloat.h"
@@ -1446,6 +1447,14 @@ void Expr::print(raw_ostream &OS, unsigned Indent) const {
PrintExpr(OS, Indent).visit(const_cast<Expr*>(this));
}
void Expr::print(ASTPrinter &Printer, const PrintOptions &Opts) const {
// FIXME: Fully use the ASTPrinter.
llvm::SmallString<128> Str;
llvm::raw_svector_ostream OS(Str);
print(OS);
Printer << OS.str();
}
//===----------------------------------------------------------------------===//
// Printing for TypeRepr and all subclasses.
//===----------------------------------------------------------------------===//