ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change
on this file since 6e300d9 was
4810867,
checked in by ajbeach <ajbeach@…>, 8 years ago
|
Added basic line directives to code generation.
|
-
Property mode set to
100644
|
File size:
1.5 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 : Mon May 8 14:03: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 | |
---|
25 | namespace CodeGen { |
---|
26 | |
---|
27 | class LineStream { |
---|
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 | LineStream & operator<<(char const *str); |
---|
52 | LineStream & operator<<(std::string const & str); |
---|
53 | LineStream & operator<<(StreamFlag flag); |
---|
54 | |
---|
55 | /// Flush all buffered output. |
---|
56 | LineStream & flush(); |
---|
57 | |
---|
58 | }; // LineStream |
---|
59 | |
---|
60 | } // CodeGen |
---|
61 | |
---|
62 | #endif // LINE_STREAM_H |
---|
Note: See
TracBrowser
for help on using the repository browser.