OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
generator.hpp
Go to the documentation of this file.
1 #ifndef COMPILER_GENERATOR_H_INCLUDED
2 #define COMPILER_GENERATOR_H_INCLUDED
3 
4 #include <vector>
5 #include <string>
6 #include <cassert>
7 
9 
10 namespace Compiler
11 {
12  class Literals;
13 
14  namespace Generator
15  {
16  typedef std::vector<Interpreter::Type_Code> CodeContainer;
17 
18  inline Interpreter::Type_Code segment0 (unsigned int c, unsigned int arg0)
19  {
20  assert (c<64);
21  return (c<<24) | (arg0 & 0xffffff);
22  }
23 
24  inline Interpreter::Type_Code segment1 (unsigned int c, unsigned int arg0,
25  unsigned int arg1)
26  {
27  assert (c<64);
28  return 0x40000000 | (c<<24) | ((arg0 & 0xfff)<<12) | (arg1 & 0xfff);
29  }
30 
31  inline Interpreter::Type_Code segment2 (unsigned int c, unsigned int arg0)
32  {
33  assert (c<1024);
34  return 0x80000000 | (c<<20) | (arg0 & 0xfffff);
35  }
36 
37  inline Interpreter::Type_Code segment3 (unsigned int c, unsigned int arg0)
38  {
39  assert (c<262144);
40  return 0xc0000000 | (c<<8) | (arg0 & 0xff);
41  }
42 
43  inline Interpreter::Type_Code segment4 (unsigned int c, unsigned int arg0,
44  unsigned int arg1)
45  {
46  assert (c<1024);
47  return 0xc4000000 | (c<<16) | ((arg0 & 0xff)<<8) | (arg1 & 0xff);
48  }
49 
50  inline Interpreter::Type_Code segment5 (unsigned int c)
51  {
52  assert (c<67108864);
53  return 0xc8000000 | c;
54  }
55 
56  void pushInt (CodeContainer& code, Literals& literals, int value);
57 
58  void pushFloat (CodeContainer& code, Literals& literals, float value);
59 
60  void pushString (CodeContainer& code, Literals& literals, const std::string& value);
61 
62  void assignToLocal (CodeContainer& code, char localType,
63  int localIndex, const CodeContainer& value, char valueType);
64 
65  void negate (CodeContainer& code, char valueType);
66 
67  void add (CodeContainer& code, char valueType1, char valueType2);
68 
69  void sub (CodeContainer& code, char valueType1, char valueType2);
70 
71  void mul (CodeContainer& code, char valueType1, char valueType2);
72 
73  void div (CodeContainer& code, char valueType1, char valueType2);
74 
75  void convert (CodeContainer& code, char fromType, char toType);
76 
78 
79  void exit (CodeContainer& code);
80 
81  void message (CodeContainer& code, Literals& literals, const std::string& message,
82  int buttons);
83 
84  void report (CodeContainer& code, Literals& literals, const std::string& message);
85 
86  void fetchLocal (CodeContainer& code, char localType, int localIndex);
87 
88  void jump (CodeContainer& code, int offset);
89 
90  void jumpOnZero (CodeContainer& code, int offset);
91 
92  void compare (CodeContainer& code, char op, char valueType1, char valueType2);
93 
94  void menuMode (CodeContainer& code);
95 
96  void assignToGlobal (CodeContainer& code, Literals& literals, char localType,
97  const std::string& name, const CodeContainer& value, char valueType);
98 
99  void fetchGlobal (CodeContainer& code, Literals& literals, char localType,
100  const std::string& name);
101 
102  void assignToMember (CodeContainer& code, Literals& literals, char memberType,
103  const std::string& name, const std::string& id, const CodeContainer& value, char valueType, bool global);
105 
106  void fetchMember (CodeContainer& code, Literals& literals, char memberType,
107  const std::string& name, const std::string& id, bool global);
109 
110  void random (CodeContainer& code);
111 
113 
114  void startScript (CodeContainer& code, Literals& literals, const std::string& id);
115 
116  void stopScript (CodeContainer& code);
117 
118  void getDistance (CodeContainer& code, Literals& literals, const std::string& id);
119 
121 
122  void getDisabled (CodeContainer& code, Literals& literals, const std::string& id);
123 
124  void enable (CodeContainer& code, Literals& literals, const std::string& id);
125 
126  void disable (CodeContainer& code, Literals& literals, const std::string& id);
127  }
128 }
129 
130 #endif
void message(CodeContainer &code, Literals &literals, const std::string &message, int buttons)
Definition: generator.cpp:537
void disable(CodeContainer &code, Literals &literals, const std::string &id)
Definition: generator.cpp:884
Interpreter::Type_Code segment1(unsigned int c, unsigned int arg0, unsigned int arg1)
Definition: generator.hpp:24
void startScript(CodeContainer &code, Literals &literals, const std::string &id)
Definition: generator.cpp:820
void assignToGlobal(CodeContainer &code, Literals &literals, char localType, const std::string &name, const CodeContainer &value, char valueType)
Definition: generator.cpp:653
Interpreter::Type_Code segment4(unsigned int c, unsigned int arg0, unsigned int arg1)
Definition: generator.hpp:43
void jumpOnZero(CodeContainer &code, int offset)
Definition: generator.cpp:596
void sub(CodeContainer &code, char valueType1, char valueType2)
Definition: generator.cpp:460
void exit(CodeContainer &code)
Definition: generator.cpp:532
Interpreter::Type_Code segment0(unsigned int c, unsigned int arg0)
Definition: generator.hpp:18
void div(CodeContainer &code, char valueType1, char valueType2)
Definition: generator.cpp:496
void assignToLocal(CodeContainer &code, char localType, int localIndex, const CodeContainer &value, char valueType)
Definition: generator.cpp:380
void pushString(CodeContainer &code, Literals &literals, const std::string &value)
Definition: generator.cpp:374
void menuMode(CodeContainer &code)
Definition: generator.cpp:648
void add(CodeContainer &code, char valueType1, char valueType2)
Definition: generator.cpp:442
std::vector< Interpreter::Type_Code > CodeContainer
Definition: generator.hpp:16
void report(CodeContainer &code, Literals &literals, const std::string &message)
Definition: generator.cpp:551
void assignToMember(CodeContainer &code, Literals &literals, char localType, const std::string &name, const std::string &id, const CodeContainer &value, char valueType, bool global)
Definition: generator.cpp:727
void compare(CodeContainer &code, char op, char valueType1, char valueType2)
Definition: generator.cpp:606
void random(CodeContainer &code)
Definition: generator.cpp:810
void convert(CodeContainer &code, char fromType, char toType)
Definition: generator.cpp:514
unsigned int Type_Code
Definition: types.hpp:8
void jump(CodeContainer &code, int offset)
Definition: generator.cpp:586
void scriptRunning(CodeContainer &code)
Definition: generator.cpp:815
Interpreter::Type_Code segment5(unsigned int c)
Definition: generator.hpp:50
void pushInt(CodeContainer &code, Literals &literals, int value)
Definition: generator.cpp:360
void fetchGlobal(CodeContainer &code, Literals &literals, char localType, const std::string &name)
Definition: generator.cpp:697
void mul(CodeContainer &code, char valueType1, char valueType2)
Definition: generator.cpp:478
void getSecondsPassed(CodeContainer &code)
Definition: generator.cpp:851
void pushFloat(CodeContainer &code, Literals &literals, float value)
Definition: generator.cpp:367
void stopScript(CodeContainer &code)
Definition: generator.cpp:832
int code
Definition: crashcatcher.cpp:70
Literal values.
Definition: literals.hpp:13
Interpreter::Type_Code segment3(unsigned int c, unsigned int arg0)
Definition: generator.hpp:37
void squareRoot(CodeContainer &code)
Definition: generator.cpp:527
void getDistance(CodeContainer &code, Literals &literals, const std::string &id)
Definition: generator.cpp:837
void fetchLocal(CodeContainer &code, char localType, int localIndex)
Definition: generator.cpp:559
void getDisabled(CodeContainer &code, Literals &literals, const std::string &id)
Definition: generator.cpp:856
void enable(CodeContainer &code, Literals &literals, const std::string &id)
Definition: generator.cpp:870
void negate(CodeContainer &code, char valueType)
Definition: generator.cpp:422
void fetchMember(CodeContainer &code, Literals &literals, char localType, const std::string &name, const std::string &id, bool global)
Definition: generator.cpp:776
Interpreter::Type_Code segment2(unsigned int c, unsigned int arg0)
Definition: generator.hpp:31
const char * name
Definition: crashcatcher.cpp:59