Objects Initial

This commit is contained in:
IlushaShurupov 2023-07-24 21:55:19 +03:00 committed by Ilya Shurupov
parent 0f639ba3b1
commit 94057d2a66
76 changed files with 7895 additions and 17 deletions

View file

@ -0,0 +1,30 @@
#include "interpreter/operandsstack.h"
using namespace obj;
OperandStack::OperandStack() {
mBuff = new Operand[MAX_STACK_SIZE];
mIdx = 0;
}
void OperandStack::push(Operand operand) {
ASSERT(MAX_STACK_SIZE - 1 > mIdx && "stack overflow");
mBuff[mIdx] = operand;
mIdx++;
}
void OperandStack::pop() {
ASSERT(mIdx != NULL && "stack overflow");
mIdx--;
}
Operand OperandStack::getOperand() {
auto ret = mBuff[mIdx - 1];
mIdx--;
return ret;
}
OperandStack::~OperandStack() {
delete[] mBuff;
}