From 8713b3b05f092abe5515ad7906188b97d8c68724 Mon Sep 17 00:00:00 2001 From: Michael Hansen Date: Tue, 8 Oct 2019 13:12:31 -0700 Subject: [PATCH] Merge 'pass' node into existing ASTKeyword node type --- ASTNode.cpp | 2 +- ASTNode.h | 8 ++++---- ASTree.cpp | 7 ++----- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ASTNode.cpp b/ASTNode.cpp index dbd39d8..0725ba2 100644 --- a/ASTNode.cpp +++ b/ASTNode.cpp @@ -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()]; } diff --git a/ASTNode.h b/ASTNode.h index e02b5c7..68ced99 100644 --- a/ASTNode.h +++ b/ASTNode.h @@ -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) { } diff --git a/ASTree.cpp b/ASTree.cpp index 57749d5..fbc1e8c 100644 --- a/ASTree.cpp +++ b/ASTree.cpp @@ -2208,7 +2208,7 @@ static void print_block(PycRef blk, PycModule* mod) { ASTBlock::list_t lines = blk->nodes(); if (lines.size() == 0) { - PycRef pass = new ASTNode(ASTNode::NODE_PASS); + PycRef pass = new ASTKeyword(ASTKeyword::KW_PASS); start_line(cur_indent); print_src(pass, mod); } @@ -2457,9 +2457,6 @@ void print_src(PycRef node, PycModule* mod) } } break; - case ASTNode::NODE_PASS: - fputs("pass", pyc_output); - break; case ASTNode::NODE_PRINT: if (node.cast()->value() == NULL) { if (!inPrint) { @@ -2897,7 +2894,7 @@ void decompyle(PycRef 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;