#include "compilercontext.hpp" #include "../mwworld/esmstore.hpp" #include #include #include "../mwbase/environment.hpp" #include "../mwbase/world.hpp" #include "../mwbase/scriptmanager.hpp" #include "../mwworld/ptr.hpp" #include "../mwworld/class.hpp" #include "../mwworld/manualref.hpp" namespace MWScript { CompilerContext::CompilerContext (Type type) : mType (type) {} bool CompilerContext::canDeclareLocals() const { return mType==Type_Full; } char CompilerContext::getGlobalType (const std::string& name) const { return MWBase::Environment::get().getWorld()->getGlobalVariableType (name); } std::pair CompilerContext::getMemberType (const std::string& name, const std::string& id) const { std::string script; bool reference = false; if (const ESM::Script *scriptRecord = MWBase::Environment::get().getWorld()->getStore().get().search (id)) { script = scriptRecord->mId; } else { MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), id); script = ref.getPtr().getClass().getScript (ref.getPtr()); reference = true; } char type = ' '; if (!script.empty()) type = MWBase::Environment::get().getScriptManager()->getLocals (script).getType ( Misc::StringUtils::lowerCase (name)); return std::make_pair (type, reference); } bool CompilerContext::isId (const std::string& name) const { const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); return store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name) || store.get().search (name); } bool CompilerContext::isJournalId (const std::string& name) const { const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); const ESM::Dialogue *topic = store.get().search (name); return topic && topic->mType==ESM::Dialogue::Journal; } }