diff --git a/ASTree.cpp b/ASTree.cpp index 281d224..851f735 100644 --- a/ASTree.cpp +++ b/ASTree.cpp @@ -2540,6 +2540,12 @@ PycRef BuildFromCode(PycRef code, PycModule* mod) curblock->append(new ASTStore(values, new ASTSubscr(dest, slice))); } break; + case Pyc::COPY_A: + { + PycRef value = stack.top(operand); + stack.push(value); + } + break; default: fprintf(stderr, "Unsupported opcode: %s (%d)\n", Pyc::OpcodeName(opcode), opcode); cleanBuild = false; diff --git a/FastStack.h b/FastStack.h index 45f8ed5..d8fb08b 100644 --- a/FastStack.h +++ b/FastStack.h @@ -32,11 +32,21 @@ public: m_stack[m_ptr--] = nullptr; } - PycRef top() const + PycRef top(int i = 1) const { - if (m_ptr > -1) - return m_stack[m_ptr]; - else + if (i > 0) { + int idx = m_ptr + 1 - i; + if ((m_ptr > -1) && (idx >= 0)) + return m_stack[idx]; + else { + #ifdef BLOCK_DEBUG + fprintf(stderr, "insufficient values on stack\n"); + #endif + return nullptr; + } + } + else { + fprintf(stderr, "incorrect operand %i\n", i); return nullptr; }