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

74 lines
1.5 KiB
C++
Raw Normal View History

2009-07-26 10:07:13 +00:00
#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()];
}
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
/* ASTBlock */
void ASTBlock::removeLast()
{
list_t::iterator it = m_nodes.end();
--it;
m_nodes.erase(it);
}
void ASTBlock::removeFirst()
{
list_t::iterator it = m_nodes.begin();
m_nodes.erase(it);
}
const char* ASTBlock::type_str() const
{
static const char* s_type_strings[] = {
"", "try", "except", "finally", "while", "for"
};
return s_type_strings[type()];
}