Modules/Objects/public/interpreter/operandsstack.h
2024-11-24 22:36:45 +03:00

39 lines
No EOL
634 B
C++

#pragma once
#include "bytecode.h"
#include "core/object.h"
namespace obj {
// can be other aligned value as well
typedef obj::Object* Operand;
class OperandStack {
enum : tp::alni {
MAX_STACK_SIZE = 512
};
public:
Operand* mBuff;
tp::ualni mIdx;
OperandStack();
void push(Operand operand);
void pop();
Operand getOperand();
template <typename ObjectType>
ObjectType* getOperand() {
auto operand = getOperand();
auto ret = NDO_CAST(ObjectType, operand);
ASSERT(ret && "Operand Has Invalid Object Type");
return ret;
}
~OperandStack();
};
};