1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-10 06:39:49 +00:00
OpenMW/apps/openmw/mwscript/scriptmanagerimp.hpp

80 lines
2.3 KiB
C++
Raw Normal View History

#ifndef GAME_SCRIPT_SCRIPTMANAGER_H
#define GAME_SCRIPT_SCRIPTMANAGER_H
#include <map>
#include <string>
2010-07-02 15:21:27 +00:00
#include <components/compiler/streamerrorhandler.hpp>
#include <components/compiler/fileparser.hpp>
#include <components/interpreter/interpreter.hpp>
#include <components/interpreter/types.hpp>
#include "../mwbase/scriptmanager.hpp"
#include "globalscripts.hpp"
namespace ESMS
{
struct ESMStore;
}
namespace Compiler
{
class Context;
}
namespace Interpreter
{
class Context;
2010-07-03 10:12:13 +00:00
class Interpreter;
}
namespace MWScript
2010-10-06 12:52:53 +00:00
{
class ScriptManager : public MWBase::ScriptManager
{
2010-07-02 15:21:27 +00:00
Compiler::StreamErrorHandler mErrorHandler;
const ESMS::ESMStore& mStore;
bool mVerbose;
2010-07-02 15:21:27 +00:00
Compiler::Context& mCompilerContext;
Compiler::FileParser mParser;
Interpreter::Interpreter mInterpreter;
bool mOpcodesInstalled;
2010-10-06 12:52:53 +00:00
2012-03-05 15:56:14 +00:00
typedef std::pair<std::vector<Interpreter::Type_Code>, Compiler::Locals> CompiledScript;
typedef std::map<std::string, CompiledScript> ScriptCollection;
ScriptCollection mScripts;
GlobalScripts mGlobalScripts;
2010-10-06 12:52:53 +00:00
public:
2010-10-06 12:52:53 +00:00
2010-07-02 15:21:27 +00:00
ScriptManager (const ESMS::ESMStore& store, bool verbose,
Compiler::Context& compilerContext);
2010-10-06 12:52:53 +00:00
virtual void run (const std::string& name, Interpreter::Context& interpreterContext);
2010-10-06 12:52:53 +00:00
///< Run the script with the given name (compile first, if not compiled yet)
virtual bool compile (const std::string& name);
2010-10-06 12:52:53 +00:00
///< Compile script with the given namen
/// \return Success?
virtual std::pair<int, int> compileAll();
///< Compile all scripts
/// \return count, success
2012-03-05 15:56:14 +00:00
virtual Compiler::Locals& getLocals (const std::string& name);
2012-03-05 15:56:14 +00:00
///< Return locals for script \a name.
virtual GlobalScripts& getGlobalScripts();
virtual int getLocalIndex (const std::string& scriptId, const std::string& variable,
char type);
///< Return index of the variable of the given name and type in the given script. Will
/// throw an exception, if there is no such script or variable or the type does not match.
};
};
#endif