2010-06-27 17:20:21 +00:00
|
|
|
#ifndef COMPILER_CONTEXT_H_INCLUDED
|
|
|
|
#define COMPILER_CONTEXT_H_INCLUDED
|
|
|
|
|
2010-07-04 10:29:28 +00:00
|
|
|
#include <string>
|
|
|
|
|
2010-06-27 17:20:21 +00:00
|
|
|
namespace Compiler
|
|
|
|
{
|
2010-07-03 07:54:01 +00:00
|
|
|
class Extensions;
|
|
|
|
|
2010-06-27 17:20:21 +00:00
|
|
|
class Context
|
|
|
|
{
|
2010-07-03 07:54:01 +00:00
|
|
|
const Extensions* mExtensions;
|
2012-06-16 11:06:23 +00:00
|
|
|
|
2010-06-28 10:32:08 +00:00
|
|
|
public:
|
2020-11-13 07:39:47 +00:00
|
|
|
Context()
|
|
|
|
: mExtensions(nullptr)
|
2022-09-22 18:26:05 +00:00
|
|
|
{
|
|
|
|
}
|
2012-06-16 11:06:23 +00:00
|
|
|
|
2020-11-13 07:39:47 +00:00
|
|
|
virtual ~Context() = default;
|
2012-06-16 11:06:23 +00:00
|
|
|
|
2020-10-22 21:57:53 +00:00
|
|
|
virtual bool canDeclareLocals() const = 0;
|
|
|
|
///< Is the compiler allowed to declare local variables?
|
2012-06-16 11:06:23 +00:00
|
|
|
|
2010-06-28 10:32:08 +00:00
|
|
|
void setExtensions(const Extensions* extensions = nullptr) { mExtensions = extensions; }
|
2012-06-16 11:06:23 +00:00
|
|
|
|
2020-11-13 07:39:47 +00:00
|
|
|
const Extensions* getExtensions() const { return mExtensions; }
|
2012-06-16 11:06:23 +00:00
|
|
|
|
2010-07-03 08:43:55 +00:00
|
|
|
virtual char getGlobalType(const std::string& name) const = 0;
|
|
|
|
///< 'l: long, 's': short, 'f': float, ' ': does not exist.
|
2012-06-16 11:06:23 +00:00
|
|
|
|
2010-07-04 10:29:28 +00:00
|
|
|
virtual std::pair<char, bool> getMemberType(const std::string& name, const std::string& id) const = 0;
|
|
|
|
///< Return type of member variable \a name in script \a id or in script of reference of
|
2014-02-10 13:45:55 +00:00
|
|
|
/// \a id
|
2010-07-09 18:35:34 +00:00
|
|
|
/// \return first: 'l: long, 's': short, 'f': float, ' ': does not exist.
|
2014-02-10 13:45:55 +00:00
|
|
|
/// second: true: script of reference
|
2012-06-16 11:06:23 +00:00
|
|
|
|
2010-07-09 18:35:34 +00:00
|
|
|
virtual bool isId(const std::string& name) const = 0;
|
|
|
|
///< Does \a name match an ID, that can be referenced?
|
2010-06-27 17:20:21 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|