1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-20 15: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.

51 lines
1.4 KiB
C++
Raw Normal View History

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