Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 79 lines (67 sloc) 1.266 kb
fb77306 @NotFound put Emit class in a separate file, add clean target and drop -Wextra fro...
authored
1 // emit.cpp
3374e4f @NotFound new builtin __ASSERT__ in stage 0
authored
2 // Revision 8-sep-2011
fb77306 @NotFound put Emit class in a separate file, add clean target and drop -Wextra fro...
authored
3
4 #include "emit.h"
5
6 Emit::Emit (std::ostream &out) :
7 o(out),
3374e4f @NotFound new builtin __ASSERT__ in stage 0
authored
8 debug(false),
fb77306 @NotFound put Emit class in a separate file, add clean target and drop -Wextra fro...
authored
9 with_an(true),
f9e0124 @NotFound improve annotations emision
authored
10 pendingf(false),
11 pendingl(false),
fb77306 @NotFound put Emit class in a separate file, add clean target and drop -Wextra fro...
authored
12 line(0)
13 { }
14
3374e4f @NotFound new builtin __ASSERT__ in stage 0
authored
15 void Emit::setDebug()
16 {
17 debug = true;
18 }
19
20 bool Emit::getDebug() const
21 {
22 return debug;
23 }
24
fb77306 @NotFound put Emit class in a separate file, add clean target and drop -Wextra fro...
authored
25 void Emit::omit_annotations()
26 {
27 with_an= false;
28 }
29
30 void Emit::comment(const std::string &msg)
31 {
32 o << "# " << msg << '\n';
33 }
34
35 void Emit::boxedcomment(const std::string &msg)
36 {
37 const size_t n= msg.size();
38 comment('+' + std::string(n + 2, '-') + '+');
39 comment("| " + msg + " |");
40 comment('+' + std::string(n + 2, '-') + '+');
41 }
42
f9e0124 @NotFound improve annotations emision
authored
43 void Emit::preemit()
44 {
45 if (pendingf)
46 {
47 o << ".annotate 'file', '" << file << "'\n";
48 pendingf= false;
49 }
50 if (pendingl)
51 {
52 o << ".annotate 'line', " << line << '\n';
53 pendingl= false;
54 }
55 }
56
fb77306 @NotFound put Emit class in a separate file, add clean target and drop -Wextra fro...
authored
57 void Emit::annotate(const Token &t)
58 {
59 if (with_an)
60 {
61 if (t.file() != file)
62 {
63 file= t.file();
f9e0124 @NotFound improve annotations emision
authored
64 pendingf= true;
65 pendingl= false;
66 line= 0;
fb77306 @NotFound put Emit class in a separate file, add clean target and drop -Wextra fro...
authored
67 }
f9e0124 @NotFound improve annotations emision
authored
68 if (t.linenum() != line)
fb77306 @NotFound put Emit class in a separate file, add clean target and drop -Wextra fro...
authored
69 {
70 line= t.linenum();
71 if (line)
f9e0124 @NotFound improve annotations emision
authored
72 pendingl= true;
fb77306 @NotFound put Emit class in a separate file, add clean target and drop -Wextra fro...
authored
73 }
74 }
75 }
76
77
78 // End of emit.cpp
Something went wrong with that request. Please try again.