1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-10 15:39:02 +00:00
OpenMW/components/interpreter/runtime.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
1.3 KiB
C++
Raw Normal View History

2010-06-28 17:20:45 +00:00
#ifndef INTERPRETER_RUNTIME_H_INCLUDED
#define INTERPRETER_RUNTIME_H_INCLUDED
2022-05-21 08:48:32 +00:00
#include <string_view>
2010-06-28 19:49:48 +00:00
#include <vector>
2010-06-28 17:20:45 +00:00
#include "types.hpp"
namespace Interpreter
{
class Context;
struct Program;
2010-06-28 17:20:45 +00:00
/// Runtime data and engine interface
2010-06-28 17:20:45 +00:00
class Runtime
{
Context* mContext = nullptr;
const Program* mProgram = nullptr;
int mPC = 0;
std::vector<Data> mStack;
2022-09-22 18:26:05 +00:00
public:
2023-01-10 03:14:13 +00:00
int getPC() const { return mPC; }
2010-06-28 18:46:15 +00:00
///< return program counter.
2010-06-28 19:49:48 +00:00
int getIntegerLiteral(int index) const;
2010-06-28 19:49:48 +00:00
float getFloatLiteral(int index) const;
std::string_view getStringLiteral(int index) const;
void configure(const Program& program, Context& context);
2010-06-28 17:20:45 +00:00
///< \a context and \a code must exist as least until either configure, clear or
/// the destructor is called.
2010-06-28 17:20:45 +00:00
void clear();
2023-01-10 03:14:13 +00:00
void setPC(int value) { mPC = value; }
2010-06-28 18:46:15 +00:00
///< set program counter.
void push(const Data& data);
2010-06-28 19:49:48 +00:00
///< push data on stack
void push(Type_Integer value);
///< push integer data on stack.
void push(Type_Float value);
///< push float data on stack.
2010-06-28 19:49:48 +00:00
void pop();
///< pop stack
2023-01-10 03:42:46 +00:00
Data& operator[](int index);
2010-06-28 19:49:48 +00:00
///< Access stack member, counted from the top.
2010-06-28 19:49:48 +00:00
Context& getContext();
2010-06-28 17:20:45 +00:00
};
}
#endif