OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
scriptopcodes.hpp
Go to the documentation of this file.
1 #ifndef INTERPRETER_SCRIPTOPCODES_H_INCLUDED
2 #define INTERPRETER_SCRIPTOPCODES_H_INCLUDED
3 
4 #include "opcodes.hpp"
5 #include "runtime.hpp"
6 #include "context.hpp"
7 
8 namespace Interpreter
9 {
10  class OpScriptRunning : public Opcode0
11  {
12  public:
13 
14  virtual void execute (Runtime& runtime)
15  {
16  std::string name = runtime.getStringLiteral (runtime[0].mInteger);
17  runtime[0].mInteger = runtime.getContext().isScriptRunning (name);
18  }
19  };
20 
21  class OpStartScript : public Opcode0
22  {
23  public:
24 
25  virtual void execute (Runtime& runtime)
26  {
27  std::string name = runtime.getStringLiteral (runtime[0].mInteger);
28  runtime.pop();
29  runtime.getContext().startScript (name, runtime.getContext().getTargetId());
30  }
31  };
32 
34  {
35  public:
36 
37  virtual void execute (Runtime& runtime)
38  {
39  std::string targetId = runtime.getStringLiteral (runtime[0].mInteger);
40  runtime.pop();
41 
42  std::string name = runtime.getStringLiteral (runtime[0].mInteger);
43  runtime.pop();
44 
45  runtime.getContext().startScript (name, targetId);
46  }
47  };
48 
49  class OpStopScript : public Opcode0
50  {
51  public:
52 
53  virtual void execute (Runtime& runtime)
54  {
55  std::string name = runtime.getStringLiteral (runtime[0].mInteger);
56  runtime.pop();
57  runtime.getContext().stopScript (name);
58  }
59  };
60 }
61 
62 #endif
63 
virtual std::string getTargetId() const =0
Definition: scriptopcodes.hpp:21
Definition: scriptopcodes.hpp:10
void pop()
pop stack
Definition: runtime.cpp:94
virtual void execute(Runtime &runtime)
Definition: scriptopcodes.hpp:37
std::string getStringLiteral(int index) const
Definition: runtime.cpp:34
Runtime data and engine interface.
Definition: runtime.hpp:15
opcode for 0 arguments
Definition: opcodes.hpp:9
virtual void execute(Runtime &runtime)
Definition: scriptopcodes.hpp:53
Definition: scriptopcodes.hpp:49
virtual void execute(Runtime &runtime)
Definition: scriptopcodes.hpp:14
virtual void startScript(const std::string &name, const std::string &targetId="")=0
virtual void execute(Runtime &runtime)
Definition: scriptopcodes.hpp:25
Context & getContext()
Definition: runtime.cpp:110
Definition: scriptopcodes.hpp:33
virtual void stopScript(const std::string &name)=0
virtual bool isScriptRunning(const std::string &name) const =0
const char * name
Definition: crashcatcher.cpp:59