OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
extensions.hpp
Go to the documentation of this file.
1 #ifndef COMPILER_EXTENSIONS_H_INCLUDED
2 #define COMPILER_EXTENSIONS_H_INCLUDED
3 
4 #include <string>
5 #include <map>
6 #include <vector>
7 
9 
10 namespace Compiler
11 {
12  class Literals;
13 
15 
28  typedef std::string ScriptArgs;
29 
31 
36  typedef char ScriptReturn;
37 
39  class Extensions
40  {
41 
42  struct Function
43  {
44  char mReturn;
46  int mCode;
48  int mSegment;
49  };
50 
51  struct Instruction
52  {
54  int mCode;
56  int mSegment;
57  };
58 
60  std::map<std::string, int> mKeywords;
61  std::map<int, Function> mFunctions;
62  std::map<int, Instruction> mInstructions;
63 
64  public:
65 
66  Extensions();
67 
68  int searchKeyword (const std::string& keyword) const;
72 
73  bool isFunction (int keyword, ScriptReturn& returnType, ScriptArgs& argumentType,
74  bool& explicitReference) const;
79 
80  bool isInstruction (int keyword, ScriptArgs& argumentType,
81  bool& explicitReference) const;
85 
86  void registerFunction (const std::string& keyword, ScriptReturn returnType,
87  const ScriptArgs& argumentType, int code, int codeExplicit = -1);
93 
94  void registerInstruction (const std::string& keyword,
95  const ScriptArgs& argumentType, int code, int codeExplicit = -1);
101 
102  void generateFunctionCode (int keyword, std::vector<Interpreter::Type_Code>& code,
103  Literals& literals, const std::string& id, int optionalArguments) const;
105 
106  void generateInstructionCode (int keyword, std::vector<Interpreter::Type_Code>& code,
107  Literals& literals, const std::string& id, int optionalArguments) const;
109 
110  void listKeywords (std::vector<std::string>& keywords) const;
112  };
113 }
114 
115 #endif
char ScriptReturn
Typedef for script return char.
Definition: extensions.hpp:36
int mSegment
Definition: extensions.hpp:48
std::string ScriptArgs
Typedef for script arguments string.
Definition: extensions.hpp:12
int mNextKeywordIndex
Definition: extensions.hpp:59
int mSegment
Definition: extensions.hpp:56
bool isInstruction(int keyword, ScriptArgs &argumentType, bool &explicitReference) const
Definition: extensions.cpp:39
std::map< int, Instruction > mInstructions
Definition: extensions.hpp:62
int mCode
Definition: extensions.hpp:46
Collection of compiler extensions.
Definition: extensions.hpp:39
bool isFunction(int keyword, ScriptReturn &returnType, ScriptArgs &argumentType, bool &explicitReference) const
Definition: extensions.cpp:23
int searchKeyword(const std::string &keyword) const
Definition: extensions.cpp:13
Definition: extensions.hpp:51
int mCode
Definition: extensions.hpp:54
std::map< int, Function > mFunctions
Definition: extensions.hpp:61
int mCodeExplicit
Definition: extensions.hpp:55
void registerFunction(const std::string &keyword, ScriptReturn returnType, const ScriptArgs &argumentType, int code, int codeExplicit=-1)
Definition: extensions.cpp:54
void registerInstruction(const std::string &keyword, const ScriptArgs &argumentType, int code, int codeExplicit=-1)
Definition: extensions.cpp:84
char mReturn
Definition: extensions.hpp:44
void generateFunctionCode(int keyword, std::vector< Interpreter::Type_Code > &code, Literals &literals, const std::string &id, int optionalArguments) const
Append code for function to code.
Definition: extensions.cpp:113
int code
Definition: crashcatcher.cpp:70
Literal values.
Definition: literals.hpp:13
Definition: extensions.hpp:42
void listKeywords(std::vector< std::string > &keywords) const
Append all known keywords to kaywords.
Definition: extensions.cpp:210
void generateInstructionCode(int keyword, std::vector< Interpreter::Type_Code > &code, Literals &literals, const std::string &id, int optionalArguments) const
Append code for function to code.
Definition: extensions.cpp:161
ScriptArgs mArguments
Definition: extensions.hpp:45
std::map< std::string, int > mKeywords
Definition: extensions.hpp:60
int mCodeExplicit
Definition: extensions.hpp:47
Extensions()
Definition: extensions.cpp:11
ScriptArgs mArguments
Definition: extensions.hpp:53