New interface
[oota-llvm.git] / include / llvm / Assembly / CachedWriter.h
index 7996982de49a6ade5694116e63e5f58294edd7e1..dbddacde9319664d8cb6722817e69614e781bec1 100644 (file)
@@ -1,4 +1,11 @@
-//===-- llvm/Assembly/CachedWriter.h - Printer Accellerator ------*- C++ -*--=//
+//===-- llvm/Assembly/CachedWriter.h - Printer Accellerator -----*- C++ -*-===//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
 //
 // This file defines a 'CacheWriter' class that is used to accelerate printing
 // chunks of LLVM.  This is used when a module is not being changed, but random
 #ifndef LLVM_ASSEMBLY_CACHED_WRITER_H
 #define LLVM_ASSEMBLY_CACHED_WRITER_H
 
-#include "llvm/Assembly/Writer.h"
+#include "llvm/Value.h"
+#include <iostream>
 
-class AssemblyWriter;  // Internal private class
+class Module;
+class PointerType;
 class SlotCalculator;
+class AssemblyWriter;  // Internal private class
 
 class CachedWriter {
   AssemblyWriter *AW;
   SlotCalculator *SC;
 public:
-  ostream &Out;
+  std::ostream &Out;
 public:
-  CachedWriter(ostream &O = cout) : AW(0), SC(0), Out(O) { }
-  CachedWriter(const Module *M, ostream &O = cout) : AW(0), SC(0), Out(O) {
+  CachedWriter(std::ostream &O = std::cout) : AW(0), SC(0), Out(O) { }
+  CachedWriter(const Module *M, std::ostream &O = std::cout)
+    : AW(0), SC(0), Out(O) {
     setModule(M);
   }
   ~CachedWriter();
@@ -35,16 +46,13 @@ public:
   inline CachedWriter &operator<<(Value *X) {
     return *this << (const Value*)X;
   }
-  inline CachedWriter &operator<<(const Module *X) {
-    return *this << (const Value*)X;
-  }
   inline CachedWriter &operator<<(const GlobalVariable *X) {
     return *this << (const Value*)X;
   }
-  inline CachedWriter &operator<<(const Method *X) {
+  inline CachedWriter &operator<<(const Function *X) {
     return *this << (const Value*)X;
   }
-  inline CachedWriter &operator<<(const MethodArgument *X) {
+  inline CachedWriter &operator<<(const Argument *X) {
     return *this << (const Value*)X;
   }
   inline CachedWriter &operator<<(const BasicBlock *X) {
@@ -53,7 +61,7 @@ public:
   inline CachedWriter &operator<<(const Instruction *X) {
     return *this << (const Value*)X; 
   }
-  inline CachedWriter &operator<<(const ConstPoolVal *X) {
+  inline CachedWriter &operator<<(const Constant *X) {
     return *this << (const Value*)X; 
   }
   inline CachedWriter &operator<<(const Type *X) {
@@ -62,12 +70,16 @@ public:
   inline CachedWriter &operator<<(const PointerType *X) {
     return *this << (const Value*)X; 
   }
-};
 
-template<class X>
-inline CachedWriter &operator<<(CachedWriter &CW, const X &v) {
-  CW.Out << v;
-  return CW;
-}
+  inline CachedWriter &operator<<(std::ostream &(&Manip)(std::ostream &)) {
+    Out << Manip; return *this;
+  }
+
+  template<class X>
+  inline CachedWriter &operator<<(const X &v) {
+    Out << v;
+    return *this;
+  }
+};
 
 #endif