[llvm-commits] CVS: llvm/include/llvm/Assembly/CachedWriter.h

Misha Brukman brukman at cs.uiuc.edu
Wed Apr 28 10:31:01 PDT 2004


Changes in directory llvm/include/llvm/Assembly:

CachedWriter.h updated: 1.13 -> 1.14

---
Log message:

* Add ability to get and set the output stream
* New feature: outputting a Type* as symbolic, controlled via the stream
  similarly to sending std::hex to change number format


---
Diffs of the changes:  (+23 -11)

Index: llvm/include/llvm/Assembly/CachedWriter.h
diff -u llvm/include/llvm/Assembly/CachedWriter.h:1.13 llvm/include/llvm/Assembly/CachedWriter.h:1.14
--- llvm/include/llvm/Assembly/CachedWriter.h:1.13	Thu Jan  8 16:21:58 2004
+++ llvm/include/llvm/Assembly/CachedWriter.h	Wed Apr 28 10:30:33 2004
@@ -30,12 +30,20 @@
 class CachedWriter {
   AssemblyWriter *AW;
   SlotCalculator *SC;
+  bool SymbolicTypes;
 public:
-  std::ostream &Out;
+  std::ostream *Out;
+
+  enum TypeWriter {
+    SymTypeOn,
+    SymTypeOff
+  };
+
 public:
-  CachedWriter(std::ostream &O = std::cout) : AW(0), SC(0), Out(O) { }
+  CachedWriter(std::ostream &O = std::cout)
+    : AW(0), SC(0), SymbolicTypes(false), Out(&O) { }
   CachedWriter(const Module *M, std::ostream &O = std::cout)
-    : AW(0), SC(0), Out(O) {
+    : AW(0), SC(0), SymbolicTypes(false), Out(&O) {
     setModule(M);
   }
   ~CachedWriter();
@@ -66,22 +74,26 @@
   inline CachedWriter &operator<<(const Constant *X) {
     return *this << (const Value*)X; 
   }
-  inline CachedWriter &operator<<(const Type *X) {
-    return *this << (const Value*)X;
-  }
-  inline CachedWriter &operator<<(const PointerType *X) {
-    return *this << (const Value*)X; 
-  }
+  CachedWriter &operator<<(const Type *X);
+  inline CachedWriter &operator<<(const PointerType *X);
 
   inline CachedWriter &operator<<(std::ostream &(&Manip)(std::ostream &)) {
-    Out << Manip; return *this;
+    *Out << Manip; return *this;
   }
 
   template<class X>
   inline CachedWriter &operator<<(const X &v) {
-    Out << v;
+    *Out << v;
     return *this;
   }
+
+  inline CachedWriter &operator<<(enum TypeWriter tw) {
+    SymbolicTypes = (tw == SymTypeOn);
+    return *this;
+  }
+
+  inline std::ostream& getStream() { return *Out; }
+  inline void setStream(std::ostream &os) { Out = &os; }
 };
 
 } // End llvm namespace





More information about the llvm-commits mailing list