Support COPY opcde

This commit is contained in:
Sahil Jain
2025-06-30 23:58:54 +05:30
parent ad5f39db56
commit 5fe61462a2
2 changed files with 20 additions and 4 deletions

View File

@@ -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;
}