Files
Pyarmor-Static-Unpack-1shot/ASTNode.cpp

82 lines
1.6 KiB
C++
Raw Normal View History

2009-07-26 10:07:13 +00:00
#include "ASTNode.h"
/* ASTNodeList */
void ASTNodeList::removeLast()
{
list_t::iterator it = m_nodes.end();
--it;
m_nodes.erase(it);
}
void ASTNodeList::removeFirst()
{
m_nodes.erase(m_nodes.cbegin());
}
/* 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 ",
" += ", " -= ", " *= ", " /= ", " %= ", " **= ", " <<= ",
2015-10-01 17:01:02 -07:00
" >>= ", " &= ", " ^= ", " |= ", " //= ", " @ ", " @= ",
};
return s_op_strings[op()];
}
2009-07-26 10:07:13 +00:00
/* ASTCompare */
const char* ASTCompare::op_str() const
{
static const char* s_cmp_strings[] = {
" < ", " <= ", " == ", " != ", " > ", " >= ", " in ", " not in ", " is ", " is not ",
2009-07-26 10:07:13 +00:00
"<EXCEPTION MATCH>", "<BAD>"
};
return s_cmp_strings[op()];
2009-07-26 10:07:13 +00:00
}
2010-12-20 22:58:44 -08:00
/* ASTKeyword */
const char* ASTKeyword::word_str() const
{
static const char* s_word_strings[] = {
"pass", "break", "continue"
};
return s_word_strings[key()];
}
2010-12-20 22:58:44 -08:00
/* ASTBlock */
void ASTBlock::removeLast()
{
list_t::iterator it = m_nodes.end();
--it;
m_nodes.erase(it);
}
void ASTBlock::removeFirst()
{
m_nodes.erase(m_nodes.begin());
2010-12-20 22:58:44 -08:00
}
const char* ASTBlock::type_str() const
{
static const char* s_type_strings[] = {
"", "if", "else", "elif", "try", "CONTAINER", "except",
2012-06-03 20:39:45 -07:00
"finally", "while", "for", "with",
2010-12-20 22:58:44 -08:00
};
return s_type_strings[blktype()];
2010-12-20 22:58:44 -08:00
}