OpenMW
|
00001 #ifndef COMPILER_EXTENSIONS_H_INCLUDED 00002 #define COMPILER_EXTENSINOS_H_INCLUDED 00003 00004 #include <string> 00005 #include <map> 00006 #include <vector> 00007 00008 #include <components/interpreter/types.hpp> 00009 00010 namespace Compiler 00011 { 00012 class Literals; 00013 00015 00016 class Extensions 00017 { 00018 struct Function 00019 { 00020 char mReturn; 00021 std::string mArguments; 00022 int mCode; 00023 int mCodeExplicit; 00024 int mSegment; 00025 }; 00026 00027 struct Instruction 00028 { 00029 std::string mArguments; 00030 int mCode; 00031 int mCodeExplicit; 00032 int mSegment; 00033 }; 00034 00035 int mNextKeywordIndex; 00036 std::map<std::string, int> mKeywords; 00037 std::map<int, Function> mFunctions; 00038 std::map<int, Instruction> mInstructions; 00039 00040 public: 00041 00042 Extensions(); 00043 00044 int searchKeyword (const std::string& keyword) const; 00048 00049 bool isFunction (int keyword, char& returnType, std::string& argumentType, 00050 bool explicitReference) const; 00053 00054 bool isInstruction (int keyword, std::string& argumentType, 00055 bool explicitReference) const; 00057 00058 void registerFunction (const std::string& keyword, char returnType, 00059 const std::string& argumentType, int code, int codeExplicit = -1); 00065 00066 void registerInstruction (const std::string& keyword, 00067 const std::string& argumentType, int code, int codeExplicit = -1); 00073 00074 void generateFunctionCode (int keyword, std::vector<Interpreter::Type_Code>& code, 00075 Literals& literals, const std::string& id, int optionalArguments) const; 00077 00078 void generateInstructionCode (int keyword, std::vector<Interpreter::Type_Code>& code, 00079 Literals& literals, const std::string& id, int optionalArguments) const; 00081 00082 void listKeywords (std::vector<std::string>& keywords) const; 00084 }; 00085 } 00086 00087 #endif