forked from zrax/pycdc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathASTNode.cpp
51 lines (42 loc) · 1.1 KB
/
ASTNode.cpp
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
#include "ASTNode.h"
PycRef<ASTNode> Node_NULL = (ASTNode*)0;
/* ASTNodeList */
void ASTNodeList::removeLast()
{
list_t::iterator it = m_nodes.end();
--it;
m_nodes.erase(it);
}
void ASTNodeList::removeFirst()
{
list_t::iterator it = m_nodes.begin();
m_nodes.erase(it);
}
/* ASTUnary */
const char* ASTUnary::op_str() const
{
static const char* s_op_strings[] = {
"+", "-", "~", "not ", "`"
};
return s_op_strings[op()];
}
/* ASTBinary */
const char* ASTBinary::op_str() const
{
static const char* s_op_strings[] = {
".", " ** ", " * ", " / ", " // ", " % ", " + ", " - ",
" << ", " >> ", " & ", " ^ ", " | ", " and ", " or ",
" += ", " -= ", " *= ", " /= ", " %= ", " **= ", " <<= ",
" >>= ", " &= ", " ^= ", " |= ", " //= "
};
return s_op_strings[op()];
}
/* ASTCompare */
const char* ASTCompare::op_str() const
{
static const char* s_cmp_strings[] = {
" < ", " <= ", " == ", " != ", " > ", " >= ", " in ", " not in ", " is ", " is not ",
"<EXCEPTION MATCH>", "<BAD>"
};
return s_cmp_strings[op()];
}