Modules/Objects/public/interpreter/Interpreter.hpp
Шурупов Илья Викторович c8104b0b61 Objects: populate the object tree and add a console panel
The tree view had no card factory, so it created no cards and stayed empty; it now builds TreeCards titled with entry names and types, and a test asserts the cards exist. The interpreter routes print through an optional output callback, falling back to stdout, and a bottom Console dock panel shows output from Execute and from debugging, with run start, finish and runtime-error markers and a Clear button.
2026-10-27 20:18:58 +03:00

50 lines
No EOL
1 KiB
C++

#pragma once
#include "OperandsStack.hpp"
#include "ScopeStack.hpp"
#include "CallStack.hpp"
#include <functional>
#include <string>
namespace tp::obj {
struct Interpreter {
OperandStack mOperandsStack;
ScopeStack mScopeStack;
CallStack mCallStack;
Object* mLastParent = nullptr;
bool mIsTypeMethod = false;
bool mError = false;
std::function<void(const std::string&)> mOutput;
void write(const std::string& line);
const TypeMethod* mTypeMethod = nullptr;
typedef struct {
Object* obj;
std::string id;
} GlobalDef;
void exec(
MethodObject* method,
ClassObject* self = nullptr,
DictObject* globals = nullptr,
InitialierList<GlobalDef> globals2 = {}
);
void stepBytecode();
void stepBytecodeIn();
void stepBytecodeOut();
void abortExecution();
bool finished() const;
void execAll(
MethodObject* method,
ClassObject* self = nullptr,
DictObject* globals = nullptr,
InitialierList<GlobalDef> globals2 = {}
);
};
}