1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-22 07:23:52 +00:00
openmw/apps/opencs/model/world/scriptcontext.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.5 KiB
C++
Raw Normal View History

#ifndef CSM_WORLD_SCRIPTCONTEXT_H
#define CSM_WORLD_SCRIPTCONTEXT_H
#include <map>
2013-09-19 10:30:42 +00:00
#include <string>
2022-10-19 17:02:00 +00:00
#include <utility>
2013-09-19 10:30:42 +00:00
#include <vector>
#include <components/compiler/context.hpp>
#include <components/compiler/locals.hpp>
#include <components/misc/algorithm.hpp>
namespace CSMWorld
{
2013-09-19 10:30:42 +00:00
class Data;
class ScriptContext : public Compiler::Context
{
2013-09-19 10:30:42 +00:00
const Data& mData;
mutable std::vector<ESM::RefId> mIds;
2013-09-19 10:30:42 +00:00
mutable bool mIdsUpdated;
mutable std::map<std::string, Compiler::Locals, Misc::StringUtils::CiComp> mLocals;
2022-09-22 18:26:05 +00:00
public:
2013-09-19 10:30:42 +00:00
ScriptContext(const Data& data);
bool canDeclareLocals() const override;
///< Is the compiler allowed to declare local variables?
char getGlobalType(const std::string& name) const override;
///< 'l: long, 's': short, 'f': float, ' ': does not exist.
std::pair<char, bool> getMemberType(const std::string& name, const ESM::RefId& id) const override;
///< Return type of member variable \a name in script \a id or in script of reference of
/// \a id
/// \return first: 'l: long, 's': short, 'f': float, ' ': does not exist.
/// second: true: script of reference
bool isId(const ESM::RefId& name) const override;
///< Does \a name match an ID, that can be referenced?
2013-09-19 10:30:42 +00:00
void invalidateIds();
2014-02-14 12:38:30 +00:00
void clear();
///< Remove all cached data.
/// \return Were there any locals that needed clearing?
bool clearLocals(const std::string& script);
};
}
#endif