-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathdebug.h
51 lines (35 loc) · 1.08 KB
/
debug.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef SEEPHIT_DEBUG_H
#define SEEPHIT_DEBUG_H
#pragma once
// Allow runtime debugging for development
#ifdef SPT_DEBUG
#define constexpr
#define DUMP cerr
#define ENDL "\n"
// Dummy function to prettify compile-time errors
#define PARSE_ERR(x) {cerr << "Parse Error:" << #x << endl;}
#define PARSE_WARN(x) {cerr << "Parse Warning:" << #x << endl;}
#else
#define DUMP DummyOut
#define ENDL 0
struct DummyOutStream
{
template<typename T> constexpr const DummyOutStream& operator <<(const T & /*unused*/) const { return *this;}
};
constexpr DummyOutStream DummyOut;
struct ErrLine
{
int dummy[0];
constexpr int &operator[](size_t i) { return dummy[i];};
};
// Dummy function to prettify compile-time errors
constexpr ErrLine ParseError(const char* /*unused*/)
{
return ErrLine{};
}
// Set error message and location if not already set
#define PARSE_ERR(x) if(m_iErrRow == -1) {m_iErrRow = cur_row(); m_iErrCol = cur_col(); m_arrErrs = x;}
// Push warning message and location to list
#define PARSE_WARN(x) m_arrWarns.push_back(Message(x, cur_row(), cur_col()))
#endif
#endif