Method object refactor

This commit is contained in:
IlyaShurupov 2024-03-25 13:57:31 +03:00 committed by Ilya Shurupov
parent 714bdaef12
commit 715175085e
25 changed files with 420 additions and 529 deletions

View file

@ -10,11 +10,11 @@ using namespace obj;
void CallStack::enter(const CallStack::CallFrame& frame) {
if (mStack.size()) {
auto& last_frame = mStack.last();
last_frame.mIp = last_frame.mMethod->mScript->mBytecode.mInstructionIdx;
last_frame.mIp = last_frame.mMethod->mBytecodeLink->mBytecode.mInstructionIdx;
}
frame.mMethod->mScript->mBytecode.mArgumentsLoaded = 0;
frame.mMethod->mScript->mBytecode.mInstructionIdx = 0;
frame.mMethod->mBytecodeLink->mBytecode.mArgumentsLoaded = 0;
frame.mMethod->mBytecodeLink->mBytecode.mInstructionIdx = 0;
objects_api::increaseReferenceCount(frame.mMethod);
mStack.append(frame);
}
@ -26,10 +26,10 @@ void CallStack::leave() {
if (mStack.size()) {
auto& last_frame = mStack.last();
last_frame.mMethod->mScript->mBytecode.mInstructionIdx = last_frame.mIp;
last_frame.mMethod->mBytecodeLink->mBytecode.mInstructionIdx = last_frame.mIp;
}
}
ByteCode* CallStack::getBytecode() { return &mStack.last().mMethod->mScript->mBytecode; }
ByteCode* CallStack::getBytecode() { return &mStack.last().mMethod->mBytecodeLink->mBytecode; }
halni CallStack::len() const { return mStack.size(); }

View file

@ -32,7 +32,7 @@ uint2 param(ByteCode* bytecode) { return loadConstDataIdx(bytecode); }
void Interpreter::exec(
obj::MethodObject* method, obj::ClassObject* self, obj::DictObject* globals, InitialierList<GlobalDef> globals2
) {
if (!method->mScript->mBytecode.mInstructions.size()) {
if (!method->mBytecodeLink->mBytecode.mInstructions.size()) {
return;
}
@ -99,7 +99,7 @@ void Interpreter::stepBytecodeIn() {
mCallStack.leave();
if (mCallStack.len()) {
mOperandsStack.push(NDO_NULL_REF);
mOperandsStack.push(objects_api::getNullReferenced());
}
return;
}
@ -305,7 +305,7 @@ void Interpreter::stepBytecodeIn() {
mScopeStack.leaveScope();
mCallStack.leave();
if (mCallStack.len()) {
mOperandsStack.push(NDO_NULL_REF);
mOperandsStack.push(objects_api::getNullReferenced());
}
break;
}
@ -600,7 +600,7 @@ void Interpreter::stepBytecodeIn() {
void Interpreter::execAll(
obj::MethodObject* method, obj::ClassObject* self, obj::DictObject* globals, InitialierList<GlobalDef> globals2
) {
if (!method->mScript->mBytecode.mInstructions.size()) {
if (!method->mBytecodeLink->mBytecode.mInstructions.size()) {
return;
}