You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.3 KiB
C++
80 lines
2.3 KiB
C++
15 years ago
|
#ifndef GAME_SCRIPT_SCRIPTMANAGER_H
|
||
|
#define GAME_SCRIPT_SCRIPTMANAGER_H
|
||
|
|
||
|
#include <map>
|
||
|
#include <string>
|
||
|
|
||
15 years ago
|
#include <components/compiler/streamerrorhandler.hpp>
|
||
|
#include <components/compiler/fileparser.hpp>
|
||
|
|
||
14 years ago
|
#include <components/interpreter/interpreter.hpp>
|
||
15 years ago
|
#include <components/interpreter/types.hpp>
|
||
|
|
||
13 years ago
|
#include "../mwbase/scriptmanager.hpp"
|
||
|
|
||
13 years ago
|
#include "globalscripts.hpp"
|
||
|
|
||
15 years ago
|
namespace ESMS
|
||
|
{
|
||
|
struct ESMStore;
|
||
|
}
|
||
|
|
||
|
namespace Compiler
|
||
|
{
|
||
|
class Context;
|
||
|
}
|
||
|
|
||
|
namespace Interpreter
|
||
|
{
|
||
|
class Context;
|
||
15 years ago
|
class Interpreter;
|
||
15 years ago
|
}
|
||
|
|
||
|
namespace MWScript
|
||
14 years ago
|
{
|
||
13 years ago
|
class ScriptManager : public MWBase::ScriptManager
|
||
15 years ago
|
{
|
||
15 years ago
|
Compiler::StreamErrorHandler mErrorHandler;
|
||
15 years ago
|
const ESMS::ESMStore& mStore;
|
||
|
bool mVerbose;
|
||
15 years ago
|
Compiler::Context& mCompilerContext;
|
||
|
Compiler::FileParser mParser;
|
||
14 years ago
|
Interpreter::Interpreter mInterpreter;
|
||
|
bool mOpcodesInstalled;
|
||
14 years ago
|
|
||
13 years ago
|
typedef std::pair<std::vector<Interpreter::Type_Code>, Compiler::Locals> CompiledScript;
|
||
|
typedef std::map<std::string, CompiledScript> ScriptCollection;
|
||
|
|
||
|
ScriptCollection mScripts;
|
||
13 years ago
|
GlobalScripts mGlobalScripts;
|
||
14 years ago
|
|
||
15 years ago
|
public:
|
||
14 years ago
|
|
||
15 years ago
|
ScriptManager (const ESMS::ESMStore& store, bool verbose,
|
||
|
Compiler::Context& compilerContext);
|
||
14 years ago
|
|
||
13 years ago
|
virtual void run (const std::string& name, Interpreter::Context& interpreterContext);
|
||
14 years ago
|
///< Run the script with the given name (compile first, if not compiled yet)
|
||
|
|
||
13 years ago
|
virtual bool compile (const std::string& name);
|
||
14 years ago
|
///< Compile script with the given namen
|
||
|
/// \return Success?
|
||
13 years ago
|
|
||
13 years ago
|
virtual std::pair<int, int> compileAll();
|
||
13 years ago
|
///< Compile all scripts
|
||
|
/// \return count, success
|
||
13 years ago
|
|
||
13 years ago
|
virtual Compiler::Locals& getLocals (const std::string& name);
|
||
13 years ago
|
///< Return locals for script \a name.
|
||
13 years ago
|
|
||
13 years ago
|
virtual GlobalScripts& getGlobalScripts();
|
||
13 years ago
|
|
||
13 years ago
|
virtual int getLocalIndex (const std::string& scriptId, const std::string& variable,
|
||
|
char type);
|
||
13 years ago
|
///< 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.
|
||
15 years ago
|
};
|
||
|
};
|
||
|
|
||
|
#endif
|