ADT
aaron-thesis
arm-eh
ast-experimental
cleanup-dtors
deferred_resn
demangler
enum
forall-pointer-decay
jacob/cs343-translation
jenkins-sandbox
new-ast
new-ast-unique-expr
new-env
no_list
persistent-indexer
pthread-emulation
qualifiedEnum
resolv-new
with_gc
Last change
on this file since f408e1a was f57668a, checked in by Andrew Beach <ajbeach@…>, 8 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 |
|
---|
25 | namespace 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.