Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
epidemian
GitHub Repository: epidemian/gravity
Path: blob/master/src/compiler/debug_macros.h
1214 views
1
//
2
// debug_macros.h
3
// gravity
4
//
5
// Created by Marco Bambini on 30/08/14.
6
// Copyright (c) 2014 CreoLabs. All rights reserved.
7
//
8
9
#ifndef __GRAVITY_CMACROS__
10
#define __GRAVITY_CMACROS__
11
12
#include <stdio.h>
13
#include <ctype.h>
14
#include <fcntl.h>
15
#include <stdlib.h>
16
#include <string.h>
17
#include <stdarg.h>
18
#include <assert.h>
19
#include <unistd.h>
20
#include <limits.h>
21
#include <float.h>
22
#include <math.h>
23
#include "gravity_memory.h"
24
25
#define GRAVITY_LEXEM_DEBUG 0
26
#define GRAVITY_LEXER_DEGUB 0
27
#define GRAVITY_PARSER_DEBUG 0
28
#define GRAVITY_SEMANTIC_DEBUG 0
29
#define GRAVITY_AST_DEBUG 0
30
#define GRAVITY_LOOKUP_DEBUG 0
31
#define GRAVITY_SYMTABLE_DEBUG 0
32
#define GRAVITY_CODEGEN_DEBUG 0
33
#define GRAVITY_OPCODE_DEBUG 0
34
#define GRAVITY_BYTECODE_DEBUG 0
35
#define GRAVITY_REGISTER_DEBUG 0
36
#define GRAVITY_FREE_DEBUG 0
37
#define GRAVITY_DESERIALIZE_DEBUG 0
38
39
#define PRINT_LINE(...) printf(__VA_ARGS__);printf("\n");fflush(stdout)
40
41
#if GRAVITY_LEXER_DEGUB
42
#define DEBUG_LEXER(l) gravity_lexer_debug(l)
43
#else
44
#define DEBUG_LEXER(...)
45
#endif
46
47
#if GRAVITY_LEXEM_DEBUG
48
#define DEBUG_LEXEM(...) do { if (!lexer->peeking) { \
49
printf("(%03d, %03d, %02d) ", lexer->token.lineno, lexer->token.colno, lexer->token.position); \
50
PRINT_LINE(__VA_ARGS__);} \
51
} while(0)
52
#else
53
#define DEBUG_LEXEM(...)
54
#endif
55
56
#if GRAVITY_PARSER_DEBUG
57
#define DEBUG_PARSER(...) PRINT_LINE(__VA_ARGS__)
58
#else
59
#define gravity_parser_debug(p)
60
#define DEBUG_PARSER(...)
61
#endif
62
63
#if GRAVITY_SEMANTIC_DEBUG
64
#define DEBUG_SEMANTIC(...) PRINT_LINE(__VA_ARGS__)
65
#else
66
#define DEBUG_SEMANTIC(...)
67
#endif
68
69
#if GRAVITY_LOOKUP_DEBUG
70
#define DEBUG_LOOKUP(...) PRINT_LINE(__VA_ARGS__)
71
#else
72
#define DEBUG_LOOKUP(...)
73
#endif
74
75
#if GRAVITY_SYMTABLE_DEBUG
76
#define DEBUG_SYMTABLE(...) printf("%*s",ident*4," ");PRINT_LINE(__VA_ARGS__)
77
#else
78
#define DEBUG_SYMTABLE(...)
79
#endif
80
81
#if GRAVITY_CODEGEN_DEBUG
82
#define DEBUG_CODEGEN(...) PRINT_LINE(__VA_ARGS__)
83
#else
84
#define DEBUG_CODEGEN(...)
85
#endif
86
87
#if GRAVITY_OPCODE_DEBUG
88
#define DEBUG_OPCODE(...) PRINT_LINE(__VA_ARGS__)
89
#else
90
#define DEBUG_OPCODE(...)
91
#endif
92
93
#if GRAVITY_BYTECODE_DEBUG
94
#define DEBUG_BYTECODE(...) PRINT_LINE(__VA_ARGS__)
95
#else
96
#define DEBUG_BYTECODE(...)
97
#endif
98
99
#if GRAVITY_REGISTER_DEBUG
100
#define DEBUG_REGISTER(...) PRINT_LINE(__VA_ARGS__)
101
#else
102
#define DEBUG_REGISTER(...)
103
#endif
104
105
#if GRAVITY_FREE_DEBUG
106
#define DEBUG_FREE(...) PRINT_LINE(__VA_ARGS__)
107
#else
108
#define DEBUG_FREE(...)
109
#endif
110
111
#if GRAVITY_DESERIALIZE_DEBUG
112
#define DEBUG_DESERIALIZE(...) PRINT_LINE(__VA_ARGS__)
113
#else
114
#define DEBUG_DESERIALIZE(...)
115
#endif
116
117
#define DEBUG_ALWAYS(...) PRINT_LINE(__VA_ARGS__)
118
119
#endif
120
121