2010-06-28 17:20:45 +00:00
|
|
|
#ifndef INTERPRETER_RUNTIME_H_INCLUDED
|
|
|
|
#define INTERPRETER_RUNTIME_H_INCLUDED
|
|
|
|
|
2010-06-28 19:49:48 +00:00
|
|
|
#include <vector>
|
2010-06-30 10:04:26 +00:00
|
|
|
#include <string>
|
2010-06-28 19:49:48 +00:00
|
|
|
|
2010-06-28 17:20:45 +00:00
|
|
|
#include "types.hpp"
|
|
|
|
|
|
|
|
namespace Interpreter
|
|
|
|
{
|
|
|
|
class Context;
|
|
|
|
|
|
|
|
/// Runtime data and engine interface
|
2011-05-18 14:01:19 +00:00
|
|
|
|
2010-06-28 17:20:45 +00:00
|
|
|
class Runtime
|
|
|
|
{
|
2011-05-18 14:01:19 +00:00
|
|
|
Context *mContext;
|
2010-06-28 18:46:15 +00:00
|
|
|
const Type_Code *mCode;
|
2010-06-28 17:20:45 +00:00
|
|
|
int mCodeSize;
|
2010-06-28 18:46:15 +00:00
|
|
|
int mPC;
|
2010-07-14 13:28:55 +00:00
|
|
|
std::vector<Data> mStack;
|
2011-05-18 14:01:19 +00:00
|
|
|
|
2010-06-28 17:20:45 +00:00
|
|
|
public:
|
2011-05-18 14:01:19 +00:00
|
|
|
|
|
|
|
Runtime ();
|
|
|
|
|
2010-06-28 18:46:15 +00:00
|
|
|
int getPC() const;
|
|
|
|
///< return program counter.
|
2011-05-18 14:01:19 +00:00
|
|
|
|
2010-06-28 19:49:48 +00:00
|
|
|
int getIntegerLiteral (int index) const;
|
2011-05-18 14:01:19 +00:00
|
|
|
|
2010-06-28 19:49:48 +00:00
|
|
|
float getFloatLiteral (int index) const;
|
2011-05-18 14:01:19 +00:00
|
|
|
|
2010-06-30 10:04:26 +00:00
|
|
|
std::string getStringLiteral (int index) const;
|
2011-05-18 14:01:19 +00:00
|
|
|
|
|
|
|
void configure (const Type_Code *code, int codeSize, 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. \a codeSize is given in 32-bit words.
|
2011-05-18 14:01:19 +00:00
|
|
|
|
2010-06-28 17:20:45 +00:00
|
|
|
void clear();
|
2011-05-18 14:01:19 +00:00
|
|
|
|
2010-06-28 18:46:15 +00:00
|
|
|
void setPC (int PC);
|
|
|
|
///< set program counter.
|
2011-05-18 14:01:19 +00:00
|
|
|
|
2010-07-14 13:28:55 +00:00
|
|
|
void push (const Data& data);
|
2010-06-28 19:49:48 +00:00
|
|
|
///< push data on stack
|
2011-05-18 14:01:19 +00:00
|
|
|
|
2010-07-14 13:28:55 +00:00
|
|
|
void push (Type_Integer value);
|
|
|
|
///< push integer data on stack.
|
2011-05-18 14:01:19 +00:00
|
|
|
|
2010-07-14 13:28:55 +00:00
|
|
|
void push (Type_Float value);
|
|
|
|
///< push float data on stack.
|
2011-05-18 14:01:19 +00:00
|
|
|
|
2010-06-28 19:49:48 +00:00
|
|
|
void pop();
|
|
|
|
///< pop stack
|
2011-05-18 14:01:19 +00:00
|
|
|
|
2010-07-14 13:28:55 +00:00
|
|
|
Data& operator[] (int Index);
|
2010-06-28 19:49:48 +00:00
|
|
|
///< Access stack member, counted from the top.
|
2011-05-18 14:01:19 +00:00
|
|
|
|
2010-06-28 19:49:48 +00:00
|
|
|
Context& getContext();
|
2010-06-28 17:20:45 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|