2013-04-10 20:49:22 +00:00
|
|
|
#ifndef CSM_WORLD_SCRIPTCONTEXT_H
|
|
|
|
#define CSM_WORLD_SCRIPTCONTEXT_H
|
|
|
|
|
2013-09-19 10:30:42 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2014-02-14 11:46:54 +00:00
|
|
|
#include <map>
|
2013-09-19 10:30:42 +00:00
|
|
|
|
2013-04-10 20:49:22 +00:00
|
|
|
#include <components/compiler/context.hpp>
|
2014-02-14 11:46:54 +00:00
|
|
|
#include <components/compiler/locals.hpp>
|
2013-04-10 20:49:22 +00:00
|
|
|
|
|
|
|
namespace CSMWorld
|
|
|
|
{
|
2013-09-19 10:30:42 +00:00
|
|
|
class Data;
|
|
|
|
|
2013-04-10 20:49:22 +00:00
|
|
|
class ScriptContext : public Compiler::Context
|
|
|
|
{
|
2013-09-19 10:30:42 +00:00
|
|
|
const Data& mData;
|
|
|
|
mutable std::vector<std::string> mIds;
|
|
|
|
mutable bool mIdsUpdated;
|
2014-02-14 11:46:54 +00:00
|
|
|
mutable std::map<std::string, Compiler::Locals> mLocals;
|
2013-09-19 10:30:42 +00:00
|
|
|
|
2013-04-10 20:49:22 +00:00
|
|
|
public:
|
|
|
|
|
2013-09-19 10:30:42 +00:00
|
|
|
ScriptContext (const Data& data);
|
|
|
|
|
2013-04-10 20:49:22 +00:00
|
|
|
virtual bool canDeclareLocals() const;
|
|
|
|
///< Is the compiler allowed to declare local variables?
|
|
|
|
|
|
|
|
virtual char getGlobalType (const std::string& name) const;
|
|
|
|
///< 'l: long, 's': short, 'f': float, ' ': does not exist.
|
|
|
|
|
2014-02-10 13:45:55 +00:00
|
|
|
virtual std::pair<char, bool> getMemberType (const std::string& name,
|
|
|
|
const std::string& id) const;
|
|
|
|
///< 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
|
2013-04-10 20:49:22 +00:00
|
|
|
|
|
|
|
virtual bool isId (const std::string& name) const;
|
|
|
|
///< Does \a name match an ID, that can be referenced?
|
2013-09-19 10:30:42 +00:00
|
|
|
|
2014-02-02 14:08:27 +00:00
|
|
|
virtual bool isJournalId (const std::string& name) const;
|
|
|
|
///< Does \a name match a journal ID?
|
|
|
|
|
2013-09-19 10:30:42 +00:00
|
|
|
void invalidateIds();
|
2013-04-10 20:49:22 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|