Support COPY opcde
This commit is contained in:
@@ -2540,6 +2540,12 @@ PycRef<ASTNode> BuildFromCode(PycRef<PycCode> code, PycModule* mod)
|
||||
curblock->append(new ASTStore(values, new ASTSubscr(dest, slice)));
|
||||
}
|
||||
break;
|
||||
case Pyc::COPY_A:
|
||||
{
|
||||
PycRef<ASTNode> value = stack.top(operand);
|
||||
stack.push(value);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "Unsupported opcode: %s (%d)\n", Pyc::OpcodeName(opcode), opcode);
|
||||
cleanBuild = false;
|
||||
|
18
FastStack.h
18
FastStack.h
@@ -32,11 +32,21 @@ public:
|
||||
m_stack[m_ptr--] = nullptr;
|
||||
}
|
||||
|
||||
PycRef<ASTNode> top() const
|
||||
PycRef<ASTNode> 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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user