source: src/CodeGen/LineStream.h @ f57668a

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since f57668a was f57668a, checked in by Andrew Beach <ajbeach@…>, 4 years ago

Foundation for adding line numbers to generated output.

  • Property mode set to 100644
File size: 1.4 KB
Line 
1//
2// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// LineStream.h -- Modified stream that inserts line directives into output.
8//
9// Author           : Andrew Beach
10// Created On       : Wed May 4 09:15:00 2017
11// Last Modified By : Andrew Beach
12// Last Modified On : Fri May 5 14:29:00 2017
13// Update Count     : 1
14//
15
16#ifndef LINE_STREAM_H
17#define LINE_STREAM_H
18
19#include <ostream>
20#include <sstream>
21#include <string>
22
23#include "Common/utility.h"
24
25namespace CodeGen {
26
27        class LineStream : public std::ostream {
28                std::ostream & baseStream;
29                std::ostringstream buffer;
30
31                bool const insertLines;
32
33                CodeLocation actualLocation;
34                CodeLocation expectedLocation;
35
36                void printLineDirective(CodeLocation const & location);
37                bool actualDiffersFromExpected() const;
38                void emptyBuffer(bool addNewline);
39
40        public:
41                typedef std::ostream &(*StreamFlag)(std::ostream &);
42
43                LineStream(std::ostream & baseStream, bool insertLines) :
44                        baseStream(baseStream), insertLines(insertLines)
45                {}
46
47                /// Update the currentLocation in source code.
48                void setLoc(CodeLocation const & location);
49
50                /// Formated output is buffered until flushed.
51                std::ostream & operator<<(char const *str);
52                std::ostream & operator<<(std::string str);
53                std::ostream & operator<<(StreamFlag flag);
54
55        }; // LineStream
56
57} // CodeGen
58
59#endif // LINE_STREAM_H
Note: See TracBrowser for help on using the repository browser.