OpenMW
apps/openmw/mwscript/scriptmanagerimp.hpp
Go to the documentation of this file.
00001 #ifndef GAME_SCRIPT_SCRIPTMANAGER_H
00002 #define GAME_SCRIPT_SCRIPTMANAGER_H
00003 
00004 #include <map>
00005 #include <string>
00006 
00007 #include <components/compiler/streamerrorhandler.hpp>
00008 #include <components/compiler/fileparser.hpp>
00009 
00010 #include <components/interpreter/interpreter.hpp>
00011 #include <components/interpreter/types.hpp>
00012 
00013 #include "../mwbase/scriptmanager.hpp"
00014 
00015 #include "globalscripts.hpp"
00016 
00017 namespace MWWorld
00018 {
00019     struct ESMStore;
00020 }
00021 
00022 namespace Compiler
00023 {
00024     class Context;
00025 }
00026 
00027 namespace Interpreter
00028 {
00029     class Context;
00030     class Interpreter;
00031 }
00032 
00033 namespace MWScript
00034 {
00035     class ScriptManager : public MWBase::ScriptManager
00036     {
00037             Compiler::StreamErrorHandler mErrorHandler;
00038             const MWWorld::ESMStore& mStore;
00039             bool mVerbose;
00040             Compiler::Context& mCompilerContext;
00041             Compiler::FileParser mParser;
00042             Interpreter::Interpreter mInterpreter;
00043             bool mOpcodesInstalled;
00044 
00045             typedef std::pair<std::vector<Interpreter::Type_Code>, Compiler::Locals> CompiledScript;
00046             typedef std::map<std::string, CompiledScript> ScriptCollection;
00047 
00048             ScriptCollection mScripts;
00049             GlobalScripts mGlobalScripts;
00050             std::map<std::string, Compiler::Locals> mOtherLocals;
00051 
00052         public:
00053 
00054             ScriptManager (const MWWorld::ESMStore& store, bool verbose,
00055                 Compiler::Context& compilerContext);
00056 
00057             virtual void run (const std::string& name, Interpreter::Context& interpreterContext);
00059 
00060             virtual bool compile (const std::string& name);
00063 
00064             virtual void resetGlobalScripts();
00065 
00066             virtual std::pair<int, int> compileAll();
00069 
00070             virtual Compiler::Locals& getLocals (const std::string& name);
00072 
00073             virtual GlobalScripts& getGlobalScripts();
00074 
00075             virtual int getLocalIndex (const std::string& scriptId, const std::string& variable,
00076                 char type);
00079     };
00080 }
00081 
00082 #endif