1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-07 12:54:00 +00:00
OpenMW/components/compiler/extensions.hpp

55 lines
1.7 KiB
C++
Raw Normal View History

2010-07-03 07:54:01 +00:00
#ifndef COMPILER_EXTENSIONS_H_INCLUDED
#define COMPILER_EXTENSINOS_H_INCLUDED
#include <string>
#include <map>
#include <vector>
#include <components/interpreter/types.hpp>
2010-07-03 07:54:01 +00:00
namespace Compiler
{
/// \brief Collection of compiler extensions
class Extensions
{
struct Function
{
char mReturn;
std::string mArguments;
int mCode;
};
2010-07-03 07:54:01 +00:00
int mNextKeywordIndex;
std::map<std::string, int> mKeywords;
std::map<int, Function> mFunctions;
2010-07-03 07:54:01 +00:00
public:
Extensions();
int searchKeyword (const std::string& keyword) const;
///< Return extension keyword code, that is assigned to the string \a keyword.
/// - if no match is found 0 is returned.
/// - keyword must be all lower case.
bool isFunction (int keyword, char& returnType, std::string& argumentType) const;
///< Is this keyword registered with a function? If yes, return return and argument
/// types.
void registerFunction (const std::string& keyword, char returnType,
const std::string& argumentType, int segment5code);
///< Register a custom function
/// - keyword must be all lower case.
/// - keyword must be unique
/// \note Currently only segment 5 opcodes are supported.
void generateFunctionCode (int keyword, std::vector<Interpreter::Type_Code>& code)
const;
///< Append code for function to \a code.
2010-07-03 07:54:01 +00:00
};
}
#endif