1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 15:35:23 +00:00

64 lines
1.4 KiB
C++
Raw Normal View History

2010-06-28 19:20:45 +02:00
#ifndef INTERPRETER_RUNTIME_H_INCLUDED
#define INTERPRETER_RUNTIME_H_INCLUDED
2022-05-21 10:48:32 +02:00
#include <string_view>
2022-09-22 21:26:05 +03:00
#include <vector>
2010-06-28 21:49:48 +02:00
2010-06-28 19:20:45 +02:00
#include "types.hpp"
namespace Interpreter
{
class Context;
/// Runtime data and engine interface
2010-06-28 19:20:45 +02:00
class Runtime
{
2022-09-22 21:26:05 +03:00
Context* mContext;
const Type_Code* mCode;
int mCodeSize;
int mPC;
std::vector<Data> mStack;
2022-09-22 21:26:05 +03:00
public:
Runtime();
2022-09-22 21:26:05 +03:00
int getPC() const;
///< return program counter.
2022-09-22 21:26:05 +03:00
int getIntegerLiteral(int index) const;
2022-09-22 21:26:05 +03:00
float getFloatLiteral(int index) const;
2022-09-22 21:26:05 +03:00
std::string_view getStringLiteral(int index) const;
2022-09-22 21:26:05 +03:00
void configure(const Type_Code* code, int codeSize, Context& context);
///< \a context and \a code must exist as least until either configure, clear or
/// the destructor is called. \a codeSize is given in 32-bit words.
2022-09-22 21:26:05 +03:00
void clear();
2022-09-22 21:26:05 +03:00
void setPC(int PC);
///< set program counter.
2022-09-22 21:26:05 +03:00
void push(const Data& data);
///< push data on stack
2022-09-22 21:26:05 +03:00
void push(Type_Integer value);
///< push integer data on stack.
2022-09-22 21:26:05 +03:00
void push(Type_Float value);
///< push float data on stack.
2022-09-22 21:26:05 +03:00
void pop();
///< pop stack
2022-09-22 21:26:05 +03:00
Data& operator[](int Index);
///< Access stack member, counted from the top.
2022-09-22 21:26:05 +03:00
Context& getContext();
2010-06-28 19:20:45 +02:00
};
}
#endif