Merge 'pass' node into existing ASTKeyword node type

This commit is contained in:
Michael Hansen
2019-10-08 13:12:31 -07:00
parent c928df906b
commit 8713b3b05f
3 changed files with 7 additions and 10 deletions

View File

@@ -52,7 +52,7 @@ const char* ASTCompare::op_str() const
const char* ASTKeyword::word_str() const
{
static const char* s_word_strings[] = {
"break", "continue"
"pass", "break", "continue"
};
return s_word_strings[key()];
}

View File

@@ -14,10 +14,10 @@ public:
NODE_DELETE, NODE_FUNCTION, NODE_CLASS, NODE_CALL, NODE_IMPORT,
NODE_TUPLE, NODE_LIST, NODE_MAP, NODE_SUBSCR, NODE_PRINT,
NODE_CONVERT, NODE_KEYWORD, NODE_RAISE, NODE_EXEC, NODE_BLOCK,
NODE_COMPREHENSION,
NODE_COMPREHENSION, NODE_LOADBUILDCLASS,
// Empty nodes
NODE_PASS, NODE_LOCALS, NODE_LOADBUILDCLASS
// Empty node types
NODE_LOCALS,
};
ASTNode(int type = NODE_INVALID) : m_refs(0), m_type(type) { }
@@ -395,7 +395,7 @@ private:
class ASTKeyword : public ASTNode {
public:
enum Word {
KW_BREAK, KW_CONTINUE
KW_PASS, KW_BREAK, KW_CONTINUE
};
ASTKeyword(Word key) : ASTNode(NODE_KEYWORD), m_key(key) { }

View File

@@ -2208,7 +2208,7 @@ static void print_block(PycRef<ASTBlock> blk, PycModule* mod) {
ASTBlock::list_t lines = blk->nodes();
if (lines.size() == 0) {
PycRef<ASTNode> pass = new ASTNode(ASTNode::NODE_PASS);
PycRef<ASTNode> pass = new ASTKeyword(ASTKeyword::KW_PASS);
start_line(cur_indent);
print_src(pass, mod);
}
@@ -2457,9 +2457,6 @@ void print_src(PycRef<ASTNode> node, PycModule* mod)
}
}
break;
case ASTNode::NODE_PASS:
fputs("pass", pyc_output);
break;
case ASTNode::NODE_PRINT:
if (node.cast<ASTPrint>()->value() == NULL) {
if (!inPrint) {
@@ -2897,7 +2894,7 @@ void decompyle(PycRef<PycCode> code, PycModule* mod)
// This is outside the clean check so a source block will always
// be compilable, even if decompylation failed.
if (clean->nodes().size() == 0 && !code.isIdent(mod->code()))
clean->append(new ASTNode(ASTNode::NODE_PASS));
clean->append(new ASTKeyword(ASTKeyword::KW_PASS));
inPrint = false;
bool part1clean = cleanBuild;